amitiitr11 / analytics-api-samples

Automatically exported from code.google.com/p/analytics-api-samples
0 stars 0 forks source link

'defaultOnError' JS undefined error when no data is returned. onError callback does not fire. #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a gadash.Chart (tested types: Table and ColumnChart)
2. Use a TableID for an account with no data.
3. Use the following metrics: 'ga:visitors' 
4. Use the following dimensions: 'ga:visitorType'

What is the expected output? What do you see instead?

I am trying to catch when no data is displayed, and show a message. However it 
seems the callback for onError cannot fire, and instead a JS error displays: 
Uncaught TypeError: Object #<Object> has no method 'defaultOnError' on line 347 
of ga-dash-1.0.js

I tested the same function on a GA account with no data, and a GA account with 
data, the one with data successfully rendered, the one without threw an error 
and would not let me catch the empty rows to provide feedback to the dashboard.

What version of the product are you using? On what operating system?
ga-dash-1.0.js, Google Chrome on Debian Lenny 

Please provide any additional information below.

I tested this with the "Table" and the "ColumnChart" object, and both rendered 
the same.

Here's the function:

    var adWordsTable = new gadash.Chart({
      'type': 'ColumnChart',
      'divContainer': 'chart-visitors',
      'last-n-days':30,
      'query': {
        'ids': 'ga:60406207', //<-- no visitors, returns js console error
        //'ids': 'ga:60052829', //<-- has visitors, renders fine
        'metrics': 'ga:visitors',
        'dimensions': 'ga:visitorType'
      },
      'chartOptions': {
          chartArea: {left:10,top:10,width:"100%",height:"75%"}
        },
      'onError': function(){
        // This is what I would like to do when there's no data:
        $('#adwords-impressions').html('No Data to Display.');
      }
    }).render();

Original issue reported on code.google.com by kri...@theresnobox.net on 9 Jun 2012 at 2:44