Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you are mixing server and client code here, You PHP code will <strong>only be executed once on the server, while the page is fetched.</strong></p> <pre><code>window.setInterval(function( displaygraph(); }, 60000); </code></pre> <p>Cannot update data, it will only re-execute displaygraph(), but the data inside this method is not updated from server, but the data that was fetched during page load will be used, you will need to use AJAX, and make an ajax request to get updated data and then use it to redraw the chart with newly fetched data. Try debugging you javascript using <a href="http://getfirebug.com/" rel="nofollow">Firebug</a>.<br> As for the first load issue, you can easily do it with an if statement inside display graph.</p> <pre><code>if(chart) chart.destroy(); </code></pre> <p>To sum it up,</p> <p>charting.js</p> <pre><code>var chart; function displaygraph() { $.getJSON("getjson.php", function(json) { if(chart) chart.destroy(); //get data from json, and use in chart chart = new Highcharts.Chart({....}); }); setInterval(displaygraph, 60000); </code></pre> <p>getjson.php</p> <pre><code>&lt;?php $data = ... echo json_encode($data); ?&gt; </code></pre> <p>More on $.getJSON @ <a href="http://api.jquery.com/jQuery.getJSON/" rel="nofollow">http://api.jquery.com/jQuery.getJSON/</a> , $.ajax @ <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a> json-encoding in php @ <a href="http://php.net/manual/en/function.json-encode.php" rel="nofollow">http://php.net/manual/en/function.json-encode.php</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload