y-takey / chartjs-plugin-stacked100

This plugin for Chart.js that makes your bar chart to 100% stacked bar chart.
MIT License
129 stars 29 forks source link

Improve type denition of ChartData #98

Open y-takey opened 11 months ago

y-takey commented 11 months ago

see https://github.com/chartjs/chartjs-plugin-datalabels/issues/388#issuecomment-1647381453

frenzymind commented 4 months ago

Is this issue should fix this type error ?

when I use options: ChartOptions<'bar'> then I can not use plugin, I get error:

Type '{ id: string; beforeInit: (chart: Chart<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint)[], unknown>, args: EmptyObject, options: PluginOptions) => void; beforeUpdate: (chart: Chart<...>, args: { ...; }, options: PluginOptions) => boolean | void; afterUpdate: (chart: Chart<...>, args: {...' is not assignable to type 'Plugin<"bar", AnyObject>[]'

I have to cast plugin type:

  public plugins: Plugin<'bar', AnyObject>[] = [
    ChartjsPluginStacked100 as Plugin<'bar', AnyObject>,
  ];

then it works.

chartjs-plugin-stacked100@1.5.2",
chart.js@4.4.1
y-takey commented 4 months ago

Hi @frenzymind , I apologize for the delayed response. Thank you for the report :)

Actually, I don't have a deep understanding of type definitions. If possible, could you make the necessary changes to the plugin's type definition and submit a pull request? That would be very helpful.