Skip to content

Commit 6e3d10c

Browse files
committed
adjust
1 parent a078c01 commit 6e3d10c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

lib/components/SChartBar.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
import { useElementSize } from '@vueuse/core'
33
import * as d3 from 'd3'
44
import { useTemplateRef, watch } from 'vue'
5-
import { type ChartColor, type KV, c, scheme } from '../support/Chart'
6-
7-
export type { ChartColor, KV }
5+
import { type ChartColor, type KV, type Margins, c, scheme } from '../support/Chart'
86
97
const props = withDefaults(defineProps<{
8+
// State
109
data: KV[]
1110
1211
// Chart appearance
1312
type?: 'horizontal' | 'vertical'
1413
colors?: ChartColor[]
14+
margins?: Margins
1515
maxBandwidth?: number
16-
margins?: Partial<{ top: number; right: number; bottom: number; left: number }>
1716
1817
// Axis & labels
1918
xLabel?: string
@@ -25,7 +24,7 @@ const props = withDefaults(defineProps<{
2524
ticks?: number
2625
tickFontSize?: string
2726
28-
// Tooltip
27+
// Tooltip & interactivity
2928
tooltip?: boolean
3029
tooltipFormat?: (d: KV, color: string) => string
3130

lib/components/SChartPie.vue

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
import { useElementSize } from '@vueuse/core'
33
import * as d3 from 'd3'
44
import { useTemplateRef, watch } from 'vue'
5-
import { type ChartColor, type KV, c, scheme } from '../support/Chart'
6-
7-
export type { ChartColor, KV }
5+
import { type ChartColor, type KV, type Margins, c, scheme } from '../support/Chart'
86
97
const props = withDefaults(defineProps<{
8+
// State
109
data: KV[]
10+
activeKey?: string
1111
1212
// Chart appearance
1313
type?: 'pie' | 'donut'
1414
half?: boolean
1515
colors?: ChartColor[]
16+
margins?: Margins
1617
innerRadius?: (outerRadius: number) => number
17-
margins?: Partial<{ top: number; right: number; bottom: number; left: number }>
1818
1919
// Labels
2020
labels?: boolean
@@ -28,13 +28,10 @@ const props = withDefaults(defineProps<{
2828
legendPadding?: number
2929
legendFontSize?: string
3030
31-
// Tooltip
31+
// Tooltip & interactivity
3232
tooltip?: boolean
3333
tooltipFormat?: (d: KV, color: string) => string
3434
35-
// Interactivity & state
36-
activeKey?: string
37-
3835
// Animation & debug
3936
animate?: boolean
4037
debug?: boolean

lib/support/Chart.ts

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const chartColors = {
4040
// eslint-disable-next-line @typescript-eslint/ban-types
4141
export type ChartColor = keyof typeof chartColors | (string & {})
4242
export type KV = { key: string; value: number; color?: ChartColor }
43+
export type Margins = Partial<{ top: number; right: number; bottom: number; left: number }>
4344

4445
export function getColor(...colors: (ChartColor | string | null | undefined)[]): string {
4546
const color = colors.find((color) => color != null)

0 commit comments

Comments
 (0)