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() with .options() #769

Closed
christianmalek opened this issue Nov 19, 2014 · 7 comments
Closed

.stack() with .options() #769

christianmalek opened this issue Nov 19, 2014 · 7 comments

Comments

@christianmalek
Copy link

Hi,

Is it possible to use .options() with .stack()? Maybe in form of an array?

@gordonwoodhull
Copy link
Contributor

You shouldn't need to, because the individual series are not displayed by separate charts, but by one chart. What are you trying to do?

@christianmalek
Copy link
Author

I use dc.js in an angular.js application through angular-dc. The problem is that stacking isn't supported by now.

@gordonwoodhull
Copy link
Contributor

Okay, thanks. I'm not very familiar with angular-dc. What problem are you running into? Is this something that needs to be supported in the wrapper, or is there a way I can help on the dc.js side?

@christianmalek
Copy link
Author

At the moment it isn't possible to use the .stack() method without workaorunds with the wrapper. The conceived way of angular-dc is to replace the dc.js method chaining through attributes in angular directives.

For example:

 pieChart
            .width(300)
            .height(300)
            .dimension(stateDimension)
            .group(sumGroup);

In angular-dc you would set the options in the DOM with a directive. It wants the data in this case as attributes:

<div dc-chart="pieChart" dc-width="300" dc-height="300" dc-dimension="stateDimension" dc-group="sumGroup"></div>

.stack()'s pendant would be dc-stack. But dc-stack isn't supported by now and would be contravene with the approach to reflect every dc.js method with an attribute. You can see the issue on angular-dc here: TomNeyland/angular-dc#19

@gordonwoodhull
Copy link
Contributor

I see. At a glance, it appears to me that .options suffers from exactly the same problem as angular-dc: it can only take one parameter. Is that accurate?

Again, at a glance, never having looked at angular-dc, I wonder if the dc-post-setup-chart attribute mentioned here might be a suitable workaround for now?

@christianmalek
Copy link
Author

I see. At a glance, it appears to me that .options suffers from exactly the same problem as angular-dc: it can only take one parameter. Is that accurate?

Yep, that's right. Because of that the possibility of passing arrays as parameter is discussed.

For me there's nothing for it but to use the workaround.

@gordonwoodhull
Copy link
Contributor

It might be a breaking change in some cases, but .options() could conceivably detect the arity of the function by function.length and then either use apply or just call the function with the value depending.

E.g. chart.stack.length === 3

To be safe, it would have to be opts[o] instanceof Array && _chart[o].length > 1, which would only break functions with multiple arguments where the first argument is an array. If there are any such functions, there probably are not many places where users have called them using .options().

I'd want to make sure first, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants