Real-time Gauges

The LED gauge is a real time chart, which can continuously request new data from the server and display the same, without involving any page refreshes. The chart initializes itself, loads new data every n seconds, and silently updates itself to reflect the current state of data. There are two different ways to update the angular gauge; one method directly polls data from the server while the other retrieves data using JavaScript API methods.

In this section, you will be shown how you can,

  • Configure real-time updates using JavaScript API

  • Configure real-time updates using server-side script

  • Stop/restart updates

  • Configure real-time events

  • Troubleshoot real-time gauges

Configuring Real-time Updates Using JavaScript API

Real-time Data Format

The data provider page on the server’s end, when invoked by the LED gauge, will output the new data in the real-time data format.

The real-time data format for gauges depends on:

  • the value to be passed

  • whether you are using the message logger for the gauge

  • the use of commands for the gauge - like stop update etc.

A real-time LED gauge looks like this:

FusionCharts should load here..

Given below is a brief description of the JavaScript API methods used to update a pointer:

Function Name Parameter Description
feedData(strData) strData This method feeds real-time data to the gauge using JavaScript. The data has to be in the same format as provided by the real-time data provider page.
getData() None This method returns the data currently being shown by the gauge.
setData(value) value This method sets the data for the gauge. The value should be within the limits of the gauge.

The data structure needed to render a real-time LED gauge is given below::

...

Configuring Real-time Updates Using Server-side Script

An LED gauge updated in real-time using a server-side script looks like this:

FusionCharts should load here..

Given below is a brief description of the attributes used to configure real-time updates using server-side scripts:

Attribute Name Description
dataStreamURL This parameter sets the path of the page which is supposed to relay real-time data to the chart. If we have special characters as a part of your data stream URL, like ? or &, wel need to URL Encode the entire dataStreamURL. This page needs to be on the same sub-domain on which the chart is hosted and invoked from. Otherwise, security will restrict it from accessing the data and hence the real-time feature won't work.
Example: dataStreamURL='led-data-example-1.php?val=50'
refreshInterval For this parameter, we can specify the number of seconds after which the chart will look for new data. This process will happen continuously - i.e., if we specify 5 seconds here, the chart will look for new data after every 5 seconds.
dataStamp Constantly changing data stamp that can be added to real-time data URL, so as to maintain a state. Please see the section advanced-charting-real-time-charts-adding-data-stamp.

The data structure needed to configure real-time updates using server-side script is given below:

...

Stopping/Restarting Updates

An LED gauge configured to stop receiving real-time updates looks like this:

FusionCharts should load here..

Given below is a brief description of the JavaScript API used to stop and restart receiving real-time updates:

Function Name Parameter Description
stopUpdate() None This method stops the chart from self-updating.
restartUpdate() None If you've stopped the real-time update of the chart, you can resume the update using this method.

The data structure needed to stop receiving real-time updates is given below:

...

Configuring Real-time Events

FusionCharts Suite XT introduces two events, realTimeUpdateComplete and realTimeUpdateError, to track real-time updates on gauges.

A real-time LED gauge configured to listen to the realTimeUpdateComplete event looks like this:

FusionCharts should load here..

Given below is a brief description of the realTimeUpdateComplete event:

The data structure needed to configure the realTimeUpdateComplete event for a real-time LED gauge is given below:

...

A LED gauge configured to listen to the realTimeUpdateError event looks like this:

FusionCharts should load here..

Given below is a brief description of the realTimeUpdateError event:

Attribute Name Description
realtimeUpdateError This event is raised when an error occurs while performing real-time update using datastreamURL. The event arguments provided in the advanced model are:
eventObject : This object contains eventId, eventType and sender properties.
argumentsObject : This object contains the property listed below:
    httpStatus : It contains the HTTP Error status value as number (e.g., 404)

The data structure needed to configure a LED gauge for the realTimeUpdateError event is given below:

...

Troubleshooting Real-time Gauges

While accessing any of the JavaScript methods listed above, if you get an error like "... is not a function of ...",

  • Make sure that you are not calling the JavaScript method before the chart has loaded and rendered. You need to use FC_Rendered function or define the event listener for Rendered event of chart to track the loading of chart as explained in the FusionWidgets XT and JavaScript section.

  • Make sure that you are NOT running the chart from the local file system (C:\ , D:). Instead, run the chart from behind a server (localhost - IIS, Apache etc.). This is because the default security settings do not allow the chart to perform JavaScript interaction on the local file system, unless otherwise specifically set.

There! You have now seen how you can configure real-time updates and events for gauges and troubleshoot them.