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
Global defaults have no effect for doughnuts and pie charts. #10927
Comments
I think this is related to new color plugin of version 4, see https://www.chartjs.org/docs/latest/general/colors.html#per-dataset-color-settings. I think it's a bug of the plugin, on the following code: Chart.js/src/plugins/plugin.colors.ts Lines 95 to 99 in 8239567
I see 2 things:
|
Nice find, thanks! Given the addition of this new plugin in v4, as a maintainer of the Angular wrapper, I wonder if I should remove the color generation feature and just delegate to the new plugin, any opinions from the Chart.js maintainers? |
@santam85 For tests you can disable this plugin by |
I don't think the colors plugin can resort to fallback colors, because then there always is a color already. The plugin can also be disabled globally: Chart.defaults.plugins.colors.enabled = false; |
@kurkle exactly what I'm thinking. No options apart disable it, globally. |
Yes that's what I did. I can confirm that it fixes my issue, so for now I'll go ahead and disable the color plugin when generating colors myself. |
Another option, for the colors plugin, could be to attach as a scriptable global default. |
@kurkle for my understanding, do you mean the plugin will set a scriptable option in the defaults? The plugin will just set the scriptable option and the logic is overthere, correct? |
Anyway, even if the color plugin is a feature and not a breaking change, I think something could be reported in the migration guide because this is a common use case which is broken. WDYT? |
That's what I've gone for in the Angular wrapper lib |
I can make a fix for this case. |
It is impossible to detect whether the defaults changed or not on the plugin level. So I suggest accepting this as expected behavior and closing the issue.
It is a valid problem only for the UMD bundle, where all plugins are enabled by default. We have a notice about that in the docs: https://www.chartjs.org/docs/latest/general/colors.html
|
@santam85 @stockiNail @kurkle what do you think? |
Fine for me |
Expected behavior
Doughnut and pie charts use global datasets defaults or arc elements defaults for backgroundColor.
Polar area charts scriptable property dataIndex seems dependent on the property type.
Current behavior
The global defaults have no effect. Scriptable options funcitons are not called.
Reproducible sample
https://codepen.io/leelenaleee/pen/WNyJXEe
Optional extra steps/info to reproduce
No response
Possible solution
No response
Context
Testing new Chart.js version for ng2-charts
chart.js version
v4.0.1
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered: