-
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
Pie doughnut dataset weight #5951
Pie doughnut dataset weight #5951
Conversation
Weight affects the relative thickness of the dataset when there are multiple datasets in pie & doughnut charts. The default weight of each dataset is 1. Providing any other numerical value will allow the pie or doughnut dataset to be drawn with a thickness relative to its default size. For example a weight of 2 will allow the dataset to be drawn double its typical dataset thickness. NOTE: The weight attribute will only have an affect on a pie or doughnut chart if there is more than one visible dataset. Using weight on a pie or doughnut dataset when there is only one dataset on the chart will have no affect.
@benmccann Thanks for the feedback. I'll make those changes. |
- added back getRingIndex function to doughnut controller. - moved getVisibleDatasetTotalWeight from the base controller file to the doughnut controller. - removed parentheses from the chartWeight assignment statement. - Also, slightly renamed the new functions
simplicfications.
Good point @nagix but it may be better to tackle this optimization in a separate PR (maybe by registering an internal plugin computing these values during I like this feature, however we may want a different API for it. I was already thinking to use Highchart uses
If we really want to implement the weight approach, maybe we could use the |
I would definitely reserve Thoughts? |
Hi @simonbrunel , sorry for the slow reply. I thought that perhaps you were asking the question of your co-reviewers. I do agree with you that this parameter should be called something other than
i'm happy to change it to Sorry to give you back a question, but... what do you think? |
Thanks @Vincent-Ip I would go for a name that will also work for other charts, for example we could implement it to control the size of bars when side by side (which is of course not the purpose of this PR). That's why I would eliminate We are not designing our features to support exactly the same syntax as CSS, I'm just saying that For example (CSS) .col-1 { flex: 2; } // size: 25%
.col-2 { flex: 2; } // size: 25%
.col-3 { flex: 4; } // size: 50% In this case, it's the same syntax and the same behavior, so could be a good match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@Vincent-Ip I think we should remove the pixel based test since it's exactly the same as the image based ones (see this comment). |
619f667
Thanks @Vincent-Ip for this work and all the iterations. |
@simonbrunel No problem. Thank you and all other reviewers for the experience. |
Ah looks like I missed the progression of this, was only following #4724. Looks great guys, I'll try to find the time to give it a spin and adjust my workaround 😄 |
Add functionality to give pie & doughnut datasets a weight attribute, which affects the relative thickness of the dataset when there are multiple datasets in pie & doughnut charts. The default weight of each dataset is 1, providing any other numerical value will allow the pie or doughnut dataset to be drawn with a thickness relative to its default size. For example a weight of 2 will allow the dataset to be drawn double its typical dataset thickness. Note that the weight attribute will only affect a pie or doughnut chart if there is more than one visible dataset. Using weight on a pie or doughnut dataset when there is only one dataset on the chart will have no affect.
I thought that this could help other people trying to adjust the relative size of Pie and Doughnut datasets. I saw a feature request for something similar #4724 and I also had a need to vary the thickness to make the pie chart look they way I wanted.
Here's an example of what the chart looks like with the new dataset attribute - weight.
In the above example, the inner dataset was given a weight of 3. This results in a data set that is 3 times the size of outer dataset (which doesn't specify a weight and so has a default weight of 1).
Fixes #4724
Fixes #5330
Fixes #5612