Here we show how to implement the graphing software so that it automatically updates without refreshing the page.
The graph below is set to plot temperature over time. The graph will acquire a new value from the server every second.
The first step is to configure the graph software to request the properties from a server script. This is done with the parameter 'JpGraphPropertyFile'. Here is the configuration used for this graph:-
For this example we have created the property script with PHP. The server side script can be written in any server side language.
The script is fairly straight forward and performs the following steps:-
Notice above we have used the javascript setTimeout function to call a getData() function after 1 second. The getData() function will issue a request to the server to get the latest temperature value and then issue commands to the graph object to set the new data.
This is a simple server side script which generate a temperature value upon request. The graph will poll this script every second to acquire a new data point to add to the chart.