Skip to content

Stacked Area Functionality #344

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

Closed
pscanlon1 opened this issue Mar 18, 2016 · 6 comments
Closed

Stacked Area Functionality #344

pscanlon1 opened this issue Mar 18, 2016 · 6 comments

Comments

@pscanlon1
Copy link

Using your stacked example here :http://codepen.io/plotly/pen/PqLGjK

If you deselect Trace 0, the Y Axis doesnt change. This is because the stack function doesnt run a second time to recalculate all the new values. Is there some workaround we could use?

image

image

@mdtusz
Copy link
Contributor

mdtusz commented Mar 18, 2016

I'm confused as to what you are hoping will happen. The axes values appear to be correct in your examples. trace 2 has values (1, 6) and (3,8), so we can't really resize the axis to be any more compact than from 0 to 8.

If you deselect trace 2, you should see that the axes will autosize and the maxium y-axis value will be 6 (where trace 1 is (3,6)).

@mdtusz
Copy link
Contributor

mdtusz commented Mar 18, 2016

After looking again, I think I understand your question.

Unfortunately (or perhaps not!), the legend trace toggles are purely for the display of data - the underlying data still exists and is calculated so the "position" of the trace will not change when toggled.

@pscanlon1
Copy link
Author

I was trying to get functionality like a stacked bar chart, so say on Category 1, you have 2 values of 5 and 10. This bar would be plotted at y = 15.

If you deselect the trace of 5, then y = 10.

@mdtusz
Copy link
Contributor

mdtusz commented Mar 18, 2016

The legend toggles only change what is displayed on the plot - the underlying data does not get recomputed.

If you would like to remove the trace, you will need to use Plotly.deleteTraces.

@pscanlon1
Copy link
Author

What would you suggest the event is that I listen for in this case?

@etpinard
Copy link
Contributor

@pscanlon1 Unfortunately, plotly.js doesn't support native stacked area charts. So, as you discovered in the example codepen you posted, computed area charts don't behave well on updates.

We are planning on adding area charts to our list of trace types at some point this year. You are not the first person to ask for this feature.

In the meantime, there is a way to hack into plotly.js' internal to fake the desired behaviour. Here's what I came up with: http://codepen.io/etpinard/pen/yOgdOb . Use at your own risk 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

No branches or pull requests

3 participants