1import type { Spacing } from '@unovis/ts'
2
3type KeyOf<T extends Record<string, any>> = Extract<keyof T, string>
4
5export interface BaseChartProps<T extends Record<string, any>> {
6 /**
7 * The source data, in which each entry is a dictionary.
8 */
9 data: T[]
10 /**
11 * Select the categories from your data. Used to populate the legend and toolip.
12 */
13 categories: KeyOf<T>[]
14 /**
15 * Sets the key to map the data to the axis.
16 */
17 index: KeyOf<T>
18 /**
19 * Change the default colors.
20 */
21 colors?: string[]
22 /**
23 * Margin of each the container
24 */
25 margin?: Spacing
26 /**
27 * Change the opacity of the non-selected field
28 * @default 0.2
29 */
30 filterOpacity?: number
31 /**
32 * Function to format X label
33 */
34 xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string
35 /**
36 * Function to format Y label
37 */
38 yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string
39 /**
40 * Controls the visibility of the X axis.
41 * @default true
42 */
43 showXAxis?: boolean
44 /**
45 * Controls the visibility of the Y axis.
46 * @default true
47 */
48 showYAxis?: boolean
49 /**
50 * Controls the visibility of tooltip.
51 * @default true
52 */
53 showTooltip?: boolean
54 /**
55 * Controls the visibility of legend.
56 * @default true
57 */
58 showLegend?: boolean
59 /**
60 * Controls the visibility of gridline.
61 * @default true
62 */
63 showGridLine?: boolean
64}