generated from solidjs-community/solid-lib-starter
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clean up typedcharts and readme
- simplified api - updated readme to reflect api - add dev to workspace folder
- Loading branch information
1 parent
19c4c16
commit c2ab929
Showing
3 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ | |
{ | ||
"name": "Source", | ||
"path": "./src" | ||
}, | ||
{ | ||
"name": "Dev", | ||
"path": "./dev" | ||
} | ||
], | ||
"settings": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
import * as ChartJS from 'chart.js' | ||
import { | ||
Chart, | ||
LineController, | ||
BarController, | ||
RadarController, | ||
DoughnutController, | ||
PolarAreaController, | ||
BubbleController, | ||
PieController, | ||
ScatterController, | ||
} from 'chart.js' | ||
import DefaultChart from './chart' | ||
import type { ChartProps } from './types' | ||
import type { ChartType, ChartComponentLike } from 'chart.js' | ||
|
||
export type TypedChartProps = Omit<ChartProps, 'type'> | ||
export { DefaultChart } | ||
|
||
function createTypedChart<T extends ChartType>(type: T, registerables: ChartComponentLike) { | ||
ChartJS.Chart.register(registerables) | ||
Chart.register(registerables) | ||
return (props: TypedChartProps) => <DefaultChart type={type} {...props} /> | ||
} | ||
|
||
export const Line = /* #__PURE__ */ createTypedChart('line', ChartJS.LineController) | ||
export const Bar = /* #__PURE__ */ createTypedChart('bar', ChartJS.BarController) | ||
export const Radar = /* #__PURE__ */ createTypedChart('radar', ChartJS.RadarController) | ||
export const Doughnut = /* #__PURE__ */ createTypedChart('doughnut', ChartJS.DoughnutController) | ||
export const PolarArea = /* #__PURE__ */ createTypedChart('polarArea', ChartJS.PolarAreaController) | ||
export const Bubble = /* #__PURE__ */ createTypedChart('bubble', ChartJS.BubbleController) | ||
export const Pie = /* #__PURE__ */ createTypedChart('pie', ChartJS.PieController) | ||
export const Scatter = /* #__PURE__ */ createTypedChart('scatter', ChartJS.ScatterController) | ||
export const Line = /* #__PURE__ */ createTypedChart('line', LineController) | ||
export const Bar = /* #__PURE__ */ createTypedChart('bar', BarController) | ||
export const Radar = /* #__PURE__ */ createTypedChart('radar', RadarController) | ||
export const Doughnut = /* #__PURE__ */ createTypedChart('doughnut', DoughnutController) | ||
export const PolarArea = /* #__PURE__ */ createTypedChart('polarArea', PolarAreaController) | ||
export const Bubble = /* #__PURE__ */ createTypedChart('bubble', BubbleController) | ||
export const Pie = /* #__PURE__ */ createTypedChart('pie', PieController) | ||
export const Scatter = /* #__PURE__ */ createTypedChart('scatter', ScatterController) |