@visactor/vrender-components 0.17.0-alpha.8 → 0.17.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/axis/base.d.ts +2 -1
- package/cjs/axis/base.js +23 -12
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +9 -4
- package/cjs/axis/circle.js +8 -5
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/grid/base.js +2 -2
- package/cjs/axis/grid/base.js.map +1 -1
- package/cjs/axis/grid/circle.d.ts +2 -1
- package/cjs/axis/grid/circle.js +2 -2
- package/cjs/axis/grid/circle.js.map +1 -1
- package/cjs/axis/grid/line.d.ts +2 -1
- package/cjs/axis/grid/line.js +2 -3
- package/cjs/axis/grid/line.js.map +1 -1
- package/cjs/axis/line.d.ts +2 -1
- package/cjs/axis/line.js +39 -45
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.js +8 -7
- package/cjs/axis/overlap/auto-hide.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/overlap/auto-rotate.js +3 -35
- package/cjs/axis/overlap/auto-rotate.js.map +1 -1
- package/cjs/axis/overlap/util.d.ts +3 -0
- package/cjs/axis/overlap/util.js +44 -0
- package/cjs/axis/overlap/util.js.map +1 -0
- package/cjs/axis/type.d.ts +6 -6
- package/cjs/axis/type.js.map +1 -1
- package/cjs/axis/util.d.ts +8 -0
- package/cjs/axis/util.js +34 -0
- package/cjs/axis/util.js.map +1 -0
- package/cjs/brush/brush.d.ts +2 -1
- package/cjs/brush/brush.js +8 -4
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/brush/type.d.ts +2 -1
- package/cjs/brush/type.js.map +1 -1
- package/cjs/checkbox/checkbox.d.ts +4 -2
- package/cjs/checkbox/checkbox.js +26 -12
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/checkbox/index.js +1 -2
- package/cjs/checkbox/type.d.ts +5 -1
- package/cjs/checkbox/type.js +2 -1
- package/cjs/checkbox/type.js.map +1 -1
- package/cjs/constant.d.ts +6 -0
- package/cjs/constant.js +6 -1
- package/cjs/constant.js.map +1 -1
- package/cjs/core/base.d.ts +4 -2
- package/cjs/core/base.js +9 -6
- package/cjs/core/base.js.map +1 -1
- package/cjs/core/type.d.ts +15 -0
- package/cjs/core/type.js.map +1 -1
- package/cjs/crosshair/circle.d.ts +2 -1
- package/cjs/crosshair/circle.js +2 -2
- package/cjs/crosshair/circle.js.map +1 -1
- package/cjs/crosshair/line.d.ts +2 -1
- package/cjs/crosshair/line.js +2 -2
- package/cjs/crosshair/line.js.map +1 -1
- package/cjs/crosshair/polygon.d.ts +2 -1
- package/cjs/crosshair/polygon.js +2 -2
- package/cjs/crosshair/polygon.js.map +1 -1
- package/cjs/crosshair/rect.d.ts +2 -1
- package/cjs/crosshair/rect.js +2 -2
- package/cjs/crosshair/rect.js.map +1 -1
- package/cjs/crosshair/sector.d.ts +2 -1
- package/cjs/crosshair/sector.js +2 -2
- package/cjs/crosshair/sector.js.map +1 -1
- package/cjs/data-zoom/config.d.ts +6 -6
- package/cjs/data-zoom/config.js +7 -7
- package/cjs/data-zoom/config.js.map +1 -1
- package/cjs/data-zoom/data-zoom.d.ts +21 -11
- package/cjs/data-zoom/data-zoom.js +80 -64
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/data-zoom/type.d.ts +17 -5
- package/cjs/data-zoom/type.js +6 -1
- package/cjs/data-zoom/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/config.js +1 -2
- package/cjs/indicator/index.js +2 -1
- package/cjs/indicator/indicator.js +43 -7
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +2 -1
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/interface.d.ts +5 -0
- package/cjs/interface.js.map +1 -1
- package/cjs/label/animate/animate.d.ts +8 -2
- package/cjs/label/animate/animate.js +37 -3
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/arc.d.ts +7 -6
- package/cjs/label/arc.js +5 -17
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/area.d.ts +15 -0
- package/cjs/label/area.js +41 -0
- package/cjs/label/area.js.map +1 -0
- package/cjs/label/base.d.ts +28 -18
- package/cjs/label/base.js +114 -61
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.d.ts +2 -1
- package/cjs/label/dataLabel.js +13 -8
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/index.d.ts +2 -0
- package/cjs/label/index.js +1 -0
- package/cjs/label/index.js.map +1 -1
- package/cjs/label/line-data.d.ts +13 -0
- package/cjs/label/line-data.js +31 -0
- package/cjs/label/line-data.js.map +1 -0
- package/cjs/label/line.d.ts +4 -3
- package/cjs/label/line.js +8 -14
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/polygon.d.ts +2 -1
- package/cjs/label/polygon.js +3 -2
- package/cjs/label/polygon.js.map +1 -1
- package/cjs/label/rect.d.ts +2 -1
- package/cjs/label/rect.js +29 -3
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/symbol.d.ts +2 -1
- package/cjs/label/symbol.js +5 -44
- package/cjs/label/symbol.js.map +1 -1
- package/cjs/label/type.d.ts +42 -8
- package/cjs/label/type.js +1 -2
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +11 -1
- package/cjs/label/util.js +74 -1
- package/cjs/label/util.js.map +1 -1
- package/cjs/legend/color/color.d.ts +2 -1
- package/cjs/legend/color/color.js +6 -5
- package/cjs/legend/color/color.js.map +1 -1
- package/cjs/legend/constant.js +2 -1
- package/cjs/legend/discrete/discrete.d.ts +5 -1
- package/cjs/legend/discrete/discrete.js +74 -61
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +2 -0
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/legend/index.d.ts +1 -0
- package/cjs/legend/index.js +2 -1
- package/cjs/legend/index.js.map +1 -1
- package/cjs/legend/size/size.d.ts +2 -3
- package/cjs/legend/size/size.js +9 -17
- package/cjs/legend/size/size.js.map +1 -1
- package/cjs/legend/type.d.ts +1 -0
- package/cjs/legend/type.js.map +1 -1
- package/cjs/legend/util.d.ts +2 -0
- package/cjs/legend/util.js +13 -0
- package/cjs/legend/util.js.map +1 -0
- package/cjs/link-path/link-path.d.ts +2 -1
- package/cjs/link-path/link-path.js +3 -3
- package/cjs/link-path/link-path.js.map +1 -1
- package/cjs/link-path/type.js +1 -1
- package/cjs/marker/area.d.ts +8 -2
- package/cjs/marker/area.js +14 -3
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -0
- package/cjs/marker/base.js +11 -7
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/line.d.ts +8 -1
- package/cjs/marker/line.js +15 -3
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +7 -4
- package/cjs/marker/point.js +8 -3
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +16 -16
- package/cjs/marker/type.js.map +1 -1
- package/cjs/pager/pager.d.ts +2 -1
- package/cjs/pager/pager.js +5 -5
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/pager/type.d.ts +1 -0
- package/cjs/pager/type.js.map +1 -1
- package/cjs/player/base-player.d.ts +2 -1
- package/cjs/player/base-player.js +7 -5
- package/cjs/player/base-player.js.map +1 -1
- package/cjs/player/continuous-player.js +2 -2
- package/cjs/player/continuous-player.js.map +1 -1
- package/cjs/player/controller/controller.d.ts +2 -1
- package/cjs/player/controller/controller.js +5 -5
- package/cjs/player/controller/controller.js.map +1 -1
- package/cjs/player/controller/type.d.ts +1 -0
- package/cjs/player/controller/type.js.map +1 -1
- package/cjs/player/discrete-player.d.ts +2 -1
- package/cjs/player/discrete-player.js +5 -5
- package/cjs/player/discrete-player.js.map +1 -1
- package/cjs/player/type/base.d.ts +1 -0
- package/cjs/player/type/base.js.map +1 -1
- package/cjs/poptip/poptip-plugin.d.ts +1 -0
- package/cjs/poptip/poptip-plugin.js +6 -3
- package/cjs/poptip/poptip-plugin.js.map +1 -1
- package/cjs/poptip/poptip.d.ts +2 -1
- package/cjs/poptip/poptip.js +3 -3
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/scrollbar/scrollbar.d.ts +6 -1
- package/cjs/scrollbar/scrollbar.js +40 -20
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/scrollbar/type.d.ts +5 -1
- package/cjs/scrollbar/type.js.map +1 -1
- package/cjs/segment/segment.d.ts +2 -1
- package/cjs/segment/segment.js +6 -4
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/segment/type.d.ts +6 -2
- package/cjs/segment/type.js.map +1 -1
- package/cjs/slider/slider.d.ts +2 -1
- package/cjs/slider/slider.js +29 -23
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/slider/type.d.ts +1 -0
- package/cjs/slider/type.js.map +1 -1
- package/cjs/tag/tag.d.ts +2 -1
- package/cjs/tag/tag.js +90 -43
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.d.ts +4 -5
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/title.d.ts +2 -1
- package/cjs/title/title.js +92 -59
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.d.ts +10 -5
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/tooltip.d.ts +2 -1
- package/cjs/tooltip/tooltip.js +53 -15
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +7 -2
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.js +9 -1
- package/cjs/tooltip/util.js.map +1 -1
- package/cjs/util/label-smartInvert.d.ts +2 -2
- package/cjs/util/label-smartInvert.js +9 -5
- package/cjs/util/label-smartInvert.js.map +1 -1
- package/dist/index.js +10321 -8995
- package/dist/index.min.js +1 -1
- package/es/axis/base.d.ts +2 -1
- package/es/axis/base.js +25 -11
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +9 -4
- package/es/axis/circle.js +9 -4
- package/es/axis/circle.js.map +1 -1
- package/es/axis/grid/base.js +2 -2
- package/es/axis/grid/base.js.map +1 -1
- package/es/axis/grid/circle.d.ts +2 -1
- package/es/axis/grid/circle.js +2 -2
- package/es/axis/grid/circle.js.map +1 -1
- package/es/axis/grid/line.d.ts +2 -1
- package/es/axis/grid/line.js +2 -2
- package/es/axis/grid/line.js.map +1 -1
- package/es/axis/line.d.ts +2 -1
- package/es/axis/line.js +39 -45
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-hide.js +9 -6
- package/es/axis/overlap/auto-hide.js.map +1 -1
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/overlap/auto-rotate.js +3 -33
- package/es/axis/overlap/auto-rotate.js.map +1 -1
- package/es/axis/overlap/util.d.ts +3 -0
- package/es/axis/overlap/util.js +35 -0
- package/es/axis/overlap/util.js.map +1 -0
- package/es/axis/type.d.ts +6 -6
- package/es/axis/type.js.map +1 -1
- package/es/axis/util.d.ts +8 -0
- package/es/axis/util.js +28 -0
- package/es/axis/util.js.map +1 -0
- package/es/brush/brush.d.ts +2 -1
- package/es/brush/brush.js +11 -7
- package/es/brush/brush.js.map +1 -1
- package/es/brush/type.d.ts +2 -1
- package/es/brush/type.js.map +1 -1
- package/es/checkbox/checkbox.d.ts +4 -2
- package/es/checkbox/checkbox.js +25 -10
- package/es/checkbox/checkbox.js.map +1 -1
- package/es/checkbox/index.js +1 -2
- package/es/checkbox/type.d.ts +5 -1
- package/es/checkbox/type.js +2 -1
- package/es/checkbox/type.js.map +1 -1
- package/es/constant.d.ts +6 -0
- package/es/constant.js +7 -0
- package/es/constant.js.map +1 -1
- package/es/core/base.d.ts +4 -2
- package/es/core/base.js +6 -4
- package/es/core/base.js.map +1 -1
- package/es/core/type.d.ts +15 -0
- package/es/core/type.js.map +1 -1
- package/es/crosshair/circle.d.ts +2 -1
- package/es/crosshair/circle.js +2 -2
- package/es/crosshair/circle.js.map +1 -1
- package/es/crosshair/line.d.ts +2 -1
- package/es/crosshair/line.js +2 -2
- package/es/crosshair/line.js.map +1 -1
- package/es/crosshair/polygon.d.ts +2 -1
- package/es/crosshair/polygon.js +2 -2
- package/es/crosshair/polygon.js.map +1 -1
- package/es/crosshair/rect.d.ts +2 -1
- package/es/crosshair/rect.js +2 -2
- package/es/crosshair/rect.js.map +1 -1
- package/es/crosshair/sector.d.ts +2 -1
- package/es/crosshair/sector.js +2 -2
- package/es/crosshair/sector.js.map +1 -1
- package/es/data-zoom/config.d.ts +6 -6
- package/es/data-zoom/config.js +6 -7
- package/es/data-zoom/config.js.map +1 -1
- package/es/data-zoom/data-zoom.d.ts +21 -11
- package/es/data-zoom/data-zoom.js +77 -58
- package/es/data-zoom/data-zoom.js.map +1 -1
- package/es/data-zoom/type.d.ts +17 -5
- package/es/data-zoom/type.js +6 -1
- package/es/data-zoom/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/indicator/config.js +1 -2
- package/es/indicator/index.js +2 -1
- package/es/indicator/indicator.js +44 -6
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +2 -1
- package/es/indicator/type.js.map +1 -1
- package/es/interface.d.ts +5 -0
- package/es/interface.js.map +1 -1
- package/es/label/animate/animate.d.ts +8 -2
- package/es/label/animate/animate.js +35 -0
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/arc.d.ts +7 -6
- package/es/label/arc.js +5 -17
- package/es/label/arc.js.map +1 -1
- package/es/label/area.d.ts +15 -0
- package/es/label/area.js +39 -0
- package/es/label/area.js.map +1 -0
- package/es/label/base.d.ts +28 -18
- package/es/label/base.js +116 -61
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.d.ts +2 -1
- package/es/label/dataLabel.js +18 -7
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/index.d.ts +2 -0
- package/es/label/index.js +4 -0
- package/es/label/index.js.map +1 -1
- package/es/label/line-data.d.ts +13 -0
- package/es/label/line-data.js +29 -0
- package/es/label/line-data.js.map +1 -0
- package/es/label/line.d.ts +4 -3
- package/es/label/line.js +9 -13
- package/es/label/line.js.map +1 -1
- package/es/label/polygon.d.ts +2 -1
- package/es/label/polygon.js +3 -2
- package/es/label/polygon.js.map +1 -1
- package/es/label/rect.d.ts +2 -1
- package/es/label/rect.js +29 -3
- package/es/label/rect.js.map +1 -1
- package/es/label/symbol.d.ts +2 -1
- package/es/label/symbol.js +6 -43
- package/es/label/symbol.js.map +1 -1
- package/es/label/type.d.ts +42 -8
- package/es/label/type.js +1 -2
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +11 -1
- package/es/label/util.js +69 -0
- package/es/label/util.js.map +1 -1
- package/es/legend/color/color.d.ts +2 -1
- package/es/legend/color/color.js +7 -6
- package/es/legend/color/color.js.map +1 -1
- package/es/legend/constant.js +2 -1
- package/es/legend/discrete/discrete.d.ts +5 -1
- package/es/legend/discrete/discrete.js +73 -59
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +2 -0
- package/es/legend/discrete/type.js.map +1 -1
- package/es/legend/index.d.ts +1 -0
- package/es/legend/index.js +2 -0
- package/es/legend/index.js.map +1 -1
- package/es/legend/size/size.d.ts +2 -3
- package/es/legend/size/size.js +8 -12
- package/es/legend/size/size.js.map +1 -1
- package/es/legend/type.d.ts +1 -0
- package/es/legend/type.js.map +1 -1
- package/es/legend/util.d.ts +2 -0
- package/es/legend/util.js +7 -0
- package/es/legend/util.js.map +1 -0
- package/es/link-path/link-path.d.ts +2 -1
- package/es/link-path/link-path.js +3 -3
- package/es/link-path/link-path.js.map +1 -1
- package/es/link-path/type.js +1 -1
- package/es/marker/area.d.ts +8 -2
- package/es/marker/area.js +14 -3
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -0
- package/es/marker/base.js +11 -7
- package/es/marker/base.js.map +1 -1
- package/es/marker/line.d.ts +8 -1
- package/es/marker/line.js +15 -3
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +7 -4
- package/es/marker/point.js +8 -3
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +16 -16
- package/es/marker/type.js.map +1 -1
- package/es/pager/pager.d.ts +2 -1
- package/es/pager/pager.js +5 -5
- package/es/pager/pager.js.map +1 -1
- package/es/pager/type.d.ts +1 -0
- package/es/pager/type.js.map +1 -1
- package/es/player/base-player.d.ts +2 -1
- package/es/player/base-player.js +7 -5
- package/es/player/base-player.js.map +1 -1
- package/es/player/continuous-player.js +2 -2
- package/es/player/continuous-player.js.map +1 -1
- package/es/player/controller/controller.d.ts +2 -1
- package/es/player/controller/controller.js +5 -5
- package/es/player/controller/controller.js.map +1 -1
- package/es/player/controller/type.d.ts +1 -0
- package/es/player/controller/type.js.map +1 -1
- package/es/player/discrete-player.d.ts +2 -1
- package/es/player/discrete-player.js +5 -4
- package/es/player/discrete-player.js.map +1 -1
- package/es/player/type/base.d.ts +1 -0
- package/es/player/type/base.js.map +1 -1
- package/es/poptip/poptip-plugin.d.ts +1 -0
- package/es/poptip/poptip-plugin.js +6 -3
- package/es/poptip/poptip-plugin.js.map +1 -1
- package/es/poptip/poptip.d.ts +2 -1
- package/es/poptip/poptip.js +3 -2
- package/es/poptip/poptip.js.map +1 -1
- package/es/scrollbar/scrollbar.d.ts +6 -1
- package/es/scrollbar/scrollbar.js +42 -20
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/scrollbar/type.d.ts +5 -1
- package/es/scrollbar/type.js.map +1 -1
- package/es/segment/segment.d.ts +2 -1
- package/es/segment/segment.js +7 -5
- package/es/segment/segment.js.map +1 -1
- package/es/segment/type.d.ts +6 -2
- package/es/segment/type.js.map +1 -1
- package/es/slider/slider.d.ts +2 -1
- package/es/slider/slider.js +29 -23
- package/es/slider/slider.js.map +1 -1
- package/es/slider/type.d.ts +1 -0
- package/es/slider/type.js.map +1 -1
- package/es/tag/tag.d.ts +2 -1
- package/es/tag/tag.js +89 -40
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.d.ts +4 -5
- package/es/tag/type.js.map +1 -1
- package/es/title/title.d.ts +2 -1
- package/es/title/title.js +91 -55
- package/es/title/title.js.map +1 -1
- package/es/title/type.d.ts +10 -5
- package/es/title/type.js.map +1 -1
- package/es/tooltip/tooltip.d.ts +2 -1
- package/es/tooltip/tooltip.js +55 -15
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +7 -2
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.js +9 -1
- package/es/tooltip/util.js.map +1 -1
- package/es/util/label-smartInvert.d.ts +2 -2
- package/es/util/label-smartInvert.js +9 -5
- package/es/util/label-smartInvert.js.map +1 -1
- package/package.json +8 -8
package/es/label/dataLabel.js
CHANGED
|
@@ -12,17 +12,28 @@ import { ArcLabel } from "./arc";
|
|
|
12
12
|
|
|
13
13
|
import { LabelBase as PointLabel } from "./base";
|
|
14
14
|
|
|
15
|
+
import { LineDataLabel } from "./line-data";
|
|
16
|
+
|
|
17
|
+
import { LineLabel } from "./line";
|
|
18
|
+
|
|
19
|
+
import { AreaLabel } from "./area";
|
|
20
|
+
|
|
15
21
|
const labelComponentMap = {
|
|
16
22
|
rect: RectLabel,
|
|
17
23
|
symbol: SymbolLabel,
|
|
18
|
-
arc: ArcLabel
|
|
24
|
+
arc: ArcLabel,
|
|
25
|
+
line: LineLabel,
|
|
26
|
+
area: AreaLabel,
|
|
27
|
+
"line-data": LineDataLabel
|
|
19
28
|
};
|
|
20
29
|
|
|
21
30
|
export class DataLabel extends AbstractComponent {
|
|
22
|
-
constructor(attributes) {
|
|
23
|
-
super(merge({}, DataLabel.defaultAttributes, attributes)),
|
|
31
|
+
constructor(attributes, options) {
|
|
32
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DataLabel.defaultAttributes, attributes)),
|
|
33
|
+
this.name = "data-label";
|
|
24
34
|
}
|
|
25
35
|
render() {
|
|
36
|
+
var _a;
|
|
26
37
|
const {dataLabels: dataLabels, size: size} = this.attribute;
|
|
27
38
|
if (!dataLabels || 0 === dataLabels.length) return;
|
|
28
39
|
const {width: width = 0, height: height = 0} = size || {};
|
|
@@ -32,12 +43,12 @@ export class DataLabel extends AbstractComponent {
|
|
|
32
43
|
for (let i = 0; i < dataLabels.length; i++) {
|
|
33
44
|
const dataLabel = dataLabels[i], labelComponent = labelComponentMap[dataLabel.type] || PointLabel;
|
|
34
45
|
if (labelComponent) {
|
|
35
|
-
const {baseMarkGroupName: baseMarkGroupName} = dataLabel
|
|
36
|
-
let component = this._componentMap.get(
|
|
46
|
+
const {baseMarkGroupName: baseMarkGroupName, type: type} = dataLabel, id = null !== (_a = dataLabel.id) && void 0 !== _a ? _a : `${baseMarkGroupName}-${type}-${i}`;
|
|
47
|
+
let component = this._componentMap.get(id);
|
|
37
48
|
component ? (component.setBitmapTool(tool), component.setBitmap(bitmap), component.setAttributes(dataLabel),
|
|
38
|
-
currentComponentMap.set(
|
|
49
|
+
currentComponentMap.set(id, component)) : (component = new labelComponent(dataLabel),
|
|
39
50
|
component.setBitmap(bitmap), component.setBitmapTool(tool), this.add(component),
|
|
40
|
-
currentComponentMap.set(
|
|
51
|
+
currentComponentMap.set(id, component));
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
prevComponentMap.forEach(((cp, key) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/dataLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OA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B,CAAC","file":"dataLabel.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport type { IGraphic, INode } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { PointLocationCfg } from '../core/type';\nimport { bitmapTool } from './overlap';\nimport { RectLabel } from './rect';\nimport { SymbolLabel } from './symbol';\nimport { ArcLabel } from './arc';\nimport type { DataLabelAttrs } from './type';\nimport type { LabelBase } from './base';\nimport { LabelBase as PointLabel } from './base';\nimport { LineDataLabel } from './line-data';\nimport { LineLabel } from './line';\nimport { AreaLabel } from './area';\nimport type { ComponentOptions } from '../interface';\n\nconst labelComponentMap = {\n rect: RectLabel,\n symbol: SymbolLabel,\n arc: ArcLabel,\n line: LineLabel,\n area: AreaLabel,\n 'line-data': LineDataLabel\n};\n\nexport class DataLabel extends AbstractComponent<DataLabelAttrs> {\n name = 'data-label';\n\n private _componentMap: Map<string, LabelBase<any>>;\n\n private static defaultAttributes: Partial<DataLabelAttrs> = {\n pickable: false\n };\n\n constructor(attributes: DataLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, DataLabel.defaultAttributes, attributes));\n }\n\n protected render(): void {\n const { dataLabels, size } = this.attribute;\n if (!dataLabels || dataLabels.length === 0) {\n return;\n }\n const { width = 0, height = 0 } = size || {};\n\n if (!width || !height || !isValidNumber(height * width)) {\n return;\n }\n\n if (!this._componentMap) {\n this._componentMap = new Map();\n }\n const tool = bitmapTool(width, height);\n const bitmap = tool.bitmap();\n\n const currentComponentMap = new Map();\n const prevComponentMap = this._componentMap;\n\n for (let i = 0; i < dataLabels.length; i++) {\n const dataLabel = dataLabels[i];\n const labelComponent = labelComponentMap[dataLabel.type] || PointLabel;\n if (labelComponent) {\n const { baseMarkGroupName, type } = dataLabel;\n const id = dataLabel.id ?? `${baseMarkGroupName}-${type}-${i}`;\n\n let component = this._componentMap.get(id);\n if (component) {\n component.setBitmapTool(tool);\n component.setBitmap(bitmap);\n component.setAttributes(dataLabel);\n currentComponentMap.set(id, component);\n } else {\n component = new labelComponent(dataLabel as any);\n component.setBitmap(bitmap);\n component.setBitmapTool(tool);\n this.add(component as unknown as INode);\n currentComponentMap.set(id, component);\n }\n }\n }\n\n prevComponentMap.forEach((cp, key) => {\n if (!currentComponentMap.get(key)) {\n this.removeChild(cp as unknown as IGraphic);\n }\n });\n\n this._componentMap = currentComponentMap;\n }\n\n setLocation(point: PointLocationCfg) {\n this.translateTo(point.x, point.y);\n }\n\n disableAnimation() {\n this._componentMap.forEach(component => {\n component.disableAnimation();\n });\n }\n\n enableAnimation() {\n this._componentMap.forEach(component => {\n component.enableAnimation();\n });\n }\n}\n"]}
|
package/es/label/index.d.ts
CHANGED
package/es/label/index.js
CHANGED
package/es/label/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/label/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAE5B,cAAc,aAAa,CAAC","file":"index.js","sourcesContent":["export * from './type';\nexport * from './symbol';\nexport * from './rect';\nexport * from './line';\nexport * from './base';\nexport * from './arc';\nexport * from './area';\nexport * from './line-data';\n\nexport * from './dataLabel';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IBoundsLike } from '@visactor/vutils';
|
|
2
|
+
import type { LineDataLabelAttrs } from './type';
|
|
3
|
+
import { LabelBase } from './base';
|
|
4
|
+
import type { ComponentOptions } from '../interface';
|
|
5
|
+
export declare class LineDataLabel extends LabelBase<LineDataLabelAttrs> {
|
|
6
|
+
name: string;
|
|
7
|
+
static defaultAttributes: Partial<LineDataLabelAttrs>;
|
|
8
|
+
constructor(attributes: LineDataLabelAttrs, options?: ComponentOptions);
|
|
9
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { merge } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { LabelBase } from "./base";
|
|
4
|
+
|
|
5
|
+
import { labelingPoint } from "./util";
|
|
6
|
+
|
|
7
|
+
export class LineDataLabel extends LabelBase {
|
|
8
|
+
constructor(attributes, options) {
|
|
9
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, LineDataLabel.defaultAttributes, attributes)),
|
|
10
|
+
this.name = "line-data-label";
|
|
11
|
+
}
|
|
12
|
+
labeling(textBounds, graphicBounds, position = "top", offset = 0) {
|
|
13
|
+
return labelingPoint(textBounds, graphicBounds, position, offset);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
LineDataLabel.defaultAttributes = {
|
|
18
|
+
textStyle: {
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
fill: "#000",
|
|
21
|
+
textAlign: "center",
|
|
22
|
+
textBaseline: "middle",
|
|
23
|
+
boundsPadding: [ -1, 0, -1, 0 ]
|
|
24
|
+
},
|
|
25
|
+
position: "top",
|
|
26
|
+
offset: 5,
|
|
27
|
+
pickable: !1
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=line-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/line-data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,OAAO,aAAc,SAAQ,SAA6B;IAgB9D,YAAY,UAA8B,EAAE,OAA0B;QACpE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,aAAa,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAhBpG,SAAI,GAAG,iBAAiB,CAAC;IAiBzB,CAAC;IAES,QAAQ,CAAC,UAAuB,EAAE,aAA0B,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC;QAClG,OAAO,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;;AAnBM,+BAAiB,GAAgC;IACtD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"line-data.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { LineDataLabelAttrs } from './type';\nimport { LabelBase } from './base';\nimport { labelingPoint } from './util';\nimport type { ComponentOptions } from '../interface';\n\nexport class LineDataLabel extends LabelBase<LineDataLabelAttrs> {\n name = 'line-data-label';\n\n static defaultAttributes: Partial<LineDataLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: LineDataLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, LineDataLabel.defaultAttributes, attributes));\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\n return labelingPoint(textBounds, graphicBounds, position, offset);\n }\n}\n"]}
|
package/es/label/line.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import type { ILine } from '@visactor/vrender-core';
|
|
|
3
3
|
import type { PointLocationCfg } from '../core/type';
|
|
4
4
|
import type { LineLabelAttrs } from './type';
|
|
5
5
|
import { LabelBase } from './base';
|
|
6
|
+
import type { ComponentOptions } from '../interface';
|
|
6
7
|
export declare class LineLabel extends LabelBase<LineLabelAttrs> {
|
|
7
8
|
name: string;
|
|
8
9
|
static defaultAttributes: Partial<LineLabelAttrs>;
|
|
9
|
-
constructor(attributes: LineLabelAttrs);
|
|
10
|
-
protected getGraphicBounds(graphic: ILine, point?: Partial<PointLocationCfg
|
|
11
|
-
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?:
|
|
10
|
+
constructor(attributes: LineLabelAttrs, options?: ComponentOptions);
|
|
11
|
+
protected getGraphicBounds(graphic: ILine, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
|
|
12
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
12
13
|
x: number;
|
|
13
14
|
y: number;
|
|
14
15
|
};
|
package/es/label/line.js
CHANGED
|
@@ -2,14 +2,17 @@ import { merge } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { LabelBase } from "./base";
|
|
4
4
|
|
|
5
|
+
import { labelingLineOrArea } from "./util";
|
|
6
|
+
|
|
5
7
|
export class LineLabel extends LabelBase {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
super(merge({}, LineLabel.defaultAttributes, attributes)),
|
|
8
|
+
constructor(attributes, options) {
|
|
9
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, LineLabel.defaultAttributes, attributes)),
|
|
10
|
+
this.name = "line-label";
|
|
8
11
|
}
|
|
9
|
-
getGraphicBounds(graphic, point = {}) {
|
|
12
|
+
getGraphicBounds(graphic, point = {}, position = "end") {
|
|
10
13
|
var _a;
|
|
11
|
-
if ("line" !== graphic.type) return super.getGraphicBounds(graphic, point);
|
|
12
|
-
const
|
|
14
|
+
if (!graphic || "line" !== graphic.type) return super.getGraphicBounds(graphic, point);
|
|
15
|
+
const points = (null === (_a = null == graphic ? void 0 : graphic.attribute) || void 0 === _a ? void 0 : _a.points) || [ point ], index = "start" === position ? 0 : points.length - 1;
|
|
13
16
|
return {
|
|
14
17
|
x1: points[index].x,
|
|
15
18
|
x2: points[index].x,
|
|
@@ -18,14 +21,7 @@ export class LineLabel extends LabelBase {
|
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
labeling(textBounds, graphicBounds, position = "end", offset = 0) {
|
|
21
|
-
|
|
22
|
-
const {x1: x1, x2: x2} = textBounds, width = Math.abs(x2 - x1), anchorX = graphicBounds.x1;
|
|
23
|
-
let x = anchorX;
|
|
24
|
-
return "end" === position ? x = anchorX + width / 2 + offset : "start" === position && (x = anchorX - width / 2 - offset),
|
|
25
|
-
{
|
|
26
|
-
x: x,
|
|
27
|
-
y: graphicBounds.y1
|
|
28
|
-
};
|
|
24
|
+
return labelingLineOrArea(textBounds, graphicBounds, position, offset);
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
|
package/es/label/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/label/line.ts"],"names":[],"mapp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EAAE,MAAM,GAAG,CAAC;QAC1G,OAAO,kBAAkB,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;;AAjCM,2BAAiB,GAA4B;IAClD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"line.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { ILine } from '@visactor/vrender-core';\nimport type { PointLocationCfg } from '../core/type';\nimport type { LineLabelAttrs } from './type';\nimport { LabelBase } from './base';\nimport { labelingLineOrArea } from './util';\nimport type { ComponentOptions } from '../interface';\n\nexport class LineLabel extends LabelBase<LineLabelAttrs> {\n name = 'line-label';\n\n static defaultAttributes: Partial<LineLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'end',\n offset: 6,\n pickable: false\n };\n\n constructor(attributes: LineLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, LineLabel.defaultAttributes, attributes));\n }\n\n protected getGraphicBounds(graphic: ILine, point: Partial<PointLocationCfg> = {}, position = 'end') {\n if (!graphic || graphic.type !== 'line') {\n return super.getGraphicBounds(graphic, point);\n }\n const points = graphic?.attribute?.points || [point];\n const index = position === 'start' ? 0 : points.length - 1;\n return {\n x1: points[index].x as number,\n x2: points[index].x as number,\n y1: points[index].y as number,\n y2: points[index].y as number\n };\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position: string = 'end', offset = 0) {\n return labelingLineOrArea(textBounds, graphicBounds, position, offset);\n }\n}\n"]}
|
package/es/label/polygon.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { IBoundsLike } from '@visactor/vutils';
|
|
2
2
|
import type { PolygonLabelAttrs } from './type';
|
|
3
3
|
import { LabelBase } from './base';
|
|
4
|
+
import type { ComponentOptions } from '../interface';
|
|
4
5
|
export declare class PolygonLabel extends LabelBase<PolygonLabelAttrs> {
|
|
5
6
|
name: string;
|
|
6
7
|
static defaultAttributes: Partial<PolygonLabelAttrs>;
|
|
7
|
-
constructor(attributes: PolygonLabelAttrs);
|
|
8
|
+
constructor(attributes: PolygonLabelAttrs, options?: ComponentOptions);
|
|
8
9
|
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: PolygonLabelAttrs['position'], offset?: number): {
|
|
9
10
|
x: number;
|
|
10
11
|
y: number;
|
package/es/label/polygon.js
CHANGED
|
@@ -3,8 +3,9 @@ import { merge } from "@visactor/vutils";
|
|
|
3
3
|
import { LabelBase } from "./base";
|
|
4
4
|
|
|
5
5
|
export class PolygonLabel extends LabelBase {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
super(merge({}, PolygonLabel.defaultAttributes, attributes)),
|
|
6
|
+
constructor(attributes, options) {
|
|
7
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, PolygonLabel.defaultAttributes, attributes)),
|
|
8
|
+
this.name = "polygon-label";
|
|
8
9
|
}
|
|
9
10
|
labeling(textBounds, graphicBounds, position = "center", offset = 0) {
|
|
10
11
|
if (!textBounds || !graphicBounds) return;
|
package/es/label/polygon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/polygon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|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":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { PolygonLabelAttrs } from './type';\nimport { LabelBase } from './base';\nimport type { ComponentOptions } from '../interface';\n\nexport class PolygonLabel extends LabelBase<PolygonLabelAttrs> {\n name = 'polygon-label';\n\n static defaultAttributes: Partial<PolygonLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'center',\n offset: 6,\n pickable: false\n };\n\n constructor(attributes: PolygonLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, PolygonLabel.defaultAttributes, attributes));\n }\n\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position: PolygonLabelAttrs['position'] = 'center',\n offset = 0\n ) {\n if (!textBounds || !graphicBounds) {\n return;\n }\n\n const { x1, x2, y2, y1 } = textBounds;\n\n const x = (x1 + x2) / 2;\n const y = (y1 + y2) / 2;\n\n return { x, y };\n }\n}\n"]}
|
package/es/label/rect.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { IBoundsLike } from '@visactor/vutils';
|
|
2
2
|
import type { RectLabelAttrs } from './type';
|
|
3
3
|
import { LabelBase } from './base';
|
|
4
|
+
import type { ComponentOptions } from '../interface';
|
|
4
5
|
export declare class RectLabel extends LabelBase<RectLabelAttrs> {
|
|
5
6
|
static tag: string;
|
|
6
7
|
static defaultAttributes: Partial<RectLabelAttrs>;
|
|
7
|
-
constructor(attributes: RectLabelAttrs);
|
|
8
|
+
constructor(attributes: RectLabelAttrs, options?: ComponentOptions);
|
|
8
9
|
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
9
10
|
x: number;
|
|
10
11
|
y: number;
|
package/es/label/rect.js
CHANGED
|
@@ -3,8 +3,8 @@ import { merge } from "@visactor/vutils";
|
|
|
3
3
|
import { LabelBase } from "./base";
|
|
4
4
|
|
|
5
5
|
export class RectLabel extends LabelBase {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
super(merge({}, RectLabel.defaultAttributes, attributes));
|
|
6
|
+
constructor(attributes, options) {
|
|
7
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, RectLabel.defaultAttributes, attributes));
|
|
8
8
|
}
|
|
9
9
|
labeling(textBounds, graphicBounds, position = "top", offset = 0) {
|
|
10
10
|
if (!textBounds || !graphicBounds) return;
|
|
@@ -29,11 +29,37 @@ export class RectLabel extends LabelBase {
|
|
|
29
29
|
case "right":
|
|
30
30
|
case "inside-right":
|
|
31
31
|
sx = .5;
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case "top-right":
|
|
35
|
+
sx = .5, sy = -.5;
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case "top-left":
|
|
39
|
+
sx = -.5, sy = -.5;
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case "bottom-right":
|
|
43
|
+
sx = .5, sy = .5;
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case "bottom-left":
|
|
47
|
+
sx = -.5, sy = .5;
|
|
32
48
|
}
|
|
33
49
|
anchorX += sx * rectWidth, anchorY += sy * rectHeight;
|
|
34
50
|
let vx = 0, vy = 0;
|
|
35
51
|
const isInside = position.includes("inside");
|
|
36
|
-
position.includes("top") ? vy = isInside ? 1 : -1 : position.includes("bottom") ? vy = isInside ? -1 : 1 : position.includes("left") ? vx = isInside ? 1 : -1 : position.includes("right") && (vx = isInside ? -1 : 1)
|
|
52
|
+
switch (position.includes("top") ? vy = isInside ? 1 : -1 : position.includes("bottom") ? vy = isInside ? -1 : 1 : position.includes("left") ? vx = isInside ? 1 : -1 : position.includes("right") && (vx = isInside ? -1 : 1),
|
|
53
|
+
position) {
|
|
54
|
+
case "top-right":
|
|
55
|
+
case "bottom-right":
|
|
56
|
+
vx = -1;
|
|
57
|
+
break;
|
|
58
|
+
|
|
59
|
+
case "top-left":
|
|
60
|
+
case "bottom-left":
|
|
61
|
+
vx = 1;
|
|
62
|
+
}
|
|
37
63
|
return {
|
|
38
64
|
x: anchorX + vx * offset + vx * width / 2,
|
|
39
65
|
y: anchorY + vy * offset + vy * height / 2
|
package/es/label/rect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/rect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/label/rect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,MAAM,OAAO,SAAU,SAAQ,SAAyB;IAgBtD,YAAY,UAA0B,EAAE,OAA0B;QAChE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAChG,CAAC;IAES,QAAQ,CAAC,UAAuB,EAAE,aAA0B,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC;QAClG,IAAI,CAAC,UAAU,IAAI,CAAC,aAAa,EAAE;YACjC,OAAO;SACR;QAED,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,UAAU,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAEjC,MAAM,SAAS,GAAG,IAAI,CAA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CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;;AAzGM,aAAG,GAAG,YAAY,CAAC;AAEnB,2BAAiB,GAA4B;IAClD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"rect.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { RectLabelAttrs } from './type';\nimport { LabelBase } from './base';\nimport type { ComponentOptions } from '../interface';\n\nexport class RectLabel extends LabelBase<RectLabelAttrs> {\n static tag = 'rect-label';\n\n static defaultAttributes: Partial<RectLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: RectLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, RectLabel.defaultAttributes, attributes));\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\n if (!textBounds || !graphicBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const rectWidth = Math.abs(graphicBounds.x2 - graphicBounds.x1);\n const rectHeight = Math.abs(graphicBounds.y2 - graphicBounds.y1);\n let anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n let anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n\n switch (position) {\n case 'top':\n case 'inside-top':\n sy = -0.5;\n break;\n case 'bottom':\n case 'inside-bottom':\n sy = 0.5;\n break;\n case 'left':\n case 'inside-left':\n sx = -0.5;\n break;\n case 'right':\n case 'inside-right':\n sx = 0.5;\n break;\n case 'top-right':\n sx = 0.5;\n sy = -0.5;\n break;\n case 'top-left':\n sx = -0.5;\n sy = -0.5;\n break;\n case 'bottom-right':\n sx = 0.5;\n sy = 0.5;\n break;\n case 'bottom-left':\n sx = -0.5;\n sy = 0.5;\n }\n\n anchorX += sx * rectWidth;\n anchorY += sy * rectHeight;\n\n let vx = 0;\n let vy = 0;\n\n const isInside = position.includes('inside');\n\n if (position.includes('top')) {\n vy = isInside ? 1 : -1;\n } else if (position.includes('bottom')) {\n vy = isInside ? -1 : 1;\n } else if (position.includes('left')) {\n vx = isInside ? 1 : -1;\n } else if (position.includes('right')) {\n vx = isInside ? -1 : 1;\n }\n\n switch (position) {\n case 'top-right':\n case 'bottom-right':\n vx = -1;\n break;\n case 'top-left':\n case 'bottom-left':\n vx = 1;\n break;\n default:\n break;\n }\n\n const x = anchorX + vx * offset + (vx * width) / 2;\n const y = anchorY + vy * offset + (vy * height) / 2;\n\n return { x, y };\n }\n}\n"]}
|
package/es/label/symbol.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { IBoundsLike } from '@visactor/vutils';
|
|
2
2
|
import type { SymbolLabelAttrs } from './type';
|
|
3
3
|
import { LabelBase } from './base';
|
|
4
|
+
import type { ComponentOptions } from '../interface';
|
|
4
5
|
export declare class SymbolLabel extends LabelBase<SymbolLabelAttrs> {
|
|
5
6
|
name: string;
|
|
6
7
|
static defaultAttributes: Partial<SymbolLabelAttrs>;
|
|
7
|
-
constructor(attributes: SymbolLabelAttrs);
|
|
8
|
+
constructor(attributes: SymbolLabelAttrs, options?: ComponentOptions);
|
|
8
9
|
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
9
10
|
x: number;
|
|
10
11
|
y: number;
|
package/es/label/symbol.js
CHANGED
|
@@ -2,52 +2,15 @@ import { merge } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { LabelBase } from "./base";
|
|
4
4
|
|
|
5
|
+
import { labelingPoint } from "./util";
|
|
6
|
+
|
|
5
7
|
export class SymbolLabel extends LabelBase {
|
|
6
|
-
constructor(attributes) {
|
|
7
|
-
super(merge({}, SymbolLabel.defaultAttributes, attributes)),
|
|
8
|
+
constructor(attributes, options) {
|
|
9
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, SymbolLabel.defaultAttributes, attributes)),
|
|
10
|
+
this.name = "symbol-label";
|
|
8
11
|
}
|
|
9
12
|
labeling(textBounds, graphicBounds, position = "top", offset = 0) {
|
|
10
|
-
|
|
11
|
-
const {x1: x1, y1: y1, x2: x2, y2: y2} = textBounds, width = Math.abs(x2 - x1), height = Math.abs(y2 - y1), anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2, anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;
|
|
12
|
-
let sx = 0, sy = 0, offsetX = 0, offsetY = 0;
|
|
13
|
-
graphicBounds && (offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2, offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2);
|
|
14
|
-
const angle = {
|
|
15
|
-
"top-right": -235,
|
|
16
|
-
"top-left": 235,
|
|
17
|
-
"bottom-right": 45,
|
|
18
|
-
"bottom-left": -45
|
|
19
|
-
};
|
|
20
|
-
switch (position) {
|
|
21
|
-
case "top":
|
|
22
|
-
sy = -1;
|
|
23
|
-
break;
|
|
24
|
-
|
|
25
|
-
case "bottom":
|
|
26
|
-
sy = 1;
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
case "left":
|
|
30
|
-
sx = -1;
|
|
31
|
-
break;
|
|
32
|
-
|
|
33
|
-
case "right":
|
|
34
|
-
sx = 1;
|
|
35
|
-
break;
|
|
36
|
-
|
|
37
|
-
case "bottom-left":
|
|
38
|
-
case "bottom-right":
|
|
39
|
-
case "top-left":
|
|
40
|
-
case "top-right":
|
|
41
|
-
sx = Math.sin(angle[position] * (Math.PI / 180)), sy = Math.cos(angle[position] * (Math.PI / 180));
|
|
42
|
-
break;
|
|
43
|
-
|
|
44
|
-
case "center":
|
|
45
|
-
sx = 0, sy = 0;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
x: anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2),
|
|
49
|
-
y: anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2)
|
|
50
|
-
};
|
|
13
|
+
return labelingPoint(textBounds, graphicBounds, position, offset);
|
|
51
14
|
}
|
|
52
15
|
}
|
|
53
16
|
|
package/es/label/symbol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/symbol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/label/symbol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,OAAO,WAAY,SAAQ,SAA2B;IAgB1D,YAAY,UAA4B,EAAE,OAA0B;QAClE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,WAAW,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAhBlG,SAAI,GAAG,cAAc,CAAC;IAiBtB,CAAC;IAES,QAAQ,CAAC,UAAuB,EAAE,aAA0B,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC;QAClG,OAAO,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;;AAnBM,6BAAiB,GAA8B;IACpD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"symbol.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { SymbolLabelAttrs } from './type';\nimport { LabelBase } from './base';\nimport { labelingPoint } from './util';\nimport type { ComponentOptions } from '../interface';\n\nexport class SymbolLabel extends LabelBase<SymbolLabelAttrs> {\n name = 'symbol-label';\n\n static defaultAttributes: Partial<SymbolLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: SymbolLabelAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, SymbolLabel.defaultAttributes, attributes));\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\n return labelingPoint(textBounds, graphicBounds, position, offset);\n }\n}\n"]}
|
package/es/label/type.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import type { EasingType, IGraphic, IGroupGraphicAttribute, ITextGraphicAttribute, Text, TextAlignType, TextBaselineType, ILineGraphicAttribute } from '@visactor/vrender-core';
|
|
1
|
+
import type { EasingType, IGraphic, IGroupGraphicAttribute, ITextGraphicAttribute, IRichTextGraphicAttribute, Text, TextAlignType, TextBaselineType, ILineGraphicAttribute, IRichTextCharacter, RichText } from '@visactor/vrender-core';
|
|
2
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
3
|
export type LabelItemStateStyle<T> = {
|
|
3
4
|
hover?: T;
|
|
4
5
|
hover_reverse?: T;
|
|
5
6
|
selected?: T;
|
|
6
7
|
selected_reverse?: T;
|
|
8
|
+
[key: string]: T;
|
|
7
9
|
};
|
|
8
10
|
export type LabelItem = {
|
|
9
11
|
id?: string;
|
|
10
12
|
data?: any;
|
|
11
13
|
[key: string]: any;
|
|
12
|
-
|
|
14
|
+
textType?: string;
|
|
15
|
+
text?: string | string[] | number | number[] | IRichTextCharacter[];
|
|
16
|
+
textAlign?: 'left' | 'right' | 'center' | 'start' | 'end';
|
|
17
|
+
textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic';
|
|
18
|
+
} & Omit<Partial<ITextGraphicAttribute>, 'textAlign' | 'textBaseline'> & Omit<Partial<IRichTextGraphicAttribute>, 'textAlign' | 'textBaseline'>;
|
|
13
19
|
export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
14
20
|
type: string;
|
|
15
21
|
baseMarkGroupName: string;
|
|
@@ -19,14 +25,21 @@ export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
|
19
25
|
data: LabelItem[];
|
|
20
26
|
textStyle?: Partial<ITextGraphicAttribute>;
|
|
21
27
|
state?: LabelItemStateStyle<ITextGraphicAttribute>;
|
|
28
|
+
labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;
|
|
29
|
+
syncState?: boolean;
|
|
22
30
|
position?: Functional<string>;
|
|
23
31
|
offset?: number;
|
|
24
32
|
overlap?: OverlapAttrs | false;
|
|
25
33
|
smartInvert?: SmartInvertAttrs | false;
|
|
26
34
|
animation?: ILabelAnimation | false;
|
|
35
|
+
animationEnter?: ILabelUpdateAnimation;
|
|
36
|
+
animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[];
|
|
37
|
+
animationExit?: ILabelExitAnimation;
|
|
27
38
|
dataFilter?: (data: LabelItem[]) => LabelItem[];
|
|
28
|
-
customLayoutFunc?: (data: LabelItem[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];
|
|
29
|
-
customOverlapFunc?: (label: Text[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];
|
|
39
|
+
customLayoutFunc?: (data: LabelItem[], getRelatedGraphic: (data: LabelItem) => IGraphic, getRelatedPoint?: (data: LabelItem) => IPointLike) => (Text | RichText)[];
|
|
40
|
+
customOverlapFunc?: (label: (Text | RichText)[], getRelatedGraphic: (data: LabelItem) => IGraphic, getRelatedPoint?: (data: LabelItem) => IPointLike) => (Text | RichText)[];
|
|
41
|
+
disableTriggerEvent?: boolean;
|
|
42
|
+
id?: string;
|
|
30
43
|
}
|
|
31
44
|
export interface OverlapAttrs {
|
|
32
45
|
size?: {
|
|
@@ -41,6 +54,7 @@ export interface OverlapAttrs {
|
|
|
41
54
|
overlapPadding?: number;
|
|
42
55
|
}
|
|
43
56
|
export interface SmartInvertAttrs {
|
|
57
|
+
mode?: string;
|
|
44
58
|
textType?: string;
|
|
45
59
|
contrastRatiosThreshold?: number;
|
|
46
60
|
alternativeColors?: string | string[];
|
|
@@ -74,12 +88,20 @@ export interface SymbolLabelAttrs extends BaseLabelAttrs {
|
|
|
74
88
|
}
|
|
75
89
|
export interface RectLabelAttrs extends BaseLabelAttrs {
|
|
76
90
|
type: 'rect';
|
|
77
|
-
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left'>;
|
|
91
|
+
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'>;
|
|
78
92
|
}
|
|
79
93
|
export interface LineLabelAttrs extends BaseLabelAttrs {
|
|
80
94
|
type: 'line';
|
|
81
95
|
position?: Functional<'start' | 'end'>;
|
|
82
96
|
}
|
|
97
|
+
export interface AreaLabelAttrs extends BaseLabelAttrs {
|
|
98
|
+
type: 'area';
|
|
99
|
+
position?: Functional<'start' | 'end'>;
|
|
100
|
+
}
|
|
101
|
+
export interface LineDataLabelAttrs extends BaseLabelAttrs {
|
|
102
|
+
type: 'line-data';
|
|
103
|
+
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'>;
|
|
104
|
+
}
|
|
83
105
|
export interface PolygonLabelAttrs extends BaseLabelAttrs {
|
|
84
106
|
type: 'polygon';
|
|
85
107
|
position?: Functional<'center'>;
|
|
@@ -120,20 +142,32 @@ export interface IArcLabelLayoutSpec {
|
|
|
120
142
|
tangentConstraint?: boolean;
|
|
121
143
|
}
|
|
122
144
|
export interface DataLabelAttrs extends IGroupGraphicAttribute {
|
|
123
|
-
dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs)[];
|
|
145
|
+
dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];
|
|
124
146
|
size: {
|
|
125
147
|
width: number;
|
|
126
148
|
height: number;
|
|
127
149
|
};
|
|
128
150
|
}
|
|
129
151
|
export type Functional<T> = T | ((data: any) => T);
|
|
130
|
-
export interface
|
|
131
|
-
mode?: 'same-time' | 'after' | 'after-all';
|
|
152
|
+
export interface ILabelExitAnimation {
|
|
132
153
|
duration?: number;
|
|
133
154
|
delay?: number;
|
|
134
155
|
easing?: EasingType;
|
|
156
|
+
}
|
|
157
|
+
export interface ILabelEnterAnimation extends ILabelExitAnimation {
|
|
158
|
+
mode?: 'same-time' | 'after' | 'after-all';
|
|
159
|
+
}
|
|
160
|
+
export interface ILabelUpdateAnimation extends ILabelExitAnimation {
|
|
135
161
|
increaseEffect?: boolean;
|
|
136
162
|
}
|
|
163
|
+
export interface ILabelUpdateChannelAnimation extends ILabelUpdateAnimation {
|
|
164
|
+
channel?: string[];
|
|
165
|
+
options?: {
|
|
166
|
+
excludeChannels?: string[];
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export interface ILabelAnimation extends ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation {
|
|
170
|
+
}
|
|
137
171
|
export interface IPoint {
|
|
138
172
|
x: number;
|
|
139
173
|
y: number;
|
package/es/label/type.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { };
|
|
2
|
-
//# sourceMappingURL=type.js.map
|
|
1
|
+
export { };
|