1 | import { COMPONENT_TYPE, DIRECTION, LAYER } from './constant';
|
2 | import {
|
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 | LegendBackgroundCfg,
|
24 | LegendItemNameCfg,
|
25 | LegendItemValueCfg,
|
26 | LegendMarkerCfg,
|
27 | LegendTitleCfg,
|
28 | PathCommand,
|
29 | Scale,
|
30 | ScaleConfig,
|
31 | ShapeAttrs,
|
32 | LineAnnotationTextCfg,
|
33 | TrendCfg,
|
34 | } from './dependents';
|
35 |
|
36 | import { View } from './chart';
|
37 | import { Facet } from './facet';
|
38 | import Element from './geometry/element';
|
39 | import { PaddingCalCtor } from './chart/layout/padding-cal';
|
40 |
|
41 |
|
42 |
|
43 | export interface LooseObject {
|
44 | [key: string]: any;
|
45 | }
|
46 |
|
47 |
|
48 | export interface Point {
|
49 | readonly x: number;
|
50 | readonly y: number;
|
51 | }
|
52 |
|
53 |
|
54 | export interface Region {
|
55 | readonly start: Point;
|
56 | readonly end: Point;
|
57 | }
|
58 |
|
59 |
|
60 | export interface Size {
|
61 | readonly width: number;
|
62 | readonly height: number;
|
63 | }
|
64 |
|
65 |
|
66 | export interface RangePoint {
|
67 | readonly x?: number | number[];
|
68 | readonly y?: number | number[];
|
69 | }
|
70 |
|
71 |
|
72 | export interface MappingDatum {
|
73 |
|
74 | _origin: Datum;
|
75 |
|
76 | points?: ShapeVertices;
|
77 |
|
78 | nextPoints?: ShapeVertices;
|
79 |
|
80 | x?: number[] | number;
|
81 |
|
82 | y?: number[] | number;
|
83 |
|
84 | color?: string;
|
85 |
|
86 | shape?: string | string[];
|
87 |
|
88 | size?: number;
|
89 | }
|
90 |
|
91 |
|
92 | export interface ShapeInfo {
|
93 |
|
94 | x: number | number[];
|
95 |
|
96 | y: number | number[];
|
97 |
|
98 | shape?: string | string[];
|
99 |
|
100 | size?: number;
|
101 |
|
102 | color?: string;
|
103 |
|
104 | style?: LooseObject;
|
105 |
|
106 | isInCircle?: boolean;
|
107 |
|
108 | data?: Datum | Data;
|
109 |
|
110 | mappingData?: MappingDatum | MappingDatum[];
|
111 |
|
112 | points?: ShapeVertices;
|
113 |
|
114 | nextPoints?: ShapeVertices;
|
115 |
|
116 | text?: string;
|
117 |
|
118 | isStack?: boolean;
|
119 |
|
120 | connectNulls?: boolean;
|
121 |
|
122 | background?: {
|
123 | style?: ShapeAttrs;
|
124 | };
|
125 |
|
126 | showSinglePoint?: boolean;
|
127 |
|
128 | defaultStyle?: LooseObject;
|
129 |
|
130 | customInfo?: CustomOption;
|
131 | }
|
132 |
|
133 |
|
134 | export interface AnimateCfg {
|
135 |
|
136 | readonly easing?: string | AnimateEasingCallback;
|
137 |
|
138 | readonly animation?: string;
|
139 |
|
140 | readonly duration?: number | AnimateDurationCallback;
|
141 |
|
142 | readonly delay?: number | AnimateDelayCallback;
|
143 |
|
144 | readonly callback?: () => any;
|
145 | }
|
146 |
|
147 |
|
148 | export interface GAnimateCfg {
|
149 |
|
150 | readonly duration: number;
|
151 |
|
152 | readonly easing?: string;
|
153 |
|
154 | readonly animation?: string;
|
155 |
|
156 | readonly delay?: number;
|
157 |
|
158 | readonly callback?: () => any;
|
159 | }
|
160 |
|
161 |
|
162 |
|
163 | export interface AttributeOption {
|
164 |
|
165 | fields?: string[];
|
166 |
|
167 | callback?: (...args) => any;
|
168 |
|
169 | values?: any[];
|
170 | }
|
171 |
|
172 |
|
173 | export interface AdjustOption {
|
174 |
|
175 | readonly type: AdjustType;
|
176 | |
177 |
|
178 |
|
179 |
|
180 |
|
181 | readonly marginRatio?: number;
|
182 | |
183 |
|
184 |
|
185 | readonly dodgeBy?: string;
|
186 | |
187 |
|
188 |
|
189 | readonly reverseOrder?: boolean;
|
190 | }
|
191 |
|
192 |
|
193 | export interface StyleOption {
|
194 |
|
195 | readonly fields?: string[];
|
196 |
|
197 | readonly callback?: (...args) => LooseObject;
|
198 |
|
199 | readonly cfg?: LooseObject;
|
200 | }
|
201 |
|
202 |
|
203 | export type CustomOption = any;
|
204 |
|
205 |
|
206 | export interface GeometryTooltipOption {
|
207 |
|
208 | readonly fields: string[];
|
209 |
|
210 | readonly callback?: (...args) => LooseObject;
|
211 | }
|
212 |
|
213 | export interface GeometryLabelLayoutCfg {
|
214 |
|
215 | type: string;
|
216 |
|
217 | cfg?: LooseObject;
|
218 | }
|
219 |
|
220 |
|
221 | export interface GeometryLabelCfg {
|
222 | |
223 |
|
224 |
|
225 |
|
226 | type?: string;
|
227 |
|
228 | offset?: number | string;
|
229 |
|
230 | offsetX?: number;
|
231 |
|
232 | offsetY?: number;
|
233 | |
234 |
|
235 |
|
236 |
|
237 |
|
238 | content?: string | IGroup | IShape | GeometryLabelContentCallback;
|
239 |
|
240 | style?: LooseObject;
|
241 |
|
242 | autoRotate?: boolean;
|
243 | |
244 |
|
245 |
|
246 | rotate?: number;
|
247 |
|
248 | labelHeight?: number;
|
249 | |
250 |
|
251 |
|
252 | labelLine?: null | boolean | { style?: object };
|
253 |
|
254 | labelEmit?: boolean;
|
255 | |
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | layout?: GeometryLabelLayoutCfg | GeometryLabelLayoutCfg[];
|
271 | |
272 |
|
273 |
|
274 | background?: {
|
275 | |
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | style?: ShapeAttrs;
|
283 |
|
284 | padding?: number | number[];
|
285 | };
|
286 | |
287 |
|
288 |
|
289 | position?:
|
290 | | ((data: Datum, mappingData: MappingDatum, index: number) => IntervalGeometryLabelPosition)
|
291 | | IntervalGeometryLabelPosition;
|
292 | /** 动画配置。 */
|
293 | animate?: AnimateOption | false | null;
|
294 | }
|
295 |
|
296 | /** `geometry().label({})` 配置定义 */
|
297 | export interface LabelOption {
|
298 | /** 映射的字段。 */
|
299 | fields?: string[];
|
300 | /** 回调函数。 */
|
301 | callback?: LabelCallback;
|
302 | cfg?: GeometryLabelCfg;
|
303 | }
|
304 |
|
305 | /** Geometry 下每个 state 的配置结构 */
|
306 | export interface StateCfg {
|
307 | /** 状态样式配置。 */
|
308 | style?: object | StateStyleCallback;
|
309 | }
|
310 |
|
311 | /** geometry.state({}) 配置定义 */
|
312 | export interface StateOption {
|
313 | /** 默认状态样式。 */
|
314 | default?: StateCfg;
|
315 | /** active 状态配置。 */
|
316 | active?: StateCfg;
|
317 | /** inactive 状态配置。 */
|
318 | inactive?: StateCfg;
|
319 | /** selected 状态配置。 */
|
320 | selected?: StateCfg;
|
321 | }
|
322 |
|
323 | /** interval label 的位置 */
|
324 | export type IntervalGeometryLabelPosition = 'top' | 'bottom' | 'middle' | 'left' | 'right';
|
325 | /** G2 提供的 adjust 类型 */
|
326 | export type AdjustType = 'stack' | 'jitter' | 'dodge' | 'symmetric';
|
327 | /** geometry.color() 图形属性回调函数定义 */
|
328 | export type ColorAttrCallback = (...args) => string;
|
329 |
|
330 | export type ShapeAttrCallback = (...args) => string | any[];
|
331 |
|
332 | export type SizeAttrCallback = (...args) => number;
|
333 |
|
334 | export type TooltipCallback = (...args) => LooseObject;
|
335 |
|
336 | export type StyleCallback = (...args) => LooseObject;
|
337 |
|
338 | export type LabelCallback = (...args) => GeometryLabelCfg | null | undefined;
|
339 |
|
340 | export type GeometryLabelContentCallback = (
|
341 | data: Datum,
|
342 | mappingData: MappingDatum,
|
343 | index: number
|
344 | ) => string | IShape | IGroup;
|
345 |
|
346 | export type StateStyleCallback = (element: Element) => LooseObject;
|
347 |
|
348 |
|
349 |
|
350 | export interface ShapeMarkerCfg {
|
351 |
|
352 | color: string;
|
353 |
|
354 | isInPolar: boolean;
|
355 | }
|
356 |
|
357 |
|
358 | export interface ShapeMarkerAttrs {
|
359 |
|
360 | symbol: string | ShapeMarkerSymbol;
|
361 | |
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 | style: ShapeAttrs;
|
429 | }
|
430 |
|
431 |
|
432 | export interface ShapePoint {
|
433 |
|
434 | readonly x: number | number[];
|
435 |
|
436 | readonly y?: number | number[];
|
437 |
|
438 | readonly y0?: number;
|
439 | size?: number;
|
440 | }
|
441 |
|
442 |
|
443 | export interface RegisterShapeFactory {
|
444 |
|
445 | readonly defaultShapeType: string;
|
446 |
|
447 | readonly getDefaultPoints?: (pointInfo: ShapePoint) => Point[];
|
448 |
|
449 | readonly getDefaultStyle?: (geometryTheme: LooseObject) => LooseObject;
|
450 |
|
451 | readonly getMarker?: (shapeType: string, markerCfg: ShapeMarkerCfg) => ShapeMarkerAttrs;
|
452 |
|
453 | readonly drawShape?: (shapeType: string, cfg: ShapeInfo, container: IGroup) => IShape | IGroup;
|
454 | }
|
455 |
|
456 |
|
457 | export interface RegisterShape {
|
458 |
|
459 | readonly getPoints?: (pointInfo: ShapePoint) => Point[];
|
460 |
|
461 | readonly getMarker?: (markerCfg: ShapeMarkerCfg) => ShapeMarkerAttrs;
|
462 |
|
463 | readonly draw: (cfg: ShapeInfo, container: IGroup) => IShape | IGroup | void;
|
464 | }
|
465 |
|
466 |
|
467 | export interface Shape extends RegisterShape {
|
468 |
|
469 | coordinate: Coordinate;
|
470 |
|
471 | parsePath: (path: any) => PathCommand[];
|
472 |
|
473 | parsePoint: (point: Point) => Point;
|
474 |
|
475 | parsePoints: (points: Point[]) => Point[];
|
476 | }
|
477 |
|
478 |
|
479 | export interface ShapeFactory extends RegisterShapeFactory {
|
480 |
|
481 | geometryType: string;
|
482 |
|
483 | coordinate: Coordinate;
|
484 |
|
485 | theme: LooseObject;
|
486 |
|
487 | getShape: (shapeType: string | string[]) => Shape;
|
488 |
|
489 | getShapePoints: (shapeType: string | string[], pointInfo: ShapePoint) => Point[];
|
490 | }
|
491 |
|
492 |
|
493 | export type ShapeMarkerSymbol = (x: number, y: number, r: number) => PathCommand[];
|
494 |
|
495 |
|
496 |
|
497 | export type AnnotationPositionCallback = (
|
498 | xScales: Scale[] | Record<string, Scale>,
|
499 | yScales: Scale[] | Record<string, Scale>
|
500 | ) => [number | string, number | string];
|
501 |
|
502 | export type AnnotationPosition =
|
503 | | [number | string, number | string]
|
504 | | Record<string, number | string>
|
505 | | AnnotationPositionCallback;
|
506 |
|
507 |
|
508 | export interface AnnotationBaseOption {
|
509 | readonly type?: string;
|
510 |
|
511 | readonly top?: boolean;
|
512 |
|
513 | readonly animate?: boolean;
|
514 |
|
515 | readonly animateOption?: ComponentAnimateOption;
|
516 |
|
517 | readonly offsetX?: number;
|
518 |
|
519 | readonly offsetY?: number;
|
520 | }
|
521 |
|
522 |
|
523 | export interface RegionPositionBaseOption extends AnnotationBaseOption {
|
524 |
|
525 | readonly start: AnnotationPosition;
|
526 |
|
527 | readonly end: AnnotationPosition;
|
528 |
|
529 | readonly style?: ShapeAttrs;
|
530 | }
|
531 |
|
532 |
|
533 | export interface PointPositionBaseOption extends AnnotationBaseOption {
|
534 |
|
535 | readonly position: AnnotationPosition;
|
536 | }
|
537 |
|
538 |
|
539 | export interface ImageOption extends RegionPositionBaseOption {
|
540 |
|
541 | readonly src: string;
|
542 | }
|
543 |
|
544 |
|
545 | export interface LineOption extends RegionPositionBaseOption {
|
546 |
|
547 | readonly text?: LineAnnotationTextCfg;
|
548 | }
|
549 |
|
550 | export type ArcOption = RegionPositionBaseOption;
|
551 |
|
552 | export type RegionOption = RegionPositionBaseOption;
|
553 |
|
554 | export interface TextOption extends PointPositionBaseOption, Omit<EnhancedTextCfg, 'content'> {
|
555 | content?: string | number | ((filteredData: object[]) => string | number);
|
556 | }
|
557 | /** 使用 DataMarker Annotation 组件的配置定义 */
|
558 | export interface DataMarkerOption extends PointPositionBaseOption {
|
559 | /** point 设置 */
|
560 | readonly point?: null | { style?: ShapeAttrs };
|
561 | /** line 设置 */
|
562 | readonly line?: null | { style?: ShapeAttrs; length?: number };
|
563 | /** text 设置 */
|
564 | readonly text: null | EnhancedTextCfg;
|
565 | /** 文本超出绘制区域时,是否自动调节文本方向,默认为 true */
|
566 | readonly autoAdjust?: boolean;
|
567 | /** 朝向,默认为 upward,可选值为 'upward' 或者 'downward' */
|
568 | readonly direction?: 'upward' | 'downward';
|
569 | }
|
570 | /** 使用 DataRegion Annotation 组件的配置定义 */
|
571 | export interface DataRegionOption extends RegionPositionBaseOption {
|
572 | /** line长度,default为 0 */
|
573 | readonly lineLength?: number;
|
574 | /** 标注区间的配置 */
|
575 | readonly region?: null | { style?: ShapeAttrs };
|
576 | /** 文本的配置 */
|
577 | readonly text?: null | EnhancedTextCfg;
|
578 | }
|
579 | /** 使用 RegionFilter Annotation 组件的配置定义 */
|
580 | export interface RegionFilterOption extends RegionPositionBaseOption {
|
581 | /** 染色色值 */
|
582 | readonly color: string;
|
583 | /* 可选,设定regionFilter只对特定geom类型起作用,如apply:['area'] */
|
584 | readonly apply?: string[];
|
585 | }
|
586 |
|
587 | /** Shape Annotation 的配置 */
|
588 | export interface ShapeAnnotationOption extends AnnotationBaseOption {
|
589 | /** 自定义 Annotation 绘制函数 */
|
590 | render: (
|
591 | container: IGroup,
|
592 | view: View,
|
593 | helpers: { parsePosition: (position: [string | number, string | number] | Datum) => Point }
|
594 | ) => void;
|
595 | }
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | export interface HtmlAnnotationOption extends PointPositionBaseOption {
|
601 |
|
602 | container?: string | HTMLElement;
|
603 |
|
604 | html: string | HTMLElement | ((container: HTMLElement, view: View) => void | string | HTMLElement);
|
605 | /** X 方向对齐 */
|
606 | alignX?: 'left' | 'middle' | 'right';
|
607 | /** Y 方向对齐 */
|
608 | alignY?: 'top' | 'middle' | 'bottom';
|
609 | /** X 方向偏移 */
|
610 | offsetX?: number;
|
611 | /** Y 方向偏移 */
|
612 | offsetY?: number;
|
613 | }
|
614 |
|
615 | // ============================ Chart && View 上的类型定义 ============================
|
616 | /** Tooltip 内容框的 css 样式定义 */
|
617 | export interface TooltipDomStyles {
|
618 | 'g2-tooltip'?: LooseObject;
|
619 | 'g2-tooltip-title'?: LooseObject;
|
620 | 'g2-tooltip-list'?: LooseObject;
|
621 | 'g2-tooltip-list-item'?: LooseObject;
|
622 | 'g2-tooltip-marker'?: LooseObject;
|
623 | 'g2-tooltip-value'?: LooseObject;
|
624 | 'g2-tooltip-name'?: LooseObject;
|
625 | }
|
626 |
|
627 | /** 目前组件动画允许的参数配置 */
|
628 | export interface ComponentAnimateCfg {
|
629 | /** 动画执行时间 */
|
630 | readonly duration?: number;
|
631 | /** 动画缓动函数 */
|
632 | readonly easing?: string;
|
633 | /** 动画延迟时间 */
|
634 | readonly delay?: number;
|
635 | }
|
636 | /** 组件各个动画类型配置 */
|
637 | export interface ComponentAnimateOption {
|
638 | /** 初入场动画配置 */
|
639 | appear?: ComponentAnimateCfg;
|
640 | /** 更新动画配置 */
|
641 | update?: ComponentAnimateCfg;
|
642 | /** 更新后新入场的动画配置 */
|
643 | enter?: ComponentAnimateCfg;
|
644 | /** 离场动画配置 */
|
645 | leave?: ComponentAnimateCfg;
|
646 | }
|
647 |
|
648 | /** 列定义配置项 */
|
649 | export interface ScaleOption extends ScaleConfig {
|
650 | /** 声明度量类型。 */
|
651 | type?: ScaleType;
|
652 | /**
|
653 | * 同步 scale。
|
654 | *
|
655 | * @example
|
656 | * ```ts
|
657 | * chart.scale({
|
658 | * x: { sync: true },
|
659 | * y: { sync: true },
|
660 | * x1: { sync: 'x1' },
|
661 | * x2: { sync: 'x1' },
|
662 | * });
|
663 | * ```
|
664 | *
|
665 | * 通过以上配置,我们会分别对 x 和 y 两个字段,x1 和 x2 两个字段进行同步度量操作。
|
666 | */
|
667 | sync?: boolean | string;
|
668 | /**
|
669 | * 只对 type: 'time' 的 scale 生效,强制显示最后的日期 tick。
|
670 | */
|
671 | showLast?: boolean;
|
672 | /**
|
673 | * 用于声明使用数据记录中的哪些字段来组成一条数据的唯一 id(如有多个字段,则使用 '-' 连接)。
|
674 | * 数据 id 用于标识 Element 图形元素,应用于 Geometry 中的图形元素 Element 更新。
|
675 | * 默认 G2 内部会有一套 ID 生成规则,如果不能满足用户需求,用户既可以使用该属性配置 id。
|
676 | * @example
|
677 | *
|
678 | * 下面的例子中,声明了将 'x' 和 'y' 字段的数值来作为每条数据记录的 id,即下面数据两条数据的 id 分别为:'1-23' 和 '2-2'。
|
679 | * ```ts
|
680 | * const data = [
|
681 | * { x: 1, y: 23, z: 'a' },
|
682 | * { x: 2, y: 2, z: 'b' },
|
683 | * ];
|
684 | *
|
685 | * chart.scale({
|
686 | * x: { key: true },
|
687 | * y: { key: true },
|
688 | * });
|
689 | * ```
|
690 | */
|
691 | key?: boolean;
|
692 | }
|
693 |
|
694 | /** Geometry 动画参数配置。geometry.animate() */
|
695 | export interface AnimateOption {
|
696 | /** chart 初始化渲染时的入场动画,false/null 表示关闭入场动画。 */
|
697 | appear?: AnimateCfg | false | null;
|
698 | /** chart 发生更新时,新增元素的入场动画,false/null 表示关闭入场动画。 */
|
699 | enter?: AnimateCfg | false | null;
|
700 | /** 更新动画配置,false/null 表示关闭更新动画。 */
|
701 | update?: AnimateCfg | false | null;
|
702 | /** 销毁动画配置,false/null 表示关闭销毁动画。 */
|
703 | leave?: AnimateCfg | false | null;
|
704 | }
|
705 |
|
706 | /** 用于配置项式声明交互行为 */
|
707 | export interface InteractionOption {
|
708 | /** 交互名称 */
|
709 | type: string;
|
710 | /** 交互配置 */
|
711 | cfg?: LooseObject;
|
712 | }
|
713 |
|
714 | /** 用于配置项式的 Geometry 创建方式 */
|
715 | export interface GeometryOption {
|
716 | /** Geometry 的类型。 */
|
717 | type?: 'interval' | 'line' | 'path' | 'point' | 'area' | 'polygon' | 'schema' | 'edge' | 'heatmap' | string;
|
718 | /** position 通道映射规则,对应 `geometry.position()`。 */
|
719 | position?: string | AttributeOption;
|
720 | /** color 通道映射规则,对应 `geometry.color()`。 */
|
721 | color?: string | AttributeOption;
|
722 | /** shape 通道映射规则,对应 `geometry.shape()`。 */
|
723 | shape?: string | AttributeOption;
|
724 | /** size 通道映射规则,对应 `geometry.size()`。 */
|
725 | size?: number | string | AttributeOption;
|
726 | /** adjust 数据调整方式,对应 `geometry.adjust()`。 */
|
727 | adjust?: string | string[] | AdjustOption | AdjustOption[];
|
728 | /** style 样式配置,对应 `geometry.size()`。 */
|
729 | style?: StyleOption | LooseObject;
|
730 | /** tooltip 配置,对应 `geometry.tooltip()`。 */
|
731 | tooltip?: GeometryTooltipOption | boolean | string;
|
732 | /** Geometry 动画配置,对应 `geometry.animate()`。 */
|
733 | animate?: AnimateOption | boolean;
|
734 | /** Label 配置,对应 `geometry.label()`。 */
|
735 | label?: LabelOption | false | string;
|
736 | /** state 样式配置,对应 `geometry.state()`。 */
|
737 | state?: StateOption;
|
738 | /** 其他配置 */
|
739 | cfg?: {
|
740 | /** 是否对数据进行排序 */
|
741 | sortable?: boolean;
|
742 | /** 是否可见 */
|
743 | visible?: boolean;
|
744 | /** 是否连接空值,仅对 'line', 'area' 和 'path' 生效 */
|
745 | connectNulls?: boolean;
|
746 | };
|
747 | }
|
748 |
|
749 | /** 用于配置型式的 View 声明方式 */
|
750 | export interface ViewOption {
|
751 | /** view 的唯一表示 ID */
|
752 | readonly id?: string;
|
753 | /** view 的绘制范围,起始点为左上角。 */
|
754 | readonly region?: Region;
|
755 | /**
|
756 | * 设置图表的内边距,使用方式参考 CSS 盒模型。
|
757 | * 下图黄色区域即为 padding 的范围。
|
758 | * ![](https:
|
759 | *
|
760 | * @example
|
761 | * 1. padding: 20
|
762 | * 2. padding: [ 10, 30, 30 ]
|
763 | */
|
764 | readonly padding?: ViewPadding;
|
765 |
|
766 | readonly theme?: LooseObject | string;
|
767 |
|
768 | readonly visible?: boolean;
|
769 | |
770 |
|
771 |
|
772 | readonly options?: Options;
|
773 | }
|
774 |
|
775 |
|
776 | export interface ChartCfg
|
777 | extends Omit<ViewCfg, 'parent' | 'canvas' | 'foregroundGroup' | 'middleGroup' | 'backgroundGroup' | 'region'> {
|
778 |
|
779 | readonly container: string | HTMLElement;
|
780 |
|
781 | readonly width?: number;
|
782 |
|
783 | readonly height?: number;
|
784 | |
785 |
|
786 |
|
787 |
|
788 | readonly autoFit?: boolean;
|
789 |
|
790 | readonly renderer?: Renderer;
|
791 |
|
792 | readonly pixelRatio?: number;
|
793 | |
794 |
|
795 |
|
796 | readonly localRefresh?: boolean;
|
797 |
|
798 | readonly supportCSSTransform?: boolean;
|
799 | |
800 |
|
801 |
|
802 | readonly defaultInteractions?: string[];
|
803 | }
|
804 |
|
805 | export type SyncViewPaddingFn = (chart: View, views: View[], PC: PaddingCalCtor) => void;
|
806 |
|
807 |
|
808 | export interface ViewCfg {
|
809 |
|
810 | readonly id?: string;
|
811 |
|
812 | readonly parent: View;
|
813 |
|
814 | readonly canvas: ICanvas;
|
815 |
|
816 | readonly foregroundGroup: IGroup;
|
817 |
|
818 | readonly middleGroup: IGroup;
|
819 |
|
820 | readonly backgroundGroup: IGroup;
|
821 |
|
822 | readonly region?: Region;
|
823 |
|
824 | readonly limitInPlot?: boolean;
|
825 | |
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 | readonly padding?: ViewPadding;
|
835 | |
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 | readonly appendPadding?: ViewAppendPadding;
|
842 | |
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 | readonly syncViewPadding?: boolean | SyncViewPaddingFn;
|
852 |
|
853 | readonly theme?: LooseObject | string;
|
854 | |
855 |
|
856 |
|
857 | readonly options?: Options;
|
858 |
|
859 | readonly visible?: boolean;
|
860 | }
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 | export interface ComponentOption {
|
867 | readonly id?: string;
|
868 | readonly component: GroupComponent | HtmlComponent;
|
869 | readonly layer: LAYER;
|
870 | direction: DIRECTION;
|
871 | readonly type: COMPONENT_TYPE;
|
872 |
|
873 | readonly extra?: any;
|
874 | }
|
875 |
|
876 |
|
877 | export interface MarkerCfg extends LegendMarkerCfg {
|
878 |
|
879 | symbol?: Marker | MarkerCallback;
|
880 | }
|
881 |
|
882 |
|
883 | export interface LegendItem {
|
884 | |
885 |
|
886 |
|
887 | id?: string;
|
888 |
|
889 | name: string;
|
890 |
|
891 | value: any;
|
892 |
|
893 | marker?: MarkerCfg;
|
894 |
|
895 | unchecked?: boolean;
|
896 | }
|
897 |
|
898 | export interface G2LegendTitleCfg extends LegendTitleCfg {
|
899 |
|
900 | text?: string;
|
901 | }
|
902 |
|
903 |
|
904 |
|
905 |
|
906 | export interface LegendCfg {
|
907 | |
908 |
|
909 |
|
910 | readonly custom?: boolean;
|
911 | |
912 |
|
913 |
|
914 | layout?: 'horizontal' | 'vertical';
|
915 | |
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 | title?: G2LegendTitleCfg;
|
930 | |
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 | background?: LegendBackgroundCfg;
|
945 |
|
946 | position?:
|
947 | | 'top'
|
948 | | 'top-left'
|
949 | | 'top-right'
|
950 | | 'right'
|
951 | | 'right-top'
|
952 | | 'right-bottom'
|
953 | | 'left'
|
954 | | 'left-top'
|
955 | | 'left-bottom'
|
956 | | 'bottom'
|
957 | | 'bottom-left'
|
958 | | 'bottom-right';
|
959 |
|
960 | animate?: boolean;
|
961 |
|
962 | animateOption?: ComponentAnimateOption;
|
963 | |
964 |
|
965 |
|
966 | itemSpacing?: number;
|
967 | |
968 |
|
969 |
|
970 | itemMarginBottom?: number;
|
971 | |
972 |
|
973 |
|
974 |
|
975 |
|
976 | maxItemWidth?: number;
|
977 | |
978 |
|
979 |
|
980 | itemWidth?: number;
|
981 | |
982 |
|
983 |
|
984 | itemHeight?: number;
|
985 | |
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 | itemName?: LegendItemNameCfg;
|
1000 | |
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 | itemValue?: LegendItemValueCfg;
|
1015 | |
1016 |
|
1017 |
|
1018 | maxWidth?: number;
|
1019 | |
1020 |
|
1021 |
|
1022 | maxHeight?: number;
|
1023 | |
1024 |
|
1025 |
|
1026 | marker?: MarkerCfg;
|
1027 | |
1028 |
|
1029 |
|
1030 | flipPage?: boolean;
|
1031 | |
1032 |
|
1033 |
|
1034 | items?: LegendItem[];
|
1035 | |
1036 |
|
1037 |
|
1038 | reversed?: boolean;
|
1039 |
|
1040 | |
1041 |
|
1042 |
|
1043 | min?: number;
|
1044 | |
1045 |
|
1046 |
|
1047 | max?: number;
|
1048 | |
1049 |
|
1050 |
|
1051 | value?: number[];
|
1052 | |
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 | track?: ContinueLegendTrackCfg;
|
1065 | |
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 | rail?: ContinueLegendRailCfg;
|
1081 | |
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 | label?: ContinueLegendLabelCfg;
|
1100 | |
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 | handler?: ContinueLegendHandlerCfg;
|
1114 | |
1115 |
|
1116 |
|
1117 | slidable?: boolean;
|
1118 |
|
1119 | offsetX?: number;
|
1120 |
|
1121 | offsetY?: number;
|
1122 |
|
1123 | padding?: number[];
|
1124 | }
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 | export interface TooltipCrosshairsText extends CrosshairTextCfg {
|
1130 |
|
1131 | content?: string;
|
1132 | }
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 | export type TooltipCrosshairsTextCallback = (
|
1143 | type: string,
|
1144 | defaultContent: any,
|
1145 | items: any[],
|
1146 | currentPoint: Point
|
1147 | ) => TooltipCrosshairsText;
|
1148 |
|
1149 | export interface TooltipCrosshairs {
|
1150 | |
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 | type?: 'x' | 'y' | 'xy';
|
1160 | |
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 | line?: CrosshairLineCfg;
|
1173 | |
1174 |
|
1175 |
|
1176 | text?: TooltipCrosshairsText | TooltipCrosshairsTextCallback;
|
1177 | |
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 | textBackground?: CrosshairTextBackgroundCfg;
|
1191 |
|
1192 | follow?: boolean;
|
1193 | }
|
1194 |
|
1195 |
|
1196 | export interface TooltipCfg {
|
1197 | |
1198 |
|
1199 |
|
1200 |
|
1201 | follow?: boolean;
|
1202 |
|
1203 | enterable?: boolean;
|
1204 |
|
1205 | showDelay?: number;
|
1206 |
|
1207 | showTitle?: boolean;
|
1208 | |
1209 |
|
1210 |
|
1211 | title?: string;
|
1212 |
|
1213 | position?: 'top' | 'bottom' | 'left' | 'right';
|
1214 |
|
1215 | shared?: boolean;
|
1216 |
|
1217 | showCrosshairs?: boolean;
|
1218 |
|
1219 | crosshairs?: TooltipCrosshairs;
|
1220 |
|
1221 | showMarkers?: boolean;
|
1222 |
|
1223 | marker?: object;
|
1224 |
|
1225 | showContent?: boolean;
|
1226 |
|
1227 | container?: string | HTMLElement;
|
1228 |
|
1229 | containerTpl?: string;
|
1230 |
|
1231 | itemTpl?: string;
|
1232 |
|
1233 | domStyles?: TooltipDomStyles;
|
1234 |
|
1235 | offset?: number;
|
1236 |
|
1237 | reversed?: boolean;
|
1238 |
|
1239 | customContent?: (title: string, data: any[]) => string | HTMLElement;
|
1240 | }
|
1241 |
|
1242 |
|
1243 | export interface CoordinateOption {
|
1244 |
|
1245 | type?: 'polar' | 'theta' | 'rect' | 'cartesian' | 'helix';
|
1246 |
|
1247 | cfg?: CoordinateCfg;
|
1248 | |
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | actions?: CoordinateActions[];
|
1256 | }
|
1257 |
|
1258 |
|
1259 | export interface CoordinateCfg {
|
1260 | |
1261 |
|
1262 |
|
1263 | startAngle?: number;
|
1264 | |
1265 |
|
1266 |
|
1267 | endAngle?: number;
|
1268 | |
1269 |
|
1270 |
|
1271 | radius?: number;
|
1272 | |
1273 |
|
1274 |
|
1275 | innerRadius?: number;
|
1276 | }
|
1277 |
|
1278 |
|
1279 | export interface AxisGridCfg {
|
1280 | |
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 | line?: GridLineCfg;
|
1294 | |
1295 |
|
1296 |
|
1297 | alternateColor?: string | string[];
|
1298 | |
1299 |
|
1300 |
|
1301 | closed?: boolean;
|
1302 | |
1303 |
|
1304 |
|
1305 |
|
1306 | alignTick?: boolean;
|
1307 | }
|
1308 |
|
1309 |
|
1310 | export interface AxisCfg {
|
1311 | |
1312 |
|
1313 |
|
1314 | position?: 'top' | 'bottom' | 'right' | 'left';
|
1315 | |
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 | line?: AxisLineCfg | null;
|
1328 | |
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 | tickLine?: AxisTickLineCfg | null;
|
1343 | |
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 | subTickLine?: AxisSubTickLineCfg | null;
|
1358 | |
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 | title?: AxisTitleCfg | null;
|
1373 | |
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 | label?: AxisLabelCfg | null;
|
1399 |
|
1400 | grid?: AxisGridCfg | null;
|
1401 |
|
1402 | animate?: boolean;
|
1403 |
|
1404 | animateOption?: ComponentAnimateOption;
|
1405 |
|
1406 | verticalFactor?: number;
|
1407 | |
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 | verticalLimitLength?: number;
|
1415 | }
|
1416 |
|
1417 | export interface SliderCfg {
|
1418 |
|
1419 | readonly height?: number;
|
1420 |
|
1421 |
|
1422 | readonly trendCfg?: TrendCfg;
|
1423 |
|
1424 | readonly backgroundStyle?: any;
|
1425 |
|
1426 | readonly foregroundStyle?: any;
|
1427 |
|
1428 | readonly handlerStyle?: any;
|
1429 |
|
1430 | readonly textStyle?: any;
|
1431 |
|
1432 | readonly minLimit?: number;
|
1433 |
|
1434 | readonly maxLimit?: number;
|
1435 |
|
1436 | readonly start?: number;
|
1437 |
|
1438 | readonly end?: number;
|
1439 |
|
1440 | readonly padding?: number[];
|
1441 |
|
1442 | formatter?: (val: any, datum: Datum, idx: number) => any;
|
1443 | }
|
1444 |
|
1445 | export type EventCallback = (event: LooseObject) => void;
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 | export interface EventCfg {
|
1451 | [key: string]: EventCallback;
|
1452 | }
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 | export type SliderOption = SliderCfg | boolean;
|
1458 |
|
1459 |
|
1460 | export interface ScrollbarCfg {
|
1461 |
|
1462 | type?: 'horizontal' | 'vertical';
|
1463 |
|
1464 | width?: number;
|
1465 |
|
1466 | height?: number;
|
1467 |
|
1468 | padding?: Padding;
|
1469 |
|
1470 | categorySize?: number;
|
1471 |
|
1472 | animate?: boolean;
|
1473 | }
|
1474 |
|
1475 |
|
1476 | export type ScrollbarOption = ScrollbarCfg | boolean;
|
1477 |
|
1478 |
|
1479 | export interface Options {
|
1480 |
|
1481 | readonly data?: Data;
|
1482 |
|
1483 | readonly filters?: Record<string, FilterCondition>;
|
1484 |
|
1485 | readonly axes?: Record<string, AxisOption> | boolean;
|
1486 |
|
1487 | readonly legends?: AllLegendsOptions;
|
1488 |
|
1489 | readonly scales?: Record<string, ScaleOption>;
|
1490 |
|
1491 | readonly tooltip?: TooltipOption;
|
1492 |
|
1493 | readonly coordinate?: CoordinateOption;
|
1494 |
|
1495 | readonly annotations?: (
|
1496 | | ArcOption
|
1497 | | RegionFilterOption
|
1498 | | ImageOption
|
1499 | | LineOption
|
1500 | | TextOption
|
1501 | | RegionOption
|
1502 | | DataMarkerOption
|
1503 | | DataRegionOption
|
1504 | )[];
|
1505 |
|
1506 | readonly geometries?: GeometryOption[];
|
1507 |
|
1508 | readonly animate?: boolean;
|
1509 |
|
1510 | readonly interactions?: InteractionOption[];
|
1511 |
|
1512 | readonly events?: EventCfg;
|
1513 |
|
1514 |
|
1515 | readonly slider?: SliderOption;
|
1516 |
|
1517 |
|
1518 | readonly scrollbar?: ScrollbarOption;
|
1519 |
|
1520 |
|
1521 | readonly views?: ViewOption[];
|
1522 |
|
1523 |
|
1524 | readonly facets?: (RectCfg | MirrorCfg | CircleCfg | ListCfg | TreeCfg)[];
|
1525 |
|
1526 |
|
1527 | readonly [name: string]: any;
|
1528 | }
|
1529 |
|
1530 |
|
1531 | export type Marker =
|
1532 | | 'circle'
|
1533 | | 'square'
|
1534 | | 'diamond'
|
1535 | | 'triangle'
|
1536 | | 'triangle-down'
|
1537 | | 'hexagon'
|
1538 | | 'bowtie'
|
1539 | | 'cross'
|
1540 | | 'tick'
|
1541 | | 'plus'
|
1542 | | 'hyphen'
|
1543 | | 'line';
|
1544 |
|
1545 | export type MarkerCallback = (x: number, y: number, r: number) => PathCommand;
|
1546 |
|
1547 | export type TooltipOption = TooltipCfg | boolean;
|
1548 |
|
1549 | export type FilterCondition = (value: any, datum: Datum, idx?: number) => boolean;
|
1550 |
|
1551 | export type AxisOption = AxisCfg | boolean;
|
1552 |
|
1553 | export type LegendOption = LegendCfg | boolean;
|
1554 |
|
1555 | export type AllLegendsOptions = LegendCfg | Record<string, LegendOption> | boolean;
|
1556 |
|
1557 | export type ScaleType =
|
1558 | | 'linear'
|
1559 | | 'cat'
|
1560 | | 'category'
|
1561 | | 'identity'
|
1562 | | 'log'
|
1563 | | 'pow'
|
1564 | | 'time'
|
1565 | | 'timeCat'
|
1566 | | 'quantize'
|
1567 | | 'quantile';
|
1568 |
|
1569 | export type CoordinateRotate = ['rotate', number];
|
1570 | export type CoordinateReflect = ['reflect', 'x' | 'y'];
|
1571 | export type CoordinateScale = ['scale', number, number];
|
1572 | export type CoordinateTranspose = ['transpose'];
|
1573 |
|
1574 | export type CoordinateActions = CoordinateRotate | CoordinateReflect | CoordinateScale | CoordinateTranspose;
|
1575 |
|
1576 |
|
1577 |
|
1578 | export type FacetCtor = new (view: View, cfg: any) => Facet;
|
1579 |
|
1580 | export interface Condition {
|
1581 | readonly field: string;
|
1582 | readonly value: any;
|
1583 | readonly values: any[];
|
1584 | }
|
1585 |
|
1586 | export type FacetDataFilter = (data: Datum[]) => boolean;
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 | export interface FacetCfg<D> {
|
1592 |
|
1593 | readonly type?: string;
|
1594 |
|
1595 | readonly eachView: (innerView: View, facet?: D) => any;
|
1596 |
|
1597 | readonly padding?: ViewPadding;
|
1598 |
|
1599 | readonly showTitle?: boolean;
|
1600 |
|
1601 | readonly fields: string[];
|
1602 | }
|
1603 |
|
1604 |
|
1605 |
|
1606 |
|
1607 | export interface FacetTitle {
|
1608 |
|
1609 | readonly offsetX?: number;
|
1610 |
|
1611 | readonly offsetY?: number;
|
1612 |
|
1613 | readonly style?: object;
|
1614 | readonly formatter?: (val: any) => any;
|
1615 | }
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 | export interface FacetData {
|
1621 |
|
1622 | readonly type: string;
|
1623 |
|
1624 | readonly data: object[];
|
1625 |
|
1626 | readonly region: Region;
|
1627 |
|
1628 | readonly padding?: number;
|
1629 |
|
1630 | view?: View;
|
1631 |
|
1632 |
|
1633 |
|
1634 | readonly rowField: string;
|
1635 |
|
1636 | readonly columnField: string;
|
1637 |
|
1638 | readonly rowValue: string;
|
1639 |
|
1640 | readonly columnValue: string;
|
1641 |
|
1642 | readonly rowIndex: number;
|
1643 |
|
1644 | readonly columnIndex: number;
|
1645 |
|
1646 | readonly rowValuesLength: number;
|
1647 |
|
1648 | readonly columnValuesLength: number;
|
1649 | }
|
1650 |
|
1651 |
|
1652 |
|
1653 | export interface RectCfg extends FacetCfg<RectData> {
|
1654 |
|
1655 | readonly columnTitle?: FacetTitle;
|
1656 |
|
1657 | readonly rowTitle?: FacetTitle;
|
1658 | }
|
1659 |
|
1660 | export interface RectData extends FacetData {}
|
1661 |
|
1662 |
|
1663 |
|
1664 | export interface MirrorCfg extends FacetCfg<MirrorData> {
|
1665 |
|
1666 | readonly transpose?: boolean;
|
1667 |
|
1668 | readonly title?: FacetTitle;
|
1669 | }
|
1670 |
|
1671 | export interface MirrorData extends FacetData {}
|
1672 |
|
1673 |
|
1674 |
|
1675 | export interface ListCfg extends FacetCfg<ListData> {
|
1676 |
|
1677 | readonly cols?: number;
|
1678 |
|
1679 | readonly title?: FacetTitle;
|
1680 | }
|
1681 |
|
1682 | export interface ListData extends FacetData {
|
1683 | readonly total: number;
|
1684 | }
|
1685 |
|
1686 |
|
1687 |
|
1688 | export interface MatrixCfg extends FacetCfg<MirrorData> {
|
1689 |
|
1690 | readonly columnTitle?: FacetTitle;
|
1691 |
|
1692 | readonly rowTitle?: FacetTitle;
|
1693 | }
|
1694 |
|
1695 | export interface MatrixData extends FacetData {}
|
1696 |
|
1697 |
|
1698 |
|
1699 | export interface CircleCfg extends FacetCfg<CircleData> {
|
1700 |
|
1701 | readonly title?: FacetTitle;
|
1702 | }
|
1703 |
|
1704 | export interface CircleData extends FacetData {}
|
1705 |
|
1706 |
|
1707 |
|
1708 | export interface Line {
|
1709 | readonly style?: ShapeAttrs;
|
1710 | readonly smooth?: boolean;
|
1711 | }
|
1712 |
|
1713 | export interface TreeCfg extends FacetCfg<TreeData> {
|
1714 | readonly line?: Line;
|
1715 | readonly title?: FacetTitle;
|
1716 | }
|
1717 |
|
1718 | export interface TreeData extends FacetData {
|
1719 | children?: TreeData[];
|
1720 | originColIndex?: number;
|
1721 | }
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 | export interface FacetCfgMap {
|
1727 |
|
1728 | readonly rect: RectCfg;
|
1729 |
|
1730 | readonly mirror: MirrorCfg;
|
1731 |
|
1732 | readonly list: ListCfg;
|
1733 |
|
1734 | readonly matrix: MatrixCfg;
|
1735 |
|
1736 | readonly circle: CircleCfg;
|
1737 |
|
1738 | readonly tree: TreeCfg;
|
1739 | }
|
1740 |
|
1741 |
|
1742 | export interface StyleSheet {
|
1743 |
|
1744 | backgroundColor?: string;
|
1745 |
|
1746 | brandColor?: string;
|
1747 |
|
1748 | paletteQualitative10?: string[];
|
1749 |
|
1750 | paletteQualitative20?: string[];
|
1751 |
|
1752 | paletteSemanticRed?: string;
|
1753 |
|
1754 | paletteSemanticGreen?: string;
|
1755 |
|
1756 | paletteSemanticYellow?: string;
|
1757 |
|
1758 | fontFamily?: string;
|
1759 |
|
1760 |
|
1761 |
|
1762 | axisLineBorderColor?: string;
|
1763 |
|
1764 | axisLineBorder?: number;
|
1765 |
|
1766 | axisLineDash?: number[];
|
1767 |
|
1768 |
|
1769 | axisTitleTextFillColor?: string;
|
1770 |
|
1771 | axisTitleTextFontSize?: number;
|
1772 |
|
1773 | axisTitleTextLineHeight?: number;
|
1774 |
|
1775 | axisTitleTextFontWeight?: number | string;
|
1776 |
|
1777 | axisTitleSpacing?: number;
|
1778 |
|
1779 |
|
1780 | axisTickLineBorderColor?: string;
|
1781 |
|
1782 | axisTickLineLength?: number;
|
1783 |
|
1784 | axisTickLineBorder?: number;
|
1785 |
|
1786 |
|
1787 | axisSubTickLineBorderColor?: string;
|
1788 |
|
1789 | axisSubTickLineLength?: number;
|
1790 |
|
1791 | axisSubTickLineBorder?: number;
|
1792 |
|
1793 |
|
1794 | axisLabelFillColor?: string;
|
1795 |
|
1796 | axisLabelFontSize?: number;
|
1797 |
|
1798 | axisLabelLineHeight?: number;
|
1799 |
|
1800 | axisLabelFontWeight?: number | string;
|
1801 |
|
1802 | axisLabelOffset: number;
|
1803 |
|
1804 |
|
1805 | axisGridBorderColor?: string;
|
1806 |
|
1807 | axisGridBorder?: number;
|
1808 |
|
1809 | axisGridLineDash?: number[];
|
1810 |
|
1811 |
|
1812 |
|
1813 | legendTitleTextFillColor?: string;
|
1814 |
|
1815 | legendTitleTextFontSize?: number;
|
1816 |
|
1817 | legendTitleTextLineHeight?: number;
|
1818 |
|
1819 | legendTitleTextFontWeight?: number | string;
|
1820 |
|
1821 |
|
1822 | legendMarkerColor?: string;
|
1823 |
|
1824 | legendMarkerSpacing?: number;
|
1825 |
|
1826 | legendMarkerSize?: number;
|
1827 |
|
1828 | legendCircleMarkerSize?: number;
|
1829 |
|
1830 | legendSquareMarkerSize?: number;
|
1831 |
|
1832 | legendLineMarkerSize?: number;
|
1833 |
|
1834 |
|
1835 | legendItemNameFillColor?: string;
|
1836 |
|
1837 | legendItemNameFontSize?: number;
|
1838 |
|
1839 | legendItemNameLineHeight?: number;
|
1840 |
|
1841 | legendItemNameFontWeight?: number | string;
|
1842 |
|
1843 | legendItemSpacing?: number;
|
1844 |
|
1845 | legendItemMarginBottom?: number;
|
1846 |
|
1847 | legendPadding?: number[];
|
1848 |
|
1849 | legendHorizontalPadding?: number[];
|
1850 |
|
1851 | legendVerticalPadding?: number[];
|
1852 |
|
1853 |
|
1854 | sliderRailFillColor?: string;
|
1855 |
|
1856 | sliderRailBorder?: number;
|
1857 |
|
1858 | sliderRailBorderColor?: string;
|
1859 |
|
1860 | sliderRailWidth?: number;
|
1861 |
|
1862 | sliderRailHeight?: number;
|
1863 |
|
1864 |
|
1865 | sliderLabelTextFillColor?: string;
|
1866 |
|
1867 | sliderLabelTextFontSize?: number;
|
1868 |
|
1869 | sliderLabelTextLineHeight?: number;
|
1870 |
|
1871 | sliderLabelTextFontWeight?: number | string;
|
1872 |
|
1873 |
|
1874 | sliderHandlerFillColor?: string;
|
1875 |
|
1876 | sliderHandlerWidth?: number;
|
1877 |
|
1878 | sliderHandlerHeight?: number;
|
1879 |
|
1880 | sliderHandlerBorder?: number;
|
1881 |
|
1882 | sliderHandlerBorderColor?: string;
|
1883 |
|
1884 |
|
1885 |
|
1886 | annotationArcBorderColor?: string;
|
1887 |
|
1888 | annotationArcBorder?: number;
|
1889 |
|
1890 |
|
1891 | annotationLineBorderColor?: string;
|
1892 |
|
1893 | annotationLineBorder?: number;
|
1894 |
|
1895 | annotationLineDash?: number[];
|
1896 |
|
1897 |
|
1898 | annotationTextFillColor?: string;
|
1899 |
|
1900 | annotationTextFontSize?: number;
|
1901 |
|
1902 | annotationTextLineHeight?: number;
|
1903 |
|
1904 | annotationTextFontWeight?: number | string;
|
1905 |
|
1906 |
|
1907 | annotationTextBorderColor?: string;
|
1908 |
|
1909 | annotationTextBorder?: number;
|
1910 |
|
1911 |
|
1912 | annotationRegionFillColor?: string;
|
1913 |
|
1914 | annotationRegionFillOpacity?: number;
|
1915 |
|
1916 | annotationRegionBorder?: number;
|
1917 |
|
1918 | annotationRegionBorderColor?: string;
|
1919 |
|
1920 |
|
1921 | annotationDataMarkerLineLength?: number;
|
1922 |
|
1923 |
|
1924 |
|
1925 | tooltipCrosshairsBorderColor?: string;
|
1926 |
|
1927 | tooltipCrosshairsBorder?: number;
|
1928 |
|
1929 | tooltipCrosshairsLineDash?: number[];
|
1930 |
|
1931 |
|
1932 | tooltipContainerFillColor?: string;
|
1933 |
|
1934 | tooltipContainerFillOpacity?: number;
|
1935 |
|
1936 | tooltipContainerShadow?: string;
|
1937 |
|
1938 | tooltipContainerBorderRadius?: number;
|
1939 |
|
1940 |
|
1941 | tooltipTextFillColor?: string;
|
1942 |
|
1943 | tooltipTextFontSize?: number;
|
1944 |
|
1945 | tooltipTextLineHeight?: number;
|
1946 |
|
1947 | tooltipTextFontWeight?: number | string;
|
1948 |
|
1949 |
|
1950 |
|
1951 | labelFillColor?: string;
|
1952 |
|
1953 | labelFillColorDark?: string;
|
1954 |
|
1955 | labelFillColorLight?: string;
|
1956 |
|
1957 | labelFontSize?: number;
|
1958 |
|
1959 | labelLineHeight?: number;
|
1960 |
|
1961 | labelFontWeight?: number | string;
|
1962 |
|
1963 | labelBorderColor?: string;
|
1964 |
|
1965 | labelBorder?: number;
|
1966 |
|
1967 |
|
1968 | innerLabelFillColor?: string;
|
1969 |
|
1970 | innerLabelFontSize?: number;
|
1971 |
|
1972 | innerLabelLineHeight?: number;
|
1973 |
|
1974 | innerLabelFontWeight?: number | string;
|
1975 |
|
1976 | innerLabelBorderColor?: string;
|
1977 |
|
1978 | innerLabelBorder?: number;
|
1979 |
|
1980 |
|
1981 | overflowLabelFillColor?: string;
|
1982 |
|
1983 | overflowLabelFillColorDark?: string;
|
1984 |
|
1985 | overflowLabelFillColorLight?: string;
|
1986 |
|
1987 | overflowLabelFontSize?: number;
|
1988 |
|
1989 | overflowLabelLineHeight?: number;
|
1990 |
|
1991 | overflowLabelFontWeight?: number | string;
|
1992 |
|
1993 | overflowLabelBorderColor?: string;
|
1994 |
|
1995 | overflowLabelBorder?: number;
|
1996 |
|
1997 |
|
1998 | labelLineBorder?: number;
|
1999 |
|
2000 | labelLineBorderColor?: string;
|
2001 |
|
2002 |
|
2003 |
|
2004 | pointSizeRange?: [number, number];
|
2005 |
|
2006 | pointFillColor?: string;
|
2007 |
|
2008 | pointFillOpacity?: number;
|
2009 |
|
2010 | pointSize?: number;
|
2011 |
|
2012 | pointBorder?: number;
|
2013 |
|
2014 | pointBorderColor?: string;
|
2015 |
|
2016 | pointBorderOpacity?: number;
|
2017 |
|
2018 |
|
2019 | pointActiveFillColor?: string;
|
2020 |
|
2021 | pointActiveFillOpacity?: number;
|
2022 |
|
2023 | pointActiveSize?: number;
|
2024 |
|
2025 | pointActiveBorder?: number;
|
2026 |
|
2027 | pointActiveBorderColor?: string;
|
2028 |
|
2029 | pointActiveBorderOpacity?: number;
|
2030 |
|
2031 |
|
2032 | pointSelectedFillColor?: string;
|
2033 |
|
2034 | pointSelectedFillOpacity?: number;
|
2035 |
|
2036 | pointSelectedSize?: number;
|
2037 |
|
2038 | pointSelectedBorder?: number;
|
2039 |
|
2040 | pointSelectedBorderColor?: string;
|
2041 |
|
2042 | pointSelectedBorderOpacity?: number;
|
2043 |
|
2044 |
|
2045 | pointInactiveFillColor?: string;
|
2046 |
|
2047 | pointInactiveFillOpacity?: number;
|
2048 |
|
2049 | pointInactiveSize?: number;
|
2050 |
|
2051 | pointInactiveBorder?: number;
|
2052 |
|
2053 | pointInactiveBorderColor?: string;
|
2054 |
|
2055 | pointInactiveBorderOpacity?: number;
|
2056 |
|
2057 |
|
2058 | hollowPointSize?: number;
|
2059 |
|
2060 | hollowPointBorder?: number;
|
2061 |
|
2062 | hollowPointBorderColor?: string;
|
2063 |
|
2064 | hollowPointBorderOpacity?: number;
|
2065 |
|
2066 | hollowPointFillColor?: string;
|
2067 |
|
2068 | hollowPointFillOpacity?: number;
|
2069 |
|
2070 |
|
2071 | hollowPointActiveSize?: number;
|
2072 |
|
2073 | hollowPointActiveBorder?: number;
|
2074 |
|
2075 | hollowPointActiveBorderColor?: string;
|
2076 |
|
2077 | hollowPointActiveBorderOpacity?: number;
|
2078 |
|
2079 |
|
2080 | hollowPointSelectedSize?: number;
|
2081 |
|
2082 | hollowPointSelectedBorder?: number;
|
2083 |
|
2084 | hollowPointSelectedBorderColor?: string;
|
2085 |
|
2086 | hollowPointSelectedBorderOpacity?: number;
|
2087 |
|
2088 |
|
2089 | hollowPointInactiveSize?: number;
|
2090 |
|
2091 | hollowPointInactiveBorder?: number;
|
2092 |
|
2093 | hollowPointInactiveBorderColor?: string;
|
2094 |
|
2095 | hollowPointInactiveBorderOpacity?: number;
|
2096 |
|
2097 |
|
2098 | lineBorder?: number;
|
2099 |
|
2100 | lineBorderColor?: string;
|
2101 |
|
2102 | lineBorderOpacity?: number;
|
2103 |
|
2104 |
|
2105 | lineActiveBorder?: number;
|
2106 |
|
2107 | lineActiveBorderColor?: string;
|
2108 |
|
2109 | lineActiveBorderOpacity?: number;
|
2110 |
|
2111 |
|
2112 | lineSelectedBorder?: number;
|
2113 |
|
2114 | lineSelectedBorderColor?: string;
|
2115 |
|
2116 | lineSelectedBorderOpacity?: number;
|
2117 |
|
2118 |
|
2119 | lineInactiveBorder?: number;
|
2120 |
|
2121 | lineInactiveBorderColor?: string;
|
2122 |
|
2123 | lineInactiveBorderOpacity?: number;
|
2124 |
|
2125 | areaBorder?: number;
|
2126 |
|
2127 | areaBorderColor?: string;
|
2128 |
|
2129 | areaBorderOpacity?: number;
|
2130 |
|
2131 | areaFillColor?: string;
|
2132 |
|
2133 | areaFillOpacity?: number;
|
2134 |
|
2135 |
|
2136 | areaActiveBorder?: number;
|
2137 |
|
2138 | areaActiveBorderColor?: string;
|
2139 |
|
2140 | areaActiveBorderOpacity?: number;
|
2141 |
|
2142 | areaActiveFillColor?: string;
|
2143 |
|
2144 | areaActiveFillOpacity?: number;
|
2145 |
|
2146 |
|
2147 | areaSelectedBorder?: number;
|
2148 |
|
2149 | areaSelectedBorderColor?: string;
|
2150 |
|
2151 | areaSelectedBorderOpacity?: number;
|
2152 |
|
2153 | areaSelectedFillColor?: string;
|
2154 |
|
2155 | areaSelectedFillOpacity?: number;
|
2156 |
|
2157 |
|
2158 | areaInactiveBorder?: number;
|
2159 |
|
2160 | areaInactiveBorderColor?: string;
|
2161 |
|
2162 | areaInactiveBorderOpacity?: number;
|
2163 |
|
2164 | areaInactiveFillColor?: string;
|
2165 |
|
2166 | areaInactiveFillOpacity?: number;
|
2167 |
|
2168 |
|
2169 | hollowAreaBorder?: number;
|
2170 |
|
2171 | hollowAreaBorderColor?: string;
|
2172 |
|
2173 | hollowAreaBorderOpacity?: number;
|
2174 |
|
2175 |
|
2176 | hollowAreaActiveBorder?: number;
|
2177 |
|
2178 | hollowAreaActiveBorderColor?: string;
|
2179 |
|
2180 | hollowAreaActiveBorderOpacity?: number;
|
2181 |
|
2182 |
|
2183 | hollowAreaSelectedBorder?: number;
|
2184 |
|
2185 | hollowAreaSelectedBorderColor?: string;
|
2186 |
|
2187 | hollowAreaSelectedBorderOpacity?: number;
|
2188 |
|
2189 |
|
2190 | hollowAreaInactiveBorder?: number;
|
2191 |
|
2192 | hollowAreaInactiveBorderColor?: string;
|
2193 |
|
2194 | hollowAreaInactiveBorderOpacity?: number;
|
2195 |
|
2196 |
|
2197 | intervalBorder?: number;
|
2198 |
|
2199 | intervalBorderColor?: string;
|
2200 |
|
2201 | intervalBorderOpacity?: number;
|
2202 |
|
2203 | intervalFillColor?: string;
|
2204 |
|
2205 | intervalFillOpacity?: number;
|
2206 |
|
2207 |
|
2208 | intervalActiveBorder?: number;
|
2209 |
|
2210 | intervalActiveBorderColor?: string;
|
2211 |
|
2212 | intervalActiveBorderOpacity?: number;
|
2213 |
|
2214 | intervalActiveFillColor?: string;
|
2215 |
|
2216 | intervalActiveFillOpacity?: number;
|
2217 |
|
2218 |
|
2219 | intervalSelectedBorder?: number;
|
2220 |
|
2221 | intervalSelectedBorderColor?: string;
|
2222 |
|
2223 | intervalSelectedBorderOpacity?: number;
|
2224 |
|
2225 | intervalSelectedFillColor?: string;
|
2226 |
|
2227 | intervalSelectedFillOpacity?: number;
|
2228 |
|
2229 |
|
2230 | intervalInactiveBorder?: number;
|
2231 |
|
2232 | intervalInactiveBorderColor?: string;
|
2233 |
|
2234 | intervalInactiveBorderOpacity?: number;
|
2235 |
|
2236 | intervalInactiveFillColor?: string;
|
2237 |
|
2238 | intervalInactiveFillOpacity?: number;
|
2239 |
|
2240 |
|
2241 | hollowIntervalBorder?: number;
|
2242 |
|
2243 | hollowIntervalBorderColor?: string;
|
2244 |
|
2245 | hollowIntervalBorderOpacity?: number;
|
2246 |
|
2247 | hollowIntervalFillColor?: string;
|
2248 |
|
2249 | hollowIntervalFillOpacity?: number;
|
2250 |
|
2251 |
|
2252 | hollowIntervalActiveBorder?: number;
|
2253 |
|
2254 | hollowIntervalActiveBorderColor?: string;
|
2255 |
|
2256 | hollowIntervalActiveBorderOpacity?: number;
|
2257 |
|
2258 |
|
2259 | hollowIntervalSelectedBorder?: number;
|
2260 |
|
2261 | hollowIntervalSelectedBorderColor?: string;
|
2262 |
|
2263 | hollowIntervalSelectedBorderOpacity?: number;
|
2264 |
|
2265 |
|
2266 | hollowIntervalInactiveBorder?: number;
|
2267 |
|
2268 | hollowIntervalInactiveBorderColor?: string;
|
2269 |
|
2270 | hollowIntervalInactiveBorderOpacity?: number;
|
2271 | }
|
2272 |
|
2273 |
|
2274 | export type StyleSheetCfg = Pick<
|
2275 | StyleSheet,
|
2276 | | 'backgroundColor'
|
2277 | | 'brandColor'
|
2278 | | 'paletteQualitative10'
|
2279 | | 'paletteQualitative20'
|
2280 | | 'paletteSemanticRed'
|
2281 | | 'paletteSemanticGreen'
|
2282 | | 'paletteSemanticYellow'
|
2283 | | 'fontFamily'
|
2284 | >;
|
2285 |
|
2286 |
|
2287 |
|
2288 | export interface IAction {
|
2289 | |
2290 |
|
2291 |
|
2292 | init();
|
2293 | |
2294 |
|
2295 |
|
2296 | name: string;
|
2297 | |
2298 |
|
2299 |
|
2300 | context: IInteractionContext;
|
2301 | |
2302 |
|
2303 |
|
2304 | destroy();
|
2305 | }
|
2306 |
|
2307 |
|
2308 | export interface IInteractionContext extends LooseObject {
|
2309 |
|
2310 | event: LooseObject;
|
2311 | |
2312 |
|
2313 |
|
2314 | view: View;
|
2315 |
|
2316 | actions: IAction[];
|
2317 | |
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 | cache(key: string, value?: any);
|
2323 | |
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 | getAction(name): IAction;
|
2329 | |
2330 |
|
2331 |
|
2332 |
|
2333 | getCurrentPoint(): Point;
|
2334 | |
2335 |
|
2336 |
|
2337 | getCurrentShape(): IShape;
|
2338 | |
2339 |
|
2340 |
|
2341 |
|
2342 | addAction(action: IAction);
|
2343 | |
2344 |
|
2345 |
|
2346 |
|
2347 | removeAction(action: IAction);
|
2348 | |
2349 |
|
2350 |
|
2351 | isInPlot();
|
2352 | |
2353 |
|
2354 |
|
2355 |
|
2356 | isInComponent(name?: string);
|
2357 | |
2358 |
|
2359 |
|
2360 |
|
2361 | isInShape(name);
|
2362 | |
2363 |
|
2364 |
|
2365 | destroy();
|
2366 | }
|
2367 |
|
2368 |
|
2369 | export type Renderer = 'svg' | 'canvas';
|
2370 |
|
2371 | export type Datum = Record<string, any>;
|
2372 | export type Data = Datum[];
|
2373 | export type ActionCallback = (context: IInteractionContext) => void;
|
2374 | export type Padding = [number, number, number, number];
|
2375 | export type ViewPadding = number | number[] | 'auto';
|
2376 | export type ViewAppendPadding = number | number[];
|
2377 | export type Position = [number, number];
|
2378 | export type AttributeType = 'position' | 'size' | 'color' | 'shape';
|
2379 | export type ShapeVertices = RangePoint[] | Point[] | Point[][];
|
2380 |
|
2381 | export type AnimateEasingCallback = (data: Datum) => string;
|
2382 |
|
2383 | export type AnimateDelayCallback = (data: Datum) => number;
|
2384 |
|
2385 | export type AnimateDurationCallback = (data: Datum) => number;
|
2386 |
|
\ | No newline at end of file |