Writing the Script - The Report Class

From the previous page, we've seen that most of the work will be in filling-in the draw function.

The function is passed an array of data, but we don't really know what any of it is and what we're supposed to do with it.

Luckily, the Report class we're using has a few extra variables we can access…

columns

A list of column information - particularly, the column name. This information is in the same order as the values passed in the parameter to the draw function.

data

A copy of the historical data. These are the same values that are usually passed to the draw function on historical graphics.

livedata

A copy of the most recent live data. These are the same values that are usually passed to the draw function on live graphics.

margin

An object containing the top, bottom, left and right margins for our graphic, if we want to avoid being too close to the page edges.

Using the margin also helps you avoid any headings or controls that are added above the Infographic.

sizing

An array containing the ideal width (index 0) and height (index 1) of the graphic.


Let's begin by creating a bar-chart of our temperatures.