Real-time Bullet Graph

The bullet graph (horizontal and vertical bullet) 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 periodically, and auto-updates to reflect the current state of data. There are two different ways to update the bullet; one method directly polls data from the server while the other retrieves data using JavaScript API methods.

Configuring Real-time Updates Using JavaScript API

Real-time Data Format

The real-time data format for bullet chart depends on the data value to be passed.

In the simplest form, if you’re looking to update the bullet chart, you need to pass a single value to the value attribute using the JSON key-value pair format. If this data is within the acceptable range of the chart, the chart will be updated to depict this value.

However, to dynamically pass values to the gauge, you use the JavaScript API.

A bullet graph configured for real-time updates using JavaScript API looks like this:

Daily Sales Tracker by SalespersonStereo Exchange Ltd, New York

FusionCharts will load here..

FusionCharts will load here..

FusionCharts will load here..

FusionCharts will load here..

FusionCharts will load here..

As you can see above, 5 real-time horizontal charts are rendered at a time to showcase a Daily Sales Tracker of salesperson for Stereo Exchange Ltd, New York.

Given below is a brief description of the JavaScript API used to configure real-time updates:

Function Name

Parameter

Description

feedData(strData)

strData

This method is used to feed real-time data to the bullet using JavaScript. The data has to be in the same format as provided by the real-time data provider page.

getData()

None

This method is used to return the data currently being shown by the gauge.

setData(value)

value

This method is used to set the data value for the gauge. The value should be within the limits of the bullet.

Configuring Real-time Updates Using Server-side Scripts

A horizontal bullet configured for real-time updates using server-side script looks like this:

Given below is a brief description of the attributes needed to configure real-time updates from the server:

Attribute Name

Description

dataStreamURL

This parameter sets the path of the page which is supposed to relay real-time data to the chart. If you have special characters as a part of the data stream URL, like ? or &, you will have 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='liveQuote.aspx?name=xyz'

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 the real-time data URL, so as to maintain a state. For more information, read the [Adding Data Stamp

Troubleshooting Real-time Graphs

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 running the chart from the local file system (C:\ , D:\). Instead, run the chart from a server (localhost - IIS, Apache etc.). This is because the default security settings do not allow the chart to perform JavaScript interactions on the local file system.