Error Property 'id' is missing
Closed this issue · 2 comments
technbuzz commented
I am trying to use it the following way but getting the error
import * as autocolors from 'chartjs-plugin-autocolors';
Chart.register(DoughnutController, ArcElement, autocolors)
const chart = new Chart(this.chartWrapper.nativeElement, {
type: 'doughnut',
data: {
labels: data.map(row => row.year),
datasets: [{
label: 'Acquisation per year',
data: data.map(row => row.count),
}]
},
plugins: [autocolors], // throws an error
})
But the plugin field throws an error
Property 'id' is missing in type 'typeof import("/path/to/project/node_modules/chartjs-plugin-autocolors/types/index.esm")' but required in type 'Plugin<"doughnut", AnyObject>'.
friberk commented
I can confirm that the issue still persists as of April 12, 2024. However, on chart.js@4.4.2, I was able to overcome the problem as follows:
import * as autocolors from 'chartjs-plugin-autocolors';
const autocoloredPlugin = {
...autocolors,
id: 'autocolors', // Adding the required 'id' property
};
// ...
const chart = new Chart(ctx, {
// ...
plugins: [
autocoloredPlugin
]
});
Although this solution is most likely a bad practice, it saves the day. Still, this issue should be resolved in the upstream.
kurkle commented
This should be fixed on v0.3.0 (exporting the pluigin as default)