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