For web applications, a realtime chart may be achieved by using browser side Javascript using one of the following methods:
- Periodically reloads the <IMG> tag that displays the chart, using JsChartViewer.streamUpdate. This method sends a "stream update request" to the server to update the chart image without refreshing the web page. The charting code in the server always draws the chart using the most up-to-date data. By using a timer to call JsChartViewer.streamUpdate periodically, we can get a real time chart.
The examples Simple Realtime Chart and Realtime Chart with Snapshot demonstrate using the JsChartViewer.streamUpdate method.
- Periodically sends AJAX chart update requests to the server using JsChartViewer.partialUpdate. The charting code in the server always draws the chart using the most up-to-date data. By using a timer to call JsChartViewer.partialUpdate periodically, we can get a real time chart.
On the server side, when the script starts to run, the first thing it does is to use WebChartViewer.isPartialUpdateRequest to detect if it is handling an AJAX chart update or an initial page request. If it is an AJAX chart update, it just draws the chart and sends back an AJAX response using WebChartViewer.partialUpdateChart. If it is an initial page request, it processes the request as usual.
The example Realtime Chart with Track Line demonstrates using the JsChartViewer.partialUpdate method.
© 2017 Advanced Software Engineering Limited. All rights reserved.