Stacked bar with positive and negative values

Hi guys,

I have data for a stacked bar with both positive and negative values. I would like the negative values to render below the x axis and stack and the positive values to render above the x axis and stack. I have tried stack and overlay MODE and in both cases at least one of my datapoints is being hidden behind another bar. MODE = group renders as expected with negative values below the line. Is this a bug?

Sounds like a similar unresolved problem here:

http://community.plotly.com/t/when-i-am-ploting-a-stacked-bar-chart-with-both-ve-ve-values-using-ployly-js-the-value-in-stacked-bar-is-coming-as-the-substraction-of-ve-value-from-ve-value-but-it-should-come-on-both-side-of-x-axis-wrt-y-axix-ve-ve-value-plz-suggest/497

Many thanks.

1 Like

This is the intended behaviour of the stack and overlay bar modes at the moment.

Your use case seems pretty common, I’m thinking we add another barmode value e.g. 'stack-relative'

Please subscribe to https://github.com/plotly/plotly.js/issues/475 for the latest development info.

1 Like

That would be awesome. Thanks.

What are the use cases of the “intended behaviour” ?

A new barmode has been added in the latest plotly.js release.

This example http://codepen.io/etpinard/pen/mPGLrY? compares the different barmode values.