You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if it's been omitted on purpose though? Looking at the other plugins in there they are not ones you need to call register for (i.e. they appear to be "preregistered plugins"). That's quite reasonable since adding it into PluginOptionsByType makes it appear from the types to be available all the time, but you have to register it before you can use it. But in that case, it feels like there is an expectation that some declaration merging has to happen (as with the plugins that live in other packages) - doing that as a user feels a bit awkward.
So I wonder if the solution might be to expose the Colors plugin on an import path rather than on the root e.g. import { Colors } from 'chart.js/colors'; you would be able to add the declaration merge in a .d.ts on that path and give the users a better experience, and retain a similar behaviour to other plugins.
Context
No response
chart.js version
v4.2.0
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered:
Expected behavior
Following the examples in the docs, and when using a typescript project, the colors plugin can be configured, without type errors.
Current behavior
The colors plugin is not included in
PluginOptionsByType
. In typescript project trying to follow the examples in the docs leads to a type error.Reproducible sample
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENYBoUQDbQDOcAvnAGZQQhwDkAxhrAHQBWhtA3AFDdqYxmUAKYBzYIRjCoACmT4iASh7d6EAHaS4wvMJoBeOABMI9AK4hh6wfRHopAUV2XrMhunUA3dB2W91wgDuKEwwMjp6OAjccLHG9ugAXIjxMD7CMISJANoAuqRYMXEwAJ5gwsm0eMABtIVxcBBgMMAaWYhFDbFgeGbimslIagRQ7UhW6ABGukbJMFBmwqSknSskfkA
Optional extra steps/info to reproduce
No response
Possible solution
One fix is really easy (and i have a branch ready to go if you want it...) which is to add the type into
PluginOptionsByType
// /src/types/index.d.ts:2795 export interface PluginOptionsByType<TType extends ChartType> { + colors: ColorsPluginOptions; decimation: DecimationOptions; filler: FillerOptions; legend: LegendOptions<TType>; subtitle: TitleOptions; title: TitleOptions; tooltip: TooltipOptions<TType>; }
I wonder if it's been omitted on purpose though? Looking at the other plugins in there they are not ones you need to call
register
for (i.e. they appear to be "preregistered plugins"). That's quite reasonable since adding it intoPluginOptionsByType
makes it appear from the types to be available all the time, but you have to register it before you can use it. But in that case, it feels like there is an expectation that some declaration merging has to happen (as with the plugins that live in other packages) - doing that as a user feels a bit awkward.So I wonder if the solution might be to expose the
Colors
plugin on an import path rather than on the root e.g.import { Colors } from 'chart.js/colors';
you would be able to add the declaration merge in a.d.ts
on that path and give the users a better experience, and retain a similar behaviour to other plugins.Context
No response
chart.js version
v4.2.0
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered: