-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Would you like to work on this feature?
- Check this if you would like to implement a PR, we are more than happy to help you go through the process.
What problem are you trying to solve?
Display a chart with mixed chart types in a typescript codebase. Currently if I import Line and try to pass it any other chart type, typescript errors.
Type '"line"' is not assignable to type '"bar"'.
Describe the solution you'd like
In typedCharts.tsx export a Mixed chart component that allows multiple ChartTypes. Currently the props that are allowed to be passed are only the ones associated with their respective ChartType ie. 'line' chart can only accept line props. Chart.js allows me to pass "bar" data to a line chart to allow mixed data charts.
Describe alternatives you've considered
I've overcome this by editing the exported Line typed chart to accept any ChartType
export declare const Line: <TData = (number | import("chart.js").ScatterDataPoint | null)[], TLabel = unknown>(props: Omit<ChartProps> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<ChartType, TData, TLabel>>;
}) => JSX.Element;Documentation, Adoption, Migration Strategy
A user would be able to import a Mixed Chart in which they would be responsible for guaranteeing the typing of the data that is passed to their chart.