Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bar/Pie "Row given with size different than" #52

Open
ellisio opened this issue Apr 2, 2014 · 17 comments
Open

Bar/Pie "Row given with size different than" #52

ellisio opened this issue Apr 2, 2014 · 17 comments
Labels

Comments

@ellisio
Copy link

ellisio commented Apr 2, 2014

Hello,

Using the latest master.zip and the following JS results in the following errors.

JS

$(function(){
oo.setAPIKey("##OUR_API_KEY##");
oo.setBarDefaults({colors:['#4a73b9','#aabd56'],isStacked: true,bar: { groupWidth: '95%' }});
oo.load(function(){
    var bar = new oo.Bar("##OUR_PROFILE_ID##", "30d");
    bar.addMetric("ga:visits", "Visits");
    bar.addMetric("ga:newVisits", "New Visits");
    bar.setDimension("ga:continent");
    bar.draw("bar-chart");

    var pie = new oo.Pie("##OUR_PROFILE_ID##", "30d");
    pie.setMetric("ga:visits", "Visits");
    pie.setDimension("ga:browser");
    pie.draw("pie-chart");
});
});

For the bar, we get this error:

Uncaught Error: Row given with size different than 2 (the number of columns in the table). 

For the pie, we get this error:

Uncaught Error: Row given with size different than 3 (the number of columns in the table).

We have created a simple HTML document that does nothing but include oocharts.min.js and even tried removing jQuery and using window.onload. This results in the same issue.

Cheers,
Andrew

@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

Do you mind sending me a copy of the script ( [email protected])? I'd like to debug the results coming back from the API.

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

Hey Tyler,

It appears this is working fine now. Might have been an issue with Google... Wouldn't surprise me any. ha

Cheers,
-Andrew

@ellisio ellisio closed this as completed Apr 2, 2014
@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

Hey Tyler,

I just sent you an email. It actually appears this is still happening when you try to set a fitler (ga:pagePath==/TEST) on Pie or Bar graphs.

Cheers,
-Andrew

@ellisio ellisio reopened this Apr 2, 2014
@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

@awellis13 Ah I see the issue. This is happening when the results are empty. I will leave this open until there is a fix for this. (filling with zeroes, perhaps?)

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

@tshaddix Take a look at the Timeline implementation though. Here is a screenshot: http://d.pr/i/xfNv So there is data coming back for the graphs. Can you see anything on the request that maybe I'm doing wrong for the Pie/Bar?

@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

@awellis13 is this for another query? Using the script provided, I'm getting zero rows back.

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

@tshaddix Take a look at the Gist; I have updated it to include the Timeline as well.

@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

@awellis13 So when using ga:date as a dimension, I'm seeing data come through. Using the continent as the dimension returns no results. That would explain the error. You might try to see if you can get results back using Google's Query Explorer.

JSONP.callbacks.request_1 && JSONP.callbacks.request_1({"total_results":0,"rows":[],"column_headers":[{"dataType":"STRING","columnType":"DIMENSION","name":"ga:continent"},{"dataType":"INTEGER","columnType":"METRIC","name":"ga:visits"},{"dataType":"INTEGER","columnType":"METRIC","name":"ga:newVisits"}]});

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

@tshaddix I do receive results. It currently is showing "Americas: 1" on the Query Explorer. I also am running into issues where the Bar chart fails when setting it to ga:continent, but works when set to ga:date.

@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

@awellis13 Ahh, so I'm guessing this page was recently visited? OOcharts caches similar requests for an hour to minimize load and quota usage on our Google keys. Once the cache is clear, you should be seeing similar results on the OOcharts end.

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

@tshaddix Cool, I'll try again in the morning since my day is coming to a close. I'll let you know if I continue to receive issues.

@tshaddix
Copy link
Owner

tshaddix commented Apr 2, 2014

@awellis13 Great! Hoping to hear good news.

@ellisio
Copy link
Author

ellisio commented Apr 2, 2014

@tshaddix Doesn't look promising. I'm toying around and changing the ga:pagePath== filter to different pages on my blog to force a new query. Each page I try to change the URL and it still fails.

For example, this is one I tried and it returned "1 Visit" using the Query Explorer, and then I tried loading it through OOCharts and it broke with the same error.

var bar = new oo.Bar(profileId, "30d", new Date("2014-04-03"));
bar.query.setFilter("ga:pagePath=~^/post.*");
bar.addMetric("ga:visits", "Visits");
bar.addMetric("ga:newVisits", "New Visits");
bar.setDimension("ga:continent");
bar.draw("chart");

On the Query Explorer I had the following set:

dimensions=ga:continent
metrics=ga:visits,ga:newVisits
filters=ga:pagePath=~^/post.*
start-date=2014-03-19
end-date=2014-04-03
max-results=50

And a screen shot of the results: http://d.pr/i/HLZK

@ellisio
Copy link
Author

ellisio commented Apr 3, 2014

@tshaddix Hey man, so this seems to be working correctly, but there is for sure a bug when an empty result set comes back. To test, simply use:

bar.query.setFilter("ga:pagePath==/-1")

For now, I'm going to put in an exception handler for this and just display a sad panda face.

Cheers,
-Andrew

@tshaddix
Copy link
Owner

tshaddix commented Apr 3, 2014

@awellis13 That's great! Sad panda faces are always the best way to go in situations like this.

I'll keep this bug open for handling empty result sets.

@ellisio
Copy link
Author

ellisio commented Apr 3, 2014

@tshaddix It appears all that you need to do is simply change:

dt.addRows(data);

To:

if (data.length && data[0].length) {
    dt.addRows(data);
}

That prevents adding empty data to the DataTable object.

Cheers,
-Andrew

@tshaddix
Copy link
Owner

tshaddix commented Apr 3, 2014

👍 Looks good.

@tshaddix tshaddix added the bug label Apr 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants