Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:34:14+00:00 2026-06-09T00:34:14+00:00

Im attempting to get a highcharts chart to refresh every minute with new data.

  • 0

Im attempting to get a highcharts chart to refresh every minute with new data. So far I have the chart being created using a php outputting on a header as javascript.

I have this at the top of the page:

<?php
    //set the output header as JS
    Header("content-type: application/x-javascript");
    //output start of javascript chart
?>
   var chart;
   chart = new Highcharts.Chart({

Then some PHP to get the data from the database, and output in the highcharts format.

I Now have this on my index page calling the graph, it displays, then does destroy the graph, and redisplays the graph but it doesn’t seem to re-run the php code:

<script>
$(document).ready(function(){
    $.ajaxSetup({
        cache: false,
    });
    $.get("api_dashchart.php?uID=<?php echo $userInfo_ID; ?>");
    var refreshId = setInterval(function(){
        if(chart) chart.destroy();
        $.get("api_dashchart.php?uID=<?php echo $userInfo_ID; ?>");
    }, 45000);
});

Continued help much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:34:17+00:00Added an answer on June 9, 2026 at 12:34 am

    I think you are mixing server and client code here,
    You PHP code will only be executed once on the server, while the page is fetched.

    window.setInterval(function(
        displaygraph();
    }, 60000);
    

    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 Firebug.
    As for the first load issue, you can easily do it with an if statement inside display graph.

    if(chart) chart.destroy();
    

    To sum it up,

    charting.js

    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);
    

    getjson.php

    <?php
      $data = ...
      echo json_encode($data);
    ?>
    

    More on $.getJSON @ http://api.jquery.com/jQuery.getJSON/ , $.ajax @ http://api.jquery.com/jQuery.ajax/ json-encoding in php @ http://php.net/manual/en/function.json-encode.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
I'm attempting to get order data from a Yahoo store. I'm using the docs
I am attempting to get all the data from a MySQL db with PHP,
I am attempting to get django working using pypy. I have everything setup and
I'm attempting to get data using NHibernate and database return the strange result. Objects
Im attempting to get a block of text from a file I have already
I´ve been attempting to get a polar plotting in a PolarChart using MSchart, and
I am attempting to get rails routes paths via nested resources. I have looked
I have been attempting to get log4net logging in my asp.net web application with
Currently attempting to get some code to compile using Lejos for the Lego NXT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.