javascript - IE8 error on GoogleChart redraw function -


i using google charts api draw several combocharts utilizing arraytodatatable routine. loads fine error occurs (in ie8 only) if try redraw of charts.

i first noticed when triggering redraw of charts using jquery's $( window ).resize issue present if execute 2 back-to-back chart.draw functions.

any ideas...

  • what causing error?
  • how can fix it?

script error ie8 (repeated multiple times):

format+en,default+en,ui+en,corechart+en.i.js 

here sample code reproduce error in ie8. resize window trigger error:

<html> <head> <title>graph test</title> <meta charset="utf-8"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript">  var opt = {       legend: { position: 'none' },       axistitlesposition: 'none',       enableinteractivity: 'false',       haxis: {textposition: 'none'},       vaxis: {textposition: 'none', maxvalue: 11, minvalue: 6, gridlines: {color: 'transparent'}, baselinecolor: 'transparent'},       linewidth: 1,       bar: {groupwidth:'75%'},       seriestype: "bars",      series: {1: {type: "line"}},       chartarea: {'width': '90%', 'height': '90%'},       colors: ['#4d8c8c', '#a7a7a7'],       backgroundcolor: '#d3eeee' }   var myarray = [     ['id', 'value', {role: 'style'}, 'rec', {role: 'certainty'}],     [1, 8, '#ff0000', 10, false],     [2, 7, '#ff0000', 10, false],     [2, 10, '#ff0000', 10, false]     ];    google.load("visualization", "1", {packages:["corechart"]});   google.setonloadcallback(function(){drawchart(myarray,opt)});   function drawchart(arr,opt) {     data = google.visualization.arraytodatatable(arr);     chart = new google.visualization.combochart(document.getelementbyid('chart_div'));     chart.draw(data, opt);   }  $(document).ready(function() {  $( window ).resize(function() {     drawchart(myarray,opt); }); });  </script> </head> <body>  <div id="chart_div" style="width: auto; height: 50px;"></div>  </body> </html> 

instead of creating new chart object each time, try redrawing existing one:

function drawchart(arr,opt) {     data = google.visualization.arraytodatatable(arr);     var chart = new google.visualization.combochart(document.getelementbyid('chart_div'));     chart.draw(data, opt);     $( window ).resize(function() {         chart.draw(data, opt);     }); } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -