0

I am building an app using requirejs, parse.com, list.js, and using gulp to serve it. I am trying to use ooCharts to load in google analytics charts.

the failing code is written in a script tag in the html being injected on the DOM via a Parse(Backbone, essentially) View. The failing code is :

  <div data-oochart="bar" data-oochart-start-date="30d" data-oochart-metrics="ga:visits,Visits,ga:newVisits,New Visits" data-oochart-dimension="ga:continent" data-oochart-profile="{{id number}}"></div>

window.onload = function(){

    oo.setAPIKey("{{my api key}}");

    oo.load();
};

In my actual code I do have the api key and id number plugged in.

First of all, the window.onload won't fire at all. secondly, when i get oo.load() to run, my console error is "Uncaught TypeError: undefined is not a function" and points to oocharts.js line 188. oo (the object given to access the functions in oocharts.js) is globally available, and is available before the function runs, so the view definitely has access to oo.load()

I also ran into a similar problem trying to use the google embed API to load in charts from my analytics. Can anyone help me with this? I believe there is some sort of conflict preventing my existing code base (the majority of which I didn't write) from working with google analytics/oocharts, but for the life of me I can't figure out where.

1 Answers1

0

in case anyone else runs into this problem:

oo.load() was calling google.load() which was not loaded onto the page by ooCharts (for whatever reason, I don't see it mentioned in the docs that it doesn't get the google methods it needs) so I was able to fix it by adding

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

into the head of the HTML.