Skip to content

Commit a078c01

Browse files
committed
sort props, add variations in data
1 parent 926e9b3 commit a078c01

File tree

3 files changed

+63
-36
lines changed

3 files changed

+63
-36
lines changed

lib/components/SChartBar.vue

+25-14
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,45 @@ export type { ChartColor, KV }
88
99
const props = withDefaults(defineProps<{
1010
data: KV[]
11+
12+
// Chart appearance
13+
type?: 'horizontal' | 'vertical'
1114
colors?: ChartColor[]
15+
maxBandwidth?: number
1216
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
2019
xLabel?: string
2120
yLabel?: string
2221
xLabelOffset?: number
2322
yLabelOffset?: number
2423
xLabelFontSize?: string
2524
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
2735
}>(), {
28-
colors: () => ['blue'],
2936
type: 'vertical',
30-
debug: false,
37+
colors: () => ['blue'],
38+
maxBandwidth: 100,
39+
40+
xLabelFontSize: '14px',
41+
yLabelFontSize: '14px',
3142
ticks: 5,
3243
tickFontSize: '14px',
33-
animate: true,
44+
3445
tooltip: true,
3546
tooltipFormat: (d: KV) => `${d.key} – ${d.value}`,
36-
xLabelFontSize: '14px',
37-
yLabelFontSize: '14px',
38-
maxBandwidth: 100
47+
48+
animate: true,
49+
debug: false
3950
})
4051
4152
const chartRef = useTemplateRef('chart')

lib/components/SChartPie.vue

+34-18
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,55 @@ export type { ChartColor, KV }
88
99
const props = withDefaults(defineProps<{
1010
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
1413
type?: 'pie' | 'donut'
1514
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
2125
legend?: boolean
2226
legendFormatKey?: (d: KV) => string
2327
legendFormatValue?: (d: KV) => string
2428
legendPadding?: number
2529
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
2941
}>(), {
3042
type: 'donut',
3143
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+
3649
legend: true,
3750
legendFormatKey: (d: KV) => d.key,
3851
legendFormatValue: (d: KV) => d.value.toString(),
3952
legendPadding: 70,
4053
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
4460
})
4561
4662
const chartRef = useTemplateRef('chart')

stories/components/SChart.01_Playground.story.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const title = 'Components / SChart / 01. Playground'
1717
1818
const data = ref<KV[]>([
1919
{ key: '2018', value: 10 },
20-
{ key: '2019', value: 15 },
21-
{ key: '2020', value: 20 },
20+
{ key: '2019', value: 20 },
21+
{ key: '2020', value: 15 },
2222
{ key: '2021', value: 25 },
23-
{ key: '2022', value: 30 },
24-
{ key: '2023', value: 35 },
23+
{ key: '2022', value: 35 },
24+
{ key: '2023', value: 30 },
2525
{ key: '2024', value: 40 },
2626
{ key: '2025', value: 45 }
2727
])

0 commit comments

Comments
 (0)