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

stack-mixin: setting custom stack layout algorithm not working #1102

Closed
jetsnguns opened this issue Feb 13, 2016 · 3 comments
Closed

stack-mixin: setting custom stack layout algorithm not working #1102

jetsnguns opened this issue Feb 13, 2016 · 3 comments
Labels
Milestone

Comments

@jetsnguns
Copy link

The chart.stackLayout method is not working correctly when you try to change the layout algorithm. Unlike its default initialization on line 28 of stack-mixin.js:

    var _stackLayout = d3.layout.stack()
        .values(prepareValues);

the method code on line 263 lacks binding values:

    _stackLayout = stack;

Changing it to

     _stackLayout = stack.values(prepareValues);

fixes the issue (tested with d3.layout.stack().offset("expand")).

@gordonwoodhull
Copy link
Contributor

Documentation link for d3.layout.stack.values:
https://github.com/mbostock/d3/wiki/Stack-Layout#values

@gordonwoodhull
Copy link
Contributor

Cool! Does this mean that we have normalized stacked bar charts?

I agree - although this feature goes back to the very early days of dc.js, it doesn't look like it could ever have worked without specifying .values().

I'm not sure if it's a good idea, but in case anyone is intentionally setting .values() differently, we could check if it is already set and only set it if not:

     _stackLayout = stack;
     if(_stackLayout.values() === d3.layout.stack().values()) {
          _stackLayout.values(prepareValues);

Kinda ugly though. The default is d3_identity but that's not exposed.

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Apr 29, 2016
@gordonwoodhull
Copy link
Contributor

I'm fixing this in 2.0 beta 28 - unfortunately I don't have time to implement tests for a different stack layout and stackLayout remains untested. 😦

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