UNPKG

96.1 kBPlain TextView Raw
1import { COMPONENT_TYPE, DIRECTION, LAYER } from './constant';
2import {
3 AxisLabelCfg,
4 AxisLineCfg,
5 AxisSubTickLineCfg,
6 AxisTickLineCfg,
7 AxisTitleCfg,
8 ContinueLegendHandlerCfg,
9 ContinueLegendLabelCfg,
10 ContinueLegendRailCfg,
11 ContinueLegendTrackCfg,
12 Coordinate,
13 CrosshairLineCfg,
14 CrosshairTextBackgroundCfg,
15 CrosshairTextCfg,
16 EnhancedTextCfg,
17 GridLineCfg,
18 GroupComponent,
19 HtmlComponent,
20 ICanvas,
21 IGroup,
22 IShape,
23 CategoryLegendCfg,
24 LegendBackgroundCfg,
25 LegendItemNameCfg,
26 LegendItemValueCfg,
27 LegendMarkerCfg,
28 LegendTitleCfg,
29 LegendPageNavigatorCfg,
30 PathCommand,
31 Scale,
32 ScaleConfig,
33 ShapeAttrs,
34 LineAnnotationTextCfg,
35 TrendCfg,
36} from './dependents';
37
38import { View } from './chart';
39import { Facet } from './facet';
40import Element from './geometry/element';
41import { PaddingCalCtor } from './chart/layout/padding-cal';
42import { LegendRadio } from '@antv/component';
43
44// ============================ 基础类型 ============================
45/**
46 * @title 通用对象
47 */
48export interface LooseObject {
49 [key: string]: any;
50}
51
52/**
53 * @title 一个点位置
54 */
55export interface Point {
56 readonly x: number;
57 readonly y: number;
58}
59
60/**
61 * @title 画布范围
62 */
63export interface Region {
64 readonly start: Point;
65 readonly end: Point;
66}
67
68/**
69 * @title 画布大小
70 */
71export interface Size {
72 readonly width: number;
73 readonly height: number;
74}
75
76/**
77 * @title 带范围的点结构
78 */
79export interface RangePoint {
80 readonly x?: number | number[];
81 readonly y?: number | number[];
82}
83
84/**
85 * WAI-ARIA 无障碍标签配置
86 */
87export type AriaOption =
88 | false
89 | {
90 readonly label: string;
91 };
92
93/**
94 * @title 用户数据经过图形映射处理后的数据结构
95 */
96export interface MappingDatum {
97 /**
98 * @title 原始数据
99 */
100 _origin: Datum;
101 /**
102 * @title shape 的关键点信息
103 */
104 points?: ShapeVertices;
105 /**
106 * @title 相对于当前 shape 的下一个 shape 的关键点信息
107 */
108 nextPoints?: ShapeVertices;
109 /**
110 * @title x 轴的坐标
111 */
112 x?: number[] | number;
113 /**
114 * @title y 轴的坐标
115 */
116 y?: number[] | number;
117 /**
118 * @title 颜色
119 */
120 color?: string;
121 /**
122 * @title 渲染的 shape 类型
123 */
124 shape?: string | string[];
125 /**
126 * @title 大小
127 */
128 size?: number;
129}
130
131/**
132 * @title 绘制 Shape 需要的图形、样式、关键点等信息
133 */
134export interface ShapeInfo {
135 /**
136 * @title x 坐标
137 */
138 x: number | number[];
139 /**
140 * @title y 坐标
141 */
142 y: number | number[];
143 /**
144 * @title 映射的 shape 类型
145 */
146 shape?: string | string[];
147 /**
148 * @title size 映射值
149 */
150 size?: number;
151 /**
152 * @title 映射的颜色值
153 */
154 color?: string;
155 /**
156 * @title 用户设置的图形样式
157 */
158 style?: LooseObject;
159 /**
160 * @title 是否在极坐标下
161 */
162 isInCircle?: boolean;
163 /**
164 * @title 对应的原始数据记录
165 */
166 data?: Datum | Data;
167 /**
168 * @title 存储进行图形映射后的数据
169 */
170 mappingData?: MappingDatum | MappingDatum[];
171 /**
172 * @title 构成 shape 的关键点
173 */
174 points?: ShapeVertices;
175 /**
176 * @title 下一个数据集对应的关键点
177 */
178 nextPoints?: ShapeVertices;
179 /**
180 * @title Geometry.Text 需要
181 */
182 text?: string;
183 /**
184 * @title 数据是否发生层叠
185 */
186 isStack?: boolean;
187 /**
188 * @title 是否连接空值,只对 Path Line Area 这三种 Geometry 生效。
189 */
190 connectNulls?: boolean;
191 /**
192 * @title shape 背景,只对 Interval Geometry 生效,目前只对 interval-rect shape 生效。
193 */
194 background?: {
195 style?: ShapeAttrs;
196 };
197 /**
198 * @title 是否展示单个孤立的数据点,只对 Path Line Area 这三种 Geometry 生效。
199 */
200 showSinglePoint?: boolean;
201 /**
202 * @title 默认的 shape 样式
203 */
204 defaultStyle?: LooseObject;
205 /**
206 * @title 自定义的数据,传入到 shapeInfo 中
207 */
208 customInfo?: CustomOption;
209}
210
211/**
212 * @title 用户配置的动画,属性均可选
213 */
214export interface AnimateCfg {
215 /**
216 * @title 动画缓动函数
217 */
218 readonly easing?: string | AnimateEasingCallback;
219 /**
220 * @title 动画执行函数
221 */
222 readonly animation?: string;
223 /**
224 * @title 动画执行时间
225 */
226 readonly duration?: number | AnimateDurationCallback;
227 /**
228 * @title 动画延迟时间
229 */
230 readonly delay?: number | AnimateDelayCallback;
231 /**
232 * @title 动画执行结束后的回调函数
233 */
234 readonly callback?: () => any;
235 /**
236 * @title 动画是否重复
237 */
238 readonly repeat?: boolean;
239}
240
241/**
242 * @title 传递给 G 的动画配置,duration 必须提供
243 */
244export interface GAnimateCfg {
245 /**
246 * @title 动画执行时间
247 */
248 readonly duration: number;
249 /**
250 * @title 动画缓动函数
251 */
252 readonly easing?: string;
253 /**
254 * @title 动画执行函数
255 */
256 readonly animation?: string;
257 /**
258 * @title 动画延迟时间
259 */
260 readonly delay?: number;
261 /**
262 * @title 动画执行结束后的回调函数
263 */
264 readonly callback?: () => any;
265 /**
266 * @title 动画是否重复
267 */
268 readonly repeat?: boolean;
269}
270
271// ============================ Geometry 接口相关的类型定义 ============================
272/**
273 * @title 图形属性配置项定义,如 geometry.position({})
274 */
275export interface AttributeOption {
276 /**
277 * @title 映射的属性字段。
278 */
279 fields?: string[];
280 /**
281 * @title 回调函数。
282 */
283 callback?: (...args) => any;
284 /**
285 * @title 指定常量映射规则。
286 */
287 values?: any[];
288}
289
290/**
291 * @title 数据调整配置项定义,`geometry.adjust({})`
292 */
293export interface AdjustOption {
294 /**
295 * @title 数据调整类型。
296 */
297 readonly type: AdjustType;
298 /**
299 * @title 间距
300 * @description 该属性只对 'dodge' 类型生效,取 0 到 1 范围的值(相对于每个柱子宽度),用于控制一个分组中柱子之间的间距。
301 * @see ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*ps3pToOg2nwAAAAAAAAAAABkARQnAQ)
302 */
303 readonly marginRatio?: number;
304 /**
305 * @title 分组字段
306 * @description 该属性只对 'dodge' 类型生效,声明以哪个数据字段为分组依据。
307 */
308 readonly dodgeBy?: string;
309 /**
310 * @title 是否反序
311 * @description 该属性只对 'stack' 类型生效,用于控制是否对数据进行反序操作。
312 */
313 readonly reverseOrder?: boolean;
314}
315
316/**
317 * @title `geometry.style({})` 样式配置定义
318 */
319export interface StyleOption {
320 /**
321 * @title 映射的字段。
322 */
323 readonly fields?: string[];
324 /**
325 * @title 回调函数。
326 */
327 readonly callback?: (...args) => LooseObject;
328 /**
329 * @title 图形样式配置。
330 */
331 readonly cfg?: LooseObject;
332}
333
334/**
335 * @title geometry.custom() custom 自定义的配置,可以传入任何数据
336 */
337export type CustomOption = any;
338
339/**
340 * @title `geometry.tooltip({})` Tooltip 配置定义
341 */
342export interface GeometryTooltipOption {
343 /**
344 * @title 参与映射的字段。
345 */
346 readonly fields: string[];
347 /**
348 * @title 回调函数。
349 */
350 readonly callback?: (...args) => LooseObject;
351}
352
353export interface GeometryLabelLayoutCfg {
354 /**
355 * @title label 布局类型。
356 */
357 type: string;
358 /**
359 * @title 各个布局函数开放给用户的配置。
360 */
361 cfg?: LooseObject;
362}
363
364/**
365 * @title geometry.label({}) 配置属性
366 */
367export interface GeometryLabelCfg {
368 /**
369 * @title 类型
370 * @description 用于声明渲染的 label 类型。当用户使用了自定义的 label 类型,需要声明具体的 type 类型,否则会使用默认的 label 类型渲染。
371 */
372 type?: string;
373 /**
374 * @title 相对数据点的偏移距离, polar 和 theta 坐标系下可使用百分比字符串。
375 */
376 offset?: number | string;
377 /**
378 * @title label 相对于数据点在 X 方向的偏移距离。
379 */
380 offsetX?: number;
381 /**
382 * @title label 相对于数据点在 Y 方向的偏移距离。
383 */
384 offsetY?: number;
385 /**
386 * @title 文本内容
387 * @description 展示的文本内容,如果不声明则按照参与映射的第一字段的值进行显示。当 content 为 IGroup 或者 IShape 类型时,请使用相对定位,即 x 和 y 坐标都设为 0,G2 内部会整体做最后的 label 进行定位的。
388 * @link 示例: https://g2.antv.vision/zh/examples/pie/basic#pie-custome-label
389 */
390 content?: string | IGroup | IShape | GeometryLabelContentCallback;
391 /**
392 * @title 文本样式
393 * @description label 文本图形属性样式。
394 */
395 style?: LooseObject;
396 /**
397 * @title 是否自动旋转
398 * @description label 是否自动旋转
399 * @default true
400 */
401 autoRotate?: boolean;
402 /**
403 * @title 旋转
404 * @description 当且仅当 `autoRotate` 为 false 时生效,用于设置文本的旋转角度,**弧度制**。
405 */
406 rotate?: number;
407 /**
408 * @title 标签高度
409 * @description 标签高度设置,仅当标签类型 type 为 pie 时生效;也可在主题中设置 pieLabels.labelHeight
410 */
411 labelHeight?: number;
412 /**
413 * @title 文本连接线
414 * @description 用于设置文本连接线的样式属性,null 表示不展示。
415 */
416 labelLine?: null | boolean | { style?: object };
417 /**
418 * @title 文本放射状
419 * @description 只对极坐标下的文本生效,表示文本是否按照角度进行放射状显示,true 表示开启,false 表示关闭。
420 */
421 labelEmit?: boolean;
422 /**
423 * @title 文本布局
424 * 文本布局类型,支持多种布局函数组合使用。
425 *
426 * 目前提供了三种:'overlap','fixedOverlap','limitInShape':
427 * 1. overlap: label 防遮挡,为了防止 label 之间相互覆盖,通过尝试向**四周偏移**来剔除放不下的 label。
428 * 2. fixed-overlap: 不改变 label 位置的情况下对相互重叠的 label 进行调整。
429 * 3. limit-in-shape: 剔除 shape 容纳不了的 label。
430 *
431 * @example
432 * ```ts
433 * layout: {
434 * type: 'overlap',
435 * },
436 * ```
437 */
438 layout?: GeometryLabelLayoutCfg | GeometryLabelLayoutCfg[];
439 /**
440 * @title 背景
441 * @description 用于绘制 label 背景
442 */
443 background?: {
444 /**
445 * @title 背景框图形属性配置
446 * - fill?: string; 背景框 填充色
447 * - stroke?: string; 背景框 描边色
448 * - lineWidth?: string; 背景框 描边宽度
449 * - radius?: number | number[]; 背景框圆角,支持整数或数组形式
450 */
451 style?: ShapeAttrs;
452 /**
453 * @title 背景框 内边距
454 */
455 padding?: number | number[];
456 };
457 /**
458 * @title 位置
459 * @description 仅当 geometry 为 interval 时生效,指定当前 label 与当前图形的相对位置。
460 */
461 position?:
462 | ((data: Datum, mappingData: MappingDatum, index: number) => IntervalGeometryLabelPosition)
463 | IntervalGeometryLabelPosition;
464 /**
465 * @title 动画配置。
466 */
467 animate?: AnimateOption | false | null;
468}
469
470/**
471 * @title `geometry().label({})` 配置定义
472 */
473export interface LabelOption {
474 /**
475 * @title 映射的字段。
476 */
477 fields?: string[];
478 /**
479 * @title 回调函数。
480 */
481 callback?: LabelCallback;
482 cfg?: GeometryLabelCfg;
483}
484
485/**
486 * @title Geometry 下每个 state 的配置结构
487 */
488export interface StateCfg {
489 /**
490 * @title 状态样式配置。
491 */
492 style?: object | StateStyleCallback;
493}
494
495/**
496 * @title geometry.state({}) 配置定义
497 */
498export interface StateOption {
499 /**
500 * @title 默认状态样式。
501 */
502 default?: StateCfg;
503 /**
504 * @title active 状态配置。
505 */
506 active?: StateCfg;
507 /**
508 * @title inactive 状态配置。
509 */
510 inactive?: StateCfg;
511 /**
512 * @title selected 状态配置。
513 */
514 selected?: StateCfg;
515}
516
517/**
518 * @title interval label 的位置
519 */
520export type IntervalGeometryLabelPosition = 'top' | 'bottom' | 'middle' | 'left' | 'right';
521/**
522 * @title G2 提供的 adjust 类型
523 */
524export type AdjustType = 'stack' | 'jitter' | 'dodge' | 'symmetric';
525/**
526 * @title geometry.color() 图形属性回调函数定义
527 */
528export type ColorAttrCallback = (...args) => string;
529/**
530 * @title geometry.shape() 图形属性回调函数定义
531 */
532export type ShapeAttrCallback = (...args) => string | any[];
533/**
534 * @title geometry.size() 图形属性回调函数定义
535 */
536export type SizeAttrCallback = (...args) => number;
537/**
538 * @title geometry.tooltip() 接口回调函数定义
539 */
540export type TooltipCallback = (...args) => LooseObject;
541/**
542 * @title geometry.style() 接口回调函数定义
543 */
544export type StyleCallback = (...args) => LooseObject;
545/**
546 * @title geometry.label() 接口回调函数定义
547 */
548export type LabelCallback = (...args) => GeometryLabelCfg | null | undefined;
549/**
550 * @title geometry label 中 content 属性的回调函数类型定义
551 */
552export type GeometryLabelContentCallback = (
553 data: Datum,
554 mappingData: MappingDatum,
555 index: number
556) => string | IShape | IGroup;
557/**
558 * @title state 下 style 回调函数定义
559 */
560export type StateStyleCallback = (element: Element) => LooseObject;
561
562// ============================ Geometry Shape 接口相关的类型定义 ============================
563/**
564 * @title 获取 shape marker 时需要的信息
565 */
566export interface ShapeMarkerCfg {
567 /**
568 * @title 颜色。
569 */
570 color: string;
571 /**
572 * @title 是否是极坐标。
573 */
574 isInPolar: boolean;
575}
576
577/**
578 * @title 图形 marker 的配置信息。
579 */
580export interface ShapeMarkerAttrs {
581 /**
582 * @title marker 的形状。
583 */
584 symbol: string | ShapeMarkerSymbol;
585 /**
586 * @title marker 样式
587 * @description
588 * marker 的样式,`ShapeAttrs` 属性结构如下:
589 *
590 * ```ts
591 * {
592 * // x 坐标
593 * x?: number;
594 * // y 坐标
595 * y?: number;
596 * // 圆半径
597 * r?: number;
598 * // 描边颜色
599 * stroke?: string | null;
600 * // 描边透明度
601 * strokeOpacity?: number;
602 * // 填充颜色
603 * fill?: string | null;
604 * // 填充透明度
605 * fillOpacity?: number;
606 * // 整体透明度
607 * opacity?: number;
608 * // 线宽
609 * lineWidth?: number;
610 * // 指定如何绘制每一条线段末端
611 * lineCap?: 'butt' | 'round' | 'square';
612 * // 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略)
613 * lineJoin?: 'bevel' | 'round' | 'miter';
614 * // 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数,数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
615 * lineDash?: number[] | null;
616 * // Path 路径
617 * path?: string | object[];
618 * // 图形坐标点
619 * points?: object[];
620 * // 宽度
621 * width?: number;
622 * // 高度
623 * height?: number;
624 * // 阴影模糊效果程度
625 * shadowBlur?: number;
626 * // 阴影颜色
627 * shadowColor?: string | null;
628 * // 阴影 x 方向偏移量
629 * shadowOffsetX?: number;
630 * // 阴影 y 方向偏移量
631 * shadowOffsetY?: number;
632 * // 设置文本内容的当前对齐方式
633 * textAlign?: 'start' | 'center' | 'end' | 'left' | 'right';
634 * // 设置在绘制文本时使用的当前文本基线
635 * textBaseline?: 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
636 * // 字体样式
637 * fontStyle?: 'normal' | 'italic' | 'oblique';
638 * // 文本字体大小
639 * fontSize?: number;
640 * // 文本字体
641 * fontFamily?: string;
642 * // 文本粗细
643 * fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | number;
644 * // 字体变体
645 * fontVariant?: 'normal' | 'small-caps' | string;
646 * // 文本行高
647 * lineHeight?: number;
648 * [key: string]: any;
649 * }
650 * ```
651 *
652 * @link https://github.com/antvis/g/blob/28e3178b616573e0fa6d59694f1aaca2baaa9766/packages/g-base/src/types.ts#L37|ShapeAttrs
653 */
654 style: ShapeAttrs;
655}
656
657/**
658 * @title shape 关键点信息
659 */
660export interface ShapePoint {
661 /**
662 * @title 数据点映射后对应 x 的值。
663 */
664 readonly x: number | number[];
665 /**
666 * @title 数据点映射后对应 y 的值。
667 */
668 readonly y?: number | number[];
669 /**
670 * @title 数据在 y 方向的最小值。
671 */
672 readonly y0?: number;
673 /**
674 * @title 大小
675 */
676 size?: number;
677}
678
679/**
680 * @title 小提琴图 shape 关键点信息
681 */
682export type ViolinShapePoint = ShapePoint & { _size?: number[] };
683
684/**
685 * @title 注册 ShapeFactory 需要实现的接口。
686 */
687export interface RegisterShapeFactory {
688 /**
689 * @title 默认的 shape 类型。
690 */
691 readonly defaultShapeType: string;
692 /**
693 * @title 返回绘制 shape 所有的关键点集合。
694 */
695 readonly getDefaultPoints?: (pointInfo: ShapePoint) => Point[];
696 /**
697 * @title 获取 shape 的默认绘制样式
698 */
699 readonly getDefaultStyle?: (geometryTheme: LooseObject) => LooseObject;
700 /**
701 * @title 获取 shape 对应的缩略图配置。
702 */
703 readonly getMarker?: (shapeType: string, markerCfg: ShapeMarkerCfg) => ShapeMarkerAttrs;
704 /**
705 * @title 创建具体的 G.Shape 实例。
706 */
707 readonly drawShape?: (shapeType: string, cfg: ShapeInfo, container: IGroup) => IShape | IGroup;
708}
709
710/**
711 * @title 注册具体 shape 需要实现的接口。
712 */
713export interface RegisterShape {
714 /**
715 * @title 计算绘制需要的关键点,在注册具体的 shape 时由开发者自己定义。
716 */
717 readonly getPoints?: (pointInfo: ShapePoint) => Point[];
718 /**
719 * @title 获取 shape 对应的缩略图样式配置,在注册具体的 shape 时由开发者自己定义。
720 */
721 readonly getMarker?: (markerCfg: ShapeMarkerCfg) => ShapeMarkerAttrs;
722 /**
723 * @title 绘制函数。
724 */
725 readonly draw: (cfg: ShapeInfo, container: IGroup) => IShape | IGroup | void;
726}
727
728/**
729 * @title Shape 接口定义。
730 */
731export interface Shape extends RegisterShape {
732 /**
733 * @title 坐标系对象。
734 */
735 coordinate: Coordinate;
736 /**
737 * @title 工具函数,将 0~1 path 转化成实际画布 path。
738 */
739 parsePath: (path: any) => PathCommand[];
740 /**
741 * @title 工具函数,0~1 的坐标点转换成实际画布坐标点。
742 */
743 parsePoint: (point: Point) => Point;
744 /**
745 * @title 工具函数,0~1 的坐标点集合转换成实际画布坐标点集合。
746 */
747 parsePoints: (points: Point[]) => Point[];
748}
749
750/**
751 * @title ShapeFactory 接口定义。
752 */
753export interface ShapeFactory extends RegisterShapeFactory {
754 /**
755 * @title 工厂名。
756 */
757 geometryType: string;
758 /**
759 * @title 坐标系对象。
760 */
761 coordinate: Coordinate;
762 /**
763 * @title ShapeFactory 下所有的主题样式。
764 */
765 theme: LooseObject;
766 /**
767 * @title 根据名称获取具体的 shape 对象。
768 */
769 getShape: (shapeType: string | string[]) => Shape;
770 /**
771 * @title 获取构成 shape 的关键点。
772 */
773 getShapePoints: (shapeType: string | string[], pointInfo: ShapePoint) => Point[];
774}
775
776/**
777 * @title 自定义 Shape marker 的函数
778 */
779export type ShapeMarkerSymbol = (x: number, y: number, r: number) => PathCommand[];
780
781// ============================ Annotation 类型定义 ============================
782/**
783 * @title Annotation position 回调函数
784 */
785export type AnnotationPositionCallback = (
786 xScales: Scale[] | Record<string, Scale>,
787 yScales: Scale[] | Record<string, Scale>
788) => [number | string, number | string];
789/**
790 * @title Annotation 位置相关属性的类型定义
791 */
792export type AnnotationPosition =
793 | [number | string, number | string]
794 | Record<string, number | string>
795 | AnnotationPositionCallback;
796
797/**
798 * @title Annotation 定义的通用属性,chart.annotation().line({})
799 */
800export interface AnnotationBaseOption {
801 /**
802 * @title 类型
803 */
804 readonly type?: string;
805 /**
806 * @title 是否顶层
807 * @description 指定 annotation 是否绘制在 canvas 最上层,默认为 false, 即绘制在最下层
808 */
809 readonly top?: boolean;
810 /**
811 * @title 是否进行动画
812 */
813 readonly animate?: boolean;
814 /**
815 * @title 动画参数配置
816 * @description 当且仅当 `animate` 属性为 true,即动画开启时生效。
817 */
818 readonly animateOption?: ComponentAnimateOption;
819 /**
820 * @title x 方向的偏移量
821 */
822 readonly offsetX?: number;
823 /**
824 * @title y 方向的偏移量
825 */
826 readonly offsetY?: number;
827}
828
829/**
830 * @title 使用 RegionPosition 定位的组件配置
831 */
832export interface RegionPositionBaseOption extends AnnotationBaseOption {
833 /**
834 * @title 起始位置
835 */
836 readonly start: AnnotationPosition;
837 /**
838 * @title 结束位置
839 */
840 readonly end: AnnotationPosition;
841 /**
842 * @title 图形样式属性
843 */
844 readonly style?: ShapeAttrs;
845}
846
847/**
848 * @title 使用 PointPosition 定位的组件配置
849 */
850export interface PointPositionBaseOption extends AnnotationBaseOption {
851 /**
852 * @title Point 定位位置
853 */
854 readonly position: AnnotationPosition;
855}
856
857/**
858 * @title 使用 Image Annotation 组件的配置定义
859 */
860export interface ImageOption extends RegionPositionBaseOption {
861 /**
862 * @title 图片路径
863 */
864 readonly src: string;
865}
866
867/**
868 * @title 使用 Line Annotation 组件的配置定义
869 */
870export interface LineOption extends RegionPositionBaseOption {
871 /**
872 * @title 文本配置定义
873 */
874 readonly text?: LineAnnotationTextCfg;
875}
876/**
877 * @title 使用 Arc Annotation 组件的配置定义
878 */
879export type ArcOption = RegionPositionBaseOption;
880/**
881 * @title 使用 Region Annotation 组件的配置定义
882 */
883export type RegionOption = RegionPositionBaseOption;
884/**
885 * @title 使用 Text Annotation 组件的配置定义
886 */
887export interface TextOption extends PointPositionBaseOption, Omit<EnhancedTextCfg, 'content'> {
888 content?: string | number | ((filteredData: object[]) => string | number);
889}
890/**
891 * @title 使用 DataMarker Annotation 组件的配置定义
892 */
893export interface DataMarkerOption extends PointPositionBaseOption {
894 /**
895 * @title point 设置
896 */
897 readonly point?: null | { style?: ShapeAttrs };
898 /**
899 * @title line 设置
900 */
901 readonly line?: null | { style?: ShapeAttrs; length?: number };
902 /**
903 * @title text 设置
904 */
905 readonly text: null | EnhancedTextCfg;
906 /**
907 * @title 文本超出绘制区域时,是否自动调节文本方向,默认为 true
908 */
909 readonly autoAdjust?: boolean;
910 /**
911 * @title 朝向,默认为 upward,可选值为 'upward' 或者 'downward'
912 */
913 readonly direction?: 'upward' | 'downward';
914}
915/**
916 * @title 使用 DataRegion Annotation 组件的配置定义
917 */
918export interface DataRegionOption extends RegionPositionBaseOption {
919 /**
920 * @title line长度,default为 0
921 */
922 readonly lineLength?: number;
923 /**
924 * @title 标注区间的配置
925 */
926 readonly region?: null | { style?: ShapeAttrs };
927 /**
928 * @title 文本的配置
929 */
930 readonly text?: null | EnhancedTextCfg;
931}
932/**
933 * @title 使用 RegionFilter Annotation 组件的配置定义
934 */
935export interface RegionFilterOption extends RegionPositionBaseOption {
936 /**
937 * @title 染色色值
938 */
939 readonly color: string;
940 /**
941 * @title 适用场景
942 * @description 可选,设定regionFilter只对特定geom类型起作用,如apply:['area']
943 */
944 readonly apply?: string[];
945}
946
947/**
948 * @title Shape Annotation 的配置
949 */
950export interface ShapeAnnotationOption extends AnnotationBaseOption {
951 /**
952 * @title 自定义 Annotation 绘制函数
953 */
954 render: (
955 container: IGroup,
956 view: View,
957 helpers: { parsePosition: (position: [string | number, string | number] | Datum) => Point }
958 ) => void;
959}
960
961/**
962 * Html Annotation 配置
963 */
964export interface HtmlAnnotationOption extends PointPositionBaseOption {
965 /**
966 * @title 容器元素
967 */
968 container?: string | HTMLElement;
969 /**
970 * @title 自定义 HTML DOM 元素
971 */
972 html: string | HTMLElement | ((container: HTMLElement, view: View) => void | string | HTMLElement);
973 /**
974 * @title X 方向对齐
975 */
976 alignX?: 'left' | 'middle' | 'right';
977 /**
978 * @title Y 方向对齐
979 */
980 alignY?: 'top' | 'middle' | 'bottom';
981 /**
982 * @title X 方向偏移
983 */
984 offsetX?: number;
985 /**
986 * @title Y 方向偏移
987 */
988 offsetY?: number;
989}
990
991// ============================ Chart && View 上的类型定义 ============================
992/**
993 * @title Tooltip 内容框的 css 样式定义
994 */
995export interface TooltipDomStyles {
996 'g2-tooltip'?: LooseObject;
997 'g2-tooltip-title'?: LooseObject;
998 'g2-tooltip-list'?: LooseObject;
999 'g2-tooltip-list-item'?: LooseObject;
1000 'g2-tooltip-marker'?: LooseObject;
1001 'g2-tooltip-value'?: LooseObject;
1002 'g2-tooltip-name'?: LooseObject;
1003}
1004
1005/**
1006 * @title 目前组件动画允许的参数配置
1007 */
1008export interface ComponentAnimateCfg {
1009 /**
1010 * @title 动画执行时间
1011 */
1012 readonly duration?: number;
1013 /**
1014 * @title 动画缓动函数
1015 */
1016 readonly easing?: string;
1017 /**
1018 * @title 动画延迟时间
1019 */
1020 readonly delay?: number;
1021}
1022/**
1023 * @title 组件各个动画类型配置
1024 */
1025export interface ComponentAnimateOption {
1026 /**
1027 * @title 初入场动画配置
1028 */
1029 appear?: ComponentAnimateCfg;
1030 /**
1031 * @title 更新动画配置
1032 */
1033 update?: ComponentAnimateCfg;
1034 /**
1035 * @title 更新后新入场的动画配置
1036 */
1037 enter?: ComponentAnimateCfg;
1038 /**
1039 * @title 离场动画配置
1040 */
1041 leave?: ComponentAnimateCfg;
1042}
1043
1044/**
1045 * @title 列定义配置项
1046 */
1047export interface ScaleOption extends ScaleConfig {
1048 /**
1049 * @title 声明度量类型。
1050 */
1051 type?: ScaleType;
1052 /**
1053 * @title 同步 scale
1054 *
1055 * @example
1056 * ```ts
1057 * chart.scale({
1058 * x: { sync: true },
1059 * y: { sync: true },
1060 * x1: { sync: 'x1' },
1061 * x2: { sync: 'x1' },
1062 * });
1063 * ```
1064 *
1065 * 通过以上配置,我们会分别对 xy 两个字段,x1x2 两个字段进行同步度量操作。
1066 */
1067 sync?: boolean | string;
1068 /**
1069 * @title 是否显示最后的 tick
1070 * @description 只对 `type: 'cat'` 以及 `type: 'time-cat'` 的 scale 生效,强制显示最后的日期 tick
1071 */
1072 showLast?: boolean;
1073 /**
1074 * @title 唯一 ID
1075 * @description
1076 * 用于声明使用数据记录中的哪些字段来组成一条数据的唯一 id(如有多个字段,则使用 '-' 连接)。
1077 * 数据 id 用于标识 Element 图形元素,应用于 Geometry 中的图形元素 Element 更新。
1078 * 默认 G2 内部会有一套 ID 生成规则,如果不能满足用户需求,用户既可以使用该属性配置 id
1079 * @example
1080 * 下面的例子中,声明了将 'x' 和 'y' 字段的数值来作为每条数据记录的 id,即下面数据两条数据的 id 分别为:'1-23' 和 '2-2'。
1081 * ```ts
1082 * const data = [
1083 * { x: 1, y: 23, z: 'a' },
1084 * { x: 2, y: 2, z: 'b' },
1085 * ];
1086 *
1087 * chart.scale({
1088 * x: { key: true },
1089 * y: { key: true },
1090 * });
1091 * ```
1092 */
1093 key?: boolean;
1094}
1095
1096/**
1097 * @title Geometry 动画参数配置。geometry.animate()
1098 */
1099export interface AnimateOption {
1100 /**
1101 * @title chart 初始化渲染时的入场动画,false/null 表示关闭入场动画。
1102 */
1103 appear?: AnimateCfg | false | null;
1104 /**
1105 * @title chart 发生更新时,新增元素的入场动画,false/null 表示关闭入场动画。
1106 */
1107 enter?: AnimateCfg | false | null;
1108 /**
1109 * @title 更新动画配置,false/null 表示关闭更新动画。
1110 */
1111 update?: AnimateCfg | false | null;
1112 /**
1113 * @title 销毁动画配置,false/null 表示关闭销毁动画。
1114 */
1115 leave?: AnimateCfg | false | null;
1116}
1117
1118/**
1119 * @title 用于配置项式声明交互行为
1120 */
1121export interface InteractionOption {
1122 /**
1123 * @title 交互名称
1124 */
1125 type: string;
1126 /**
1127 * @title 交互配置
1128 */
1129 cfg?: LooseObject;
1130}
1131
1132/**
1133 * @title 用于配置项式的 Geometry 创建方式
1134 */
1135export interface GeometryOption {
1136 /**
1137 * @title Geometry 的类型。
1138 */
1139 type?: 'interval' | 'line' | 'path' | 'point' | 'area' | 'polygon' | 'schema' | 'edge' | 'heatmap' | string;
1140 /**
1141 * @title position 通道映射规则,对应 `geometry.position()`。
1142 */
1143 position?: string | AttributeOption;
1144 /**
1145 * @title color 通道映射规则,对应 `geometry.color()`。
1146 */
1147 color?: string | AttributeOption;
1148 /**
1149 * @title shape 通道映射规则,对应 `geometry.shape()`。
1150 */
1151 shape?: string | AttributeOption;
1152 /**
1153 * @title size 通道映射规则,对应 `geometry.size()`。
1154 */
1155 size?: number | string | AttributeOption;
1156 /**
1157 * @title adjust 数据调整方式,对应 `geometry.adjust()`。
1158 */
1159 adjust?: string | string[] | AdjustOption | AdjustOption[];
1160 /**
1161 * @title style 样式配置,对应 `geometry.size()`。
1162 */
1163 style?: StyleOption | LooseObject;
1164 /**
1165 * @title tooltip 配置,对应 `geometry.tooltip()`。
1166 */
1167 tooltip?: GeometryTooltipOption | boolean | string;
1168 /**
1169 * @title Geometry 动画配置,对应 `geometry.animate()`。
1170 */
1171 animate?: AnimateOption | boolean;
1172 /**
1173 * @title Label 配置,对应 `geometry.label()`。
1174 */
1175 label?: LabelOption | false | string;
1176 /**
1177 * @title state 样式配置,对应 `geometry.state()`。
1178 */
1179 state?: StateOption;
1180 /**
1181 * @title 其他配置
1182 */
1183 cfg?: {
1184 /**
1185 * @title 是否对数据进行排序
1186 */
1187 sortable?: boolean;
1188 /**
1189 * @title 是否可见
1190 */
1191 visible?: boolean;
1192 /**
1193 * @title 是否连接空值,仅对 'line', 'area' 和 'path' 生效
1194 */
1195 connectNulls?: boolean;
1196 };
1197}
1198
1199/**
1200 * @title 用于配置型式的 View 声明方式
1201 */
1202export interface ViewOption {
1203 /**
1204 * @title view 的唯一表示 ID
1205 */
1206 readonly id?: string;
1207 /**
1208 * @title view 的绘制范围,起始点为左上角。
1209 */
1210 readonly region?: Region;
1211 /**
1212 * 设置图表的内边距,使用方式参考 CSS 盒模型。
1213 * 下图黄色区域即为 padding 的范围。
1214 * ![](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*pYwiQrdXGJ8AAAAAAAAAAABkARQnAQ)
1215 *
1216 * @example
1217 * 1. padding: 20
1218 * 2. padding: [ 10, 30, 30 ]
1219 */
1220 readonly padding?: ViewPadding;
1221 /**
1222 * @title 设置主题。
1223 */
1224 readonly theme?: LooseObject | string;
1225 /**
1226 * @title 是否可见。
1227 */
1228 readonly visible?: boolean;
1229 /**
1230 * 图表组件、图形映射等相关的配置。
1231 */
1232 readonly options?: Options;
1233}
1234
1235/**
1236 * @title Chart 构造方法的入参
1237 */
1238export interface ChartCfg
1239 extends Omit<ViewCfg, 'parent' | 'canvas' | 'foregroundGroup' | 'middleGroup' | 'backgroundGroup' | 'region'> {
1240 /**
1241 * @title 指定 chart 绘制的 DOM,可以传入 DOM id,也可以直接传入 dom 实例。
1242 */
1243 readonly container: string | HTMLElement;
1244 /**
1245 * @title 图表宽度。
1246 */
1247 readonly width?: number;
1248 /**
1249 * @title 图表高度。
1250 */
1251 readonly height?: number;
1252 /**
1253 * @title 否自适应容器宽高
1254 * @description
1255 * 图表是否自适应容器宽高,默认为 false,用户需要手动设置 width 和 height。当 `autoFit: true` 时,
1256 * 会自动取图表容器的宽高,如果用户设置了 height,那么会以用户设置的 height 为准。
1257 * @default false
1258 */
1259 readonly autoFit?: boolean;
1260 /**
1261 * @title 渲染引擎
1262 * @default "canvas"
1263 */
1264 readonly renderer?: Renderer;
1265 /**
1266 * @title 像素比
1267 * @description 设置设备像素比,默认取浏览器的值 `window.devicePixelRatio`。
1268 */
1269 readonly pixelRatio?: number;
1270 /**
1271 * @title 是否开启局部刷新
1272 * @default true
1273 */
1274 readonly localRefresh?: boolean;
1275 /**
1276 * @title 是否支持 CSS transform
1277 * @description 开启后图表的交互以及事件将在页面设置了 css transform 属性时生效,默认关闭。
1278 * @default false
1279 */
1280 readonly supportCSSTransform?: boolean;
1281 /**
1282 * @title 配置图表默认交互,仅支持字符串形式。
1283 */
1284 readonly defaultInteractions?: string[];
1285}
1286
1287export type SyncViewPaddingFn = (chart: View, views: View[], PC: PaddingCalCtor) => void;
1288
1289/**
1290 * @title View 构造参数
1291 */
1292export interface ViewCfg {
1293 /**
1294 * @title View id,可以由外部传入
1295 */
1296 readonly id?: string;
1297 /**
1298 * @title 当前 view 的父级 view。
1299 */
1300 readonly parent: View;
1301 /**
1302 * @title canvas 实例。
1303 */
1304 readonly canvas: ICanvas;
1305 /**
1306 * @title 前景层
1307 */
1308 readonly foregroundGroup: IGroup;
1309 /**
1310 * @title 中间层
1311 */
1312 readonly middleGroup: IGroup;
1313 /**
1314 * @title 背景层
1315 */
1316 readonly backgroundGroup: IGroup;
1317 /**
1318 * @title view 的绘制范围
1319 */
1320 readonly region?: Region;
1321 /**
1322 * @title 是否对超出坐标系范围的 Geometry 进行剪切
1323 */
1324 readonly limitInPlot?: boolean;
1325 /**
1326 * @title 内边距
1327 * @description 设置图表的内边距,使用方式参考 CSS 盒模型,下图黄色区域即为 padding 的范围。
1328 * @see ![](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*pYwiQrdXGJ8AAAAAAAAAAABkARQnAQ)
1329 * @example
1330 * 1. padding: 20
1331 * 2. padding: [ 10, 30, 30 ]
1332 */
1333 readonly padding?: ViewPadding;
1334 /**
1335 * @title 额外边距
1336 * @description 设置图表的内边距在padding的基础上增加appendPadding的调整。
1337 * @example
1338 * 1. padding: 20
1339 * 2. padding: [ 10, 30, 30 ]
1340 */
1341 readonly appendPadding?: ViewAppendPadding;
1342 /**
1343 * @title 是否同步子 view 的 padding
1344 * @description 是否同步子 view 的 padding,可以是 boolean / SyncViewPaddingFn
1345 * @example
1346 * view1 的 padding 10
1347 * view2 的 padding 20
1348 * 那么两个子 view 的 padding 统一变成最大的 20.
1349 *
1350 * 如果是 Funcion,则使用自定义的方式去计算子 view 的 padding,这个函数中去修改所有的 views autoPadding 值
1351 */
1352 readonly syncViewPadding?: boolean | SyncViewPaddingFn;
1353 /**
1354 * @title 主题
1355 * @description 设置 view 实例主题
1356 */
1357 readonly theme?: LooseObject | string;
1358 /**
1359 * @title 图表组件、图形映射等相关的配置。
1360 */
1361 readonly options?: Options;
1362 /**
1363 * @title 是否可见
1364 */
1365 readonly visible?: boolean;
1366}
1367
1368/**
1369 * @ignore
1370 * 组件及布局的信息
1371 */
1372export interface ComponentOption {
1373 readonly id?: string;
1374 readonly component: GroupComponent | HtmlComponent;
1375 readonly layer: LAYER;
1376 direction: DIRECTION;
1377 readonly type: COMPONENT_TYPE;
1378 /* 其他的额外信息 */
1379 readonly extra?: any;
1380}
1381
1382/**
1383 * @title Legend marker 的配置结构
1384 */
1385export interface MarkerCfg extends LegendMarkerCfg {
1386 /**
1387 * @title 配置图例 marker 的 symbol 形状。
1388 */
1389 symbol?: Marker | MarkerCallback;
1390 style?: ShapeAttrs | ((style: ShapeAttrs) => ShapeAttrs);
1391}
1392
1393/**
1394 * @title Legend item 各个图例项的数据结构
1395 */
1396export interface LegendItem {
1397 /**
1398 * 唯一值,用于动画或者查找
1399 */
1400 id?: string;
1401 /**
1402 * @title 名称
1403 */
1404 name: string;
1405 /**
1406 * @title 值
1407 */
1408 value: any;
1409 /**
1410 * @title 图形标记
1411 */
1412 marker?: MarkerCfg | ((name: string, index: number, item: { name: string; value: string } & MarkerCfg) => MarkerCfg);
1413 /**
1414 * @title 初始是否处于未激活状态
1415 */
1416 unchecked?: boolean;
1417}
1418
1419export interface G2LegendTitleCfg extends LegendTitleCfg {
1420 /**
1421 * @title title 文本显示内容
1422 */
1423 text?: string;
1424}
1425
1426/**
1427 * 图例项配置
1428 */
1429export interface LegendCfg extends Omit<CategoryLegendCfg, 'marker'> {
1430 /**
1431 * @title 是否为自定义图例
1432 * @description 当该属性为 true 时,需要声明 items 属性。
1433 */
1434 readonly custom?: boolean;
1435 /**
1436 * @title 布局
1437 * @description 布局方式: horizontal,vertical
1438 */
1439 layout?: 'horizontal' | 'vertical';
1440 /**
1441 * @title 图例标题配置
1442 * @description 默认不展示。
1443 * @example
1444 * 属性结构如下:
1445 *
1446 * ```ts
1447 * {
1448 * spacing?: number; // 标题同图例项的间距
1449 * style?: ShapeAttrs; // 文本样式配置项
1450 * }
1451 * ```
1452 *
1453 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L639|LegendTitleCfg
1454 */
1455 title?: G2LegendTitleCfg;
1456 /**
1457 * @title 背景框配置项。
1458 * @example
1459 * 属性结构如下:
1460 *
1461 * ```ts
1462 * {
1463 * padding?: number | number[]; // 背景的留白
1464 * style?: ShapeAttrs; // 背景样式配置项
1465 * }
1466 * ```
1467 *
1468 * 详见 {@link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L652|LegendBackgroundCfg}
1469 */
1470 background?: LegendBackgroundCfg;
1471 /**
1472 * @title 图例的位置。
1473 */
1474 position?:
1475 | 'top'
1476 | 'top-left'
1477 | 'top-right'
1478 | 'right'
1479 | 'right-top'
1480 | 'right-bottom'
1481 | 'left'
1482 | 'left-top'
1483 | 'left-bottom'
1484 | 'bottom'
1485 | 'bottom-left'
1486 | 'bottom-right';
1487 /**
1488 * @title 动画开关,默认关闭。
1489 */
1490 animate?: boolean;
1491 /**
1492 * @title 动画
1493 * @description 动画参数配置,当且仅当 `animate` 属性为 true,即动画开启时生效。
1494 */
1495 animateOption?: ComponentAnimateOption;
1496 /**
1497 * @title 水平间距
1498 * @description **分类图例适用**,控制图例项水平方向的间距。
1499 */
1500 itemSpacing?: number;
1501 /**
1502 * @title 垂直间距
1503 * @description **分类图例适用**,控制图例项垂直方向的间距。
1504 */
1505 itemMarginBottom?: number;
1506 /**
1507 * @title 图例项的最大宽度
1508 * @description
1509 * **分类图例适用**,图例项的最大宽度,超出则自动缩略。
1510 * `maxItemWidth` 可以是像素值;
1511 * 也可以是相对值(取 0 到 1 范围的数值),代表占图表宽度的多少
1512 */
1513 maxItemWidth?: number;
1514 /**
1515 * @title 图例项的宽度
1516 * @description **分类图例适用**,图例项的宽度, 默认为 null,自动计算。
1517 */
1518 itemWidth?: number;
1519 /**
1520 * @title 图例项的高度
1521 * @description **分类图例适用**,图例的高度,默认为 null。
1522 */
1523 itemHeight?: number;
1524 /**
1525 * @title 图例项 name
1526 * @description
1527 * **分类图例适用**,图例项 name 文本的配置。
1528 * 属性结构如下:
1529 *
1530 * ```ts
1531 * {
1532 * spacing?: number; // 图例项 name 同后面 value 的间距
1533 * formatter?: (text: string, item: ListItem, index: number) => any; // 格式化文本函数
1534 * style?: ShapeAttrs; // 文本配置项
1535 * }
1536 * ```
1537 *
1538 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L665|LegendItemNameCfg
1539 */
1540 itemName?: LegendItemNameCfg;
1541 /**
1542 * @title 图例项 value
1543 * @description
1544 * **分类图例适用**,图例项 value 附加值的配置项。
1545 * 属性结构如下:
1546 *
1547 * ```ts
1548 * {
1549 * alignRight?: boolean; // 是否右对齐,默认为 false,仅当设置图例项宽度时生效
1550 * formatter?: (text: string, item: ListItem, index: number) => any; // 格式化文本函数
1551 * style?: ShapeAttrs; // 图例项附加值的配置
1552 * }
1553 * ```
1554 *
1555 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L685|LegendItemValueCfg
1556 */
1557 itemValue?: LegendItemValueCfg;
1558 /**
1559 * @title 最大宽度
1560 * @description **分类图例适用**,图例项最大宽度设置。
1561 */
1562 maxWidth?: number;
1563 /**
1564 * @title 最大高度
1565 * @description **分类图例适用**,图例项最大高度设置。
1566 */
1567 maxHeight?: number;
1568 /**
1569 * @title 最大宽度比例
1570 * @description **分类图例适用**,图例项最大宽度比例(以 view 的 bbox 宽度为参照,默认 0.25)。
1571 */
1572 maxWidthRatio?: number;
1573 /**
1574 * @title 最大高度比例
1575 * @description **分类图例适用**,图例项最大高度比例(以 view 的 bbox 高度为参照,默认 0.25)。
1576 */
1577 maxHeightRatio?: number;
1578 /**
1579 * @title 图例项的 marker
1580 * @description **分类图例适用**,图例项的 marker 图标的配置。
1581 */
1582 marker?: MarkerCfg | ((name: string, index: number, item: { name: string; value: string } & MarkerCfg) => MarkerCfg);
1583 /**
1584 * @title 是否进行分页
1585 * @description **适用于分类图例**,当图例项过多时是否进行分页。
1586 */
1587 flipPage?: boolean;
1588 /**
1589 * @title 分页器的样式
1590 * @description **适用于分类图例**,图例分页器的样式设置。
1591 */
1592 pageNavigator?: LegendPageNavigatorCfg;
1593 /**
1594 * @title 图例项
1595 * @description **分类图例适用**,用户自己配置图例项的内容。
1596 */
1597 items?: LegendItem[];
1598 /**
1599 * @title 反选
1600 * @description **分类图里适用**,用来配置正反选功能
1601 */
1602 radio?: LegendRadio;
1603 /**
1604 * @title 是否逆序
1605 * @description **分类图例适用**,是否将图例项逆序展示。
1606 */
1607 reversed?: boolean;
1608
1609 /**
1610 * @title 最小值
1611 * @description **连续图例适用**,选择范围的最小值。
1612 */
1613 min?: number;
1614 /**
1615 * @title 最大
1616 * @description **连续图例适用**,选择范围的最大值。
1617 */
1618 max?: number;
1619 /**
1620 * @title value
1621 * @description **连续图例适用**,选择的值。
1622 */
1623 value?: number[];
1624 /**
1625 * @title 色块样式
1626 * @description
1627 * **连续图例适用**,选择范围的色块样式配置项。
1628 * 属性结构如下:
1629 *
1630 * ```ts
1631 * {
1632 * style?: ShapeAttrs; // 选定范围的样式
1633 * }
1634 * ```
1635 *
1636 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L574|ContinueLegendTrackCfg
1637 */
1638 track?: ContinueLegendTrackCfg;
1639 /**
1640 * @title 滑轨(背景
1641 * @description
1642 * **连续图例适用**,图例滑轨(背景)的样式配置项。
1643 * 属性结构如下:
1644 *
1645 * ```ts
1646 * {
1647 * type?: string; // rail 的类型,color, size
1648 * size?: number; // 滑轨的宽度
1649 * defaultLength?: number; // 滑轨的默认长度,,当限制了 maxWidth,maxHeight 时,不会使用这个属性会自动计算长度
1650 * style?: ShapeAttrs; // 滑轨的样式
1651 * }
1652 * ```
1653 *
1654 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L595|ContinueLegendRailCfg
1655 */
1656 rail?: ContinueLegendRailCfg;
1657 /**
1658 * @title 文本
1659 * @description
1660 * **连续图例适用**,文本的配置项。
1661 * 属性结构如下:
1662 *
1663 * ```ts
1664 * {
1665 * // 文本同滑轨的对齐方式,有五种类型
1666 * // rail : 同滑轨对齐,在滑轨的两端
1667 * // top, bottom: 图例水平布局时有效
1668 * // left, right: 图例垂直布局时有效
1669 * align?: string;
1670 * spacing?: number; // 文本同滑轨的距离
1671 * style?: ShapeAttrs; // 文本样式
1672 * }
1673 * ```
1674 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L618|ContinueLegendLabelCfg
1675 */
1676 label?: ContinueLegendLabelCfg;
1677 /**
1678 * @title 滑块
1679 * @description
1680 * **连续图例适用**,滑块的配置项。
1681 * 属性结构如下:
1682 *
1683 * ```ts
1684 * {
1685 * size?: number; // 滑块的大小
1686 * style?: ShapeAttrs; // 滑块的样式设置
1687 * }
1688 * ```
1689 *
1690 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L582|ContinueLegendTrackCfg
1691 */
1692 handler?: ContinueLegendHandlerCfg;
1693 /**
1694 * @title 是否可滑动
1695 * @description **连续图例适用**,滑块是否可以滑动。
1696 */
1697 slidable?: boolean;
1698 /**
1699 * @title 图例 x 方向的偏移。
1700 */
1701 offsetX?: number;
1702 /**
1703 * @title 图例 y 方向的偏移。
1704 */
1705 offsetY?: number;
1706 /**
1707 * @title 图例在四个方向的偏移量
1708 */
1709 padding?: number[];
1710 /**
1711 * 图例高亮状态,false 表示默认置灰,无或 true 表示高亮
1712 */
1713 selected?: {
1714 [key: string]: boolean;
1715 };
1716}
1717
1718/**
1719 * Tooltip Crosshairs 的文本数据结构。
1720 */
1721export interface TooltipCrosshairsText extends CrosshairTextCfg {
1722 /**
1723 * @title crosshairs 文本内容
1724 */
1725 content?: string;
1726}
1727
1728/**
1729 * 辅助线文本回调函数
1730 * @param type 对应当前 crosshairs 的类型,值为 'x' 或者 'y'
1731 * @param defaultContent 对应当前 crosshairs 默认的文本内容
1732 * @param items 对应当前 tooltip 内容框中的数据
1733 * @param currentPoint 对应当前坐标点
1734 * @returns 返回当前 crosshairs 对应的辅助线文本配置
1735 */
1736export type TooltipCrosshairsTextCallback = (
1737 type: string,
1738 defaultContent: any,
1739 items: any[],
1740 currentPoint: Point
1741) => TooltipCrosshairsText;
1742/**
1743 * @title Tooltip crosshairs 配置结构
1744 */
1745export interface TooltipCrosshairs {
1746 /**
1747 * @title 类型
1748 * @description
1749 * crosshairs 的类型: `x` 表示 x 轴上的辅助线,`y` 表示 y 轴上的辅助项。
1750 * 以下是在不同坐标系下,crosshairs 各个类型的表现:
1751 *
1752 * | 坐标系 | type = 'x' | type = 'xy' | type = 'y' |
1753 * | ------------ | ------------- | ------------- |
1754 * | 直角坐标系 | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*jmUBQ4nbtXsAAAAAAAAAAABkARQnAQ) | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*RpWXT76ZSQgAAAAAAAAAAABkARQnAQ) | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*Xjl8TLIJLuUAAAAAAAAAAABkARQnAQ) |
1755 * | 极坐标 | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*zbMVSoKTyFsAAAAAAAAAAABkARQnAQ) | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*k5EYRJspET0AAAAAAAAAAABkARQnAQ) | ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*n_TKQpUaXWEAAAAAAAAAAABkARQnAQ) |
1756 */
1757 type?: 'x' | 'y' | 'xy';
1758 /**
1759 * @title 辅助线的样式配置。
1760 * @description
1761 * 属性结构如下:
1762 *
1763 * ```ts
1764 * {
1765 * style?: ShapeAttrs; // 线的样式配置
1766 * }
1767 * ```
1768 *
1769 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L1177|CrosshairLineCfg
1770 */
1771 line?: CrosshairLineCfg;
1772 /**
1773 * @title 文本
1774 * @description 辅助线文本配置,支持回调。
1775 */
1776 text?: TooltipCrosshairsText | TooltipCrosshairsTextCallback;
1777 /**
1778 * @title 辅助线文本背景配置。
1779 * @description
1780 * 属性结构如下:
1781 *
1782 * ```ts
1783 * {
1784 * padding?: number | number[]; // 文本背景周围的留白
1785 * style?: ShapeAttrs; // 文本背景的样式
1786 * }
1787 * ```
1788 *
1789 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L1185|CrosshairTextBackgroundCfg
1790 */
1791 textBackground?: CrosshairTextBackgroundCfg;
1792 /**
1793 * @title 辅助线是否跟随鼠标移动
1794 * @description 即定位到数据点
1795 * @default false
1796 */
1797 follow?: boolean;
1798}
1799
1800export type TooltipTitle = string | ((title: string, datum: Datum) => string);
1801
1802export type TooltipItem = {
1803 /**
1804 * @title 原始数据
1805 */
1806 readonly data: Datum; // 原始数据
1807 /**
1808 * @title 映射之后的数据
1809 */
1810 readonly mappingData: Datum; // 映射后的数据
1811 /**
1812 * @title tooltip item 中名称
1813 */
1814 readonly name: string;
1815 /**
1816 * @title tooltip item 中值
1817 */
1818 readonly value: string | number;
1819 /**
1820 * @title tooltip item 中颜色
1821 */
1822 readonly color: string;
1823 /**
1824 * @title tooltip item 中图标类型
1825 */
1826 readonly marker: string;
1827};
1828
1829/**
1830 * @title chart.tooltip() 接口配置属性
1831 */
1832export interface TooltipCfg {
1833 /**
1834 * @title 设置 tooltip 内容框是否跟随鼠标移动。
1835 * @description 默认为 true,跟随鼠标移动,false 则固定位置不随鼠标移动。
1836 * @default true
1837 */
1838 follow?: boolean;
1839 /**
1840 * @title tooltip 是否允许鼠标滑入
1841 * @default false
1842 */
1843 enterable?: boolean;
1844 /**
1845 * @title tooltip 显示延迟(ms)
1846 * @description 默认为 16ms,建议在 enterable = true 的时候才设置
1847 * @default "16ms"
1848 */
1849 showDelay?: number;
1850 /**
1851 * @title 是否展示 tooltip 标题。
1852 */
1853 showTitle?: boolean;
1854 /**
1855 * @title 标题
1856 * @description
1857 * 设置 tooltip 的标题内容:如果值为数据字段名,则会展示数据中对应该字段的数值,如果数据中不存在该字段,则直接展示 title 值。
1858 * 同时支持传入方法,回调的方式返回字符串
1859 */
1860 title?: TooltipTitle;
1861 /**
1862 * @title 设置 tooltip 的固定展示位置,相对于数据点。
1863 */
1864 position?: 'top' | 'bottom' | 'left' | 'right';
1865 /**
1866 * @title 是否合并当前点对应的所有数据
1867 * @description true 表示合并当前点对应的所有数据并展示,false 表示只展示离当前点最逼近的数据内容。
1868 */
1869 shared?: boolean; // 是否只展示单条数据
1870 /**
1871 * @title 是否展示 crosshairs。
1872 */
1873 showCrosshairs?: boolean;
1874 /**
1875 * @title 交叉线
1876 * @description 配置 tooltip 的 crosshairs,当且仅当 `showCrosshairs` 为 true 时生效。
1877 */
1878 crosshairs?: TooltipCrosshairs;
1879 /**
1880 * @title 是否渲染 tooltipMarkers。
1881 */
1882 showMarkers?: boolean;
1883 /**
1884 * @title tooltipMarker 的样式配置。
1885 */
1886 marker?: object;
1887 /**
1888 * @title 是否展示 tooltip 内容框
1889 */
1890 showContent?: boolean | ((datum: Datum) => boolean);
1891 /**
1892 * @title 自定义 tooltip 的容器。
1893 */
1894 container?: string | HTMLElement;
1895 /**
1896 * @title 图例容器的模板
1897 * @description 用于指定图例容器的模板,自定义模板时必须包含各个 dom 节点的 class。
1898 */
1899 containerTpl?: string;
1900 /**
1901 * @title 默认模板
1902 * @description 每项记录的默认模板,自定义模板时必须包含各个 dom 节点的 class。
1903 */
1904 itemTpl?: string;
1905 /**
1906 * @title dom 样式
1907 * @description 传入各个 dom 的样式。
1908 */
1909 domStyles?: TooltipDomStyles;
1910 /**
1911 * @title tooltip 偏移量。
1912 */
1913 offset?: number;
1914 /**
1915 * @title 是否将 tooltip items 逆序
1916 */
1917 reversed?: boolean;
1918 /**
1919 * @title 是否显示空值的 tooltip 项目
1920 */
1921 showNil?: boolean;
1922 /**
1923 * @description 在 tooltip 渲染之前,对最终的 items 进行自定义处理(比如排序、过滤、格式化等)
1924 */
1925 customItems?: (originalItems: TooltipItem[]) => TooltipItem[];
1926 /**
1927 * @title 自定义模板
1928 */
1929 customContent?: (title: string, data: any[]) => string | HTMLElement;
1930}
1931
1932/**
1933 * @title 坐标系配置
1934 */
1935export interface CoordinateOption {
1936 /**
1937 * @title 坐标系类型
1938 */
1939 type?: 'polar' | 'theta' | 'rect' | 'cartesian' | 'helix';
1940 /**
1941 * @title 坐标系配置项,目前常用于极坐标。
1942 */
1943 cfg?: CoordinateCfg;
1944 /**
1945 * @title 坐标系变换
1946 * @description
1947 * 1. rotate 表示旋转,使用弧度制。
1948 * 2. scale 表示沿着 x 和 y 方向的缩放比率。
1949 * 3. reflect 表示沿 x 方向镜像或者沿 y 轴方向映射。
1950 * 4. transpose 表示 x,y 轴置换。
1951 */
1952 actions?: CoordinateActions[];
1953}
1954
1955/**
1956 * @title 极坐标系支持的配置属性
1957 */
1958export interface CoordinateCfg {
1959 /**
1960 * @title 起始弧度
1961 * @description 用于极坐标,配置起始弧度。
1962 */
1963 startAngle?: number;
1964 /**
1965 * @title 结束弧度
1966 * @description 用于极坐标,配置结束弧度。
1967 */
1968 endAngle?: number;
1969 /**
1970 * @title 半径
1971 * @description 用于极坐标,配置极坐标半径,0 - 1 范围的数值。
1972 */
1973 radius?: number;
1974 /**
1975 * @title 内半径
1976 * @description 用于极坐标,极坐标内半径,0 -1 范围的数值。
1977 */
1978 innerRadius?: number;
1979}
1980
1981/**
1982 * @title 坐标轴网格线的配置属性
1983 */
1984export interface AxisGridCfg {
1985 /**
1986 * @title 线的样式
1987 * @description
1988 * 属性结构如下:
1989 *
1990 * ```ts
1991 * {
1992 * type?: string; // 栅格线的类型,'line' 或者 'circle'
1993 * style?: ShapeAttrs; // 栅格线的样式配置项
1994 * }
1995 * ```
1996 *
1997 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L407|GridLineCfg
1998 */
1999 line?: GridLineCfg;
2000 /**
2001 * @title 两个栅格线间的填充色。
2002 */
2003 alternateColor?: string | string[];
2004 /**
2005 * @title 是否关闭
2006 * @description 对于 circle 是否关闭 grid。
2007 */
2008 closed?: boolean;
2009 /**
2010 * @title 是否同刻度线对齐
2011 * @description 如果值为 false,则会显示在两个刻度中间。
2012 * @see ![image](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*YX6fS4GTTvMAAAAAAAAAAABkARQnAQ)
2013 */
2014 alignTick?: boolean;
2015}
2016
2017/**
2018 * @title 坐标轴配置属性,chart.axis()
2019 */
2020export interface AxisCfg {
2021 /**
2022 * @title 是否渲染在画布顶层
2023 * @description 防止部分图形中,需要将 axis 显示在图形上面,避免被图形遮挡
2024 */
2025 top?: boolean;
2026 /**
2027 * @title 坐标轴的位置
2028 * @description 适用于直角坐标系,设置坐标轴的位置。
2029 */
2030 position?: 'top' | 'bottom' | 'right' | 'left';
2031 /**
2032 * @title 轴线
2033 * @description
2034 * 坐标轴线的配置项,null 表示不展示。
2035 * 属性结构如下:
2036 *
2037 * ```ts
2038 * {
2039 * style?: ShapeAttrs; // 坐标轴线的样式配置项
2040 * }
2041 * ```
2042 *
2043 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L91|AxisLineCfg
2044 */
2045 line?: AxisLineCfg | null;
2046 /**
2047 * @title 刻度线线
2048 * @description
2049 * 坐标轴刻度线线的配置项,null 表示不展示。
2050 * 属性结构如下:
2051 *
2052 * ```ts
2053 * {
2054 * style?: ShapeAttrs; // 坐标轴刻度线的样式配置项
2055 * alignTick?: boolean; // 是否同 tick 对齐
2056 * length?: number; // 长度
2057 * }
2058 * ```
2059 *
2060 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L103|AxisTickLineCfg
2061 */
2062 tickLine?: AxisTickLineCfg | null;
2063 /**
2064 * @title 子刻度线
2065 * @description
2066 * 坐标轴子刻度线的配置项,null 表示不展示。
2067 * 属性结构如下:
2068 *
2069 * ```ts
2070 * {
2071 * style?: ShapeAttrs; // 坐标轴刻度线的样式配置项
2072 * count?: number; // 子刻度个数
2073 * length?: number; // 子刻度线长度
2074 * }
2075 * ```
2076 *
2077 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L169|AxisSubTickLineCfg
2078 */
2079 subTickLine?: AxisSubTickLineCfg | null;
2080 /**
2081 * @title 标题
2082 * @description
2083 * 标题的配置项,null 表示不展示。
2084 * 属性结构如下:
2085 *
2086 * ```ts
2087 * {
2088 * offset?: number; // 标题距离坐标轴的距离
2089 * style?: ShapeAttrs; // 标题文本配置项
2090 * autoRotate?: boolean; // 是否自动旋转
2091 * }
2092 * ```
2093 *
2094 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L191|AxisTitleCfg
2095 */
2096 title?: AxisTitleCfg | null;
2097 /**
2098 * @title 文本标签
2099 * @description
2100 * 文本标签的配置项,null 表示不展示。
2101 * 属性结构如下:
2102 *
2103 * ```ts
2104 * {
2105 * // 坐标轴文本的样式
2106 * style?: ShapeAttrs;
2107 * // label 的偏移量
2108 * offset?: number;
2109 * // 文本旋转角度
2110 * rotate?: number;
2111 * // 格式化函数
2112 * formatter?: (text: string, item: ListItem, index: number) => any;
2113 * // 是否自动旋转,默认 false
2114 * autoRotate?: boolean | (isVertical: boolean, labelGroup: IGroup, limitLength?: number) => boolean; | string;
2115 * // 是否自动隐藏,默认 true
2116 * autoHide?: boolean | (isVertical: boolean, labelGroup: IGroup, limitLength?: number) => boolean; | string;
2117 * // 是否自动省略,默认 false
2118 * autoEllipsis?: boolean | (isVertical: boolean, labelGroup: IGroup, limitLength?: number) => boolean; | string;
2119 * }
2120 * ```
2121 *
2122 * @link https://github.com/antvis/component/blob/81890719a431b3f9088e0c31c4d5d382ef0089df/src/types.ts#L127|AxisLabelCfg
2123 */
2124 label?: AxisLabelCfg | null;
2125 /**
2126 * @title 网格线
2127 * @description 坐标轴网格线的配置项,null 表示不展示。
2128 */
2129 grid?: AxisGridCfg | null;
2130 /**
2131 * @title 动画
2132 * @default true
2133 */
2134 animate?: boolean;
2135 /**
2136 * @title 动画参数
2137 */
2138 animateOption?: ComponentAnimateOption;
2139 /**
2140 * @title 坐标轴 label 的方向
2141 * @description 标记坐标轴 label 的方向,左侧为 1,右侧为 -1。
2142 */
2143 verticalFactor?: number;
2144 /**
2145 * @title 坐标轴垂直方向的最大限制长度
2146 * @description
2147 * 配置坐标轴垂直方向的最大限制长度,对文本自适应有很大影响。
2148 * 1. 可以直接设置像素值,如 100;
2149 * 2. 也可设置绝对值,如 0.2,如果是 x 轴,则相对于图表的高度,如果是 y 轴,则相对于图表的宽度
2150 *
2151 * 在 G2 中,x 轴的文本默认最大高度为图表高度的 1/2,y 轴的文本默认最大长度为图表宽度的 1/3
2152 */
2153 verticalLimitLength?: number;
2154}
2155
2156export interface SliderCfg {
2157 /**
2158 * @title slider 高度
2159 */
2160 readonly height?: number;
2161
2162 /**
2163 * @title 滑块背景区域配置
2164 */
2165 readonly trendCfg?: Omit<TrendCfg, 'data'> & { data?: number[] };
2166 /**
2167 * @title 滑块背景样式
2168 */
2169 readonly backgroundStyle?: any;
2170 /**
2171 * @title 滑块前景样式
2172 */
2173 readonly foregroundStyle?: any;
2174 /**
2175 * @title 滑块两个操作块样式
2176 */
2177 readonly handlerStyle?: any;
2178 /**
2179 * @title 文本样式
2180 */
2181 readonly textStyle?: any;
2182 /**
2183 * @title 允许滑动位置的最小值
2184 */
2185 readonly minLimit?: number;
2186 /**
2187 * @title 允许滑动位置的最大值
2188 */
2189 readonly maxLimit?: number;
2190 /**
2191 * @title 滑块初始化的起始位置
2192 */
2193 readonly start?: number;
2194 /**
2195 * @title 滑块初始化的结束位置
2196 */
2197 readonly end?: number;
2198 /**
2199 * @title 布局的 padding
2200 */
2201 readonly padding?: number[];
2202 /**
2203 * @title 滑块文本格式化函数
2204 */
2205 formatter?: (val: any, datum: Datum, idx: number) => any;
2206}
2207
2208/**
2209 * 事件 payload
2210 */
2211export type EventPayload = LooseObject & {
2212 /**
2213 * @title 触发事件的来源
2214 */
2215 source?: string;
2216};
2217
2218export type EventCallback = (event: LooseObject) => void;
2219/**
2220 * todo: 事件名可穷举,后续需要补充
2221 * 事件配置项
2222 */
2223export interface EventCfg {
2224 [key: string]: EventCallback;
2225}
2226
2227/**
2228 * 缩略轴的配置项
2229 */
2230export type SliderOption = SliderCfg | boolean;
2231
2232/**
2233 * @title 滚动条组件配置项
2234 */
2235export interface ScrollbarCfg {
2236 /**
2237 * @title 滚动条类型,默认 horizontal
2238 */
2239 type?: 'horizontal' | 'vertical';
2240 /**
2241 * @title 宽度,在 vertical 下生效
2242 */
2243 width?: number;
2244 /**
2245 * @title 高度,在 horizontal 下生效
2246 */
2247 height?: number;
2248 /**
2249 * @title 可选 padding
2250 */
2251 padding?: Padding;
2252 /**
2253 * @title 对应水平滚动条,为 X 轴每个分类字段的宽度;对于垂直滚动条,为 X 轴每个分类字段的高度
2254 */
2255 categorySize?: number;
2256 /**
2257 * @title 滚动的时候是否开启动画,默认跟随 view 中 animate 配置
2258 */
2259 animate?: boolean;
2260 /**
2261 * @title 主题样式设置, 暂不提供 hover 高亮滑块样式配置
2262 */
2263 style?: {
2264 /**
2265 * @title 滑道颜色
2266 */
2267 trackColor?: string;
2268 /**
2269 * @title 滑块颜色
2270 */
2271 thumbColor?: string;
2272 /**
2273 * @title 滑块高亮样式,对应主题的 hover.style.thumbColor
2274 */
2275 thumbHighlightColor?: string;
2276 /**
2277 * @title 是否圆角
2278 */
2279 lineCap?: string;
2280 };
2281}
2282
2283/**
2284 * @title 滚动条配置
2285 */
2286export type ScrollbarOption = ScrollbarCfg | boolean;
2287
2288/**
2289 * @title 配置项声明式
2290 */
2291export interface Options {
2292 /**
2293 * @title 数据源配置。
2294 */
2295 readonly data?: Data;
2296 /**
2297 * @title 设置数据过滤条件,以 data 中的数据属性为 key。
2298 */
2299 readonly filters?: Record<string, FilterCondition>;
2300 /**
2301 * @title 坐标轴配置,以 data 中的数据属性为 key。
2302 */
2303 readonly axes?: Record<string, AxisOption> | boolean;
2304 /**
2305 * @title 图例配置,以 data 中的数据属性为 key。
2306 */
2307 readonly legends?: AllLegendsOptions;
2308 /**
2309 * @title 列定义配置,用于配置数值的类型等,以 data 中的数据属性为 key。
2310 */
2311 readonly scales?: Record<string, ScaleOption>;
2312 /**
2313 * @title Tooltip 配置。
2314 */
2315 readonly tooltip?: TooltipOption;
2316 /**
2317 * @title 坐标系配置。
2318 */
2319 readonly coordinate?: CoordinateOption;
2320 /**
2321 * @title 静态辅助元素声明。
2322 */
2323 readonly annotations?: (
2324 | ArcOption
2325 | RegionFilterOption
2326 | ImageOption
2327 | LineOption
2328 | TextOption
2329 | RegionOption
2330 | DataMarkerOption
2331 | DataRegionOption
2332 )[];
2333 /**
2334 * @title Geometry 配置
2335 */
2336 readonly geometries?: GeometryOption[];
2337 /**
2338 * @title 开启/关闭动画,默认开启
2339 */
2340 readonly animate?: boolean;
2341 /**
2342 * @title 配置需要使用的交互行为
2343 */
2344 readonly interactions?: InteractionOption[];
2345 /**
2346 * @title 事件配置
2347 */
2348 readonly events?: EventCfg;
2349
2350 /**
2351 * @title 缩略轴的配置
2352 */
2353 readonly slider?: SliderOption;
2354
2355 /**
2356 * @title 滚动条配置
2357 */
2358 readonly scrollbar?: ScrollbarOption;
2359
2360 /**
2361 * @title 子 View
2362 */
2363 readonly views?: ViewOption[];
2364
2365 /**
2366 * @title 分面
2367 */
2368 readonly facets?: (RectCfg | MirrorCfg | CircleCfg | ListCfg | TreeCfg)[];
2369
2370 /**
2371 * @title 其他自定义的 option
2372 */
2373 readonly [name: string]: any;
2374}
2375
2376/**
2377 * @title 支持的 Marker 类型
2378 */
2379export type Marker =
2380 | 'circle'
2381 | 'square'
2382 | 'diamond'
2383 | 'triangle'
2384 | 'triangle-down'
2385 | 'hexagon'
2386 | 'bowtie'
2387 | 'cross'
2388 | 'tick'
2389 | 'plus'
2390 | 'hyphen'
2391 | 'line';
2392/**
2393 * @title 自定义 Marker 的回调函数定义
2394 */
2395export type MarkerCallback = (x: number, y: number, r: number) => PathCommand[];
2396/**
2397 * @title chart.tooltip() 参数类型
2398 */
2399export type TooltipOption = TooltipCfg | boolean;
2400/* 筛选器函数类型定义 */
2401export type FilterCondition = (value: any, datum: Datum, idx?: number) => boolean;
2402/**
2403 * @title chart.axis() 参数类型
2404 */
2405export type AxisOption = AxisCfg | boolean;
2406/**
2407 * @title chart.legend() 参数类型
2408 */
2409export type LegendOption = LegendCfg | boolean;
2410/**
2411 * @title Options 中 legends 的配置定义
2412 */
2413export type AllLegendsOptions = LegendCfg | Record<string, LegendOption> | boolean;
2414/**
2415 * @title G2 支持的度量类型
2416 */
2417export type ScaleType =
2418 | 'linear'
2419 | 'cat'
2420 | 'category'
2421 | 'identity'
2422 | 'log'
2423 | 'pow'
2424 | 'time'
2425 | 'timeCat'
2426 | 'quantize'
2427 | 'quantile';
2428
2429export type CoordinateRotate = ['rotate', number];
2430export type CoordinateReflect = ['reflect', 'x' | 'y'];
2431export type CoordinateScale = ['scale', number, number];
2432export type CoordinateTranspose = ['transpose'];
2433/**
2434 * @title 坐标系支持的 action 配置
2435 */
2436export type CoordinateActions = CoordinateRotate | CoordinateReflect | CoordinateScale | CoordinateTranspose;
2437
2438// ============================ Facet 分面相关类型定义 ============================
2439// 分面基类
2440export type FacetCtor = new (view: View, cfg: any) => Facet;
2441
2442export interface Condition {
2443 readonly field: string;
2444 readonly value: any;
2445 readonly values: any[];
2446}
2447
2448export type FacetDataFilter = (data: Datum[]) => boolean;
2449
2450/**
2451 * 默认的基础配置
2452 */
2453export interface FacetCfg<D> {
2454 /**
2455 * @title 布局类型。
2456 */
2457 readonly type?: string;
2458 /**
2459 * @title view 创建回调。
2460 */
2461 readonly eachView: (innerView: View, facet?: D) => any;
2462 /**
2463 * @title 分面 view 之间的间隔, 百分比或像素值
2464 */
2465 readonly spacing?: [number | string, number | string];
2466 /**
2467 * @title facet view padding。
2468 */
2469 readonly padding?: ViewPadding;
2470 /**
2471 * @title 是否显示标题。
2472 */
2473 readonly showTitle?: boolean;
2474 /**
2475 * @title facet 数据划分维度。
2476 */
2477 readonly fields: string[];
2478}
2479
2480/**
2481 * Facet title 配置项
2482 */
2483export interface FacetTitle {
2484 /**
2485 * @title x 方向偏移。
2486 */
2487 readonly offsetX?: number;
2488 /**
2489 * @title y 方向偏移。
2490 */
2491 readonly offsetY?: number;
2492 /**
2493 * @title 文本样式。
2494 */
2495 readonly style?: object;
2496 /**
2497 * @title 格式化
2498 */
2499 readonly formatter?: (val: any) => any;
2500}
2501
2502/**
2503 * 分面数据
2504 */
2505export interface FacetData {
2506 /**
2507 * @title 分面类型。
2508 */
2509 readonly type: string;
2510 /**
2511 * @title 当前分面子 view 的数据。
2512 */
2513 readonly data: object[];
2514 /**
2515 * @title 当前分面子 view 的范围。
2516 */
2517 readonly region: Region;
2518 /**
2519 * @title 当前分面子 view 的 padding。
2520 */
2521 readonly padding?: number;
2522 /**
2523 * @title 当前 facet 对应生成的 view。
2524 */
2525 view?: View;
2526
2527 // facet data
2528 /**
2529 * @title 分面行字段。
2530 */
2531 readonly rowField: string;
2532 /**
2533 * @title 分面列字段。
2534 */
2535 readonly columnField: string;
2536 /**
2537 * @title 当前行分面的枚举值。
2538 */
2539 readonly rowValue: string;
2540 /**
2541 * @title 当前列分面的枚举值。
2542 */
2543 readonly columnValue: string;
2544 /**
2545 * @title 当前行索引。
2546 */
2547 readonly rowIndex: number;
2548 /**
2549 * @title 当前列索引。
2550 */
2551 readonly columnIndex: number;
2552 /**
2553 * @title 当前行字段的枚举值长度。
2554 */
2555 readonly rowValuesLength: number;
2556 /**
2557 * @title 当前列字段的枚举值长度。
2558 */
2559 readonly columnValuesLength: number;
2560}
2561
2562// ===================== rect 相关类型定义 =====================
2563/**
2564 * @title rect 分面类型配置
2565 */
2566export interface RectCfg extends FacetCfg<RectData> {
2567 /**
2568 * @title 行标题的样式。
2569 */
2570 readonly columnTitle?: FacetTitle;
2571 /**
2572 * @title 列标题的样式。
2573 */
2574 readonly rowTitle?: FacetTitle;
2575}
2576
2577export type RectData = FacetData;
2578
2579// ===================== mirror 相关类型定义 =====================
2580/**
2581 * @title mirror 分面类型配置
2582 */
2583export interface MirrorCfg extends FacetCfg<MirrorData> {
2584 /**
2585 * @title 是否转置。
2586 */
2587 readonly transpose?: boolean;
2588 /**
2589 * @title 标题样式。
2590 */
2591 readonly title?: FacetTitle;
2592}
2593
2594export type MirrorData = FacetData;
2595
2596// ===================== list 相关类型定义 =====================
2597/**
2598 * @title list 分面类型配置
2599 */
2600export interface ListCfg extends FacetCfg<ListData> {
2601 /**
2602 * @title 指定每行可显示分面的个数,超出时会自动换行。
2603 */
2604 readonly cols?: number;
2605 /**
2606 * @title 每个分面标题配置。
2607 */
2608 readonly title?: FacetTitle;
2609}
2610
2611export interface ListData extends FacetData {
2612 readonly total?: number;
2613}
2614
2615// ===================== matrix 相关类型定义 =====================
2616/**
2617 * @title matrix 分面类型配置
2618 */
2619export interface MatrixCfg extends FacetCfg<MirrorData> {
2620 /**
2621 * @title 列标题的样式
2622 */
2623 readonly columnTitle?: FacetTitle;
2624 /**
2625 * @title 列标题的样式
2626 */
2627 readonly rowTitle?: FacetTitle;
2628}
2629
2630export type MatrixData = FacetData;
2631
2632// ===================== circle 相关类型定义 =====================
2633/**
2634 * @title circle 分面类型配置
2635 */
2636export interface CircleCfg extends FacetCfg<CircleData> {
2637 /**
2638 * @title 分面标题配置。
2639 */
2640 readonly title?: FacetTitle;
2641}
2642
2643export type CircleData = FacetData;
2644
2645// ===================== tree 相关类型定义 =====================
2646
2647export interface Line {
2648 readonly style?: ShapeAttrs;
2649 readonly smooth?: boolean;
2650}
2651/**
2652 * @title tree 分面类型配置
2653 */
2654export interface TreeCfg extends FacetCfg<TreeData> {
2655 readonly line?: Line;
2656 readonly title?: FacetTitle;
2657}
2658
2659export interface TreeData extends FacetData {
2660 children?: TreeData[];
2661 originColIndex?: number;
2662}
2663
2664/**
2665 * facet object map
2666 */
2667export interface FacetCfgMap {
2668 /**
2669 * @title rect 类型分面配置
2670 */
2671 readonly rect: RectCfg;
2672 /**
2673 * @title mirror 类型分面配置
2674 */
2675 readonly mirror: MirrorCfg;
2676 /**
2677 * @title list 类型分面配置
2678 */
2679 readonly list: ListCfg;
2680 /**
2681 * @title matrix 类型分面配置
2682 */
2683 readonly matrix: MatrixCfg;
2684 /**
2685 * @title circle 类型分面配置
2686 */
2687 readonly circle: CircleCfg;
2688 /**
2689 * @title tree 类型分面配置
2690 */
2691 readonly tree: TreeCfg;
2692}
2693
2694// ============================ 主题样式表定义 ============================
2695export interface StyleSheet {
2696 /**
2697 * @title 背景色
2698 */
2699 backgroundColor?: string;
2700 /**
2701 * @title 主题色
2702 */
2703 brandColor?: string;
2704 /**
2705 * @title 辅助色
2706 */
2707 subColor?: string;
2708 /**
2709 * @title 分类色板 1,在数据量小于等于 10 时使用
2710 */
2711 paletteQualitative10?: string[];
2712 /**
2713 * @title 分类色板 2,在数据量大于 10 时使用
2714 */
2715 paletteQualitative20?: string[];
2716 /**
2717 * @title 语义色
2718 */
2719 paletteSemanticRed?: string;
2720 /**
2721 * @title 语义色
2722 */
2723 paletteSemanticGreen?: string;
2724 /**
2725 * @title 语义色
2726 */
2727 paletteSemanticYellow?: string;
2728 /**
2729 * @title (单色)顺序色板
2730 */
2731 paletteSequence?: string[];
2732 /**
2733 * @title 字体
2734 */
2735 fontFamily?: string;
2736
2737 // -------------------- 坐标轴 --------------------
2738 /**
2739 * @title 坐标轴线颜色
2740 */
2741 axisLineBorderColor?: string;
2742 /**
2743 * @title 坐标轴线粗细
2744 */
2745 axisLineBorder?: number;
2746 /**
2747 * @title 坐标轴线 lineDash 设置
2748 */
2749 axisLineDash?: number[];
2750
2751 /**
2752 * @title 坐标轴标题颜色
2753 */
2754 axisTitleTextFillColor?: string;
2755 /**
2756 * @title 坐标轴标题文本字体大小
2757 */
2758 axisTitleTextFontSize?: number;
2759 /**
2760 * @title 坐标轴标题文本行高
2761 */
2762 axisTitleTextLineHeight?: number;
2763 /**
2764 * @title 坐标轴标题文本字体粗细
2765 */
2766 axisTitleTextFontWeight?: number | string;
2767 /**
2768 * @title 坐标轴标题距离坐标轴文本的间距
2769 */
2770 axisTitleSpacing?: number;
2771 /**
2772 * @title 坐标轴详细说明icon颜色
2773 */
2774 axisDescriptionIconFillColor?: string;
2775 /**
2776 * @title 坐标轴刻度线颜色
2777 */
2778 axisTickLineBorderColor?: string;
2779 /**
2780 * @title 坐标轴刻度线长度
2781 */
2782 axisTickLineLength?: number;
2783 /**
2784 * @title 坐标轴刻度线粗细
2785 */
2786 axisTickLineBorder?: number;
2787
2788 /**
2789 * @title 坐标轴次刻度线颜色
2790 */
2791 axisSubTickLineBorderColor?: string;
2792 /**
2793 * @title 坐标轴次刻度线长度
2794 */
2795 axisSubTickLineLength?: number;
2796 /**
2797 * @title 坐标轴次刻度线粗细
2798 */
2799 axisSubTickLineBorder?: number;
2800
2801 /**
2802 * @title 坐标轴刻度文本颜色
2803 */
2804 axisLabelFillColor?: string;
2805 /**
2806 * @title 坐标轴刻度文本字体大小
2807 */
2808 axisLabelFontSize?: number;
2809 /**
2810 * @title 坐标轴刻度文本行高
2811 */
2812 axisLabelLineHeight?: number;
2813 /**
2814 * @title 坐标轴刻度文本字体粗细
2815 */
2816 axisLabelFontWeight?: number | string;
2817 /**
2818 * @title 坐标轴刻度文本距离坐标轴线的间距
2819 */
2820 axisLabelOffset: number;
2821
2822 /**
2823 * @title 坐标轴网格线颜色
2824 */
2825 axisGridBorderColor?: string;
2826 /**
2827 * @title 坐标轴网格线粗细
2828 */
2829 axisGridBorder?: number;
2830 /**
2831 * @title 坐标轴网格线虚线设置
2832 */
2833 axisGridLineDash?: number[];
2834
2835 // -------------------- 图例 --------------------
2836 /**
2837 * @title 图例标题颜色
2838 */
2839 legendTitleTextFillColor?: string;
2840 /**
2841 * @title 图例标题文本字体大小
2842 */
2843 legendTitleTextFontSize?: number;
2844 /**
2845 * @title 图例标题文本行高
2846 */
2847 legendTitleTextLineHeight?: number;
2848 /**
2849 * @title 图例标题文本字体粗细
2850 */
2851 legendTitleTextFontWeight?: number | string;
2852
2853 /**
2854 * @title 图例 marker 颜色
2855 */
2856 legendMarkerColor?: string;
2857 /**
2858 * @title 图例 marker 距离图例文本的间距
2859 */
2860 legendMarkerSpacing?: number;
2861 /**
2862 * @title 图例 marker 默认半径大小
2863 */
2864 legendMarkerSize?: number;
2865 /**
2866 * @title 图例 'circle' marker 半径
2867 */
2868 legendCircleMarkerSize?: number;
2869 /**
2870 * @title 图例 'square' marker 半径
2871 */
2872 legendSquareMarkerSize?: number;
2873 /**
2874 * @title 图例 'line' marker 半径
2875 */
2876 legendLineMarkerSize?: number;
2877
2878 /**
2879 * @title 图例项文本颜色
2880 */
2881 legendItemNameFillColor?: string;
2882 /**
2883 * @title 图例项文本字体大小
2884 */
2885 legendItemNameFontSize?: number;
2886 /**
2887 * @title 图例项文本行高
2888 */
2889 legendItemNameLineHeight?: number;
2890 /**
2891 * @title 图例项粗细
2892 */
2893 legendItemNameFontWeight?: number | string;
2894 /**
2895 * @title 图例项之间的水平间距
2896 */
2897 legendItemSpacing?: number;
2898 /**
2899 * @title 图例项垂直方向的间隔
2900 */
2901 legendItemMarginBottom?: number;
2902 /**
2903 * @title 图例与图表绘图区域的偏移距离
2904 */
2905 legendPadding?: number[];
2906 /**
2907 * @title 水平布局的图例与绘图区域偏移距离
2908 */
2909 legendHorizontalPadding?: number[];
2910 /**
2911 * @title 垂直布局的图例与绘图区域偏移距离
2912 */
2913 legendVerticalPadding?: number[];
2914
2915 /**
2916 * @title 图例分页器 marker 大小
2917 */
2918 legendPageNavigatorMarkerSize: number;
2919 /**
2920 * @title 图例分页器 marker 非激活状态填充色
2921 */
2922 legendPageNavigatorMarkerInactiveFillColor: string;
2923 /**
2924 * @title 图例分页器 marker 非激活状态填充色透明度
2925 */
2926 legendPageNavigatorMarkerInactiveFillOpacity: number;
2927 /**
2928 * @title 图例分页器 marker 填充色
2929 */
2930 legendPageNavigatorMarkerFillColor: string;
2931 /**
2932 * @title 图例分页器 marker 填充色透明度
2933 */
2934 legendPageNavigatorMarkerFillOpacity: number;
2935 /**
2936 * @title 图例分页器文本颜色
2937 */
2938 legendPageNavigatorTextFillColor: string;
2939 /**
2940 * @title 图例分页器文本字体大小
2941 */
2942 legendPageNavigatorTextFontSize: number;
2943
2944 /**
2945 * @title 连续图例滑块填充色
2946 */
2947 sliderRailFillColor?: string;
2948 /**
2949 * @title 连续图例滑块边框粗细
2950 */
2951 sliderRailBorder?: number;
2952 /**
2953 * @title 连续图例滑块边框颜色
2954 */
2955 sliderRailBorderColor?: string;
2956 /**
2957 * @title 连续图例滑块宽度
2958 */
2959 sliderRailWidth?: number;
2960 /**
2961 * @title 连续图例滑块高度
2962 */
2963 sliderRailHeight?: number;
2964
2965 /**
2966 * @title 连续图例文本颜色
2967 */
2968 sliderLabelTextFillColor?: string;
2969 /**
2970 * @title 连续图例文本字体大小
2971 */
2972 sliderLabelTextFontSize?: number;
2973 /**
2974 * @title 连续图例文本行高
2975 */
2976 sliderLabelTextLineHeight?: number;
2977 /**
2978 * @title 连续图例文本字体粗细
2979 */
2980 sliderLabelTextFontWeight?: number | string;
2981
2982 /**
2983 * @title 连续图例滑块颜色
2984 */
2985 sliderHandlerFillColor?: string;
2986 /**
2987 * @title 连续图例滑块宽度
2988 */
2989 sliderHandlerWidth?: number;
2990 /**
2991 * @title 连续图例滑块高度
2992 */
2993 sliderHandlerHeight?: number;
2994 /**
2995 * @title 连续图例滑块边框粗细
2996 */
2997 sliderHandlerBorder?: number;
2998 /**
2999 * @title 连续图例滑块边框颜色
3000 */
3001 sliderHandlerBorderColor?: string;
3002
3003 // -------------------- Annotation,图形标注 --------------------
3004 /**
3005 * @title arc 图形标注描边颜色
3006 */
3007 annotationArcBorderColor?: string;
3008 /**
3009 * @title arc 图形标注粗细
3010 */
3011 annotationArcBorder?: number;
3012
3013 /**
3014 * @title line 图形标注颜色
3015 */
3016 annotationLineBorderColor?: string;
3017 /**
3018 * @title line 图形标注粗细
3019 */
3020 annotationLineBorder?: number;
3021 /**
3022 * @title lube 图形标注的虚线间隔
3023 */
3024 annotationLineDash?: number[];
3025
3026 /**
3027 * @title text 图形标注文本颜色
3028 */
3029 annotationTextFillColor?: string;
3030 /**
3031 * @title text 图形标注文本字体大小
3032 */
3033 annotationTextFontSize?: number;
3034 /**
3035 * @title text 图形标注文本行高
3036 */
3037 annotationTextLineHeight?: number;
3038 /**
3039 * @title text 图形标注文本字体粗细
3040 */
3041 annotationTextFontWeight?: number | string;
3042
3043 /**
3044 * @title text 图形标注文本边框颜色
3045 */
3046 annotationTextBorderColor?: string;
3047 /**
3048 * @title text 图形标注文本边框粗细
3049 */
3050 annotationTextBorder?: number;
3051
3052 /**
3053 * @title region 图形标注填充颜色
3054 */
3055 annotationRegionFillColor?: string;
3056 /**
3057 * @title region 图形标注填充颜色透明色
3058 */
3059 annotationRegionFillOpacity?: number;
3060 /**
3061 * @title region 图形标注描边粗细
3062 */
3063 annotationRegionBorder?: number;
3064 /**
3065 * @title region 图形标注描边颜色
3066 */
3067 annotationRegionBorderColor?: string;
3068
3069 /**
3070 * @title dataMarker 图形标注的连接线长度
3071 */
3072 annotationDataMarkerLineLength?: number;
3073
3074 // -------------------- Tooltip --------------------
3075 /**
3076 * @title tooltip crosshairs 辅助线颜色
3077 */
3078 tooltipCrosshairsBorderColor?: string;
3079 /**
3080 * @title tooltip crosshairs 辅助线粗细
3081 */
3082 tooltipCrosshairsBorder?: number;
3083 /**
3084 * @title tooltip crosshairs 辅助线虚线间隔
3085 */
3086 tooltipCrosshairsLineDash?: number[];
3087
3088 /**
3089 * @title tooltip 内容框背景色
3090 */
3091 tooltipContainerFillColor?: string;
3092 /**
3093 * @title tooltip 内容框背景透明度
3094 */
3095 tooltipContainerFillOpacity?: number;
3096 /**
3097 * @title tooltip 内容框阴影
3098 */
3099 tooltipContainerShadow?: string;
3100 /**
3101 * @title tooltip 内容框圆角
3102 */
3103 tooltipContainerBorderRadius?: number;
3104
3105 /**
3106 * @title tooltip 文本颜色
3107 */
3108 tooltipTextFillColor?: string;
3109 /**
3110 * @title tooltip 文本字体大小
3111 */
3112 tooltipTextFontSize?: number;
3113 /**
3114 * @title tooltip 文本行高
3115 */
3116 tooltipTextLineHeight?: number;
3117 /**
3118 * @title tooltip 文本字体粗细
3119 */
3120 tooltipTextFontWeight?: number | string;
3121
3122 // -------------------- Geometry labels --------------------
3123 /**
3124 * @title Geometry label 文本颜色
3125 */
3126 labelFillColor?: string;
3127 /**
3128 * @title Geometry label 暗色文本颜色
3129 */
3130 labelFillColorDark?: string;
3131 /**
3132 * @title Geometry label 亮色文本颜色
3133 */
3134 labelFillColorLight?: string;
3135 /**
3136 * @title Geometry label 文本字体大小
3137 */
3138 labelFontSize?: number;
3139 /**
3140 * @title Geometry label 文本行高
3141 */
3142 labelLineHeight?: number;
3143 /**
3144 * @title Geometry label 文本字体粗细
3145 */
3146 labelFontWeight?: number | string;
3147 /**
3148 * @title Geometry label 文本描边颜色
3149 */
3150 labelBorderColor?: string;
3151 /**
3152 * @title Geometry label 文本描边粗细
3153 */
3154 labelBorder?: number;
3155
3156 /**
3157 * @title Geometry innerLabel 文本颜色
3158 */
3159 innerLabelFillColor?: string;
3160 /**
3161 * @title Geometry innerLabel 文本字体大小
3162 */
3163 innerLabelFontSize?: number;
3164 /**
3165 * @title Geometry innerLabel 文本行高
3166 */
3167 innerLabelLineHeight?: number;
3168 /**
3169 * @title Geometry innerLabel 文本字体粗细
3170 */
3171 innerLabelFontWeight?: number | string;
3172 /**
3173 * @title Geometry innerLabel 文本描边颜色
3174 */
3175 innerLabelBorderColor?: string;
3176 /**
3177 * @title Geometry innerLabel 文本描边粗细
3178 */
3179 innerLabelBorder?: number;
3180
3181 /**
3182 * @title Geometry overflowLabel 文本颜色
3183 */
3184 overflowLabelFillColor?: string;
3185 /**
3186 * @title Geometry overflowLabel 暗色文本颜色
3187 */
3188 overflowLabelFillColorDark?: string;
3189 /**
3190 * @title Geometry overflowLabel 亮色文本颜色
3191 */
3192 overflowLabelFillColorLight?: string;
3193 /**
3194 * @title Geometry overflowLabel 文本字体大小
3195 */
3196 overflowLabelFontSize?: number;
3197 /**
3198 * @title Geometry overflowLabel 文本行高
3199 */
3200 overflowLabelLineHeight?: number;
3201 /**
3202 * @title Geometry overflowLabel 文本字体粗细
3203 */
3204 overflowLabelFontWeight?: number | string;
3205 /**
3206 * @title Geometry overflowLabel 文本描边颜色
3207 */
3208 overflowLabelBorderColor?: string;
3209 /**
3210 * @title Geometry overflowLabel 文本描边粗细
3211 */
3212 overflowLabelBorder?: number;
3213
3214 /**
3215 * @title Geometry label 文本连接线粗细
3216 */
3217 labelLineBorder?: number;
3218 /**
3219 * @title Geometry label 文本连接线颜色
3220 */
3221 labelLineBorderColor?: string;
3222
3223 // -------------------- Slider 组件样式--------------------
3224 /**
3225 * @title slider 滑道高度
3226 */
3227 cSliderRailHieght?: number;
3228 /**
3229 * @title slider 滑道背景色
3230 */
3231 cSliderBackgroundFillColor?: string;
3232 /**
3233 * @title slider 滑道背景色透明度
3234 */
3235 cSliderBackgroundFillOpacity?: number;
3236 /**
3237 * @title slider 滑道前景色
3238 */
3239 cSliderForegroundFillColor?: string;
3240 /**
3241 * @title slider 滑道前景色透明度
3242 */
3243 cSliderForegroundFillOpacity?: number;
3244
3245 // slider handlerStyle 手柄样式
3246 /**
3247 * @title slider 手柄高度
3248 */
3249 cSliderHandlerHeight?: number;
3250 /**
3251 * @title Slider 手柄宽度
3252 */
3253 cSliderHandlerWidth?: number;
3254 /**
3255 * @title Slider 手柄背景色
3256 */
3257 cSliderHandlerFillColor?: string;
3258 /**
3259 * @title Slider 手柄背景色透明度
3260 */
3261 cSliderHandlerFillOpacity?: number;
3262 /**
3263 * @title Slider 手柄高亮背景色
3264 */
3265 cSliderHandlerHighlightFillColor?: string;
3266 /**
3267 * @title Slider 手柄边框色
3268 */
3269 cSliderHandlerBorderColor?: string;
3270 /**
3271 * @title Slider 手柄边框粗细
3272 */
3273 cSliderHandlerBorder?: number;
3274 /**
3275 * @title Slider 手柄边框圆角
3276 */
3277 cSliderHandlerBorderRadius?: number;
3278
3279 // slider textStyle 字体标签样式
3280 /**
3281 * @title Slider 字体标签颜色
3282 */
3283 cSliderTextFillColor?: string;
3284 /**
3285 * @title Slider 字体标签透明度
3286 */
3287 cSliderTextFillOpacity?: number;
3288 /**
3289 * @title Slider 字体标签大小
3290 */
3291 cSliderTextFontSize?: number;
3292 /**
3293 * @title Slider 字体标签行高
3294 */
3295 cSliderTextLineHeight?: number;
3296 /**
3297 * @title Slider 字体标签字重
3298 */
3299 cSliderTextFontWeight?: number | string;
3300 /**
3301 * @title Slider 字体标签描边色
3302 */
3303 cSliderTextBorderColor?: string;
3304 /**
3305 * @title Slider 字体标签描边粗细
3306 */
3307 cSliderTextBorder?: number;
3308
3309 // -------------------- Scrollbar 组件样式--------------------
3310 /**
3311 * @title 滚动条 滚道填充色
3312 */
3313 scrollbarTrackFillColor?: string;
3314 /**
3315 * @title 滚动条 滑块填充色
3316 */
3317 scrollbarThumbFillColor?: string;
3318 /**
3319 * @title 滚动条 滑块高亮填充色
3320 */
3321 scrollbarThumbHighlightFillColor?: string;
3322
3323 // -------------------- Geometry 图形样式--------------------
3324 /**
3325 * @title 点图的大小范围
3326 */
3327 pointSizeRange?: [number, number];
3328 /**
3329 * @title 点图填充颜色
3330 */
3331 pointFillColor?: string;
3332 /**
3333 * @title 点图填充颜色透明度
3334 */
3335 pointFillOpacity?: number;
3336 /**
3337 * @title 点图大小
3338 */
3339 pointSize?: number;
3340 /**
3341 * @title 点图描边粗细
3342 */
3343 pointBorder?: number;
3344 /**
3345 * @title 点图描边颜色
3346 */
3347 pointBorderColor?: string;
3348 /**
3349 * @title 点图描边透明度
3350 */
3351 pointBorderOpacity?: number;
3352
3353 /**
3354 * @title 点图 active 状态下填充颜色
3355 */
3356 pointActiveFillColor?: string;
3357 /**
3358 * @title 点图 active 状态下填充颜色透明度
3359 */
3360 pointActiveFillOpacity?: number;
3361 /**
3362 * @title 点图 active 状态下大小
3363 */
3364 pointActiveSize?: number;
3365 /**
3366 * @title 点图 active 状态下描边粗细
3367 */
3368 pointActiveBorder?: number;
3369 /**
3370 * @title 点图 active 状态下描边颜色
3371 */
3372 pointActiveBorderColor?: string;
3373 /**
3374 * @title 点图 active 状态下描边透明度
3375 */
3376 pointActiveBorderOpacity?: number;
3377
3378 /**
3379 * @title 点图 selected 状态下填充颜色
3380 */
3381 pointSelectedFillColor?: string;
3382 /**
3383 * @title 点图 selected 状态下填充颜色透明度
3384 */
3385 pointSelectedFillOpacity?: number;
3386 /**
3387 * @title 点图 selected 状态下大小
3388 */
3389 pointSelectedSize?: number;
3390 /**
3391 * @title 点图 selected 状态下描边粗细
3392 */
3393 pointSelectedBorder?: number;
3394 /**
3395 * @title 点图 selected 状态下描边颜色
3396 */
3397 pointSelectedBorderColor?: string;
3398 /**
3399 * @title 点图 selected 状态下描边透明度
3400 */
3401 pointSelectedBorderOpacity?: number;
3402
3403 /**
3404 * @title 点图 inactive 状态下填充颜色
3405 */
3406 pointInactiveFillColor?: string;
3407 /**
3408 * @title 点图 inactive 状态下填充颜色透明度
3409 */
3410 pointInactiveFillOpacity?: number;
3411 /**
3412 * @title 点图 inactive 状态下大小
3413 */
3414 pointInactiveSize?: number;
3415 /**
3416 * @title 点图 inactive 状态下描边粗细
3417 */
3418 pointInactiveBorder?: number;
3419 /**
3420 * @title 点图 inactive 状态下描边颜色
3421 */
3422 pointInactiveBorderColor?: string;
3423 /**
3424 * @title 点图 inactive 状态下描边透明度
3425 */
3426 pointInactiveBorderOpacity?: number;
3427
3428 /**
3429 * @title 描边点图大小
3430 */
3431 hollowPointSize?: number;
3432 /**
3433 * @title 描边点图描边粗细
3434 */
3435 hollowPointBorder?: number;
3436 /**
3437 * @title 描边点图描边颜色
3438 */
3439 hollowPointBorderColor?: string;
3440 /**
3441 * @title 描边点图描边透明度
3442 */
3443 hollowPointBorderOpacity?: number;
3444 /**
3445 * @title 描边点图填充颜色
3446 */
3447 hollowPointFillColor?: string;
3448 /**
3449 * @title 描边点图填充透明度
3450 */
3451 hollowPointFillOpacity?: number;
3452
3453 /**
3454 * @title 点 描边 active 状态下大小
3455 */
3456 hollowPointActiveSize?: number;
3457 /**
3458 * @title 点 描边 active 状态下描边粗细
3459 */
3460 hollowPointActiveBorder?: number;
3461 /**
3462 * @title 点 描边 active 状态下描边颜色
3463 */
3464 hollowPointActiveBorderColor?: string;
3465 /**
3466 * @title 点 描边 active 状态下描边透明度
3467 */
3468 hollowPointActiveBorderOpacity?: number;
3469
3470 /**
3471 * @title 点 描边 selected 状态下大小
3472 */
3473 hollowPointSelectedSize?: number;
3474 /**
3475 * @title 点 描边 selected 状态下描边粗细
3476 */
3477 hollowPointSelectedBorder?: number;
3478 /**
3479 * @title 点 描边 selected 状态下描边颜色
3480 */
3481 hollowPointSelectedBorderColor?: string;
3482 /**
3483 * @title 点 描边 selected 状态下描边透明度
3484 */
3485 hollowPointSelectedBorderOpacity?: number;
3486
3487 /**
3488 * @title 点 描边 inactive 状态下大小
3489 */
3490 hollowPointInactiveSize?: number;
3491 /**
3492 * @title 点 描边 inactive 状态下描边粗细
3493 */
3494 hollowPointInactiveBorder?: number;
3495 /**
3496 * @title 点 描边 inactive 状态下描边颜色
3497 */
3498 hollowPointInactiveBorderColor?: string;
3499 /**
3500 * @title 点 描边 inactive 状态下描边透明度
3501 */
3502 hollowPointInactiveBorderOpacity?: number;
3503
3504 /**
3505 * @title 线图粗细
3506 */
3507 lineBorder?: number;
3508 /**
3509 * @title 线图颜色
3510 */
3511 lineBorderColor?: string;
3512 /**
3513 * @title 线图透明度
3514 */
3515 lineBorderOpacity?: number;
3516
3517 /**
3518 * @title 线图 active 状态下粗细
3519 */
3520 lineActiveBorder?: number;
3521 /**
3522 * @title 线图 active 状态下颜色
3523 */
3524 lineActiveBorderColor?: string;
3525 /**
3526 * @title 线图 active 状态下透明度
3527 */
3528 lineActiveBorderOpacity?: number;
3529
3530 /**
3531 * @title 线图 selected 状态下粗细
3532 */
3533 lineSelectedBorder?: number;
3534 /**
3535 * @title 线图 selected 状态下颜色
3536 */
3537 lineSelectedBorderColor?: string;
3538 /**
3539 * @title 线图 selected 状态下透明度
3540 */
3541 lineSelectedBorderOpacity?: number;
3542
3543 /**
3544 * @title 线图 inactive 状态下粗细
3545 */
3546 lineInactiveBorder?: number;
3547 /**
3548 * @title 线图 inactive 状态下颜色
3549 */
3550 lineInactiveBorderColor?: string;
3551 /**
3552 * @title 线图 inactive 状态下透明度
3553 */
3554 lineInactiveBorderOpacity?: number;
3555
3556 areaBorder?: number;
3557 /**
3558 * @title area 边框颜色
3559 */
3560 areaBorderColor?: string;
3561 /**
3562 * @title area 边框透明度
3563 */
3564 areaBorderOpacity?: number;
3565 /**
3566 * @title area 填充颜色
3567 */
3568 areaFillColor?: string;
3569 /**
3570 * @title area 填充透明度
3571 */
3572 areaFillOpacity?: number;
3573
3574 /**
3575 * @title area Active 状态下边框粗细
3576 */
3577 areaActiveBorder?: number;
3578 /**
3579 * @title area Active 状态下边框颜色
3580 */
3581 areaActiveBorderColor?: string;
3582 /**
3583 * @title area Active 状态下边框透明度
3584 */
3585 areaActiveBorderOpacity?: number;
3586 /**
3587 * @title area Active 状态下填充颜色
3588 */
3589 areaActiveFillColor?: string;
3590 /**
3591 * @title area Active 状态下填充透明度
3592 */
3593 areaActiveFillOpacity?: number;
3594
3595 /**
3596 * @title area selected 状态下边框粗细
3597 */
3598 areaSelectedBorder?: number;
3599 /**
3600 * @title area selected 状态下边框颜色
3601 */
3602 areaSelectedBorderColor?: string;
3603 /**
3604 * @title area selected 状态下边框透明度
3605 */
3606 areaSelectedBorderOpacity?: number;
3607 /**
3608 * @title area selected 状态下填充颜色
3609 */
3610 areaSelectedFillColor?: string;
3611 /**
3612 * @title area selected 状态下填充透明度
3613 */
3614 areaSelectedFillOpacity?: number;
3615
3616 /**
3617 * @title area inactive 状态下边框粗细
3618 */
3619 areaInactiveBorder?: number;
3620 /**
3621 * @title area inactive 状态下边框颜色
3622 */
3623 areaInactiveBorderColor?: string;
3624 /**
3625 * @title area inactive 状态下边框透明度
3626 */
3627 areaInactiveBorderOpacity?: number;
3628 /**
3629 * @title area inactive 状态下填充颜色
3630 */
3631 areaInactiveFillColor?: string;
3632 /**
3633 * @title area inactive 状态下填充透明度
3634 */
3635 areaInactiveFillOpacity?: number;
3636
3637 /**
3638 * @title hollowArea 边框粗细
3639 */
3640 hollowAreaBorder?: number;
3641 /**
3642 * @title hollowArea 边框颜色
3643 */
3644 hollowAreaBorderColor?: string;
3645 /**
3646 * @title hollowArea 边框透明度
3647 */
3648 hollowAreaBorderOpacity?: number;
3649
3650 /**
3651 * @title hollowArea Active 状态下边框粗细
3652 */
3653 hollowAreaActiveBorder?: number;
3654 /**
3655 * @title hollowArea Active 状态下边框颜色
3656 */
3657 hollowAreaActiveBorderColor?: string;
3658 /**
3659 * @title hollowArea Active 状态下边框透明度
3660 */
3661 hollowAreaActiveBorderOpacity?: number;
3662
3663 /**
3664 * @title hollowArea selected 状态下边框粗细
3665 */
3666 hollowAreaSelectedBorder?: number;
3667 /**
3668 * @title hollowArea selected 状态下边框颜色
3669 */
3670 hollowAreaSelectedBorderColor?: string;
3671 /**
3672 * @title hollowArea selected 状态下边框透明度
3673 */
3674 hollowAreaSelectedBorderOpacity?: number;
3675
3676 /**
3677 * @title hollowArea inactive 状态下边框粗细
3678 */
3679 hollowAreaInactiveBorder?: number;
3680 /**
3681 * @title hollowArea inactive 状态下边框颜色
3682 */
3683 hollowAreaInactiveBorderColor?: string;
3684 /**
3685 * @title hollowArea inactive 状态下边框透明度
3686 */
3687 hollowAreaInactiveBorderOpacity?: number;
3688
3689 /**
3690 * @title interval 边框粗细
3691 */
3692 intervalBorder?: number;
3693 /**
3694 * @title interval 边框颜色
3695 */
3696 intervalBorderColor?: string;
3697 /**
3698 * @title interval 边框透明度
3699 */
3700 intervalBorderOpacity?: number;
3701 /**
3702 * @title interval 填充颜色
3703 */
3704 intervalFillColor?: string;
3705 /**
3706 * @title interval 填充透明度
3707 */
3708 intervalFillOpacity?: number;
3709
3710 /**
3711 * @title interval active 状态下边框粗细
3712 */
3713 intervalActiveBorder?: number;
3714 /**
3715 * @title interval active 状态下边框颜色
3716 */
3717 intervalActiveBorderColor?: string;
3718 /**
3719 * @title interval active 状态下边框透明度
3720 */
3721 intervalActiveBorderOpacity?: number;
3722 /**
3723 * @title interval active 状态下填充颜色
3724 */
3725 intervalActiveFillColor?: string;
3726 /**
3727 * @title interval active 状态下填充透明度
3728 */
3729 intervalActiveFillOpacity?: number;
3730
3731 /**
3732 * @title interval selected 状态下边框粗细
3733 */
3734 intervalSelectedBorder?: number;
3735 /**
3736 * @title interval selected 状态下边框颜色
3737 */
3738 intervalSelectedBorderColor?: string;
3739 /**
3740 * @title interval selected 状态下边框透明度
3741 */
3742 intervalSelectedBorderOpacity?: number;
3743 /**
3744 * @title interval selected 状态下填充颜色
3745 */
3746 intervalSelectedFillColor?: string;
3747 /**
3748 * @title interval selected 状态下填充透明度
3749 */
3750 intervalSelectedFillOpacity?: number;
3751
3752 /**
3753 * @title interval inactive 状态下边框粗细
3754 */
3755 intervalInactiveBorder?: number;
3756 /**
3757 * @title interval inactive 状态下边框颜色
3758 */
3759 intervalInactiveBorderColor?: string;
3760 /**
3761 * @title interval inactive 状态下边框透明度
3762 */
3763 intervalInactiveBorderOpacity?: number;
3764 /**
3765 * @title interval inactive 状态下填充颜色
3766 */
3767 intervalInactiveFillColor?: string;
3768 /**
3769 * @title interval inactive 状态下填充透明度
3770 */
3771 intervalInactiveFillOpacity?: number;
3772
3773 /**
3774 * @title hollowInterval 边框粗细
3775 */
3776 hollowIntervalBorder?: number;
3777 /**
3778 * @title hollowInterval 边框颜色
3779 */
3780 hollowIntervalBorderColor?: string;
3781 /**
3782 * @title hollowInterval 边框透明度
3783 */
3784 hollowIntervalBorderOpacity?: number;
3785 /**
3786 * @title hollowInterval 填充颜色
3787 */
3788 hollowIntervalFillColor?: string;
3789 /**
3790 * @title hollowInterval 填充透明度
3791 */
3792 hollowIntervalFillOpacity?: number;
3793
3794 /**
3795 * @title hollowInterval active 状态下边框粗细
3796 */
3797 hollowIntervalActiveBorder?: number;
3798 /**
3799 * @title hollowInterval active 状态下边框颜色
3800 */
3801 hollowIntervalActiveBorderColor?: string;
3802 /**
3803 * @title hollowInterval active 状态下边框透明度
3804 */
3805 hollowIntervalActiveBorderOpacity?: number;
3806
3807 /**
3808 * @title hollowInterval selected 状态下边框粗细
3809 */
3810 hollowIntervalSelectedBorder?: number;
3811 /**
3812 * @title hollowInterval selected 状态下边框颜色
3813 */
3814 hollowIntervalSelectedBorderColor?: string;
3815 /**
3816 * @title hollowInterval selected 状态下边框透明度
3817 */
3818 hollowIntervalSelectedBorderOpacity?: number;
3819
3820 /**
3821 * @title hollowInterval inactive 状态下边框粗细
3822 */
3823 hollowIntervalInactiveBorder?: number;
3824 /**
3825 * @title hollowInterval inactive 状态下边框颜色
3826 */
3827 hollowIntervalInactiveBorderColor?: string;
3828 /**
3829 * @title hollowInterval inactive 状态下边框透明度
3830 */
3831 hollowIntervalInactiveBorderOpacity?: number;
3832}
3833
3834/**
3835 * @title createTheme 主题样式表配置
3836 */
3837export type StyleSheetCfg = Partial<StyleSheet>;
3838
3839// ============================ 交互相关的类型定义 ============================
3840/**
3841 * @title 交互反馈的定义
3842 */
3843export interface IAction {
3844 /**
3845 * 初始化
3846 */
3847 init();
3848 /**
3849 * 交互 action (反馈)的名称
3850 */
3851 name: string;
3852 /**
3853 * 上下文
3854 */
3855 context: IInteractionContext;
3856 /**
3857 * 销毁函数
3858 */
3859 destroy();
3860}
3861
3862/**
3863 * @title 交互上下文的接口定义
3864 */
3865export interface IInteractionContext extends LooseObject {
3866 /**
3867 * @title 事件对象
3868 */
3869 event: LooseObject;
3870 /**
3871 * 当前的 view
3872 */
3873 view: View;
3874 /**
3875 * @title 交互相关的 Actions
3876 */
3877 actions: IAction[];
3878 /**
3879 * 缓存属性,用于上下文传递信息
3880 * @param key 键名
3881 * @param value 值
3882 */
3883 cache(key: string, value?: any);
3884 /**
3885 * 获取 action
3886 * @param name - action 的名称
3887 * @returns 指定 name 的 Action
3888 */
3889 getAction(name): IAction;
3890 /**
3891 * 获取当前的点
3892 * @returns 返回当前的点
3893 */
3894 getCurrentPoint(): Point;
3895 /**
3896 * 获取当前的图形
3897 */
3898 getCurrentShape(): IShape;
3899 /**
3900 * 添加 action
3901 * @param action 指定交互 action
3902 */
3903 addAction(action: IAction);
3904 /**
3905 * 移除 action
3906 * @param action 移除的 action
3907 */
3908 removeAction(action: IAction);
3909 /**
3910 * 事件触发时是否在 view 内部
3911 */
3912 isInPlot();
3913 /**
3914 * 是否在组件的包围盒内
3915 * @param name 组件名,可省略
3916 */
3917 isInComponent(name?: string);
3918 /**
3919 * 是否在指定的图形内
3920 * @param name shape 的名称
3921 */
3922 isInShape(name);
3923 /**
3924 * 销毁
3925 */
3926 destroy();
3927}
3928
3929/**
3930 * @title G 的渲染类型
3931 */
3932export type Renderer = 'svg' | 'canvas';
3933/**
3934 * @title 数据的定义
3935 */
3936export type Datum = Record<string, any>;
3937export type Data = Datum[];
3938export type ActionCallback = (context: IInteractionContext) => void;
3939export type Padding = [number, number, number, number];
3940export type ViewPadding = number | number[] | 'auto';
3941export type ViewAppendPadding = number | number[];
3942export type Position = [number, number];
3943export type AttributeType = 'position' | 'size' | 'color' | 'shape';
3944export type ShapeVertices = RangePoint[] | Point[] | Point[][];
3945/**
3946 * @title easing 的回调函数, 入参 data 为对应的原始数据记录
3947 */
3948export type AnimateEasingCallback = (data: Datum) => string;
3949/**
3950 * @title delay 的回调函数, 入参 data 为对应的原始数据记录
3951 */
3952export type AnimateDelayCallback = (data: Datum) => number;
3953/**
3954 * @title duration 的回调函数, 入参 data 为对应的原始数据记录
3955 */
3956export type AnimateDurationCallback = (data: Datum) => number;
3957
\No newline at end of file