javascriptgoogle-visualizationgoogle-loader

How to add callback to gstatic loader.js google charts library?


As mentioned in http://developers.google.com/chart/interactive/docs/basic_load_libs#update-library-loader-code , it is advised to upgrade from old jsapi to new gstatic...loader.js for google charts.

Problem: Currently I'm having callback that is executed after loading of the js file completed: http://www.google.com/jsapi?callback=oldCallback

But with the new library, this callback is never executed:

http://www.gstatic.com/charts/loader.js?callback=newCallback

Why?

Example: https://jsfiddle.net/rLo9vdqm/1/


Solution

  • Listed under the limitations for the new loader.js...

    1. You can't autoload the library.

    which I take as --> you can't include anything on the url...

    you can include it with the load statement however...

    google.charts.load('current', {
      callback: newCallback,
      packages: ['corechart']
    });