/
types.ts
64 lines (60 loc) 路 1.58 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { DefineComponent } from 'vue'
import type {
Chart as ChartJS,
ChartType,
ChartData,
ChartOptions,
DefaultDataPoint,
Plugin,
UpdateMode
} from 'chart.js'
export interface ChartProps<
TType extends ChartType = ChartType,
TData = DefaultDataPoint<TType>,
TLabel = unknown
> {
/**
* Chart.js chart type
*/
type: TType
/**
* The data object that is passed into the Chart.js chart
* @see https://www.chartjs.org/docs/latest/getting-started/
*/
data: ChartData<TType, TData, TLabel>
/**
* The options object that is passed into the Chart.js chart
* @see https://www.chartjs.org/docs/latest/general/options.html
* @default {}
*/
options?: ChartOptions<TType>
/**
* The plugins array that is passed into the Chart.js chart
* @see https://www.chartjs.org/docs/latest/developers/plugins.html
* @default []
*/
plugins?: Plugin<TType>[]
/**
* Key name to identificate dataset
* @default 'label'
*/
datasetIdKey?: string
/**
* A mode string to indicate transition configuration should be used.
* @see https://www.chartjs.org/docs/latest/developers/api.html#update-mode
*/
updateMode?: UpdateMode
}
export interface ChartComponentRef<
TType extends ChartType = ChartType,
TData = DefaultDataPoint<TType>,
TLabel = unknown
> {
chart: ChartJS<TType, TData, TLabel> | null
}
export type ChartComponent = DefineComponent<ChartProps>
export type TypedChartComponent<
TType extends ChartType,
TData = DefaultDataPoint<TType>,
TLabel = unknown
> = DefineComponent<Omit<ChartProps<TType, TData, TLabel>, 'type'>>