-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Possible to group a stacked bar chart? #2643
Comments
@chadcodes if you're ok to set your y axis limits manually check out - http://jsfiddle.net/4rjge8sk/ |
@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? |
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! @chadcodes - just set
The above is hardcoded to just take 3 - the nice way would be to use |
@potatopeelings sounds good. changing the calculateBarY and calculateBarBase functions is probably the way to go |
@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. |
@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! |
@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? |
@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. |
@potatopeelings not a problem. I might look into this over the weekend. I'll link you if I get something done :) |
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? |
+1 👍 |
@potatopeelings thank for you this. Although you'll notice in your example that when you click on the legend for "My First Dataset" it's not toggle-able in the graph. Do you have any idea how to rectify this? All of the others work fine, but I assume because we're rendering the first dataset next to the others, it somehow loses its reference? |
@Wildhoney I'm having same problem. Do you find any solution ? |
Not yet — it seems as though @potatopeelings or a native Chart.js solution are our only saviours. |
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. |
I would love to see group/stacked with support as well. It should be a standard type if you ask me. Super useful. |
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! |
Hate to ask a noobie question like this but does that mean this is standard in the main release now with examples? |
Thanks @potatopeelings – good effort 👍 @cgountanis it will be once the PR has been merged in, tagged, and released. |
Great work @potatopeelings! 👍 Today I tried the new code and it works great. I have only one question, is it possible to use the |
Thanks @potatopeelings, it works !! |
Done in #3563 |
@Rido - I believe you should be able to override |
@potatopeelings - Great work.. |
Group stacked bar charts (chartjs#2643)
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.
https://jsfiddle.net/7oo4ugbj/
The text was updated successfully, but these errors were encountered: