Writing the Script - Part 2

Let's look at a bare-bones version of an Infographic.

class ActiveReport extends SVGReport 
{
	initialise() {
		super.initialise();		
	};
	
	create() {
		this.liveReport("'Temperature - Air' PROPERTY ALLPOINTS");		
	}
	
	update() {
		this.draw(report.livedata);		
	}
		
	draw(data) {
        }
}

There are four key functions here.

Initialise

This is called once, when the Infographic is first being prepared.

This function is simply where you'd set up any variables you'd need or do any preparation - you're not expected to draw anything or request any data.

Create

This is called once, after your AQL query has been sent and there's fresh data to be visualised.

This is where you may do any once-off data manipulation or investigation (such as calculating the total number of points that you're going to draw).

Update

In live data Infographics, this function is called whenever there are new live values to be processed.

Draw

This function contains the code that actually draws or updates the graphic. It will automatically be called once the results of the initial AQL query have been returned.

It is passed a single parameter. For live graphics, this is a single array of the most recent point values. For historical graphics, it's a list of samples over time.

Writing the Script - Part 3