Using Events

Real-time gauges are used when a single value is of interest and has to be monitored constantly. For example, if you want to monitor the forex rate, you can use a real time gauge to display the current currency value, at every set interval. Based on the rates, if you intend to trade or take suitable action, you can use events to track the updates and trigger appropriate functions.

To know more about how to configure a real-time gauge, click here.

FusionChart Suite XT offers two real-time events:

  • realTimeUpdateComplete()

  • realTimeUpdateError()

Event realtimeUpdateComplete()

This event is triggered every time the gauge updates itself with new data, in one of the following ways:

  • through datastreamURL

  • through JavaScript API methods [setData(), feedData(), setDataForId()]

  • through user interaction (Angular and Linear gauges provide an edit mode in which the

    user can directly update the value on the gauge)

A real-time thermometer gauge configured to listen to realTimeUpdateComplete() event is shown below:

FusionCharts should load here..

The gauge displays the current temperature at Central Cold Store. When the temperature changes, the event realTimeUpdateComplete() is triggered. The gauge and the annotation are updated.

A brief description of the realTimeUpdateComplete() event is as follows:

Event Name Parameters
realtimeUpdateComplete(eventObject, argumentsObject) eventObject: contains the eventId, eventType, and sender properties.
argumentsObject: contains the following properties:
prevData : previous value fed to the gauge
source : method in which data is fed to the gauge - feeddata or XmlHttpRequest
updateObject : contains the actual data received
url : the URL of data source if the source is XmlHttpRequest; else null

The data structure to render the above gauge is given below:

...

Event realTimeUpdateError()

This event is triggered when an error occurs while a gauge is updated in real time, using datastreamURL.

A thermometer gauge configured to listen to the event realTimeUpdateError() is shown below:

FusionCharts should load here..

Here, the URL is set to thermometerData.php which does not exist. Hence, the page returns an error and this is captured by the event realTimeUpdateError() that displays an error message.

A brief description of the realTimeUpdateError() event is as follows:

Attribute Name Parameters
realtimeUpdateError(eventObject, argumentsObject) eventObject: contains eventId, eventType and sender properties.
argumentsObject: contains the following properties:
httpStatus : the HTTP Error status value as a number (for example, 404)
error : kind of error
source : method in which data is fed to the gauge - feeddata or XmlHttpRequest
url : the URL of data source if the source is xmlhttpRequest; else null

The data structure to render the above gauge is given below:

...