UNPKG

27 kBPlain TextView Raw
1import { GeometryCfg } from './geometry/base';
2import { IInteractionContext } from './interface';
3
4// 注册黑暗主题
5import { registerTheme } from './core';
6import { antvDark } from './theme/style-sheet/dark';
7import { createThemeByStyleSheet } from './theme/util/create-by-style-sheet';
8registerTheme('dark', createThemeByStyleSheet(antvDark));
9
10// 注册 G 渲染引擎
11import * as CanvasEngine from '@antv/g-canvas';
12import * as SVGEngine from '@antv/g-svg';
13import { registerEngine } from './core';
14
15registerEngine('canvas', CanvasEngine);
16registerEngine('svg', SVGEngine);
17
18// 注册 G2 内置的 geometry
19import { registerGeometry } from './core';
20import Area, { AreaCfg } from './geometry/area';
21import Edge from './geometry/edge';
22import Heatmap from './geometry/heatmap';
23import Interval, { IntervalCfg } from './geometry/interval';
24import Line from './geometry/line';
25import Path, { PathCfg } from './geometry/path';
26import Point from './geometry/point';
27import Polygon from './geometry/polygon';
28import Schema from './geometry/schema';
29import Violin from './geometry/violin';
30
31registerGeometry('Polygon', Polygon);
32registerGeometry('Interval', Interval);
33registerGeometry('Schema', Schema);
34registerGeometry('Path', Path);
35registerGeometry('Point', Point);
36registerGeometry('Line', Line);
37registerGeometry('Area', Area);
38registerGeometry('Edge', Edge);
39registerGeometry('Heatmap', Heatmap);
40registerGeometry('Violin', Violin);
41
42// 引入所有内置的 shapes
43import './geometry/shape/area/line';
44import './geometry/shape/area/smooth';
45import './geometry/shape/area/smooth-line';
46
47import './geometry/shape/edge/arc';
48import './geometry/shape/edge/smooth';
49import './geometry/shape/edge/vhv';
50
51import './geometry/shape/interval/funnel';
52import './geometry/shape/interval/hollow-rect';
53import './geometry/shape/interval/line';
54import './geometry/shape/interval/pyramid';
55import './geometry/shape/interval/tick';
56
57import './geometry/shape/line/step';
58
59import './geometry/shape/point/hollow';
60import './geometry/shape/point/image';
61import './geometry/shape/point/solid';
62
63import './geometry/shape/schema/box';
64import './geometry/shape/schema/candle';
65
66import './geometry/shape/polygon/square';
67
68import './geometry/shape/violin/smooth';
69import './geometry/shape/violin/hollow';
70
71// 注册 Geometry 内置的 label
72import { registerGeometryLabel } from './core';
73import GeometryLabel from './geometry/label/base';
74import IntervalLabel from './geometry/label/interval';
75import PieLabel from './geometry/label/pie';
76import PolarLabel from './geometry/label/polar';
77
78registerGeometryLabel('base', GeometryLabel);
79registerGeometryLabel('interval', IntervalLabel);
80registerGeometryLabel('pie', PieLabel);
81registerGeometryLabel('polar', PolarLabel);
82
83// 注册 Geometry label 内置的布局函数
84import { registerGeometryLabelLayout } from './core';
85import { distribute } from './geometry/label/layout/pie/distribute';
86import { pieOuterLabelLayout } from './geometry/label/layout/pie/outer';
87import { pieSpiderLabelLayout } from './geometry/label/layout/pie/spider';
88import { limitInCanvas } from './geometry/label/layout/limit-in-canvas';
89import { limitInShape } from './geometry/label/layout/limit-in-shape';
90import { fixedOverlap, overlap } from './geometry/label/layout/overlap';
91import { hideOverlap } from './geometry/label/layout/hide-overlap';
92import { adjustColor } from './geometry/label/layout/adjust-color';
93import { intervalAdjustPosition } from './geometry/label/layout/interval/adjust-position';
94import { intervalHideOverlap } from './geometry/label/layout/interval/hide-overlap';
95import { pointAdjustPosition } from './geometry/label/layout/point/adjust-position';
96import { pathAdjustPosition } from './geometry/label/layout/path/adjust-position';
97import { limitInPlot } from './geometry/label/layout/limit-in-plot';
98
99registerGeometryLabelLayout('overlap', overlap);
100registerGeometryLabelLayout('distribute', distribute);
101registerGeometryLabelLayout('fixed-overlap', fixedOverlap);
102registerGeometryLabelLayout('hide-overlap', hideOverlap);
103registerGeometryLabelLayout('limit-in-shape', limitInShape);
104registerGeometryLabelLayout('limit-in-canvas', limitInCanvas);
105registerGeometryLabelLayout('limit-in-plot', limitInPlot);
106registerGeometryLabelLayout('pie-outer', pieOuterLabelLayout);
107registerGeometryLabelLayout('adjust-color', adjustColor);
108registerGeometryLabelLayout('interval-adjust-position', intervalAdjustPosition);
109registerGeometryLabelLayout('interval-hide-overlap', intervalHideOverlap);
110registerGeometryLabelLayout('point-adjust-position', pointAdjustPosition);
111registerGeometryLabelLayout('pie-spider', pieSpiderLabelLayout);
112registerGeometryLabelLayout('path-adjust-position', pathAdjustPosition);
113
114// 注册需要的动画执行函数
115import { fadeIn, fadeOut } from './animate/animation/fade';
116import { growInX, growInXY, growInY } from './animate/animation/grow-in';
117import { pathIn } from './animate/animation/path-in';
118import { positionUpdate } from './animate/animation/position-update';
119import { scaleInX, scaleInY } from './animate/animation/scale-in';
120import { sectorPathUpdate } from './animate/animation/sector-path-update';
121import { waveIn } from './animate/animation/wave-in';
122import { zoomIn, zoomOut } from './animate/animation/zoom';
123import { registerAnimation } from './core';
124
125registerAnimation('fade-in', fadeIn);
126registerAnimation('fade-out', fadeOut);
127registerAnimation('grow-in-x', growInX);
128registerAnimation('grow-in-xy', growInXY);
129registerAnimation('grow-in-y', growInY);
130registerAnimation('scale-in-x', scaleInX);
131registerAnimation('scale-in-y', scaleInY);
132registerAnimation('wave-in', waveIn);
133registerAnimation('zoom-in', zoomIn);
134registerAnimation('zoom-out', zoomOut);
135registerAnimation('position-update', positionUpdate);
136registerAnimation('sector-path-update', sectorPathUpdate);
137registerAnimation('path-in', pathIn);
138
139// 注册内置的 Facet
140import { registerFacet } from './core';
141import Circle from './facet/circle';
142import List from './facet/list';
143import Matrix from './facet/matrix';
144import Mirror from './facet/mirror';
145import Rect from './facet/rect';
146import Tree from './facet/tree';
147
148registerFacet('rect', Rect);
149registerFacet('mirror', Mirror);
150registerFacet('list', List);
151registerFacet('matrix', Matrix);
152registerFacet('circle', Circle);
153registerFacet('tree', Tree);
154
155// 注册内置的 Component
156import { registerComponentController } from './core';
157
158import Annotation from './chart/controller/annotation';
159import Axis from './chart/controller/axis';
160import Legend from './chart/controller/legend';
161import Slider from './chart/controller/slider';
162import Tooltip from './chart/controller/tooltip';
163import Scrollbar from './chart/controller/scrollbar';
164
165// register build-in components
166registerComponentController('axis', Axis);
167registerComponentController('legend', Legend);
168registerComponentController('tooltip', Tooltip);
169registerComponentController('annotation', Annotation);
170registerComponentController('slider', Slider);
171registerComponentController('scrollbar', Scrollbar);
172
173// 注册 Interaction Action
174import { registerAction } from './core';
175import ActiveRegion from './interaction/action/active-region';
176import SiblingTooltip from './interaction/action/component/tooltip/sibling';
177import TooltipAction from './interaction/action/component/tooltip/geometry';
178import EllipsisTextAction from './interaction/action/component/tooltip/ellipsis-text';
179
180import ElementActive from './interaction/action/element/active';
181import ElementLinkByColor from './interaction/action/element/link-by-color';
182import ElementRangeActive from './interaction/action/element/range-active';
183import ElementSingleActive from './interaction/action/element/single-active';
184
185import ElementHighlight from './interaction/action/element/highlight';
186import ElementHighlightByColor from './interaction/action/element/highlight-by-color';
187import ElementHighlightByX from './interaction/action/element/highlight-by-x';
188
189import ElementRangeHighlight, { ELEMENT_RANGE_HIGHLIGHT_EVENTS } from './interaction/action/element/range-highlight';
190import ElementSingleHighlight from './interaction/action/element/single-highlight';
191
192import ElementRangeSelected from './interaction/action/element/range-selected';
193import ElementSelected from './interaction/action/element/selected';
194import ElementSingleSelected from './interaction/action/element/single-selected';
195
196import ListActive from './interaction/action/component/list-active';
197import ListHighlight from './interaction/action/component/list-highlight';
198import ListSelected from './interaction/action/component/list-selected';
199import ListUnchecked from './interaction/action/component/list-unchecked';
200import ListChecked from './interaction/action/component/list-checked';
201import ListFocus from './interaction/action/component/list-focus';
202import ListRadio from './interaction/action/component/list-radio';
203
204import CircleMask from './interaction/action/mask/circle';
205import DimMask from './interaction/action/mask/dim-rect';
206import PathMask from './interaction/action/mask/path';
207import RectMask from './interaction/action/mask/rect';
208import SmoothPathMask from './interaction/action/mask/smooth-path';
209
210import CursorAction from './interaction/action/cursor';
211import DataFilter from './interaction/action/data/filter';
212import DataRangeFilter, { BRUSH_FILTER_EVENTS } from './interaction/action/data/range-filter';
213import SiblingFilter from './interaction/action/data/sibling-filter';
214
215import ElementFilter from './interaction/action/element/filter';
216import ElementSiblingFilter from './interaction/action/element/sibling-filter';
217import ButtonAction from './interaction/action/view/button';
218import ViewDrag from './interaction/action/view/drag';
219import ViewMove from './interaction/action/view/move';
220import ScaleTranslate from './interaction/action/view/scale-translate';
221import ScaleZoom from './interaction/action/view/scale-zoom';
222import MousewheelScroll from './interaction/action/view/mousewheel-scroll';
223import AxisDescription from './interaction/action/component/axis/axis-description'
224
225registerAction('tooltip', TooltipAction);
226registerAction('sibling-tooltip', SiblingTooltip);
227registerAction('ellipsis-text', EllipsisTextAction);
228registerAction('element-active', ElementActive);
229registerAction('element-single-active', ElementSingleActive);
230registerAction('element-range-active', ElementRangeActive);
231
232registerAction('element-highlight', ElementHighlight);
233registerAction('element-highlight-by-x', ElementHighlightByX);
234registerAction('element-highlight-by-color', ElementHighlightByColor);
235
236registerAction('element-single-highlight', ElementSingleHighlight);
237registerAction('element-range-highlight', ElementRangeHighlight);
238registerAction('element-sibling-highlight', ElementRangeHighlight, {
239 effectSiblings: true,
240 effectByRecord: true,
241});
242
243registerAction('element-selected', ElementSelected);
244registerAction('element-single-selected', ElementSingleSelected);
245registerAction('element-range-selected', ElementRangeSelected);
246registerAction('element-link-by-color', ElementLinkByColor);
247
248registerAction('active-region', ActiveRegion);
249registerAction('list-active', ListActive);
250registerAction('list-selected', ListSelected);
251registerAction('list-highlight', ListHighlight);
252registerAction('list-unchecked', ListUnchecked);
253registerAction('list-checked', ListChecked);
254registerAction('list-focus', ListFocus);
255registerAction('list-radio', ListRadio);
256
257registerAction('legend-item-highlight', ListHighlight, {
258 componentNames: ['legend'],
259});
260
261registerAction('axis-label-highlight', ListHighlight, {
262 componentNames: ['axis'],
263});
264registerAction('axis-description', AxisDescription)
265
266registerAction('rect-mask', RectMask);
267registerAction('x-rect-mask', DimMask, { dim: 'x' });
268registerAction('y-rect-mask', DimMask, { dim: 'y' });
269registerAction('circle-mask', CircleMask);
270registerAction('path-mask', PathMask);
271registerAction('smooth-path-mask', SmoothPathMask);
272
273registerAction('cursor', CursorAction);
274registerAction('data-filter', DataFilter);
275
276registerAction('brush', DataRangeFilter);
277registerAction('brush-x', DataRangeFilter, { dims: ['x'] });
278registerAction('brush-y', DataRangeFilter, { dims: ['y'] });
279registerAction('sibling-filter', SiblingFilter);
280registerAction('sibling-x-filter', SiblingFilter);
281registerAction('sibling-y-filter', SiblingFilter);
282
283registerAction('element-filter', ElementFilter);
284registerAction('element-sibling-filter', ElementSiblingFilter);
285registerAction('element-sibling-filter-record', ElementSiblingFilter, { byRecord: true });
286
287registerAction('view-drag', ViewDrag);
288registerAction('view-move', ViewMove);
289
290registerAction('scale-translate', ScaleTranslate);
291registerAction('scale-zoom', ScaleZoom);
292registerAction('reset-button', ButtonAction, {
293 name: 'reset-button',
294 text: 'reset',
295});
296
297registerAction('mousewheel-scroll', MousewheelScroll);
298
299// 注册默认的 Interaction 交互行为
300import { registerInteraction } from './core';
301
302function isPointInView(context: IInteractionContext) {
303 return context.isInPlot();
304}
305
306// 注册 tooltip 的 interaction
307registerInteraction('tooltip', {
308 start: [
309 { trigger: 'plot:mousemove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } },
310 { trigger: 'plot:touchmove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } },
311 ],
312 end: [
313 { trigger: 'plot:mouseleave', action: 'tooltip:hide' },
314 { trigger: 'plot:leave', action: 'tooltip:hide' },
315 { trigger: 'plot:touchend', action: 'tooltip:hide' },
316 ],
317});
318
319registerInteraction('ellipsis-text', {
320 start: [
321 {
322 trigger: 'legend-item-name:mousemove',
323 action: 'ellipsis-text:show',
324 throttle: { wait: 50, leading: true, trailing: false },
325 },
326 {
327 trigger: 'legend-item-name:touchstart',
328 action: 'ellipsis-text:show',
329 throttle: { wait: 50, leading: true, trailing: false },
330 },
331 {
332 trigger: 'axis-label:mousemove',
333 action: 'ellipsis-text:show',
334 throttle: { wait: 50, leading: true, trailing: false },
335 },
336 {
337 trigger: 'axis-label:touchstart',
338 action: 'ellipsis-text:show',
339 throttle: { wait: 50, leading: true, trailing: false },
340 },
341 ],
342 end: [
343 { trigger: 'legend-item-name:mouseleave', action: 'ellipsis-text:hide' },
344 { trigger: 'legend-item-name:touchend', action: 'ellipsis-text:hide' },
345 { trigger: 'axis-label:mouseleave', action: 'ellipsis-text:hide' },
346 { trigger: 'axis-label:mouseout', action: 'ellipsis-text:hide' },
347 { trigger: 'axis-label:touchend', action: 'ellipsis-text:hide' },
348 ],
349});
350
351// 移动到 element 上 active
352registerInteraction('element-active', {
353 start: [{ trigger: 'element:mouseenter', action: 'element-active:active' }],
354 end: [{ trigger: 'element:mouseleave', action: 'element-active:reset' }],
355});
356
357// 点击选中,允许取消
358registerInteraction('element-selected', {
359 start: [{ trigger: 'element:click', action: 'element-selected:toggle' }],
360});
361
362// hover highlight,允许取消
363registerInteraction('element-highlight', {
364 start: [{ trigger: 'element:mouseenter', action: 'element-highlight:highlight' }],
365 end: [{ trigger: 'element:mouseleave', action: 'element-highlight:reset' }],
366});
367
368// hover highlight by x,允许取消
369registerInteraction('element-highlight-by-x', {
370 start: [{ trigger: 'element:mouseenter', action: 'element-highlight-by-x:highlight' }],
371 end: [{ trigger: 'element:mouseleave', action: 'element-highlight-by-x:reset' }],
372});
373
374// hover highlight by y,允许取消
375registerInteraction('element-highlight-by-color', {
376 start: [{ trigger: 'element:mouseenter', action: 'element-highlight-by-color:highlight' }],
377 end: [{ trigger: 'element:mouseleave', action: 'element-highlight-by-color:reset' }],
378});
379
380// legend hover,element active
381registerInteraction('legend-active', {
382 start: [{ trigger: 'legend-item:mouseenter', action: ['list-active:active', 'element-active:active'] }],
383 end: [{ trigger: 'legend-item:mouseleave', action: ['list-active:reset', 'element-active:reset'] }],
384});
385
386// legend hover,element active
387registerInteraction('legend-highlight', {
388 start: [
389 { trigger: 'legend-item:mouseenter', action: ['legend-item-highlight:highlight', 'element-highlight:highlight'] },
390 ],
391 end: [{ trigger: 'legend-item:mouseleave', action: ['legend-item-highlight:reset', 'element-highlight:reset'] }],
392});
393
394// legend hover,element active
395registerInteraction('axis-label-highlight', {
396 start: [
397 { trigger: 'axis-label:mouseenter', action: ['axis-label-highlight:highlight', 'element-highlight:highlight'] },
398 ],
399 end: [{ trigger: 'axis-label:mouseleave', action: ['axis-label-highlight:reset', 'element-highlight:reset'] }],
400});
401
402// legend hover,element active
403registerInteraction('element-list-highlight', {
404 start: [{ trigger: 'element:mouseenter', action: ['list-highlight:highlight', 'element-highlight:highlight'] }],
405 end: [{ trigger: 'element:mouseleave', action: ['list-highlight:reset', 'element-highlight:reset'] }],
406});
407
408// 框选
409registerInteraction('element-range-highlight', {
410 showEnable: [
411 { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
412 { trigger: 'mask:mouseenter', action: 'cursor:move' },
413 { trigger: 'plot:mouseleave', action: 'cursor:default' },
414 { trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
415 ],
416 start: [
417 {
418 trigger: 'plot:mousedown',
419 isEnable(context) {
420 // 不要点击在 mask 上重新开始
421 return !context.isInShape('mask');
422 },
423 action: ['rect-mask:start', 'rect-mask:show'],
424 },
425 {
426 trigger: 'mask:dragstart',
427 action: ['rect-mask:moveStart'],
428 },
429 ],
430 processing: [
431 {
432 trigger: 'plot:mousemove',
433 action: ['rect-mask:resize'],
434 },
435 {
436 trigger: 'mask:drag',
437 action: ['rect-mask:move'],
438 },
439 {
440 trigger: 'mask:change',
441 action: ['element-range-highlight:highlight'],
442 },
443 ],
444 end: [
445 { trigger: 'plot:mouseup', action: ['rect-mask:end'] },
446 { trigger: 'mask:dragend', action: ['rect-mask:moveEnd'] },
447 {
448 trigger: 'document:mouseup',
449 isEnable(context) {
450 return !context.isInPlot();
451 },
452 action: ['element-range-highlight:clear', 'rect-mask:end', 'rect-mask:hide'],
453 },
454 ],
455 rollback: [{ trigger: 'dblclick', action: ['element-range-highlight:clear', 'rect-mask:hide'] }],
456});
457
458registerInteraction('brush', {
459 showEnable: [
460 { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
461 { trigger: 'plot:mouseleave', action: 'cursor:default' },
462 ],
463 start: [
464 {
465 trigger: 'mousedown',
466 isEnable: isPointInView,
467 action: ['brush:start', 'rect-mask:start', 'rect-mask:show'],
468 },
469 ],
470 processing: [
471 {
472 trigger: 'mousemove',
473 isEnable: isPointInView,
474 action: ['rect-mask:resize'],
475 },
476 ],
477 end: [
478 {
479 trigger: 'mouseup',
480 isEnable: isPointInView,
481 action: ['brush:filter', 'brush:end', 'rect-mask:end', 'rect-mask:hide', 'reset-button:show'],
482 },
483 ],
484 rollback: [{ trigger: 'reset-button:click', action: ['brush:reset', 'reset-button:hide', 'cursor:crosshair'] }],
485});
486
487registerInteraction('brush-visible', {
488 showEnable: [
489 { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
490 { trigger: 'plot:mouseleave', action: 'cursor:default' },
491 ],
492 start: [
493 {
494 trigger: 'plot:mousedown',
495 action: ['rect-mask:start', 'rect-mask:show'],
496 },
497 ],
498 processing: [
499 {
500 trigger: 'plot:mousemove',
501 action: ['rect-mask:resize'],
502 },
503 { trigger: 'mask:change', action: ['element-range-highlight:highlight'] },
504 ],
505 end: [
506 {
507 trigger: 'plot:mouseup',
508 action: ['rect-mask:end', 'rect-mask:hide', 'element-filter:filter', 'element-range-highlight:clear'],
509 },
510 ],
511 rollback: [
512 {
513 trigger: 'dblclick',
514 action: ['element-filter:clear'],
515 },
516 ],
517});
518
519registerInteraction('brush-x', {
520 showEnable: [
521 { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
522 { trigger: 'plot:mouseleave', action: 'cursor:default' },
523 ],
524 start: [
525 {
526 trigger: 'mousedown',
527 isEnable: isPointInView,
528 action: ['brush-x:start', 'x-rect-mask:start', 'x-rect-mask:show'],
529 },
530 ],
531 processing: [
532 {
533 trigger: 'mousemove',
534 isEnable: isPointInView,
535 action: ['x-rect-mask:resize'],
536 },
537 ],
538 end: [
539 {
540 trigger: 'mouseup',
541 isEnable: isPointInView,
542 action: ['brush-x:filter', 'brush-x:end', 'x-rect-mask:end', 'x-rect-mask:hide'],
543 },
544 ],
545 rollback: [{ trigger: 'dblclick', action: ['brush-x:reset'] }],
546});
547
548registerInteraction('element-path-highlight', {
549 showEnable: [
550 { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
551 { trigger: 'plot:mouseleave', action: 'cursor:default' },
552 ],
553 start: [
554 { trigger: 'mousedown', isEnable: isPointInView, action: 'path-mask:start' },
555 { trigger: 'mousedown', isEnable: isPointInView, action: 'path-mask:show' },
556 ],
557 processing: [{ trigger: 'mousemove', action: 'path-mask:addPoint' }],
558 end: [{ trigger: 'mouseup', action: 'path-mask:end' }],
559 rollback: [{ trigger: 'dblclick', action: 'path-mask:hide' }],
560});
561
562// 点击选中,允许取消
563registerInteraction('element-single-selected', {
564 start: [{ trigger: 'element:click', action: 'element-single-selected:toggle' }],
565});
566
567// 筛选数据
568registerInteraction('legend-filter', {
569 showEnable: [
570 { trigger: 'legend-item:mouseenter', action: ['cursor:pointer', 'list-radio:show'] },
571 { trigger: 'legend-item:mouseleave', action: ['cursor:default', 'list-radio:hide'] },
572 ],
573 start: [
574 {
575 trigger: 'legend-item:click',
576 isEnable: (context) => {
577 return !context.isInShape('legend-item-radio');
578 },
579 action: ['list-unchecked:toggle', 'data-filter:filter', 'list-radio:show'],
580 },
581 // 正反选数据: 只有当 radio === truthy 的时候才会有 legend-item-radio 这个元素
582 {
583 trigger: 'legend-item-radio:mouseenter',
584 action: ['list-radio:showTip'],
585 },
586 {
587 trigger: 'legend-item-radio:mouseleave',
588 action: ['list-radio:hideTip'],
589 },
590 {
591 trigger: 'legend-item-radio:click',
592 action: ['list-focus:toggle', 'data-filter:filter', 'list-radio:show'],
593 },
594 ],
595});
596
597// 筛选数据
598registerInteraction('continuous-filter', {
599 start: [{ trigger: 'legend:valuechanged', action: 'data-filter:filter' }],
600});
601// 筛选数据
602registerInteraction('continuous-visible-filter', {
603 start: [{ trigger: 'legend:valuechanged', action: 'element-filter:filter' }],
604});
605
606// 筛选图形
607registerInteraction('legend-visible-filter', {
608 showEnable: [
609 { trigger: 'legend-item:mouseenter', action: 'cursor:pointer' },
610 { trigger: 'legend-item:mouseleave', action: 'cursor:default' },
611 ],
612 start: [{ trigger: 'legend-item:click', action: ['list-unchecked:toggle', 'element-filter:filter'] }],
613});
614
615// 出现背景框
616registerInteraction('active-region', {
617 start: [{ trigger: 'plot:mousemove', action: 'active-region:show' }],
618 end: [{ trigger: 'plot:mouseleave', action: 'active-region:hide' }],
619});
620
621// 显示坐标轴标题详情信息
622registerInteraction('axis-description', {
623 start: [{ trigger: 'axis-description:mousemove', action: 'axis-description:show' }],
624 end: [{ trigger: 'axis-description:mouseleave', action: 'axis-description:hide' }]
625})
626
627function isWheelDown(event) {
628 event.gEvent.preventDefault();
629 return event.gEvent.originalEvent.deltaY > 0;
630}
631registerInteraction('view-zoom', {
632 start: [
633 {
634 trigger: 'plot:mousewheel',
635 isEnable(context) {
636 return isWheelDown(context.event);
637 },
638 action: 'scale-zoom:zoomOut',
639 throttle: { wait: 100, leading: true, trailing: false },
640 },
641 {
642 trigger: 'plot:mousewheel',
643 isEnable(context) {
644 return !isWheelDown(context.event);
645 },
646 action: 'scale-zoom:zoomIn',
647 throttle: { wait: 100, leading: true, trailing: false },
648 },
649 ],
650});
651
652registerInteraction('sibling-tooltip', {
653 start: [{ trigger: 'plot:mousemove', action: 'sibling-tooltip:show' }],
654 end: [{ trigger: 'plot:mouseleave', action: 'sibling-tooltip:hide' }],
655});
656
657registerInteraction('plot-mousewheel-scroll', {
658 start: [{ trigger: 'plot:mousewheel', action: 'mousewheel-scroll:scroll' }],
659});
660
661// 让 TS 支持 View 原型上添加的创建 Geometry 方法的智能提示
662/**
663 * 往 View 原型上添加的创建 Geometry 的方法
664 *
665 * Tips:
666 * view module augmentation, detail: http://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
667 */
668declare module './chart/view' {
669 interface View {
670 /**
671 * 创建 Polygon 几何标记。
672 * @param [cfg] 传入 Polygon 构造函数的配置。
673 * @returns polygon 返回 Polygon 实例。
674 */
675 polygon(cfg?: Partial<GeometryCfg>): Polygon;
676 /**
677 * 创建 Point 几何标记。
678 * @param [cfg] 传入 Point 构造函数的配置。
679 * @returns point 返回 Point 实例。
680 */
681 point(cfg?: Partial<GeometryCfg>): Point;
682 /**
683 * 创建 Interval 几何标记。
684 * @param [cfg] 传入 Interval 构造函数的配置。
685 * @returns interval 返回 Interval 实例。
686 */
687 interval(cfg?: Partial<IntervalCfg>): Interval;
688 /**
689 * 创建 Schema 几何标记。
690 * @param [cfg] 传入 Schema 构造函数的配置。
691 * @returns schema 返回 Schema 实例。
692 */
693 schema(cfg?: Partial<GeometryCfg>): Schema;
694 /**
695 * 创建 Path 几何标记。
696 * @param [cfg] 传入 Path 构造函数的配置。
697 * @returns path 返回 Path 实例。
698 */
699 path(cfg?: Partial<PathCfg>): Path;
700 /**
701 * 创建 Line 几何标记。
702 * @param [cfg] 传入 Line 构造函数的配置。
703 * @returns line 返回 Line 实例。
704 */
705 line(cfg?: Partial<PathCfg>): Line;
706 /**
707 * 创建 Area 几何标记。
708 * @param [cfg] 传入 Area 构造函数的配置。
709 * @returns area 返回 Area 实例。
710 */
711 area(cfg?: Partial<AreaCfg>): Area;
712 /**
713 * 创建 Edge 几何标记。
714 * @param [cfg] 传入 Edge 构造函数的配置。
715 * @returns schema 返回 Edge 实例。
716 */
717 edge(cfg?: Partial<GeometryCfg>): Edge;
718 /**
719 * 创建 Heatmap 几何标记。
720 * @param [cfg] 传入 Heatmap 构造函数的配置。
721 * @returns heatmap 返回 Heatmap 实例。
722 */
723 heatmap(cfg?: Partial<GeometryCfg>): Heatmap;
724 /**
725 * 创建 Violin 几何标记。
726 * @param [cfg] 传入 Violin 构造函数的配置。
727 * @returns violin 返回 Violin 实例。
728 */
729 violin(cfg?: Partial<GeometryCfg>): Violin;
730 }
731}
732
733// 暴露一些常量
734export { VIEW_LIFE_CIRCLE } from './constant';
735/** brush 范围筛选的一些事件常量 */
736export { BRUSH_FILTER_EVENTS, ELEMENT_RANGE_HIGHLIGHT_EVENTS };
737
738export * from './core';