File tree 3 files changed +63
-36
lines changed
3 files changed +63
-36
lines changed Original file line number Diff line number Diff line change @@ -8,34 +8,45 @@ export type { ChartColor, KV }
8
8
9
9
const props = withDefaults (defineProps <{
10
10
data: KV []
11
+
12
+ // Chart appearance
13
+ type? : ' horizontal' | ' vertical'
11
14
colors? : ChartColor []
15
+ maxBandwidth? : number
12
16
margins? : Partial <{ top: number ; right: number ; bottom: number ; left: number }>
13
- type? : ' horizontal' | ' vertical'
14
- debug? : boolean
15
- ticks? : number
16
- tickFontSize? : string
17
- animate? : boolean
18
- tooltip? : boolean
19
- tooltipFormat? : (d : KV , color : string ) => string
17
+
18
+ // Axis & labels
20
19
xLabel? : string
21
20
yLabel? : string
22
21
xLabelOffset? : number
23
22
yLabelOffset? : number
24
23
xLabelFontSize? : string
25
24
yLabelFontSize? : string
26
- maxBandwidth? : number
25
+ ticks? : number
26
+ tickFontSize? : string
27
+
28
+ // Tooltip
29
+ tooltip? : boolean
30
+ tooltipFormat? : (d : KV , color : string ) => string
31
+
32
+ // Animation & debug
33
+ animate? : boolean
34
+ debug? : boolean
27
35
}>(), {
28
- colors : () => [' blue' ],
29
36
type: ' vertical' ,
30
- debug: false ,
37
+ colors : () => [' blue' ],
38
+ maxBandwidth: 100 ,
39
+
40
+ xLabelFontSize: ' 14px' ,
41
+ yLabelFontSize: ' 14px' ,
31
42
ticks: 5 ,
32
43
tickFontSize: ' 14px' ,
33
- animate: true ,
44
+
34
45
tooltip: true ,
35
46
tooltipFormat : (d : KV ) => ` ${d .key } – ${d .value } ` ,
36
- xLabelFontSize: ' 14px ' ,
37
- yLabelFontSize: ' 14px ' ,
38
- maxBandwidth: 100
47
+
48
+ animate: true ,
49
+ debug: false
39
50
})
40
51
41
52
const chartRef = useTemplateRef (' chart' )
Original file line number Diff line number Diff line change @@ -8,39 +8,55 @@ export type { ChartColor, KV }
8
8
9
9
const props = withDefaults (defineProps <{
10
10
data: KV []
11
- colors? : ChartColor []
12
- margins? : Partial <{ top: number ; right: number ; bottom: number ; left: number }>
13
- innerRadius? : (outerRadius : number ) => number
11
+
12
+ // Chart appearance
14
13
type? : ' pie' | ' donut'
15
14
half? : boolean
16
- debug? : boolean
17
- animate? : boolean
18
- tooltip? : boolean
19
- activeKey? : string
20
- tooltipFormat? : (d : KV , color : string ) => string
15
+ colors? : ChartColor []
16
+ innerRadius? : (outerRadius : number ) => number
17
+ margins? : Partial <{ top: number ; right: number ; bottom: number ; left: number }>
18
+
19
+ // Labels
20
+ labels? : boolean
21
+ labelFormat? : (d : KV ) => string
22
+ labelFontSize? : string
23
+
24
+ // Legend
21
25
legend? : boolean
22
26
legendFormatKey? : (d : KV ) => string
23
27
legendFormatValue? : (d : KV ) => string
24
28
legendPadding? : number
25
29
legendFontSize? : string
26
- labels? : boolean
27
- labelFormat? : (d : KV ) => string
28
- labelFontSize? : string
30
+
31
+ // Tooltip
32
+ tooltip? : boolean
33
+ tooltipFormat? : (d : KV , color : string ) => string
34
+
35
+ // Interactivity & state
36
+ activeKey? : string
37
+
38
+ // Animation & debug
39
+ animate? : boolean
40
+ debug? : boolean
29
41
}>(), {
30
42
type: ' donut' ,
31
43
half: false ,
32
- debug: false ,
33
- animate: true ,
34
- tooltip: true ,
35
- tooltipFormat : (d : KV ) => ` ${d .key } – ${d .value } ` ,
44
+
45
+ labels: false ,
46
+ labelFormat : (d : KV ) => ` ${d .key } – ${d .value } ` ,
47
+ labelFontSize: ' 14px' ,
48
+
36
49
legend: true ,
37
50
legendFormatKey : (d : KV ) => d .key ,
38
51
legendFormatValue : (d : KV ) => d .value .toString (),
39
52
legendPadding: 70 ,
40
53
legendFontSize: ' 14px' ,
41
- labels: false ,
42
- labelFormat : (d : KV ) => ` ${d .key } – ${d .value } ` ,
43
- labelFontSize: ' 14px'
54
+
55
+ tooltip: true ,
56
+ tooltipFormat : (d : KV ) => ` ${d .key } – ${d .value } ` ,
57
+
58
+ animate: true ,
59
+ debug: false
44
60
})
45
61
46
62
const chartRef = useTemplateRef (' chart' )
Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ const title = 'Components / SChart / 01. Playground'
17
17
18
18
const data = ref <KV []>([
19
19
{ key: ' 2018' , value: 10 },
20
- { key: ' 2019' , value: 15 },
21
- { key: ' 2020' , value: 20 },
20
+ { key: ' 2019' , value: 20 },
21
+ { key: ' 2020' , value: 15 },
22
22
{ key: ' 2021' , value: 25 },
23
- { key: ' 2022' , value: 30 },
24
- { key: ' 2023' , value: 35 },
23
+ { key: ' 2022' , value: 35 },
24
+ { key: ' 2023' , value: 30 },
25
25
{ key: ' 2024' , value: 40 },
26
26
{ key: ' 2025' , value: 45 }
27
27
])
You can’t perform that action at this time.
0 commit comments