1
- import { App , defineComponent , h } from 'vue'
1
+ import { App , defineComponent , h , PropType } from 'vue'
2
+ import { ChartData , ChartOptions , Plugin } from 'chart.js/auto'
2
3
import { CChart } from './CChart'
3
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
+ }
47
+
4
48
const CChartBar = defineComponent ( {
49
+ name : 'CChartBar' ,
50
+ props : CChartProps ,
5
51
setup ( props ) {
6
52
return ( ) => h ( CChart , { type : 'bar' , ...props } )
7
53
} ,
8
54
} )
9
55
10
56
const CChartBubble = defineComponent ( {
57
+ name : 'CChartBubble' ,
58
+ props : CChartProps ,
11
59
setup ( props ) {
12
60
return ( ) => h ( CChart , { type : 'bubble' , ...props } )
13
61
} ,
14
62
} )
15
63
16
64
const CChartDoughnut = defineComponent ( {
65
+ name : 'CChartDoughnut' ,
66
+ props : CChartProps ,
17
67
setup ( props ) {
18
68
return ( ) => h ( CChart , { type : 'doughnut' , ...props } )
19
69
} ,
20
70
} )
21
71
22
72
const CChartLine = defineComponent ( {
73
+ name : 'CChartLine' ,
74
+ props : CChartProps ,
23
75
setup ( props ) {
24
76
return ( ) => h ( CChart , { type : 'line' , ...props } )
25
77
} ,
26
78
} )
27
79
80
+ const CChartPie = defineComponent ( {
81
+ name : 'CChartPie' ,
82
+ props : CChartProps ,
83
+ setup ( props ) {
84
+ return ( ) => h ( CChart , { type : 'pie' , ...props } )
85
+ } ,
86
+ } )
87
+
28
88
const CChartPolarArea = defineComponent ( {
89
+ name : 'CChartPolarArea' ,
90
+ props : CChartProps ,
29
91
setup ( props ) {
30
92
return ( ) => h ( CChart , { type : 'polarArea' , ...props } )
31
93
} ,
32
94
} )
33
95
34
96
const CChartRadar = defineComponent ( {
97
+ name : 'CChartRadar' ,
98
+ props : CChartProps ,
35
99
setup ( props ) {
36
100
return ( ) => h ( CChart , { type : 'radar' , ...props } )
37
101
} ,
38
102
} )
39
103
40
104
const CChartScatter = defineComponent ( {
105
+ name : 'CChartScatter' ,
106
+ props : CChartProps ,
41
107
setup ( props ) {
42
108
return ( ) => h ( CChart , { type : 'scatter' , ...props } )
43
109
} ,
@@ -50,6 +116,7 @@ const CChartPlugin = {
50
116
app . component ( 'CChartBubble' , CChartBubble )
51
117
app . component ( 'CChartDoughnut' , CChartDoughnut )
52
118
app . component ( 'CChartLine' , CChartLine )
119
+ app . component ( 'CChartPie' , CChartPie )
53
120
app . component ( 'CChartPolarArea' , CChartPolarArea )
54
121
app . component ( 'CChartRadar' , CChartRadar )
55
122
app . component ( 'CChartScatter' , CChartScatter )
@@ -64,6 +131,7 @@ export {
64
131
CChartBubble ,
65
132
CChartDoughnut ,
66
133
CChartLine ,
134
+ CChartPie ,
67
135
CChartPolarArea ,
68
136
CChartRadar ,
69
137
CChartScatter ,
0 commit comments