import {
Chart as ChartJS,
LineController,
BarController,
RadarController,
DoughnutController,
PolarAreaController,
BubbleController,
PieController,
ScatterController,
} from 'chart.js'
import { Chart } from './chart'
import type { ChartProps, ChartJSOrUndefined, TypedChartComponent } from './types'
import type { ChartType, ChartComponentLike } from 'chart.js'
function createTypedChart<T extends ChartType>(type: T, registerables: ChartComponentLike) {
ChartJS.register(registerables)
return forwardRef<ChartJSOrUndefined<T>, Omit<ChartProps<T>, 'type'>>((props, ref) => (
<Chart {...props} ref={ref} type={type} />
)) as TypedChartComponent<T>
}
export const Line = /* #__PURE__ */ createTypedChart('line', LineController)
import {
Chart as ChartJS,
LineController,
BarController,
RadarController,
DoughnutController,
PolarAreaController,
BubbleController,
PieController,
ScatterController,
} from 'chart.js'
import { Chart } from './chart'
import type { ChartProps, ChartJSOrUndefined, TypedChartComponent } from './types'
import type { ChartType, ChartComponentLike } from 'chart.js'
function createTypedChart<T extends ChartType>(type: T, registerables: ChartComponentLike) {
ChartJS.register(registerables)
return forwardRef<ChartJSOrUndefined<T>, Omit<ChartProps<T>, 'type'>>((props, ref) => (
<Chart {...props} ref={ref} type={type} />
)) as TypedChartComponent<T>
}
export const Line = /* #__PURE__ */ createTypedChart('line', LineController)