Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google charts "is not a function" in every browser except chrome

a[jc] is not a function

Firefox, safari, safari on ios, IE, ... all of them behave the same way.

no matter what I do, this error is only avoidable on the chrome browser.

Note that it is not a date formatting issue as I use

var rows = [
    [new Date(Date.UTC(x,y,z,...)), ...],
    ...
  ];
var table = new google.visualization.DataTable();
table.addColumn('datetime', 'Time');
table.addColumn(...);
...
table.addRows(rows);

i've done

<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script>

as per https://stackoverflow.com/a/29777575/3338098

and i've done

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
  var googleChartLoaded = false;
  google.load('visualization', '1', {packages: ['corechart'], callback: function() {
    googleChartLoaded = true;
  }});
</script>

and even

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
  google.load('visualization', '1', {packages: ['corechart']});
  google.setOnLoadCallback(function() {
    googleChartLoaded = true;
  });
</script>

I have tried as per https://nealpoole.com/blog/2010/07/jquery-getjson-firefox-and-google-visualization-madness/

window.setTimeout(function() {
  try {chart.draw(table, chartOptions);}catch(err) {
    console.err(err);
  }
}, 1000);

our issue is identical to https://developer.appcelerator.com/question/148481/how-i-make-line-graph-on-android-device

how do I go about diagnosing this issue... I assumed a google product would of been cross-browser compatible...

like image 796
user3338098 Avatar asked Dec 19 '25 14:12

user3338098


1 Answers

I had the same issue with exact this error message. Here, the issue is with options object that is passed to draw function.

In my case, I had two options : vAxis.ticks and hAxis.viewWindow The documentation says these options are only for continuous axis and my axes were continuous. However these were the problem. I took them out, and its working perfectly.

like image 125
shinoymm Avatar answered Dec 22 '25 03:12

shinoymm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!