/    Sign up×
Community /Pin to ProfileBookmark

google chart API auto refresh chart java script time intervals ("n" seconds)

I am using google chart with PHP. chart is working fine when the page is

load for the first time.

But I want to refresh the chart (not the entire page, only the chart), after

“n” seconds, automatically (based on java script intervals), dynamiccal I need

to push the server data,

Please assist me to fix this issue
where should I put java script interval part to refresh the chart

This is my code
—————

<head>
<!–Load the AJAX API–>
<script type=”text/javascript” src=”jsapi.js”></script>
<script type=”text/javascript” src=”jquery.js”></script>
<script type=”text/javascript”>

// Load the Visualization API and the piechart package.
google.load(‘visualization’, ‘1’, {‘packages’:[‘corechart’]});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

**// This part needed to be changed to refresh the chart**

function drawChart() {
var jsonData = $.ajax({
url: “dataFetch/packageRenewals_WSC_AvaBill_Data.php”,
dataType:”json”,
async: false
}).responseText;

// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);

// Instantiate and draw our chart, passing in some options.
// var chart = new google.visualization.PieChart

(document.getElementById(‘chart_div’));
var chart = new google.visualization.BarChart(document.getElementById

(‘chart_div’));

chart.draw(data, {width: 450, height: 240});
}

</script>
</head>

<body>
<!–Div that will hold the pie chart–>
<div id=”chart_div”></div>
</body>

Best Regards
Gayan

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @gpdissanayake spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...