nagix / chartjs-plugin-colorschemes

Predefined color schemes for Chart.js
MIT License
263 stars 58 forks source link

Register with Chart.register? #39

Open awdorrin opened 2 months ago

awdorrin commented 2 months ago

Using the following:

"chart.js": "^4.4.2",
"chartjs-plugin-annotation": "^3.0.1",
"chartjs-plugin-colorschemes": "^0.4.0",
"chartjs-plugin-datalabels": "^2.2.0",
"ng2-charts": "^5.0.4",

I am trying to create a custom color scheme, as shown in the docs:

colors: string[] = ['#43B02A', '#61B3E4', '#9E7691', '#70A087', '#00968F', '#CC6C4E', '#005E5D', '#007396', '#59315F', '#414042', '#003CA6', '#7DDBD3', '#FFCD00'];
 public lineChartOptions: ChartConfiguration['options'] = {
   responsive: true,
   plugins: {
     legend: { position: 'top', },
     title: { display: true, text: 'Chart.js Line Chart' },
     colorscheme: { scheme: this.colors, }
   }
 };
 public lineChartType: ChartType = 'line';

however, I get an error on the colorscheme line stating: Object literal my only specify known properties, and 'colorscheme' does not exist in type '_DeepPartialObject<PluginOptionsByType<keyof ChartTypeRegistry>>'

I figure this is a ng2-charts issue, related to Chart.register() - but I have not been able to figure out how to register this plugin.