1 | /// <reference types="react" />
|
2 | import type { TooltipComponent, Data as G2Data } from '@antv/g2';
|
3 | import { Options, Spec } from './core';
|
4 | /**
|
5 | * @title 图表浮窗配置
|
6 | * @title.en_US Chart tooltip configuration
|
7 | */
|
8 | export type Tooltip = TooltipComponent;
|
9 | export type Plot = any;
|
10 | export interface Chart extends Plot {
|
11 | toDataURL?: (type?: string, encoderOptions?: number) => string;
|
12 | downloadImage?: (name?: string, type?: string, encoderOptions?: number) => string;
|
13 | }
|
14 | export interface ContainerConfig {
|
15 | /**
|
16 | * @title 图表样式
|
17 | * @description 配置容器样式
|
18 | * @title.en_US Chart containerStyle
|
19 | * @description.en_US Configure chart container styles
|
20 | */
|
21 | containerStyle?: React.CSSProperties;
|
22 | /**
|
23 | * @title 容器自定义属性
|
24 | * @description 配置容器自定义属性
|
25 | * @title.en_US Chart containerAttr
|
26 | * @description.en_US Configure chart container attributes
|
27 | */
|
28 | containerAttributes?: Record<string, any>;
|
29 | /**
|
30 | * @title 容器class
|
31 | * @description 类名添加
|
32 | * @title.en_US Container class name
|
33 | * @description.en_US Class name addition
|
34 | */
|
35 | className?: string;
|
36 | /**
|
37 | * @title 加载状态
|
38 | * @description 是否加载中
|
39 | * @default false
|
40 | * @title.en_US Loading status
|
41 | * @description.en_US Is it loading
|
42 | * @default.en_US false
|
43 | */
|
44 | loading?: boolean;
|
45 | /**
|
46 | * @title 加载模板
|
47 | * @description 加载模板
|
48 | * @title.en_US Load template
|
49 | * @description.en_US Load template
|
50 | */
|
51 | loadingTemplate?: React.ReactElement;
|
52 | /**
|
53 | * @title 出错模板
|
54 | * @description 出错时占位模板
|
55 | * @title.en_US error template
|
56 | * @description.en_US Error placeholder template
|
57 | */
|
58 | errorTemplate?: (e: Error) => React.ReactNode;
|
59 | }
|
60 | export interface AttachConfig {
|
61 | /**
|
62 | * @title 浮窗提示
|
63 | * @description 设置浮窗提示
|
64 | * @title.en_US Chart tooltip
|
65 | * @description.en_US Set chart tooltip
|
66 | */
|
67 | tooltip?: false | Tooltip;
|
68 | /**
|
69 | * @title 图表渲染
|
70 | * @description 图表渲染完成执行回调
|
71 | * @title.en_US Chart rendering
|
72 | * @description.en_US Callback when chart rendering is complete
|
73 | */
|
74 | onReady?: (chart: Chart) => void;
|
75 | /**
|
76 | * @title 图形事件
|
77 | * @description 任何图形事件触发回调
|
78 | * @title.en_US Graphics event
|
79 | * @description.en_US Any graphics event triggers a callback
|
80 | */
|
81 | onEvent?: (chart: Chart, event: PlotEvent) => void;
|
82 | }
|
83 | /**
|
84 | * @title 事件
|
85 | * @description 事件类型的浅拷贝
|
86 | * @title.en_US event
|
87 | * @description.en_US Shallow copy of event type
|
88 | */
|
89 | export type PlotEvent = any;
|
90 | export type Datum = G2Data | any[];
|
91 | type TransformType<T> = T extends object ? {
|
92 | [P in keyof T]: TransformType<T[P]>;
|
93 | } : T;
|
94 | export interface Common extends AttachConfig, ContainerConfig {
|
95 | data?: Datum;
|
96 | /**
|
97 | * @title 内部属性,只读
|
98 | */
|
99 | readonly chartType?: string;
|
100 | }
|
101 | export type CommonConfig<T = Spec> = Common & TransformType<T>;
|
102 | export { Options };
|