You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to group a set of stacked bars in this version of ChartJS? I've got a fiddle of a triple stacked bar with 3 datasets, and I would like to group them together so I can add another set of 3 stacked bars. Hopefully this makes sense.
Edit: could you PR those changes? I think they'd be a great way to round out the core bar implementation. When you PR, could you implement for both vertical and horizontal bar charts?
Definitely ok with setting the y axis manually. My data is normalized going in so I can control the upper limit of the y. Thank you so much for the fiddle, helps me out quite a bit.
I have a follow up question for you. I've modified your fiddle a little to fit my data and I find I'm doubling up my labels. The data within each grouped stack is the same so I'm not sure how to avoid duplication of the labels. I might be coming at the problem wrong with my datasets.
@etimberg - sure, will check if I can figure out a cleaner way (the fiddle uses a lot of shortcuts :-) - I just hide datasets and call the original calculateBarY and calculateBarBase, instead of changing those methods). Might take a week or so because I'm on something else right now. Cheers!
@potatopeelings I had a quick follow up question on stack if you have a moment to have a look. Would love to understand a little more how to draw on the chart via the plugin interface. Thanks again!
@etimberg - it'd be great if someone can use the prototype for a PR. Sorry I couldn't get around to it as I hoped - got stuck with a couple of things at work.
This is a really interesting topic. The value of having a groupable "stacked" bar chart is huge. Any word on this becoming a standard feature or maybe it is already? Working on a project that could use this functionality and it would be great to simply add type: groupableBar, a stack id to the dataset JSON vs. all the examples. I think the hardest part is figuring out the MAX Y value which if it was built in, could be automatic, maybe?
Reacted by Adam Timberlake, Chris, Bob van Leeuwen, Tawani Anyangwe, jkeruzec, Corneel and rayan-nativex
I would love to have this in the core but I've been focused on fixing tooltips for v2.4. If someone wants to base something on @potatopeelings work then I can happily look at a PR.
PR for grouping stacked bars based on the previous code. Code Climate complains because of the duplication across bar and horizontal bar.
I think tooltips (mode = group?) and axes (a separate label line with the stack names) will probably need some enhancements to really wrap this one up.
Today I tried the new code and it works great. I have only one question, is it possible to use the stack as legend filter instead of the dataset label?
Activity
potatopeelings commentedon May 26, 2016
@chadcodes if you're ok to set your y axis limits manually check out - http://jsfiddle.net/4rjge8sk/
etimberg commentedon May 26, 2016
@potatopeelings awesome example there!
Edit: could you PR those changes? I think they'd be a great way to round out the core bar implementation. When you PR, could you implement for both vertical and horizontal bar charts?
chadcodes commentedon May 26, 2016
Definitely ok with setting the y axis manually. My data is normalized going in so I can control the upper limit of the y. Thank you so much for the fiddle, helps me out quite a bit.
I have a follow up question for you. I've modified your fiddle a little to fit my data and I find I'm doubling up my labels. The data within each grouped stack is the same so I'm not sure how to avoid duplication of the labels. I might be coming at the problem wrong with my datasets.
http://jsfiddle.net/4rjge8sk/1/
potatopeelings commentedon May 26, 2016
@etimberg - sure, will check if I can figure out a cleaner way (the fiddle uses a lot of shortcuts :-) - I just hide datasets and call the original calculateBarY and calculateBarBase, instead of changing those methods). Might take a week or so because I'm on something else right now. Cheers!
@chadcodes - just set
legend.labels.generateLabels. See http://jsfiddle.net/2xjwoLq0/The above is hardcoded to just take 3 - the nice way would be to use
config.datato figure out the count.etimberg commentedon May 26, 2016
@potatopeelings sounds good. changing the calculateBarY and calculateBarBase functions is probably the way to go
chadcodes commentedon May 26, 2016
@potatopeelings amazing work! I really appreciate the help on this. I'll work on using the config.data to update the fiddle and repost it here.
chadcodes commentedon May 31, 2016
@potatopeelings I had a quick follow up question on stack if you have a moment to have a look. Would love to understand a little more how to draw on the chart via the plugin interface. Thanks again!
http://stackoverflow.com/questions/37546590/add-a-custom-label-to-the-top-or-bottom-of-a-stacked-bar-chart
etimberg commentedon Jun 29, 2016
@potatopeelings have you been able to work on a PR for this, or could someone run with your prototype and turn it into a PR?
potatopeelings commentedon Jun 30, 2016
@etimberg - it'd be great if someone can use the prototype for a PR. Sorry I couldn't get around to it as I hoped - got stuck with a couple of things at work.
etimberg commentedon Jun 30, 2016
@potatopeelings not a problem. I might look into this over the weekend. I'll link you if I get something done :)
cgountanis commentedon Aug 12, 2016
This is a really interesting topic. The value of having a groupable "stacked" bar chart is huge. Any word on this becoming a standard feature or maybe it is already? Working on a project that could use this functionality and it would be great to simply add type: groupableBar, a stack id to the dataset JSON vs. all the examples. I think the hardest part is figuring out the MAX Y value which if it was built in, could be automatic, maybe?
Wildhoney commentedon Aug 22, 2016
+1 👍
6 remaining items
Wildhoney commentedon Sep 29, 2016
Not yet — it seems as though @potatopeelings or a native Chart.js solution are our only saviours.
etimberg commentedon Sep 29, 2016
I would love to have this in the core but I've been focused on fixing tooltips for v2.4. If someone wants to base something on @potatopeelings work then I can happily look at a PR.
cgountanis commentedon Sep 29, 2016
I would love to see group/stacked with support as well. It should be a standard type if you ask me. Super useful.
potatopeelings commentedon Nov 7, 2016
PR for grouping stacked bars based on the previous code. Code Climate complains because of the duplication across bar and horizontal bar.
I think tooltips (mode = group?) and axes (a separate label line with the stack names) will probably need some enhancements to really wrap this one up.
@Wildhoney - check out the fiddle in the PR (https://jsfiddle.net/Lvj2qnrp/1/). It works now. Cheers!
cgountanis commentedon Nov 7, 2016
Hate to ask a noobie question like this but does that mean this is standard in the main release now with examples?
Wildhoney commentedon Nov 7, 2016
Thanks @potatopeelings – good effort 👍
@cgountanis it will be once the PR has been merged in, tagged, and released.
Rido commentedon Dec 12, 2016
Great work @potatopeelings! 👍
Today I tried the new code and it works great. I have only one question, is it possible to use the
stackas legend filter instead of the dataset label?rjurado01 commentedon Dec 28, 2016
Thanks @potatopeelings, it works !!
Group stacked bar charts (#2643) (#3563)
etimberg commentedon Jan 1, 2017
Done in #3563
potatopeelings commentedon Jan 3, 2017
@Rido - I believe you should be able to override
generateLabelsto return labels for each group and then overrideonClickto toggle visibility of datasets of the group (https://github.com/chartjs/Chart.js/blob/master/src/core/core.legend.js)atulpendse commentedon Jan 19, 2017
@potatopeelings - Great work..
Group stacked bar charts (chartjs#2643) (chartjs#3563)