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

layers.size() raises exception #1118

Closed
rlora opened this issue Mar 15, 2016 · 6 comments
Closed

layers.size() raises exception #1118

rlora opened this issue Mar 15, 2016 · 6 comments
Labels
Milestone

Comments

@rlora
Copy link

rlora commented Mar 15, 2016

On dc.js the line var last = layers.size() - 1; should be var last = layers.length - 1;?
I debugged the exception and haven't found a reason why size() its been used.

@gordonwoodhull
Copy link
Contributor

Hi @rlora, thanks for the report.

Could you give more detail or a short example which demonstrates the problem you're seeing? And also the exception you're seeing?

I take it you are referring to the bar chart code and some recent code which renders labels. I think .size() is correct as it's fetching the size of the d3 selection:

https://github.com/mbostock/d3/wiki/Selections#size

Note that the loop below is also a d3 selection each not a straight Javascript loop. So it seems to match.

But I don't doubt you're seeing a bug, so let's try to track that down!

@gordonwoodhull
Copy link
Contributor

This code was introduced in #1031

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Mar 16, 2016
@rlora
Copy link
Author

rlora commented Mar 17, 2016

Hi @gordonwoodhull, thanks for your reply.

I'm not sure if you were able to confirm this as a bug. It is happening in BarCharts. I was able to use series and other charts without issues.

The charts I'm using are very simple:

CHARTS.chart21 = dc.barChart("#_cubesExploreChart-2-1", GLOBAL_SCOPE).elasticY(true);
CHARTS.chart21.colors(d3.scale.ordinal().range(Colors.Brewer.Paired[3]));
CHARTS.chart21.x(d3.scale.ordinal().domain(_.pluck(FILTERS.dimensions.weekday.group().all(), "key"))).xUnits(dc.units.ordinal);
CHARTS.chart21.dimension(FILTERS.dimensions.weekday);
CHARTS.chart21.group(FILTERS.dimensions.weekday.group().reduceSum(d => d.value));

dc.renderAll(GLOBAL_SCOPE);

The exception is:
screen shot 2016-03-17 at 11 20 32 am

Debugging the exception the layers variable does not contain a size function, although it contains length. Making the change fixes it, and charts work. Although I can't be sure if this has collateral issues.

Thanks!

@gordonwoodhull
Copy link
Contributor

No I wasn't able to confirm it and I can't figure out how a d3 selection object would not have a size function. What version of d3.js are you using?

@rlora
Copy link
Author

rlora commented Mar 17, 2016

I'm sorry, my bad. I was using the d3 version packaged by Meteor. Turned out it was outdated and there is an official one. Now using 3.5.8 and it works perfectly. Previously using 3.1.4.

Appreciate your help :)

@gordonwoodhull
Copy link
Contributor

Oh phew, glad that fixed it. Good to know about the interface change and Meteor lagging.

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