【发布时间】:2020-03-05 14:15:29
【问题描述】:
我正在尝试根据全局注销 chartjs 插件 https://chartjs-plugin-datalabels.netlify.com/guide/getting-started.html#registration
我的 Angular 应用结构
布局---->
module a---> lazy loaded
component a1---> chart js chart
module b ----> lazy loaded
component b1---> chart js chart
module c---->lazy loaded
这些组件从 .ts 文件中获取我的选项
我用的是普通的ts文件
我的 .ts 文件
import ChartDataLabels from "chartjs-plugin-datalabels";
Chart.plugins.unregister(ChartDataLabels);
// a function which return chart options to component
get myChartOptions()
{
var options = new Options(); //my class
let plugin = options.getPlugin(); //another .ts file which assign value
return options;
}
Expected: Chartjs Data Plugin will get unregistered itself at load.
Actual: Plugin is not getting itself unregistered. Datalabels are
being in on component change also.
How to globally unregister the plugin in .ts file ??
【问题讨论】: