|
1 | | -import { App, defineComponent, h, PropType } from 'vue' |
2 | | -import { ChartData, ChartOptions, Plugin } from 'chart.js/auto' |
3 | | -import { CChart } from './CChart' |
4 | | - |
5 | | -const CChartProps = { |
6 | | - customTooltips: { |
7 | | - type: Boolean, |
8 | | - default: true, |
9 | | - required: false, |
10 | | - }, |
11 | | - data: { |
12 | | - type: [Object, Function] as PropType<ChartData | ((canvas: HTMLCanvasElement) => ChartData)>, |
13 | | - required: true, |
14 | | - }, |
15 | | - height: { |
16 | | - type: Number, |
17 | | - default: 150, |
18 | | - required: false, |
19 | | - }, |
20 | | - id: { |
21 | | - type: String, |
22 | | - default: undefined, |
23 | | - required: false, |
24 | | - }, |
25 | | - options: { |
26 | | - type: Object as PropType<ChartOptions>, |
27 | | - default: undefined, |
28 | | - required: false, |
29 | | - }, |
30 | | - plugins: { |
31 | | - type: Array as PropType<Plugin[]>, |
32 | | - default: undefined, |
33 | | - required: false, |
34 | | - }, |
35 | | - redraw: Boolean, |
36 | | - width: { |
37 | | - type: Number, |
38 | | - default: 300, |
39 | | - required: false, |
40 | | - }, |
41 | | - wrapper: { |
42 | | - type: Boolean, |
43 | | - default: true, |
44 | | - required: false, |
45 | | - }, |
46 | | -} |
| 1 | +import { App, defineComponent, h } from 'vue' |
| 2 | +import CChart from './CChart' |
47 | 3 |
|
48 | 4 | const CChartBar = defineComponent({ |
| 5 | + extends: CChart, |
49 | 6 | name: 'CChartBar', |
50 | | - props: CChartProps, |
51 | 7 | setup(props) { |
52 | | - return () => h(CChart, { type: 'bar', ...props }) |
| 8 | + return () => h(CChart, { ...props, type: 'bar' }) |
53 | 9 | }, |
54 | 10 | }) |
55 | 11 |
|
56 | 12 | const CChartBubble = defineComponent({ |
| 13 | + extends: CChart, |
57 | 14 | name: 'CChartBubble', |
58 | | - props: CChartProps, |
59 | 15 | setup(props) { |
60 | | - return () => h(CChart, { type: 'bubble', ...props }) |
| 16 | + return () => h(CChart, { ...props, type: 'bubble' }) |
61 | 17 | }, |
62 | 18 | }) |
63 | 19 |
|
64 | 20 | const CChartDoughnut = defineComponent({ |
| 21 | + extends: CChart, |
65 | 22 | name: 'CChartDoughnut', |
66 | | - props: CChartProps, |
67 | 23 | setup(props) { |
68 | | - return () => h(CChart, { type: 'doughnut', ...props }) |
| 24 | + return () => h(CChart, { ...props, type: 'doughnut' }) |
69 | 25 | }, |
70 | 26 | }) |
71 | 27 |
|
72 | 28 | const CChartLine = defineComponent({ |
| 29 | + extends: CChart, |
73 | 30 | name: 'CChartLine', |
74 | | - props: CChartProps, |
75 | 31 | setup(props) { |
76 | | - return () => h(CChart, { type: 'line', ...props }) |
| 32 | + return () => h(CChart, { ...props, type: 'line' }) |
77 | 33 | }, |
78 | 34 | }) |
79 | 35 |
|
80 | 36 | const CChartPie = defineComponent({ |
| 37 | + extends: CChart, |
81 | 38 | name: 'CChartPie', |
82 | | - props: CChartProps, |
83 | 39 | setup(props) { |
84 | | - return () => h(CChart, { type: 'pie', ...props }) |
| 40 | + return () => h(CChart, { ...props, type: 'pie' }) |
85 | 41 | }, |
86 | 42 | }) |
87 | 43 |
|
88 | 44 | const CChartPolarArea = defineComponent({ |
| 45 | + extends: CChart, |
89 | 46 | name: 'CChartPolarArea', |
90 | | - props: CChartProps, |
91 | 47 | setup(props) { |
92 | | - return () => h(CChart, { type: 'polarArea', ...props }) |
| 48 | + return () => h(CChart, { ...props, type: 'polarArea' }) |
93 | 49 | }, |
94 | 50 | }) |
95 | 51 |
|
96 | 52 | const CChartRadar = defineComponent({ |
| 53 | + extends: CChart, |
97 | 54 | name: 'CChartRadar', |
98 | | - props: CChartProps, |
99 | 55 | setup(props) { |
100 | | - return () => h(CChart, { type: 'radar', ...props }) |
| 56 | + return () => h(CChart, { ...props, type: 'radar' }) |
101 | 57 | }, |
102 | 58 | }) |
103 | 59 |
|
104 | 60 | const CChartScatter = defineComponent({ |
| 61 | + extends: CChart, |
105 | 62 | name: 'CChartScatter', |
106 | | - props: CChartProps, |
107 | 63 | setup(props) { |
108 | | - return () => h(CChart, { type: 'scatter', ...props }) |
| 64 | + return () => h(CChart, { ...props, type: 'scatter' }) |
109 | 65 | }, |
110 | 66 | }) |
111 | 67 |
|
|
0 commit comments