@visactor/vgrammar-core 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/component/axis.js.map +1 -1
- package/cjs/component/datazoom.d.ts +7 -4
- package/cjs/component/datazoom.js +21 -43
- package/cjs/component/datazoom.js.map +1 -1
- package/cjs/component/grid.js.map +1 -1
- package/cjs/component/index.d.ts +0 -2
- package/cjs/component/index.js +1 -19
- package/cjs/component/index.js.map +1 -1
- package/cjs/component/label.js.map +1 -1
- package/cjs/component/legend.d.ts +1 -3
- package/cjs/component/legend.js +5 -26
- package/cjs/component/legend.js.map +1 -1
- package/cjs/component/player.d.ts +1 -2
- package/cjs/component/player.js +15 -31
- package/cjs/component/player.js.map +1 -1
- package/cjs/component/scale.d.ts +1 -0
- package/cjs/component/scale.js +3 -0
- package/cjs/component/scale.js.map +1 -1
- package/cjs/component/scrollbar.d.ts +3 -4
- package/cjs/component/scrollbar.js +12 -54
- package/cjs/component/scrollbar.js.map +1 -1
- package/cjs/component/slider.d.ts +2 -5
- package/cjs/component/slider.js +4 -26
- package/cjs/component/slider.js.map +1 -1
- package/cjs/component/title.js.map +1 -1
- package/cjs/core/factory.d.ts +6 -3
- package/cjs/core/factory.js +9 -2
- package/cjs/core/factory.js.map +1 -1
- package/cjs/env.d.ts +1 -0
- package/cjs/env.js +20 -0
- package/cjs/env.js.map +1 -0
- package/cjs/glyph/index.js +2 -1
- package/cjs/glyph/link-path.js +1 -2
- package/cjs/graph/animation/animate.js +25 -19
- package/cjs/graph/animation/animate.js.map +1 -1
- package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/cjs/graph/animation/animator.js +4 -4
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/graph/animation/attribute.d.ts +2 -2
- package/cjs/graph/animation/attribute.js +12 -12
- package/cjs/graph/animation/attribute.js.map +1 -1
- package/cjs/graph/animation/morph.js +4 -4
- package/cjs/graph/animation/morph.js.map +1 -1
- package/cjs/graph/attributes/index.js +1 -1
- package/cjs/graph/attributes/index.js.map +1 -1
- package/cjs/graph/canvas-renderer.d.ts +1 -1
- package/cjs/graph/canvas-renderer.js +5 -5
- package/cjs/graph/canvas-renderer.js.map +1 -1
- package/cjs/graph/element.d.ts +1 -1
- package/cjs/graph/element.js +4 -4
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/enums.d.ts +25 -8
- package/cjs/graph/enums.js +23 -14
- package/cjs/graph/enums.js.map +1 -1
- package/cjs/graph/glyph-element.d.ts +1 -1
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/graph/mark/encode.d.ts +0 -3
- package/cjs/graph/mark/encode.js +3 -12
- package/cjs/graph/mark/encode.js.map +1 -1
- package/cjs/graph/mark/large-rects.d.ts +2 -2
- package/cjs/graph/mark/large-rects.js +3 -3
- package/cjs/graph/mark/large-rects.js.map +1 -1
- package/cjs/graph/mark/large-symbols.d.ts +2 -2
- package/cjs/graph/mark/large-symbols.js +3 -3
- package/cjs/graph/mark/large-symbols.js.map +1 -1
- package/cjs/graph/util/env.js +2 -2
- package/cjs/graph/util/env.js.map +1 -1
- package/cjs/graph/util/events-extend.d.ts +1 -1
- package/cjs/graph/util/events-extend.js +1 -1
- package/cjs/graph/util/events-extend.js.map +1 -1
- package/cjs/graph/util/graphic.d.ts +3 -3
- package/cjs/graph/util/graphic.js +21 -21
- package/cjs/graph/util/graphic.js.map +1 -1
- package/cjs/index.d.ts +5 -1
- package/cjs/index.js +13 -3
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/base-tooltip.d.ts +29 -0
- package/cjs/interactions/base-tooltip.js +74 -0
- package/cjs/interactions/base-tooltip.js.map +1 -0
- package/cjs/interactions/base.d.ts +14 -0
- package/cjs/interactions/base.js +41 -0
- package/cjs/interactions/base.js.map +1 -0
- package/cjs/interactions/brush-active.d.ts +17 -0
- package/cjs/interactions/brush-active.js +27 -0
- package/cjs/interactions/brush-active.js.map +1 -0
- package/cjs/interactions/brush-base.d.ts +43 -0
- package/cjs/interactions/brush-base.js +106 -0
- package/cjs/interactions/brush-base.js.map +1 -0
- package/cjs/interactions/brush-filter.d.ts +24 -0
- package/cjs/interactions/brush-filter.js +34 -0
- package/cjs/interactions/brush-filter.js.map +1 -0
- package/cjs/interactions/brush-highlight.d.ts +17 -0
- package/cjs/interactions/brush-highlight.js +34 -0
- package/cjs/interactions/brush-highlight.js.map +1 -0
- package/cjs/interactions/crosshair.d.ts +53 -0
- package/cjs/{component → interactions}/crosshair.js +80 -79
- package/cjs/interactions/crosshair.js.map +1 -0
- package/cjs/interactions/datazoom-filter.d.ts +13 -0
- package/cjs/interactions/datazoom-filter.js +42 -0
- package/cjs/interactions/datazoom-filter.js.map +1 -0
- package/cjs/interactions/dimension-tooltip.d.ts +18 -0
- package/cjs/interactions/dimension-tooltip.js +99 -0
- package/cjs/interactions/dimension-tooltip.js.map +1 -0
- package/cjs/interactions/drill-down.d.ts +25 -0
- package/cjs/interactions/drill-down.js +48 -0
- package/cjs/interactions/drill-down.js.map +1 -0
- package/cjs/interactions/element-active-by-legend.d.ts +17 -0
- package/cjs/interactions/element-active-by-legend.js +44 -0
- package/cjs/interactions/element-active-by-legend.js.map +1 -0
- package/cjs/interactions/element-active.d.ts +16 -0
- package/cjs/interactions/element-active.js +33 -0
- package/cjs/interactions/element-active.js.map +1 -0
- package/cjs/interactions/element-highlight-by-group.d.ts +17 -0
- package/cjs/interactions/element-highlight-by-group.js +53 -0
- package/cjs/interactions/element-highlight-by-group.js.map +1 -0
- package/cjs/interactions/element-highlight-by-key.d.ts +17 -0
- package/cjs/interactions/element-highlight-by-key.js +53 -0
- package/cjs/interactions/element-highlight-by-key.js.map +1 -0
- package/cjs/interactions/element-highlight-by-legend.d.ts +17 -0
- package/cjs/interactions/element-highlight-by-legend.js +47 -0
- package/cjs/interactions/element-highlight-by-legend.js.map +1 -0
- package/cjs/interactions/element-highlight-by-name.d.ts +18 -0
- package/cjs/interactions/element-highlight-by-name.js +59 -0
- package/cjs/interactions/element-highlight-by-name.js.map +1 -0
- package/cjs/interactions/element-highlight.d.ts +17 -0
- package/cjs/interactions/element-highlight.js +48 -0
- package/cjs/interactions/element-highlight.js.map +1 -0
- package/cjs/interactions/element-select.d.ts +18 -0
- package/cjs/interactions/element-select.js +42 -0
- package/cjs/interactions/element-select.js.map +1 -0
- package/cjs/interactions/filter.d.ts +20 -0
- package/cjs/interactions/filter.js +37 -0
- package/cjs/interactions/filter.js.map +1 -0
- package/cjs/interactions/fish-eye.d.ts +38 -0
- package/cjs/interactions/fish-eye.js +109 -0
- package/cjs/interactions/fish-eye.js.map +1 -0
- package/cjs/interactions/index.d.ts +50 -0
- package/cjs/interactions/index.js +386 -0
- package/cjs/interactions/index.js.map +1 -0
- package/cjs/interactions/legend-filter.d.ts +13 -0
- package/cjs/interactions/legend-filter.js +33 -0
- package/cjs/interactions/legend-filter.js.map +1 -0
- package/cjs/interactions/player-filter.d.ts +14 -0
- package/cjs/interactions/player-filter.js +32 -0
- package/cjs/interactions/player-filter.js.map +1 -0
- package/cjs/interactions/roll-up.d.ts +16 -0
- package/cjs/interactions/roll-up.js +47 -0
- package/cjs/interactions/roll-up.js.map +1 -0
- package/cjs/interactions/scrollbar-filter.d.ts +13 -0
- package/cjs/interactions/scrollbar-filter.js +54 -0
- package/cjs/interactions/scrollbar-filter.js.map +1 -0
- package/cjs/interactions/slider-filter.d.ts +13 -0
- package/cjs/interactions/slider-filter.js +32 -0
- package/cjs/interactions/slider-filter.js.map +1 -0
- package/cjs/interactions/tooltip.d.ts +15 -0
- package/cjs/interactions/tooltip.js +62 -0
- package/cjs/interactions/tooltip.js.map +1 -0
- package/cjs/interactions/view-drag-mixin.d.ts +22 -0
- package/cjs/interactions/view-drag-mixin.js +52 -0
- package/cjs/interactions/view-drag-mixin.js.map +1 -0
- package/cjs/interactions/view-drag.d.ts +19 -0
- package/cjs/interactions/view-drag.js +49 -0
- package/cjs/interactions/view-drag.js.map +1 -0
- package/cjs/interactions/view-navigation-base.d.ts +17 -0
- package/cjs/interactions/view-navigation-base.js +81 -0
- package/cjs/interactions/view-navigation-base.js.map +1 -0
- package/cjs/interactions/view-roam.d.ts +30 -0
- package/cjs/interactions/view-roam.js +93 -0
- package/cjs/interactions/view-roam.js.map +1 -0
- package/cjs/interactions/view-scroll-mixin.d.ts +10 -0
- package/cjs/interactions/view-scroll-mixin.js +45 -0
- package/cjs/interactions/view-scroll-mixin.js.map +1 -0
- package/cjs/interactions/view-scroll.d.ts +17 -0
- package/cjs/interactions/view-scroll.js +37 -0
- package/cjs/interactions/view-scroll.js.map +1 -0
- package/cjs/interactions/view-utils.d.ts +14 -0
- package/cjs/interactions/view-utils.js +73 -0
- package/cjs/interactions/view-utils.js.map +1 -0
- package/cjs/interactions/view-zoom-mixin.d.ts +29 -0
- package/cjs/interactions/view-zoom-mixin.js +77 -0
- package/cjs/interactions/view-zoom-mixin.js.map +1 -0
- package/cjs/interactions/view-zoom.d.ts +23 -0
- package/cjs/interactions/view-zoom.js +53 -0
- package/cjs/interactions/view-zoom.js.map +1 -0
- package/cjs/parse/coordinate.js +1 -1
- package/cjs/parse/event.d.ts +2 -0
- package/cjs/parse/event.js +8 -4
- package/cjs/parse/event.js.map +1 -1
- package/cjs/parse/mark.js +1 -1
- package/cjs/parse/option.js +2 -1
- package/cjs/parse/scale.js +1 -1
- package/cjs/parse/transform.js +1 -1
- package/cjs/parse/util.js +1 -1
- package/cjs/parse/view.js +1 -1
- package/cjs/semantic-marks/cell.d.ts +1 -1
- package/cjs/semantic-marks/cell.js +4 -4
- package/cjs/semantic-marks/cell.js.map +1 -1
- package/cjs/semantic-marks/interval.d.ts +1 -1
- package/cjs/semantic-marks/interval.js +1 -1
- package/cjs/semantic-marks/text.js +1 -1
- package/cjs/theme/dark.js +1 -1
- package/cjs/theme/default.js +1 -1
- package/cjs/theme/theme-manager.js +1 -1
- package/cjs/transforms/index.js +1 -1
- package/cjs/transforms/mark/dodge.js +4 -4
- package/cjs/transforms/mark/dodge.js.map +1 -1
- package/cjs/transforms/mark/jitter.js +2 -2
- package/cjs/transforms/mark/jitter.js.map +1 -1
- package/cjs/types/animate.d.ts +1 -1
- package/cjs/types/animate.js +1 -1
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/base.js +1 -1
- package/cjs/types/component.d.ts +16 -88
- package/cjs/types/component.js +1 -1
- package/cjs/types/component.js.map +1 -1
- package/cjs/types/coordinate.js +1 -1
- package/cjs/types/data.js +2 -1
- package/cjs/types/dataflow.js +1 -1
- package/cjs/types/element.d.ts +1 -1
- package/cjs/types/element.js +1 -1
- package/cjs/types/element.js.map +1 -1
- package/cjs/types/event.d.ts +11 -4
- package/cjs/types/event.js +1 -1
- package/cjs/types/event.js.map +1 -1
- package/cjs/types/glyph.js +1 -1
- package/cjs/types/grammar.d.ts +6 -2
- package/cjs/types/grammar.js +1 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/hooks.js +1 -1
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +3 -2
- package/cjs/types/index.js.map +1 -1
- package/cjs/types/interaction.d.ts +353 -0
- package/cjs/types/interaction.js +6 -0
- package/cjs/types/interaction.js.map +1 -0
- package/cjs/types/mark.d.ts +2 -3
- package/cjs/types/mark.js.map +1 -1
- package/cjs/types/morph.d.ts +1 -1
- package/cjs/types/morph.js.map +1 -1
- package/cjs/types/plot.d.ts +1 -1
- package/cjs/types/plot.js.map +1 -1
- package/cjs/types/renderer.d.ts +1 -1
- package/cjs/types/renderer.js.map +1 -1
- package/cjs/types/theme.d.ts +1 -1
- package/cjs/types/theme.js.map +1 -1
- package/cjs/types/view.d.ts +13 -14
- package/cjs/types/view.js.map +1 -1
- package/cjs/util/scale.d.ts +4 -0
- package/cjs/util/scale.js +24 -0
- package/cjs/util/scale.js.map +1 -0
- package/cjs/util/text.d.ts +1 -1
- package/cjs/util/text.js +3 -3
- package/cjs/util/text.js.map +1 -1
- package/cjs/view/View.d.ts +9 -13
- package/cjs/view/View.js +49 -74
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/component.d.ts +2 -6
- package/cjs/view/component.js +1 -19
- package/cjs/view/component.js.map +1 -1
- package/cjs/view/dataflow.js +1 -1
- package/cjs/view/dataflow.js.map +1 -1
- package/cjs/view/events.d.ts +1 -1
- package/cjs/view/mark.d.ts +2 -2
- package/cjs/view/mark.js +12 -10
- package/cjs/view/mark.js.map +1 -1
- package/cjs/view/scale.d.ts +7 -1
- package/cjs/view/scale.js +17 -3
- package/cjs/view/scale.js.map +1 -1
- package/es/component/axis.js.map +1 -1
- package/es/component/datazoom.d.ts +7 -4
- package/es/component/datazoom.js +26 -42
- package/es/component/datazoom.js.map +1 -1
- package/es/component/grid.js.map +1 -1
- package/es/component/index.d.ts +0 -2
- package/es/component/index.js +0 -4
- package/es/component/index.js.map +1 -1
- package/es/component/label.js.map +1 -1
- package/es/component/legend.d.ts +1 -3
- package/es/component/legend.js +11 -26
- package/es/component/legend.js.map +1 -1
- package/es/component/player.d.ts +1 -2
- package/es/component/player.js +17 -30
- package/es/component/player.js.map +1 -1
- package/es/component/scale.d.ts +1 -0
- package/es/component/scale.js +3 -0
- package/es/component/scale.js.map +1 -1
- package/es/component/scrollbar.d.ts +3 -4
- package/es/component/scrollbar.js +17 -53
- package/es/component/scrollbar.js.map +1 -1
- package/es/component/slider.d.ts +2 -5
- package/es/component/slider.js +9 -25
- package/es/component/slider.js.map +1 -1
- package/es/component/title.js.map +1 -1
- package/es/core/factory.d.ts +6 -3
- package/es/core/factory.js +9 -2
- package/es/core/factory.js.map +1 -1
- package/es/env.d.ts +1 -0
- package/es/env.js +1 -0
- package/es/env.js.map +1 -0
- package/es/glyph/index.js +2 -1
- package/es/glyph/link-path.js +1 -2
- package/es/graph/animation/animate.js +24 -19
- package/es/graph/animation/animate.js.map +1 -1
- package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/es/graph/animation/animator.js +1 -1
- package/es/graph/animation/animator.js.map +1 -1
- package/es/graph/animation/attribute.d.ts +2 -2
- package/es/graph/animation/attribute.js +7 -7
- package/es/graph/animation/attribute.js.map +1 -1
- package/es/graph/animation/morph.js +1 -1
- package/es/graph/animation/morph.js.map +1 -1
- package/es/graph/attributes/index.js +1 -1
- package/es/graph/attributes/index.js.map +1 -1
- package/es/graph/canvas-renderer.d.ts +1 -1
- package/es/graph/canvas-renderer.js +3 -1
- package/es/graph/canvas-renderer.js.map +1 -1
- package/es/graph/element.d.ts +1 -1
- package/es/graph/element.js +3 -3
- package/es/graph/element.js.map +1 -1
- package/es/graph/enums.d.ts +25 -8
- package/es/graph/enums.js +27 -11
- package/es/graph/enums.js.map +1 -1
- package/es/graph/glyph-element.d.ts +1 -1
- package/es/graph/glyph-element.js.map +1 -1
- package/es/graph/mark/encode.d.ts +0 -3
- package/es/graph/mark/encode.js +0 -10
- package/es/graph/mark/encode.js.map +1 -1
- package/es/graph/mark/large-rects.d.ts +2 -2
- package/es/graph/mark/large-rects.js +1 -1
- package/es/graph/mark/large-rects.js.map +1 -1
- package/es/graph/mark/large-symbols.d.ts +2 -2
- package/es/graph/mark/large-symbols.js +1 -1
- package/es/graph/mark/large-symbols.js.map +1 -1
- package/es/graph/util/env.js +1 -1
- package/es/graph/util/env.js.map +1 -1
- package/es/graph/util/events-extend.d.ts +1 -1
- package/es/graph/util/events-extend.js +1 -1
- package/es/graph/util/events-extend.js.map +1 -1
- package/es/graph/util/graphic.d.ts +3 -3
- package/es/graph/util/graphic.js +1 -1
- package/es/graph/util/graphic.js.map +1 -1
- package/es/index.d.ts +5 -1
- package/es/index.js +11 -2
- package/es/index.js.map +1 -1
- package/es/interactions/base-tooltip.d.ts +29 -0
- package/es/interactions/base-tooltip.js +73 -0
- package/es/interactions/base-tooltip.js.map +1 -0
- package/es/interactions/base.d.ts +14 -0
- package/es/interactions/base.js +32 -0
- package/es/interactions/base.js.map +1 -0
- package/es/interactions/brush-active.d.ts +17 -0
- package/es/interactions/brush-active.js +23 -0
- package/es/interactions/brush-active.js.map +1 -0
- package/es/interactions/brush-base.d.ts +43 -0
- package/es/interactions/brush-base.js +103 -0
- package/es/interactions/brush-base.js.map +1 -0
- package/es/interactions/brush-filter.d.ts +24 -0
- package/es/interactions/brush-filter.js +33 -0
- package/es/interactions/brush-filter.js.map +1 -0
- package/es/interactions/brush-highlight.d.ts +17 -0
- package/es/interactions/brush-highlight.js +31 -0
- package/es/interactions/brush-highlight.js.map +1 -0
- package/es/interactions/crosshair.d.ts +53 -0
- package/es/{component → interactions}/crosshair.js +82 -81
- package/es/interactions/crosshair.js.map +1 -0
- package/es/interactions/datazoom-filter.d.ts +13 -0
- package/es/interactions/datazoom-filter.js +40 -0
- package/es/interactions/datazoom-filter.js.map +1 -0
- package/es/interactions/dimension-tooltip.d.ts +18 -0
- package/es/interactions/dimension-tooltip.js +99 -0
- package/es/interactions/dimension-tooltip.js.map +1 -0
- package/es/interactions/drill-down.d.ts +25 -0
- package/es/interactions/drill-down.js +46 -0
- package/es/interactions/drill-down.js.map +1 -0
- package/es/interactions/element-active-by-legend.d.ts +17 -0
- package/es/interactions/element-active-by-legend.js +43 -0
- package/es/interactions/element-active-by-legend.js.map +1 -0
- package/es/interactions/element-active.d.ts +16 -0
- package/es/interactions/element-active.js +29 -0
- package/es/interactions/element-active.js.map +1 -0
- package/es/interactions/element-highlight-by-group.d.ts +17 -0
- package/es/interactions/element-highlight-by-group.js +49 -0
- package/es/interactions/element-highlight-by-group.js.map +1 -0
- package/es/interactions/element-highlight-by-key.d.ts +17 -0
- package/es/interactions/element-highlight-by-key.js +50 -0
- package/es/interactions/element-highlight-by-key.js.map +1 -0
- package/es/interactions/element-highlight-by-legend.d.ts +17 -0
- package/es/interactions/element-highlight-by-legend.js +46 -0
- package/es/interactions/element-highlight-by-legend.js.map +1 -0
- package/es/interactions/element-highlight-by-name.d.ts +18 -0
- package/es/interactions/element-highlight-by-name.js +56 -0
- package/es/interactions/element-highlight-by-name.js.map +1 -0
- package/es/interactions/element-highlight.d.ts +17 -0
- package/es/interactions/element-highlight.js +43 -0
- package/es/interactions/element-highlight.js.map +1 -0
- package/es/interactions/element-select.d.ts +18 -0
- package/es/interactions/element-select.js +38 -0
- package/es/interactions/element-select.js.map +1 -0
- package/es/interactions/filter.d.ts +20 -0
- package/es/interactions/filter.js +31 -0
- package/es/interactions/filter.js.map +1 -0
- package/es/interactions/fish-eye.d.ts +38 -0
- package/es/interactions/fish-eye.js +105 -0
- package/es/interactions/fish-eye.js.map +1 -0
- package/es/interactions/index.d.ts +50 -0
- package/es/interactions/index.js +149 -0
- package/es/interactions/index.js.map +1 -0
- package/es/interactions/legend-filter.d.ts +13 -0
- package/es/interactions/legend-filter.js +32 -0
- package/es/interactions/legend-filter.js.map +1 -0
- package/es/interactions/player-filter.d.ts +14 -0
- package/es/interactions/player-filter.js +32 -0
- package/es/interactions/player-filter.js.map +1 -0
- package/es/interactions/roll-up.d.ts +16 -0
- package/es/interactions/roll-up.js +45 -0
- package/es/interactions/roll-up.js.map +1 -0
- package/es/interactions/scrollbar-filter.d.ts +13 -0
- package/es/interactions/scrollbar-filter.js +50 -0
- package/es/interactions/scrollbar-filter.js.map +1 -0
- package/es/interactions/slider-filter.d.ts +13 -0
- package/es/interactions/slider-filter.js +29 -0
- package/es/interactions/slider-filter.js.map +1 -0
- package/es/interactions/tooltip.d.ts +15 -0
- package/es/interactions/tooltip.js +58 -0
- package/es/interactions/tooltip.js.map +1 -0
- package/es/interactions/view-drag-mixin.d.ts +22 -0
- package/es/interactions/view-drag-mixin.js +46 -0
- package/es/interactions/view-drag-mixin.js.map +1 -0
- package/es/interactions/view-drag.d.ts +19 -0
- package/es/interactions/view-drag.js +47 -0
- package/es/interactions/view-drag.js.map +1 -0
- package/es/interactions/view-navigation-base.d.ts +17 -0
- package/es/interactions/view-navigation-base.js +78 -0
- package/es/interactions/view-navigation-base.js.map +1 -0
- package/es/interactions/view-roam.d.ts +30 -0
- package/es/interactions/view-roam.js +91 -0
- package/es/interactions/view-roam.js.map +1 -0
- package/es/interactions/view-scroll-mixin.d.ts +10 -0
- package/es/interactions/view-scroll-mixin.js +37 -0
- package/es/interactions/view-scroll-mixin.js.map +1 -0
- package/es/interactions/view-scroll.d.ts +17 -0
- package/es/interactions/view-scroll.js +35 -0
- package/es/interactions/view-scroll.js.map +1 -0
- package/es/interactions/view-utils.d.ts +14 -0
- package/es/interactions/view-utils.js +60 -0
- package/es/interactions/view-utils.js.map +1 -0
- package/es/interactions/view-zoom-mixin.d.ts +29 -0
- package/es/interactions/view-zoom-mixin.js +68 -0
- package/es/interactions/view-zoom-mixin.js.map +1 -0
- package/es/interactions/view-zoom.d.ts +23 -0
- package/es/interactions/view-zoom.js +51 -0
- package/es/interactions/view-zoom.js.map +1 -0
- package/es/parse/event.d.ts +2 -0
- package/es/parse/event.js +5 -1
- package/es/parse/event.js.map +1 -1
- package/es/parse/option.js +2 -1
- package/es/parse/scale.js +1 -2
- package/es/semantic-marks/cell.d.ts +1 -1
- package/es/semantic-marks/cell.js +4 -2
- package/es/semantic-marks/cell.js.map +1 -1
- package/es/semantic-marks/interval.d.ts +1 -1
- package/es/semantic-marks/interval.js +1 -1
- package/es/semantic-marks/text.js +1 -1
- package/es/theme/dark.js +1 -1
- package/es/theme/default.js +1 -1
- package/es/theme/theme-manager.js +1 -1
- package/es/transforms/index.js +1 -1
- package/es/transforms/mark/dodge.js +2 -2
- package/es/transforms/mark/dodge.js.map +1 -1
- package/es/transforms/mark/jitter.js +2 -2
- package/es/transforms/mark/jitter.js.map +1 -1
- package/es/types/animate.d.ts +1 -1
- package/es/types/animate.js +1 -1
- package/es/types/animate.js.map +1 -1
- package/es/types/base.js +1 -1
- package/es/types/component.d.ts +16 -88
- package/es/types/component.js +1 -1
- package/es/types/component.js.map +1 -1
- package/es/types/coordinate.js +1 -1
- package/es/types/data.js +2 -1
- package/es/types/dataflow.js +1 -1
- package/es/types/element.d.ts +1 -1
- package/es/types/element.js +1 -1
- package/es/types/element.js.map +1 -1
- package/es/types/event.d.ts +11 -4
- package/es/types/event.js +1 -1
- package/es/types/event.js.map +1 -1
- package/es/types/glyph.js +1 -1
- package/es/types/grammar.d.ts +6 -2
- package/es/types/grammar.js +1 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/hooks.js +1 -1
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +3 -1
- package/es/types/index.js.map +1 -1
- package/es/types/interaction.d.ts +353 -0
- package/es/types/interaction.js +2 -0
- package/es/types/interaction.js.map +1 -0
- package/es/types/mark.d.ts +2 -3
- package/es/types/mark.js.map +1 -1
- package/es/types/morph.d.ts +1 -1
- package/es/types/morph.js.map +1 -1
- package/es/types/plot.d.ts +1 -1
- package/es/types/plot.js.map +1 -1
- package/es/types/renderer.d.ts +1 -1
- package/es/types/renderer.js.map +1 -1
- package/es/types/theme.d.ts +1 -1
- package/es/types/theme.js.map +1 -1
- package/es/types/view.d.ts +13 -14
- package/es/types/view.js.map +1 -1
- package/es/util/scale.d.ts +4 -0
- package/es/util/scale.js +15 -0
- package/es/util/scale.js.map +1 -0
- package/es/util/text.d.ts +1 -1
- package/es/util/text.js +1 -1
- package/es/util/text.js.map +1 -1
- package/es/view/View.d.ts +9 -13
- package/es/view/View.js +49 -69
- package/es/view/View.js.map +1 -1
- package/es/view/component.d.ts +2 -6
- package/es/view/component.js +0 -20
- package/es/view/component.js.map +1 -1
- package/es/view/dataflow.js +1 -1
- package/es/view/dataflow.js.map +1 -1
- package/es/view/events.d.ts +1 -1
- package/es/view/mark.d.ts +2 -2
- package/es/view/mark.js +12 -10
- package/es/view/mark.js.map +1 -1
- package/es/view/scale.d.ts +7 -1
- package/es/view/scale.js +17 -2
- package/es/view/scale.js.map +1 -1
- package/package.json +9 -8
- package/cjs/component/crosshair.d.ts +0 -50
- package/cjs/component/crosshair.js.map +0 -1
- package/cjs/component/tooltip.d.ts +0 -62
- package/cjs/component/tooltip.js +0 -305
- package/cjs/component/tooltip.js.map +0 -1
- package/es/component/crosshair.d.ts +0 -50
- package/es/component/crosshair.js.map +0 -1
- package/es/component/tooltip.d.ts +0 -62
- package/es/component/tooltip.js +0 -303
- package/es/component/tooltip.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AABBBounds, array, getAngleByPoint, isString, throttle } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { BaseTooltip } from "./base-tooltip";
|
|
4
|
+
|
|
5
|
+
import { generateTooltipAttributes } from "./base-tooltip";
|
|
6
|
+
|
|
7
|
+
import { BridgeElementKey } from "../graph/constants";
|
|
8
|
+
|
|
9
|
+
import { invokeFunctionType } from "../parse/util";
|
|
10
|
+
|
|
11
|
+
const isEqualTooltipDatum = (current, previous) => {
|
|
12
|
+
const currentDatum = array(current), previousDatum = array(previous);
|
|
13
|
+
return currentDatum.length === previousDatum.length && (currentDatum.every((datum => previousDatum.includes(datum))) && previousDatum.every((datum => currentDatum.includes(datum))));
|
|
14
|
+
}, computeTooltipFilterValue = (point, scale, type, groupSize, tooltipCenter) => {
|
|
15
|
+
if ("x" === type) return scale.invert(point.x);
|
|
16
|
+
if ("y" === type) return scale.invert(point.y);
|
|
17
|
+
if ("radius" === type) {
|
|
18
|
+
const center = null != tooltipCenter ? tooltipCenter : {
|
|
19
|
+
x: groupSize.width / 2,
|
|
20
|
+
y: groupSize.height / 2
|
|
21
|
+
}, radius = Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2);
|
|
22
|
+
return scale.invert(radius);
|
|
23
|
+
}
|
|
24
|
+
if ("angle" === type) {
|
|
25
|
+
const center = null != tooltipCenter ? tooltipCenter : {
|
|
26
|
+
x: groupSize.width / 2,
|
|
27
|
+
y: groupSize.height / 2
|
|
28
|
+
}, angle = getAngleByPoint(center, point);
|
|
29
|
+
return scale.invert(angle < 0 ? angle + 2 * Math.PI : angle);
|
|
30
|
+
}
|
|
31
|
+
return scale.invert(point.x);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export class DimensionTooltip extends BaseTooltip {
|
|
35
|
+
constructor(view, options) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
super(view, options), this.type = DimensionTooltip.type, this._avoidMarks = [],
|
|
38
|
+
this._tooltipDataFilter = null, this.handleTooltipShow = throttle((event => {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
const scale = (isString(this.options.scale) ? this.view.getScaleById(this.options.scale) : this.options.scale).getScale(), groupGraphicItem = this._container.getGroupGraphicItem(), point = {
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0
|
|
43
|
+
};
|
|
44
|
+
groupGraphicItem.globalTransMatrix.transformPoint(event.canvas, point);
|
|
45
|
+
const groupSize = {
|
|
46
|
+
width: groupGraphicItem.attribute.width,
|
|
47
|
+
height: groupGraphicItem.attribute.height
|
|
48
|
+
};
|
|
49
|
+
if (point.x < 0 || point.x > groupGraphicItem.attribute.width || point.y < 0 || point.y > groupGraphicItem.attribute.height) return void this._tooltipComponent.hideAll();
|
|
50
|
+
const eventTargetMark = null === (_b = null === (_a = event.target) || void 0 === _a ? void 0 : _a[BridgeElementKey]) || void 0 === _b ? void 0 : _b.mark;
|
|
51
|
+
if (this._avoidMarks.includes(eventTargetMark)) return void this._tooltipComponent.hideAll();
|
|
52
|
+
const target = null === (_c = this.options.target) || void 0 === _c ? void 0 : _c.data, lastDataGrammar = target ? isString(target) ? this.view.getDataById(target) : target : null, data = lastDataGrammar ? lastDataGrammar.getValue() : [], filterValue = computeTooltipFilterValue(point, scale, this.options.tooltipType, groupSize, this.options.center), tooltipDatum = this._tooltipDataFilter ? data.filter((datum => this._tooltipDataFilter(datum, filterValue))) : [];
|
|
53
|
+
if (this._tooltipComponent.showAll(), isEqualTooltipDatum(tooltipDatum, this._lastDatum)) return void this._tooltipComponent.setAttributes({
|
|
54
|
+
pointerX: point.x,
|
|
55
|
+
pointerY: point.y
|
|
56
|
+
});
|
|
57
|
+
this._lastDatum = tooltipDatum;
|
|
58
|
+
const boundsStart = {
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 0
|
|
61
|
+
};
|
|
62
|
+
groupGraphicItem.globalTransMatrix.transformPoint({
|
|
63
|
+
x: 0,
|
|
64
|
+
y: 0
|
|
65
|
+
}, boundsStart);
|
|
66
|
+
const boundsEnd = {
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0
|
|
69
|
+
};
|
|
70
|
+
groupGraphicItem.globalTransMatrix.transformPoint({
|
|
71
|
+
x: this.view.getSignalById("width").getValue(),
|
|
72
|
+
y: this.view.getSignalById("height").getValue()
|
|
73
|
+
}, boundsEnd);
|
|
74
|
+
const bounds = (new AABBBounds).set(boundsStart.x, boundsStart.y, boundsEnd.x, boundsEnd.y), {title: title, content: content} = this._computeTitleContent(tooltipDatum), theme = this.view.getCurrentTheme(), addition = invokeFunctionType(this.options.attributes, this.parameters(), {}), attributes = generateTooltipAttributes(point, title, content, bounds, theme, addition);
|
|
75
|
+
this._tooltipComponent.setAttributes(attributes);
|
|
76
|
+
}), 10), this.handleTooltipHide = event => {
|
|
77
|
+
this._tooltipComponent.hideAll();
|
|
78
|
+
}, this.options = Object.assign({}, DimensionTooltip.defaultOptions, options), this._marks = view.getMarksBySelector(this.options.selector),
|
|
79
|
+
this._avoidMarks = null !== (_a = view.getMarksBySelector(this.options.avoidMark)) && void 0 !== _a ? _a : [],
|
|
80
|
+
this._container = null !== (_c = null === (_b = view.getMarksBySelector(this.options.container)) || void 0 === _b ? void 0 : _b[0]) && void 0 !== _c ? _c : view.rootMark;
|
|
81
|
+
}
|
|
82
|
+
getEvents() {
|
|
83
|
+
const filter = this.options.target.filter;
|
|
84
|
+
return this._tooltipDataFilter = isString(filter) ? (datum, filterValue) => filterValue === datum[filter] : filter,
|
|
85
|
+
[ {
|
|
86
|
+
type: this.options.trigger,
|
|
87
|
+
handler: this.handleTooltipShow
|
|
88
|
+
}, {
|
|
89
|
+
type: this.options.resetTrigger,
|
|
90
|
+
handler: this.handleTooltipHide
|
|
91
|
+
} ];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
DimensionTooltip.type = "dimension-tooltip", DimensionTooltip.defaultOptions = {
|
|
96
|
+
trigger: "pointermove",
|
|
97
|
+
resetTrigger: "pointerleave"
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=dimension-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/dimension-tooltip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,mBAAmB,GAAG,CAAC,OAAc,EAAE,QAAe,EAAE,EAAE;IAC9D,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,YAAY,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE;QAChD,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CACL,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1D,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAChC,KAAiB,EACjB,KAAiB,EACjB,IAAiB,EACjB,SAA4C,EAC5C,aAA0B,EAC1B,EAAE;IACF,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,KAAK,CAAC,MAA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int-disable-next-line no-duplicate-imports\nimport { AABBBounds, array, getAngleByPoint, isString, throttle } from '@visactor/vutils';\nimport type { DimensionTooltipOptions, IGroupMark, IMark, IView, TooltipType } from '../types';\nimport { BaseTooltip } from './base-tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport { generateTooltipAttributes } from './base-tooltip';\nimport { BridgeElementKey } from '../graph/constants';\nimport type { IBaseScale } from '@visactor/vscale';\nimport { invokeFunctionType } from '../parse/util';\n\nconst isEqualTooltipDatum = (current: any[], previous: any[]) => {\n const currentDatum = array(current);\n const previousDatum = array(previous);\n if (currentDatum.length !== previousDatum.length) {\n return false;\n }\n return (\n currentDatum.every(datum => previousDatum.includes(datum)) &&\n previousDatum.every(datum => currentDatum.includes(datum))\n );\n};\n\nconst computeTooltipFilterValue = (\n point: IPointLike,\n scale: IBaseScale,\n type: TooltipType,\n groupSize: { width: number; height: number },\n tooltipCenter?: IPointLike\n) => {\n if (type === 'x') {\n return scale.invert(point.x);\n }\n if (type === 'y') {\n return scale.invert(point.y);\n }\n if (type === 'radius') {\n const center = tooltipCenter ?? { x: groupSize.width / 2, y: groupSize.height / 2 };\n const radius = Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2);\n return scale.invert(radius);\n }\n if (type === 'angle') {\n const center = tooltipCenter ?? { x: groupSize.width / 2, y: groupSize.height / 2 };\n const angle = getAngleByPoint(center, point);\n return scale.invert(angle < 0 ? angle + Math.PI * 2 : angle);\n }\n return scale.invert(point.x);\n};\n\nexport class DimensionTooltip extends BaseTooltip<DimensionTooltipOptions> {\n static type: string = 'dimension-tooltip';\n type: string = DimensionTooltip.type;\n\n static defaultOptions: Omit<DimensionTooltipOptions, 'target'> = {\n trigger: 'pointermove',\n resetTrigger: 'pointerleave'\n };\n protected _avoidMarks: IMark[] = [];\n protected _lastDatum: any;\n protected _tooltipDataFilter: ((datum: any, filterValue: any[]) => boolean) | null = null;\n protected _container: IGroupMark;\n\n constructor(view: IView, options?: DimensionTooltipOptions) {\n super(view, options);\n this.options = Object.assign({}, DimensionTooltip.defaultOptions, options);\n this._marks = view.getMarksBySelector(this.options.selector);\n this._avoidMarks = view.getMarksBySelector(this.options.avoidMark) ?? [];\n this._container = (view.getMarksBySelector(this.options.container)?.[0] as IGroupMark) ?? view.rootMark;\n }\n\n protected getEvents() {\n const filter = this.options.target.filter;\n\n this._tooltipDataFilter = isString(filter)\n ? (datum: any, filterValue: any[]) => filterValue === datum[filter]\n : filter;\n\n return [\n { type: this.options.trigger, handler: this.handleTooltipShow },\n { type: this.options.resetTrigger, handler: this.handleTooltipHide }\n ];\n }\n\n protected handleTooltipShow = throttle((event: any) => {\n const scaleGrammar = isString(this.options.scale) ? this.view.getScaleById(this.options.scale) : this.options.scale;\n const scale = scaleGrammar.getScale();\n const groupGraphicItem = this._container.getGroupGraphicItem();\n // FIXME: waiting for vRender to add transformed position to event\n const point = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint(event.canvas, point);\n const groupSize = { width: groupGraphicItem.attribute.width, height: groupGraphicItem.attribute.height };\n\n // if pointer is not within the area of group, hide tooltip\n if (\n point.x < 0 ||\n point.x > groupGraphicItem.attribute.width ||\n point.y < 0 ||\n point.y > groupGraphicItem.attribute.height\n ) {\n this._tooltipComponent.hideAll();\n return;\n }\n // if pointer is hovered on the avoided marks, hide tooltip\n const eventTargetMark = event.target?.[BridgeElementKey]?.mark;\n if (this._avoidMarks.includes(eventTargetMark)) {\n this._tooltipComponent.hideAll();\n return;\n }\n\n const target = this.options.target?.data;\n const lastDataGrammar = !target ? null : isString(target) ? this.view.getDataById(target) : target;\n const data = lastDataGrammar ? lastDataGrammar.getValue() : [];\n\n const filterValue = computeTooltipFilterValue(\n point,\n scale,\n this.options.tooltipType,\n groupSize,\n this.options.center\n );\n const tooltipDatum = this._tooltipDataFilter\n ? data.filter(datum => this._tooltipDataFilter(datum, filterValue))\n : [];\n\n this._tooltipComponent.showAll();\n if (isEqualTooltipDatum(tooltipDatum, this._lastDatum)) {\n // only update pointer when element is not changed\n this._tooltipComponent.setAttributes({ pointerX: point.x, pointerY: point.y } as any);\n return;\n }\n this._lastDatum = tooltipDatum;\n\n // compute tooltip bounds\n const boundsStart = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint({ x: 0, y: 0 }, boundsStart);\n const boundsEnd = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint(\n {\n x: this.view.getSignalById('width').getValue() as number,\n y: this.view.getSignalById('height').getValue() as number\n },\n boundsEnd\n );\n const bounds = new AABBBounds().set(boundsStart.x, boundsStart.y, boundsEnd.x, boundsEnd.y);\n const { title, content } = this._computeTitleContent(tooltipDatum);\n const theme = this.view.getCurrentTheme();\n const addition = invokeFunctionType(this.options.attributes, this.parameters(), {}) as any;\n const attributes = generateTooltipAttributes(point, title, content, bounds, theme, addition);\n this._tooltipComponent.setAttributes(attributes);\n }, 10);\n\n protected handleTooltipHide = (event: any) => {\n this._tooltipComponent.hideAll();\n };\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IPolygon } from '@visactor/vrender-core';
|
|
2
|
+
import type { DrillDownOptions, IView, InteractionEvent } from '../types';
|
|
3
|
+
import { BrushBase } from './brush-base';
|
|
4
|
+
import { type IBounds } from '@visactor/vutils';
|
|
5
|
+
import type { FilterMixin } from './filter';
|
|
6
|
+
export interface DrillDown extends Pick<FilterMixin, '_data' | '_filterValue' | '_dataFilter' | 'handleFilter' | '_filterData'>, BrushBase<DrillDownOptions> {
|
|
7
|
+
}
|
|
8
|
+
export declare class DrillDown extends BrushBase<DrillDownOptions> {
|
|
9
|
+
static type: string;
|
|
10
|
+
type: string;
|
|
11
|
+
static defaultOptions: Omit<DrillDownOptions, 'target'>;
|
|
12
|
+
constructor(view: IView, option?: DrillDownOptions);
|
|
13
|
+
protected getEvents(): {
|
|
14
|
+
type: string;
|
|
15
|
+
handler: import("../types").InteractionEventHandler;
|
|
16
|
+
}[];
|
|
17
|
+
handleBrushUpdate: (options: {
|
|
18
|
+
operateType: string;
|
|
19
|
+
operateMask: IPolygon;
|
|
20
|
+
operatedMaskAABBBounds: {
|
|
21
|
+
[name: string]: IBounds;
|
|
22
|
+
};
|
|
23
|
+
}) => void;
|
|
24
|
+
handleTrigger: (event: InteractionEvent) => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BrushBase } from "./brush-base";
|
|
2
|
+
|
|
3
|
+
import { isString, array } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import { DataFilterRank } from "../graph";
|
|
6
|
+
|
|
7
|
+
export class DrillDown extends BrushBase {
|
|
8
|
+
constructor(view, option) {
|
|
9
|
+
super(view, Object.assign({}, DrillDown.defaultOptions, option)), this.type = DrillDown.type,
|
|
10
|
+
this.handleBrushUpdate = options => {
|
|
11
|
+
const elements = [];
|
|
12
|
+
let filterValue = [];
|
|
13
|
+
this._marks.forEach((mark => {
|
|
14
|
+
mark.elements.forEach((el => {
|
|
15
|
+
this.isBrushContainGraphicItem(options.operateMask, el.getGraphicItem()) && (elements.push(el),
|
|
16
|
+
filterValue = filterValue.concat(array(el.getDatum())));
|
|
17
|
+
}));
|
|
18
|
+
})), this._data && (filterValue = Array.from(new Set(filterValue)), this._filterValue && filterValue.length === this._filterValue.length && !filterValue.some((datum => !this._filterValue.includes(datum))) || (this._filterValue = filterValue,
|
|
19
|
+
this.handleFilter())), this.dispatchEvent(options, elements);
|
|
20
|
+
}, this.handleTrigger = event => {
|
|
21
|
+
const element = event.element;
|
|
22
|
+
if (element && this._marks && this._marks.includes(element.mark)) {
|
|
23
|
+
const filterValue = array(element.getDatum());
|
|
24
|
+
this._filterValue && filterValue.length === this._filterValue.length && !filterValue.some((datum => !this._filterValue.includes(datum))) || (this._filterValue = filterValue,
|
|
25
|
+
this.handleFilter());
|
|
26
|
+
}
|
|
27
|
+
}, this._data = isString(this.options.target.data) ? view.getDataById(this.options.target.data) : this.options.target.data;
|
|
28
|
+
}
|
|
29
|
+
getEvents() {
|
|
30
|
+
if (!this._data) return [];
|
|
31
|
+
const transform = this.options.target.transform;
|
|
32
|
+
return this._filterData(this._data, null, DataFilterRank.drillDown, null, void 0, ((data, filterValue) => {
|
|
33
|
+
const nextData = filterValue || data;
|
|
34
|
+
return transform ? transform(data, filterValue) : nextData;
|
|
35
|
+
})), this.options.brush ? super.getEvents() : [ {
|
|
36
|
+
type: this.options.trigger,
|
|
37
|
+
handler: this.handleTrigger
|
|
38
|
+
} ];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
DrillDown.type = "drill-down", DrillDown.defaultOptions = {
|
|
43
|
+
brush: !1,
|
|
44
|
+
trigger: "click"
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=drill-down.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/drill-down.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAgB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,OAAO,SAAU,SAAQ,SAA2B;IASxD,YAAY,IAAW,EAAE,MAAyB;QAChD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;QARnE,SAAI,GAAW,SAAS,CAAC,IAAI,CAAC;QAsC9B,sBAAiB,GAAG,CAAC,OAIpB,EAAE,EAAE;YACH,MAAM,QAAQ,GAAiC,EAAE,CAAC;YAElD,IAAI,WAAW,GAAU,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;oBACzB,MAAM,QAAQ,GAA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,CAAC,aAAa;aAC5B;SACF,CAAC;IACJ,CAAC;;AArCM,cAAI,GAAW,YAAY,CAAC;AAG5B,wBAAc,GAAqC;IACxD,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,OAAO;CACjB,CAAC","file":"drill-down.js","sourcesContent":["import type { IPolygon } from '@visactor/vrender-core';\nimport type { DrillDownOptions, IElement, IGlyphElement, IView, InteractionEvent } from '../types';\nimport { BrushBase } from './brush-base';\nimport { isString, type IBounds, array } from '@visactor/vutils';\nimport { DataFilterRank } from '../graph';\nimport type { FilterMixin } from './filter';\n\nexport interface DrillDown\n extends Pick<FilterMixin, '_data' | '_filterValue' | '_dataFilter' | 'handleFilter' | '_filterData'>,\n BrushBase<DrillDownOptions> {}\n\nexport class DrillDown extends BrushBase<DrillDownOptions> {\n static type: string = 'drill-down';\n type: string = DrillDown.type;\n\n static defaultOptions: Omit<DrillDownOptions, 'target'> = {\n brush: false,\n trigger: 'click'\n };\n\n constructor(view: IView, option?: DrillDownOptions) {\n super(view, Object.assign({}, DrillDown.defaultOptions, option));\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._data) {\n return [];\n }\n\n const transform = this.options.target.transform;\n const dataTransform = (data: any[], filterValue: any) => {\n const nextData = !filterValue ? data : filterValue;\n return transform ? transform(data, filterValue) : nextData;\n };\n\n this._filterData(this._data, null, DataFilterRank.drillDown, null, undefined, dataTransform);\n\n if (this.options.brush) {\n return super.getEvents();\n }\n return [\n {\n type: this.options.trigger,\n handler: this.handleTrigger\n }\n ];\n }\n\n handleBrushUpdate = (options: {\n operateType: string;\n operateMask: IPolygon;\n operatedMaskAABBBounds: { [name: string]: IBounds };\n }) => {\n const elements: (IElement | IGlyphElement)[] = [];\n\n let filterValue: any[] = [];\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isActive = this.isBrushContainGraphicItem(options.operateMask, el.getGraphicItem());\n\n if (isActive) {\n elements.push(el);\n filterValue = filterValue.concat(array(el.getDatum()));\n }\n });\n });\n\n if (this._data) {\n // remove repeated datum\n filterValue = Array.from(new Set(filterValue));\n\n // shallow compare\n if (\n !this._filterValue ||\n filterValue.length !== this._filterValue.length ||\n filterValue.some(datum => !this._filterValue.includes(datum))\n ) {\n this._filterValue = filterValue;\n this.handleFilter();\n }\n }\n\n this.dispatchEvent(options, elements);\n };\n\n handleTrigger = (event: InteractionEvent) => {\n const element = event.element;\n if (element && this._marks && this._marks.includes(element.mark)) {\n const filterValue = array(element.getDatum());\n // shallow compare\n if (\n !this._filterValue ||\n filterValue.length !== this._filterValue.length ||\n filterValue.some(datum => !this._filterValue.includes(datum))\n ) {\n this._filterValue = filterValue;\n this.handleFilter();\n }\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ElementActiveByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
import { LegendEvent } from '@visactor/vrender-components';
|
|
4
|
+
export declare class ElementActiveByLegend extends BaseInteraction<ElementActiveByLegendOptions> {
|
|
5
|
+
static type: string;
|
|
6
|
+
type: string;
|
|
7
|
+
static defaultOptions: ElementActiveByLegendOptions;
|
|
8
|
+
options: ElementActiveByLegendOptions;
|
|
9
|
+
protected _marks?: IMark[];
|
|
10
|
+
constructor(view: IView, options?: ElementActiveByLegendOptions);
|
|
11
|
+
protected getEvents(): {
|
|
12
|
+
type: LegendEvent;
|
|
13
|
+
handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
|
|
14
|
+
}[];
|
|
15
|
+
handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
|
|
16
|
+
handleReset: (e: InteractionEvent) => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { InteractionStateEnum } from "../graph/enums";
|
|
2
|
+
|
|
3
|
+
import { BaseInteraction } from "./base";
|
|
4
|
+
|
|
5
|
+
import { LegendEvent } from "@visactor/vrender-components";
|
|
6
|
+
|
|
7
|
+
import { isNil } from "@visactor/vutils";
|
|
8
|
+
|
|
9
|
+
export class ElementActiveByLegend extends BaseInteraction {
|
|
10
|
+
constructor(view, options) {
|
|
11
|
+
super(view, options), this.type = ElementActiveByLegend.type, this.handleStart = (e, element) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const itemKey = null === (_b = null === (_a = e.detail) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b.id;
|
|
14
|
+
isNil(itemKey) || this._marks.forEach((mark => {
|
|
15
|
+
mark.elements.forEach((el => {
|
|
16
|
+
el[this.options.filterType] === itemKey ? el.addState(this.options.state) : el.removeState(this.options.state);
|
|
17
|
+
}));
|
|
18
|
+
}));
|
|
19
|
+
}, this.handleReset = e => {
|
|
20
|
+
this._marks.forEach((mark => {
|
|
21
|
+
mark.elements.forEach((el => {
|
|
22
|
+
el.hasState(this.options.state) && el.removeState(this.options.state);
|
|
23
|
+
}));
|
|
24
|
+
}));
|
|
25
|
+
}, this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options),
|
|
26
|
+
this._marks = view.getMarksBySelector(this.options.selector);
|
|
27
|
+
}
|
|
28
|
+
getEvents() {
|
|
29
|
+
return [ {
|
|
30
|
+
type: LegendEvent.legendItemHover,
|
|
31
|
+
handler: this.handleStart
|
|
32
|
+
}, {
|
|
33
|
+
type: LegendEvent.legendItemUnHover,
|
|
34
|
+
handler: this.handleReset
|
|
35
|
+
} ];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ElementActiveByLegend.type = "element-active-by-legend", ElementActiveByLegend.defaultOptions = {
|
|
40
|
+
state: InteractionStateEnum.active,
|
|
41
|
+
filterType: "groupKey"
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=element-active-by-legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/element-active-by-leg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E,CAAC,EAAE;oBACzB,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;wBACnC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;qBACpC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QA9CA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,qBAAqB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAEhF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAES,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,WAAW,CAAC,eAAe;gBACjC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD;gBACE,IAAI,EAAE,WAAW,CAAC,iBAAiB;gBACnC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;SACF,CAAC;IACJ,CAAC;;AA5BM,0BAAI,GAAW,0BAA0B,CAAC;AAG1C,oCAAc,GAAiC;IACpD,KAAK,EAAE,oBAAoB,CAAC,MAAM;IAClC,UAAU,EAAE,UAAU;CACvB,CAAC","file":"element-active-by-legend.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type { ElementActiveByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { LegendEvent } from '@visactor/vrender-components';\nimport { isNil } from '@visactor/vutils';\n\nexport class ElementActiveByLegend extends BaseInteraction<ElementActiveByLegendOptions> {\n static type: string = 'element-active-by-legend';\n type: string = ElementActiveByLegend.type;\n\n static defaultOptions: ElementActiveByLegendOptions = {\n state: InteractionStateEnum.active,\n filterType: 'groupKey'\n };\n options: ElementActiveByLegendOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementActiveByLegendOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: LegendEvent.legendItemHover,\n handler: this.handleStart\n },\n {\n type: LegendEvent.legendItemUnHover,\n handler: this.handleReset\n }\n ];\n }\n\n handleStart = (e: InteractionEvent, element: IElement | IGlyphElement) => {\n const itemKey = e.detail?.data?.id;\n\n if (isNil(itemKey)) {\n return;\n }\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isActive = el[this.options.filterType] === itemKey;\n\n if (isActive) {\n el.addState(this.options.state);\n } else {\n el.removeState(this.options.state);\n }\n });\n });\n };\n\n handleReset = (e: InteractionEvent) => {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.state)) {\n el.removeState(this.options.state);\n }\n });\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ElementActiveOptions, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
export declare class ElementActive extends BaseInteraction<ElementActiveOptions> {
|
|
4
|
+
static type: string;
|
|
5
|
+
type: string;
|
|
6
|
+
static defaultOptions: ElementActiveOptions;
|
|
7
|
+
options: ElementActiveOptions;
|
|
8
|
+
protected _marks?: IMark[];
|
|
9
|
+
constructor(view: IView, options?: ElementActiveOptions);
|
|
10
|
+
protected getEvents(): {
|
|
11
|
+
type: import("../types").EventType;
|
|
12
|
+
handler: (e: InteractionEvent) => void;
|
|
13
|
+
}[];
|
|
14
|
+
handleStart: (e: InteractionEvent) => void;
|
|
15
|
+
handleReset: (e: InteractionEvent) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InteractionStateEnum } from "../graph/enums";
|
|
2
|
+
|
|
3
|
+
import { BaseInteraction } from "./base";
|
|
4
|
+
|
|
5
|
+
export class ElementActive extends BaseInteraction {
|
|
6
|
+
constructor(view, options) {
|
|
7
|
+
super(view, options), this.type = ElementActive.type, this.handleStart = e => {
|
|
8
|
+
e.element && this._marks && this._marks.includes(e.element.mark) && e.element.addState(this.options.state);
|
|
9
|
+
}, this.handleReset = e => {
|
|
10
|
+
e.element && this._marks && this._marks.includes(e.element.mark) && e.element.removeState(this.options.state);
|
|
11
|
+
}, this.options = Object.assign({}, ElementActive.defaultOptions, options), this._marks = view.getMarksBySelector(this.options.selector);
|
|
12
|
+
}
|
|
13
|
+
getEvents() {
|
|
14
|
+
return [ {
|
|
15
|
+
type: this.options.trigger,
|
|
16
|
+
handler: this.handleStart
|
|
17
|
+
}, {
|
|
18
|
+
type: this.options.resetTrigger,
|
|
19
|
+
handler: this.handleReset
|
|
20
|
+
} ];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ElementActive.type = "element-active", ElementActive.defaultOptions = {
|
|
25
|
+
state: InteractionStateEnum.active,
|
|
26
|
+
trigger: "pointerover",
|
|
27
|
+
resetTrigger: "pointerout"
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=element-active.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/element-active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,OAAO,aAAc,SAAQ,eAAqC;IAYtE,YAAY,IAAW,EAAE,OAA8B;QACrD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAXvB,SAAI,GAAW,aAAa,CAAC,IAAI,CAAC;QA2BlC,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,OAAO,EAAE;gBACb,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACvD,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBACxC;aACF;QACH,CAAC,CAAC;QAEF,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,OAAO,EAAE;gBACb,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACvD,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC3C;aACF;QACH,CAAC,CAAC;QA7BA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAExE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAES,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC1B,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;SAC/D,CAAC;IACJ,CAAC;;AA1BM,kBAAI,GAAW,gBAAgB,CAAC;AAGhC,4BAAc,GAAyB;IAC5C,KAAK,EAAE,oBAAoB,CAAC,MAAM;IAClC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-active.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type { ElementActiveOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\n\nexport class ElementActive extends BaseInteraction<ElementActiveOptions> {\n static type: string = 'element-active';\n type: string = ElementActive.type;\n\n static defaultOptions: ElementActiveOptions = {\n state: InteractionStateEnum.active,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementActiveOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementActiveOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActive.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element) {\n if (this._marks && this._marks.includes(e.element.mark)) {\n e.element.addState(this.options.state);\n }\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n if (e.element) {\n if (this._marks && this._marks.includes(e.element.mark)) {\n e.element.removeState(this.options.state);\n }\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
export declare class ElementHighlightByGroup extends BaseInteraction<ElementHighlightOptions> {
|
|
4
|
+
static type: string;
|
|
5
|
+
type: string;
|
|
6
|
+
static defaultOptions: ElementHighlightOptions;
|
|
7
|
+
options: ElementHighlightOptions;
|
|
8
|
+
protected _marks?: IMark[];
|
|
9
|
+
constructor(view: IView, options?: ElementHighlightOptions);
|
|
10
|
+
protected getEvents(): {
|
|
11
|
+
type: import("../types").EventType;
|
|
12
|
+
handler: (e: InteractionEvent) => void;
|
|
13
|
+
}[];
|
|
14
|
+
clearPrevElements(): void;
|
|
15
|
+
handleStart: (e: InteractionEvent) => void;
|
|
16
|
+
handleReset: (e: InteractionEvent) => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isNil } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { BaseInteraction } from "./base";
|
|
4
|
+
|
|
5
|
+
import { InteractionStateEnum } from "../graph/enums";
|
|
6
|
+
|
|
7
|
+
export class ElementHighlightByGroup extends BaseInteraction {
|
|
8
|
+
constructor(view, options) {
|
|
9
|
+
super(view, options), this.type = ElementHighlightByGroup.type, this.handleStart = e => {
|
|
10
|
+
if (e.element && this._marks && this._marks.includes(e.element.mark)) {
|
|
11
|
+
const highlightKey = e.element.groupKey;
|
|
12
|
+
if (isNil(highlightKey)) return;
|
|
13
|
+
this._marks.forEach((mark => {
|
|
14
|
+
mark.elements.forEach((el => {
|
|
15
|
+
el.groupKey === highlightKey ? (el.removeState(this.options.blurState), el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
|
|
16
|
+
el.addState(this.options.blurState));
|
|
17
|
+
}));
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
}, this.handleReset = e => {
|
|
21
|
+
e.element && this._marks && this._marks.includes(e.element.mark) && this.clearPrevElements();
|
|
22
|
+
}, this.options = Object.assign({}, ElementHighlightByGroup.defaultOptions, options),
|
|
23
|
+
this._marks = view.getMarksBySelector(this.options.selector);
|
|
24
|
+
}
|
|
25
|
+
getEvents() {
|
|
26
|
+
return [ {
|
|
27
|
+
type: this.options.trigger,
|
|
28
|
+
handler: this.handleStart
|
|
29
|
+
}, {
|
|
30
|
+
type: this.options.resetTrigger,
|
|
31
|
+
handler: this.handleReset
|
|
32
|
+
} ];
|
|
33
|
+
}
|
|
34
|
+
clearPrevElements() {
|
|
35
|
+
this._marks.forEach((mark => {
|
|
36
|
+
mark.elements.forEach((el => {
|
|
37
|
+
el.hasState(this.options.highlightState) && el.removeState(this.options.highlightState),
|
|
38
|
+
el.hasState(this.options.blurState) && el.removeState(this.options.blurState);
|
|
39
|
+
}));
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ElementHighlightByGroup.type = "element-highlight-by-group", ElementHighlightByGroup.defaultOptions = {
|
|
45
|
+
highlightState: InteractionStateEnum.highlight,
|
|
46
|
+
blurState: InteractionStateEnum.blur,
|
|
47
|
+
trigger: "pointerover",
|
|
48
|
+
resetTrigger: "pointerout"
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/element-highlight-by-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,OAAO,uBAAwB,SAAQ,eAAwC;IAanF,YAAY,IAAW,EAAE,OAAiC;QACxD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAZvB,SAAI,GAAW,uBAAuB,CAAC,IAAI,CAAC;QA0C5C,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACpE,MAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAExC,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE;oBACvB,OAAO;iBACR;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;wBACzB,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,KAAK,YAAY,CAAC;wBAEjD,IAAI,WAAW,EAAE;4BACf,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;4BACvC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;yBAC1C;6BAAM;4BACL,EAAE,CAAC,WAAW,CAAC,IAAI,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AC;iBAC7C;gBAED,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;oBACvC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;iBACxC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAzCM,4BAAI,GAAW,4BAA4B,CAAC;AAG5C,sCAAc,GAA4B;IAC/C,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-highlight-by-group.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { InteractionStateEnum } from '../graph/enums';\n\nexport class ElementHighlightByGroup extends BaseInteraction<ElementHighlightOptions> {\n static type: string = 'element-highlight-by-group';\n type: string = ElementHighlightByGroup.type;\n\n static defaultOptions: ElementHighlightOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementHighlightOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByGroup.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n clearPrevElements() {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.highlightState)) {\n el.removeState(this.options.highlightState);\n }\n\n if (el.hasState(this.options.blurState)) {\n el.removeState(this.options.blurState);\n }\n });\n });\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element && this._marks && this._marks.includes(e.element.mark)) {\n const highlightKey = e.element.groupKey;\n\n if (isNil(highlightKey)) {\n return;\n }\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el.groupKey === highlightKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n const hasActiveElement = e.element && this._marks && this._marks.includes(e.element.mark);\n\n if (hasActiveElement) {\n this.clearPrevElements();\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
export declare class ElementHighlightByKey extends BaseInteraction<ElementHighlightOptions> {
|
|
4
|
+
static type: string;
|
|
5
|
+
type: string;
|
|
6
|
+
static defaultOptions: ElementHighlightOptions;
|
|
7
|
+
options: ElementHighlightOptions;
|
|
8
|
+
protected _marks?: IMark[];
|
|
9
|
+
constructor(view: IView, options?: ElementHighlightOptions);
|
|
10
|
+
protected getEvents(): {
|
|
11
|
+
type: import("../types").EventType;
|
|
12
|
+
handler: (e: InteractionEvent) => void;
|
|
13
|
+
}[];
|
|
14
|
+
clearPrevElements(): void;
|
|
15
|
+
handleStart: (e: InteractionEvent) => void;
|
|
16
|
+
handleReset: (e: InteractionEvent) => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isNil } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { BaseInteraction } from "./base";
|
|
4
|
+
|
|
5
|
+
import { InteractionStateEnum } from "../graph/enums";
|
|
6
|
+
|
|
7
|
+
export class ElementHighlightByKey extends BaseInteraction {
|
|
8
|
+
constructor(view, options) {
|
|
9
|
+
super(view, options), this.type = ElementHighlightByKey.type, this.handleStart = e => {
|
|
10
|
+
if (e.element && this._marks && this._marks.includes(e.element.mark)) {
|
|
11
|
+
const highlightKey = e.element.key;
|
|
12
|
+
if (isNil(highlightKey)) return;
|
|
13
|
+
this._marks.forEach((mark => {
|
|
14
|
+
mark.elements.forEach((el => {
|
|
15
|
+
el.key === highlightKey ? (el.removeState(this.options.blurState), el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
|
|
16
|
+
el.addState(this.options.blurState));
|
|
17
|
+
}));
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
}, this.handleReset = e => {
|
|
21
|
+
e.element && this._marks && this._marks.includes(e.element.mark) && this.clearPrevElements();
|
|
22
|
+
}, this.options = Object.assign({}, ElementHighlightByKey.defaultOptions, options),
|
|
23
|
+
this._marks = view.getMarksBySelector(this.options.selector);
|
|
24
|
+
}
|
|
25
|
+
getEvents() {
|
|
26
|
+
return [ {
|
|
27
|
+
type: this.options.trigger,
|
|
28
|
+
handler: this.handleStart
|
|
29
|
+
}, {
|
|
30
|
+
type: this.options.resetTrigger,
|
|
31
|
+
handler: this.handleReset
|
|
32
|
+
} ];
|
|
33
|
+
}
|
|
34
|
+
clearPrevElements() {
|
|
35
|
+
this._marks.forEach((mark => {
|
|
36
|
+
mark.elements.forEach((el => {
|
|
37
|
+
el.hasState(this.options.highlightState) && el.removeState(this.options.highlightState),
|
|
38
|
+
el.hasState(this.options.blurState) && el.removeState(this.options.blurState);
|
|
39
|
+
}));
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ElementHighlightByKey.type = "element-highlight-by-key", ElementHighlightByKey.defaultOptions = {
|
|
45
|
+
highlightState: InteractionStateEnum.highlight,
|
|
46
|
+
blurState: InteractionStateEnum.blur,
|
|
47
|
+
trigger: "pointerover",
|
|
48
|
+
resetTrigger: "pointerout"
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=element-highlight-by-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interact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C,CAAC;iBACxC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAzCM,0BAAI,GAAW,0BAA0B,CAAC;AAG1C,oCAAc,GAA4B;IAC/C,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-highlight-by-key.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { InteractionStateEnum } from '../graph/enums';\n\nexport class ElementHighlightByKey extends BaseInteraction<ElementHighlightOptions> {\n static type: string = 'element-highlight-by-key';\n type: string = ElementHighlightByKey.type;\n\n static defaultOptions: ElementHighlightOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementHighlightOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByKey.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n clearPrevElements() {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.highlightState)) {\n el.removeState(this.options.highlightState);\n }\n\n if (el.hasState(this.options.blurState)) {\n el.removeState(this.options.blurState);\n }\n });\n });\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element && this._marks && this._marks.includes(e.element.mark)) {\n const highlightKey = e.element.key;\n\n if (isNil(highlightKey)) {\n return;\n }\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el.key === highlightKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n const hasActiveElement = e.element && this._marks && this._marks.includes(e.element.mark);\n\n if (hasActiveElement) {\n this.clearPrevElements();\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ElementHighlightByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
import { LegendEvent } from '@visactor/vrender-components';
|
|
4
|
+
export declare class ElementHighlightByLegend extends BaseInteraction<ElementHighlightByLegendOptions> {
|
|
5
|
+
static type: string;
|
|
6
|
+
type: string;
|
|
7
|
+
static defaultOptions: ElementHighlightByLegendOptions;
|
|
8
|
+
options: ElementHighlightByLegendOptions;
|
|
9
|
+
protected _marks?: IMark[];
|
|
10
|
+
constructor(view: IView, options?: ElementHighlightByLegendOptions);
|
|
11
|
+
protected getEvents(): {
|
|
12
|
+
type: LegendEvent;
|
|
13
|
+
handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
|
|
14
|
+
}[];
|
|
15
|
+
handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
|
|
16
|
+
handleReset: (e: InteractionEvent) => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InteractionStateEnum } from "../graph/enums";
|
|
2
|
+
|
|
3
|
+
import { BaseInteraction } from "./base";
|
|
4
|
+
|
|
5
|
+
import { LegendEvent } from "@visactor/vrender-components";
|
|
6
|
+
|
|
7
|
+
import { isNil } from "@visactor/vutils";
|
|
8
|
+
|
|
9
|
+
export class ElementHighlightByLegend extends BaseInteraction {
|
|
10
|
+
constructor(view, options) {
|
|
11
|
+
super(view, options), this.type = ElementHighlightByLegend.type, this.handleStart = (e, element) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const itemKey = null === (_b = null === (_a = e.detail) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b.id;
|
|
14
|
+
isNil(itemKey) || this._marks.forEach((mark => {
|
|
15
|
+
mark.elements.forEach((el => {
|
|
16
|
+
el[this.options.filterType] === itemKey ? (el.removeState(this.options.blurState),
|
|
17
|
+
el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
|
|
18
|
+
el.addState(this.options.blurState));
|
|
19
|
+
}));
|
|
20
|
+
}));
|
|
21
|
+
}, this.handleReset = e => {
|
|
22
|
+
this._marks.forEach((mark => {
|
|
23
|
+
mark.elements.forEach((el => {
|
|
24
|
+
el.removeState(this.options.blurState), el.removeState(this.options.highlightState);
|
|
25
|
+
}));
|
|
26
|
+
}));
|
|
27
|
+
}, this.options = Object.assign({}, ElementHighlightByLegend.defaultOptions, options),
|
|
28
|
+
this._marks = view.getMarksBySelector(this.options.selector);
|
|
29
|
+
}
|
|
30
|
+
getEvents() {
|
|
31
|
+
return [ {
|
|
32
|
+
type: LegendEvent.legendItemHover,
|
|
33
|
+
handler: this.handleStart
|
|
34
|
+
}, {
|
|
35
|
+
type: LegendEvent.legendItemUnHover,
|
|
36
|
+
handler: this.handleReset
|
|
37
|
+
} ];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ElementHighlightByLegend.type = "element-highlight-by-legend", ElementHighlightByLegend.defaultOptions = {
|
|
42
|
+
highlightState: InteractionStateEnum.highlight,
|
|
43
|
+
blurState: InteractionStateEnum.blur,
|
|
44
|
+
filterType: "groupKey"
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=element-highlight-by-legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/element-highlight-by-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAStD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE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,EAAE,CAAC,EAAE;oBACzB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;oBACvC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QA5CA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,wBAAwB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAEnF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAES,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,WAAW,CAAC,eAAe;gBACjC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD,EAAE,IAAI,EAAE,WAAW,CAAC,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;SACnE,CAAC;IACJ,CAAC;;AA1BM,6BAAI,GAAW,6BAA6B,CAAC;AAG7C,uCAAc,GAAoC;IACvD,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,UAAU,EAAE,UAAU;CACvB,CAAC","file":"element-highlight-by-legend.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type {\n ElementHighlightByLegendOptions,\n IElement,\n IGlyphElement,\n IMark,\n IView,\n InteractionEvent\n} from '../types';\nimport { BaseInteraction } from './base';\nimport { LegendEvent } from '@visactor/vrender-components';\nimport { isNil } from '@visactor/vutils';\n\nexport class ElementHighlightByLegend extends BaseInteraction<ElementHighlightByLegendOptions> {\n static type: string = 'element-highlight-by-legend';\n type: string = ElementHighlightByLegend.type;\n\n static defaultOptions: ElementHighlightByLegendOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n filterType: 'groupKey'\n };\n options: ElementHighlightByLegendOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightByLegendOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByLegend.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: LegendEvent.legendItemHover,\n handler: this.handleStart\n },\n { type: LegendEvent.legendItemUnHover, handler: this.handleReset }\n ];\n }\n\n handleStart = (e: InteractionEvent, element: IElement | IGlyphElement) => {\n const itemKey = e.detail?.data?.id;\n\n if (isNil(itemKey)) {\n return;\n }\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el[this.options.filterType] === itemKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n };\n\n handleReset = (e: InteractionEvent) => {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n el.removeState(this.options.blurState);\n el.removeState(this.options.highlightState);\n });\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ElementHighlightByNameOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
|
|
2
|
+
import { BaseInteraction } from './base';
|
|
3
|
+
export declare class ElementHighlightByName extends BaseInteraction<ElementHighlightByNameOptions> {
|
|
4
|
+
static type: string;
|
|
5
|
+
type: string;
|
|
6
|
+
static defaultOptions: ElementHighlightByNameOptions;
|
|
7
|
+
options: ElementHighlightByNameOptions;
|
|
8
|
+
protected _marks?: IMark[];
|
|
9
|
+
constructor(view: IView, options?: ElementHighlightByNameOptions);
|
|
10
|
+
protected getEvents(): {
|
|
11
|
+
type: import("../types").EventType;
|
|
12
|
+
handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
|
|
13
|
+
}[];
|
|
14
|
+
protected _filterByName(e: InteractionEvent): boolean;
|
|
15
|
+
protected _parseTargetKey(e: InteractionEvent, element: IElement | IGlyphElement): any;
|
|
16
|
+
handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
|
|
17
|
+
handleReset: (e: InteractionEvent) => void;
|
|
18
|
+
}
|