Loading

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.

FusionCharts Suite XT offers two real-time events:

  • realTimeUpdateComplete()

  • realTimeUpdateError()

The realtimeUpdateComplete() Event

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 the realTimeUpdateComplete() event is shown below:

FusionCharts will load here..

The gauge displays the current temperature at Central Cold Store. When the temperature changes, the event realTimeUpdateComplete() is triggered. Consequently, 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:

{ "chart": { "caption": "Temperature Monitor", "subcaption": " Central cold store", "lowerLimit": "-10", "upperLimit": "0", "decimals": "1", "numberSuffix": "°C", "showhovereffect": "1", "thmFillColor": "#008ee4", "showGaugeBorder": "1", "gaugeBorderColor": "#008ee4", "gaugeBorderThickness": "2", "gaugeBorderAlpha": "30", "thmOriginX": "100", "chartBottomMargin": "20", "valueFontColor": "#000000", "theme": "fint" }, "value": "-6", "annotations": { "showbelow": "0", "groups": [ { "id": "indicator", "items": [ { "id": "background", "type": "rectangle", "alpha": "50", "fillColor": "#AABBCC", "x": "$gaugeEndX-40", "tox": "$gaugeEndX", "y": "$gaugeEndY+54", "toy": "$gaugeEndY+72" } ] } ] } }
{
    "chart": {
        "caption": "Temperature Monitor",
        "subcaption": " Central cold store",
        "lowerLimit": "-10",
        "upperLimit": "0",
        "decimals": "1",
        "numberSuffix": "°C",
        "showhovereffect": "1",
        "thmFillColor": "#008ee4",
        "showGaugeBorder": "1",
        "gaugeBorderColor": "#008ee4",
        "gaugeBorderThickness": "2",
        "gaugeBorderAlpha": "30",
        "thmOriginX": "100",
        "chartBottomMargin": "20",
        "valueFontColor": "#000000",
        "theme": "fint"
    },
    "value": "-6",
    "annotations": {
        "showbelow": "0",
        "groups": [
            {
                "id": "indicator",
                "items": [
                    {
                        "id": "background",
                        "type": "rectangle",
                        "alpha": "50",
                        "fillColor": "#AABBCC",
                        "x": "$gaugeEndX-40",
                        "tox": "$gaugeEndX",
                        "y": "$gaugeEndY+54",
                        "toy": "$gaugeEndY+72"
                    }
                ]
            }
        ]
    }
}

The realTimeUpdateError() Event

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 realTimeUpdateError() event is shown below:

FusionCharts will 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 realTimeUpdateError() event 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 using 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:

{ "chart": { "caption": "Temperature Monitor", "subcaption": " Central cold store", "lowerLimit": "-10", "upperLimit": "0", "numberSuffix": "°C", "decimals": "1", "showhovereffect": "1", "thmFillColor": "#008ee4", "showGaugeBorder": "1", "gaugeBorderColor": "#008ee4", "gaugeBorderThickness": "2", "gaugeBorderAlpha": "30", "thmOriginX": "100", "dataStreamURL": "thermometerData.php", "refreshInterval": "5", "theme": "fint" }, "value": "-6" }
{
    "chart": {
        "caption": "Temperature Monitor",
        "subcaption": " Central cold store",
        "lowerLimit": "-10",
        "upperLimit": "0",
        "numberSuffix": "°C",
        "decimals": "1",
        "showhovereffect": "1",
        "thmFillColor": "#008ee4",
        "showGaugeBorder": "1",
        "gaugeBorderColor": "#008ee4",
        "gaugeBorderThickness": "2",
        "gaugeBorderAlpha": "30",
        "thmOriginX": "100",
        "dataStreamURL": "thermometerData.php",
        "refreshInterval": "5",
        "theme": "fint"
    },
    "value": "-6"
}
Top