简体   繁体   English

如何访问 ChartJS 默认值

[英]How to access ChartJS defaults

i need help with ChartJS v3 after migrating from v2从 v2 迁移后,我需要有关 ChartJS v3 的帮助

In v2 version i had a function that modifies ChartJS' default configuration as seen in the image below.在 v2 版本中,我有一个函数可以修改 ChartJS 的默认配置,如下图所示。 configuration ChartJS v2配置 ChartJS v2

However, after migrating to ChartJS v3, i'm unable to access the default ChartJS export from the library plus my defaults do not get applied even if i modified the defaults of an already existing Chart.但是,在迁移到 ChartJS v3 后,我无法访问库中的默认 ChartJS 导出,而且即使我修改了现有图表的默认值,我的默认值也不会应用。

Has this happened to anyone?有人遇到过这种情况吗? Any tips on how to fix it?有关如何修复它的任何提示?

I found out you need to import Chart and registerables, plus registering all of them in a tree-shaking approach.我发现您需要导入 Chart 和 registerables,并以摇树的方式注册所有这些。 I had Chart2 in my project and Chart3 in my library.我的项目中有 Chart2,我的库中有 Chart3。 Using Chart3 as peerDependency and updating my project's version fixed most of the issues.使用 Chart3 作为 peerDependency 并更新我的项目版本修复了大部分问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM