Try reusing the chart object instead of recreating them over and over. Get
rid of the setInterval call and replace drawChart with this:
function drawChart() {
var chart = new
google.visualization.AnnotationChart(document.getElementById('chart_div'));
function updateChart () {
var jsonData = $.ajax({
url: "/data/aceResponse.txt",
dataType: "json",
async: false,
cache: false
}).responseText;
var interval = $.ajax({
url: "/data/IntervalRequest.txt",
dataType: "text",
async: false,
cache: false
}).responseText;
$("#interval").text(interval);
var data = new google.visualization.DataTable(jsonData);
chart.draw(data, {
is3D: true,
colors: ['red'],
displayZoomButtons: false,
displayRangeSelector: false,
dateFormat: 'HH:mm:ss'
});
}
updateChart();
setInterval(updateChart, 10000);
}
On Thursday, May 22, 2014 3:41:00 PM UTC-4, Paul Duer wrote:
>
>
> Hey all, I am using the following Javascript. But, it causing the chart to
> BREAK badly on each update.
>
> What have I done wrong?
>
> <script type="text/javascript">
> google.load('visualization', '1.1', { 'packages':
> ['annotationchart'] });
> google.setOnLoadCallback(drawChart);
>
> setInterval(drawChart, 10000);
>
>
> function drawChart() {
> var jsonData = $.ajax({
> url: "/data/aceResponse.txt",
> dataType: "json",
> async: false,
> cache: false
> }).responseText;
> var interval = $.ajax({
> url: "/data/IntervalRequest.txt",
> dataType: "text",
> async: false,
> cache: false
> }).responseText;
>
> $("#interval").text(interval);
> var data = new google.visualization.DataTable(jsonData);
>
> var chart = new
> google.visualization.AnnotationChart(document.getElementById('chart_div'));
> chart.draw(data, {
> is3D: true,
>
> colors: ['red'],
> displayZoomButtons: false,
> displayRangeSelector: false,
> dateFormat: 'HH:mm:ss'
> });
> }
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.