c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Totals on stacked bar chart

Open philipcdavis opened this issue 9 years ago • 11 comments

It would be nice to be able to add totals as a data label to stacked bar charts and to their corresponding tool tips. Something like this.

This might require additional design decisions like exposing the ability to center data labels within bars charts as well.

philipcdavis avatar Feb 09 '15 16:02 philipcdavis

Yeah, looks nice. Let me mark as enhancement and plugin candidate. Thanks!

masayuki0812 avatar Mar 10 '15 12:03 masayuki0812

Was this ever implemented?

avoliva avatar Mar 03 '16 00:03 avoliva

Is it possible to show only the total instead of cluttering all values? Lets say my stacked bar values are [0, 1, 2, 500] and in this case text labels overlap each other for 0, 1, 2 with formatting like 'n degree' in rotated axis graph. Is it possible to sum everything and show just one at the top. While selecting label we will pass data-n id as array to consider for sum because graph wont know for which stacked bar it has to show sum, in case of multiple stacked bars.

smartameer avatar May 12 '16 10:05 smartameer

Bump...

Some news about this?

nbpalomino avatar Aug 02 '16 20:08 nbpalomino

+1 showing the total on top of the stacked bar chart would be very useful

johnnymetz avatar Dec 08 '17 21:12 johnnymetz

Any updates on showing total on the top?

ArtyomMinsk avatar Feb 12 '18 19:02 ArtyomMinsk

Any news about the optional display text label center in the bar? I got same problem.

n2lose avatar Feb 27 '18 04:02 n2lose

Here a quick solution on how to get totals on stacked bar charts:

You can make a stacked bar chart a combination chart by adding a line into the chart which has as data the totals. Because the line represents the totals, it sits exactly on top of the bars, because the stack size is the sum=total. Now we use CSS to remove the line, because you want only see the labels and in order to avoid overlapping labels, we move the labels of the total line a little bit up via CSS. That's it.

Here is a fiddle, which shows the result: https://jsfiddle.net/thomasw/t2aj7xsL/20/

tvw avatar Jun 29 '18 16:06 tvw

Any updates on showing total on the top, I also need this feature urgently?

guptavijay208 avatar May 22 '19 09:05 guptavijay208

sorry to dig out such an old subject but any news about it ? i do need this feature.

Zenthae avatar Dec 09 '20 23:12 Zenthae

While this does not get implemented, the person that made this fiddle hacked their way to make it work, might be useful for someone else as it was for me: https://jsfiddle.net/Dimmy/d5sxjng2/6/

apolinario avatar Apr 02 '21 08:04 apolinario