@visactor/vrender-components 0.15.0-alpha.6 → 0.15.1
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/animate/group-fade.js.map +1 -1
- package/cjs/axis/animate/group-transition.js.map +1 -1
- package/cjs/axis/animate/index.js.map +1 -1
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/config.js.map +1 -1
- package/cjs/axis/constant.js.map +1 -1
- package/cjs/axis/grid/base.js.map +1 -1
- package/cjs/axis/grid/circle.js.map +1 -1
- package/cjs/axis/grid/index.js.map +1 -1
- package/cjs/axis/grid/line.js.map +1 -1
- package/cjs/axis/grid/type.js.map +1 -1
- package/cjs/axis/index.js.map +1 -1
- package/cjs/axis/line.js +50 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/mixin/circle.js.map +1 -1
- package/cjs/axis/mixin/line.js.map +1 -1
- 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 +2 -2
- package/cjs/axis/overlap/auto-rotate.js.map +1 -1
- package/cjs/axis/type.d.ts +1 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.d.ts +1 -0
- package/cjs/brush/brush.js +5 -0
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/brush/config.js.map +1 -1
- package/cjs/brush/index.js.map +1 -1
- package/cjs/brush/type.js.map +1 -1
- package/cjs/constant.js.map +1 -1
- package/cjs/core/base.d.ts +2 -1
- package/cjs/core/base.js +4 -2
- package/cjs/core/base.js.map +1 -1
- package/cjs/core/type.js.map +1 -1
- package/cjs/crosshair/base.js.map +1 -1
- package/cjs/crosshair/circle.js.map +1 -1
- package/cjs/crosshair/index.js.map +1 -1
- package/cjs/crosshair/line.js.map +1 -1
- package/cjs/crosshair/polygon.js.map +1 -1
- package/cjs/crosshair/rect.js.map +1 -1
- package/cjs/crosshair/sector.js.map +1 -1
- package/cjs/crosshair/type.js.map +1 -1
- package/cjs/data-zoom/config.js.map +1 -1
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/data-zoom/index.js.map +1 -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.map +1 -1
- package/cjs/indicator/index.js.map +1 -1
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/jsx/component-type.js.map +1 -1
- package/cjs/jsx/index.js.map +1 -1
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/animate/index.js.map +1 -1
- package/cjs/label/arc.d.ts +12 -5
- package/cjs/label/arc.js +83 -41
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +12 -9
- package/cjs/label/base.js +126 -140
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +4 -4
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/index.js.map +1 -1
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/overlap/bitmap.js.map +1 -1
- package/cjs/label/overlap/index.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +2 -2
- package/cjs/label/overlap/place.js +15 -8
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/cjs/label/polygon.d.ts +12 -0
- package/cjs/label/polygon.js +35 -0
- package/cjs/label/polygon.js.map +1 -0
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/symbol.js.map +1 -1
- package/cjs/label/type.d.ts +9 -5
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.js.map +1 -1
- package/cjs/legend/base.js.map +1 -1
- package/cjs/legend/color/color.js.map +1 -1
- package/cjs/legend/color/index.js.map +1 -1
- package/cjs/legend/color/type.js.map +1 -1
- package/cjs/legend/constant.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +28 -27
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/index.js.map +1 -1
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/legend/index.js.map +1 -1
- package/cjs/legend/size/index.js.map +1 -1
- package/cjs/legend/size/size.d.ts +2 -2
- package/cjs/legend/size/size.js.map +1 -1
- package/cjs/legend/size/type.js.map +1 -1
- package/cjs/legend/type.js.map +1 -1
- package/cjs/link-path/index.js +1 -2
- package/cjs/link-path/index.js.map +1 -1
- package/cjs/link-path/link-path.js +2 -1
- package/cjs/link-path/link-path.js.map +1 -1
- package/cjs/link-path/type.js.map +1 -1
- package/cjs/marker/area.d.ts +1 -20
- package/cjs/marker/area.js +37 -37
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -0
- package/cjs/marker/base.js +28 -18
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/config.d.ts +1 -1
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/index.js.map +1 -1
- package/cjs/marker/line.js +31 -16
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +7 -7
- package/cjs/marker/point.js +6 -5
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +8 -5
- package/cjs/marker/type.js.map +1 -1
- package/cjs/marker/util.d.ts +1 -0
- package/cjs/marker/util.js +3 -0
- package/cjs/marker/util.js.map +1 -0
- package/cjs/pager/index.js.map +1 -1
- package/cjs/pager/pager.js +4 -2
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/pager/type.js.map +1 -1
- package/cjs/player/base-player.d.ts +9 -1
- package/cjs/player/base-player.js +25 -22
- package/cjs/player/base-player.js.map +1 -1
- package/cjs/player/constant.d.ts +1 -0
- package/cjs/player/constant.js +1 -0
- package/cjs/player/constant.js.map +1 -1
- package/cjs/player/continuous-player.js +6 -6
- package/cjs/player/continuous-player.js.map +1 -1
- package/cjs/player/controller/assets/index.js.map +1 -1
- package/cjs/player/controller/constant.js.map +1 -1
- package/cjs/player/controller/controller.d.ts +2 -2
- package/cjs/player/controller/controller.js +15 -7
- package/cjs/player/controller/controller.js.map +1 -1
- package/cjs/player/controller/icon/icon.js.map +1 -1
- package/cjs/player/controller/icon/index.js.map +1 -1
- package/cjs/player/controller/icon/type.js.map +1 -1
- package/cjs/player/controller/index.js.map +1 -1
- package/cjs/player/controller/type.d.ts +14 -6
- package/cjs/player/controller/type.js.map +1 -1
- package/cjs/player/discrete-player.js +11 -11
- package/cjs/player/discrete-player.js.map +1 -1
- package/cjs/player/index.js.map +1 -1
- package/cjs/player/type/base.js.map +1 -1
- package/cjs/player/type/continuous-player.d.ts +2 -2
- package/cjs/player/type/continuous-player.js.map +1 -1
- package/cjs/player/type/direction.js.map +1 -1
- package/cjs/player/type/discrete-player.js.map +1 -1
- package/cjs/player/type/event.d.ts +12 -6
- package/cjs/player/type/event.js +5 -3
- package/cjs/player/type/event.js.map +1 -1
- package/cjs/player/type/index.js.map +1 -1
- package/cjs/player/type/layout.d.ts +5 -2
- package/cjs/player/type/layout.js.map +1 -1
- package/cjs/player/utils.js.map +1 -1
- package/cjs/poptip/contribution.js +3 -1
- package/cjs/poptip/contribution.js.map +1 -1
- package/cjs/poptip/index.js.map +1 -1
- package/cjs/poptip/poptip-plugin.js.map +1 -1
- package/cjs/poptip/poptip.js +30 -11
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/poptip/register.d.ts +1 -1
- package/cjs/poptip/register.js +8 -6
- package/cjs/poptip/register.js.map +1 -1
- package/cjs/poptip/theme.js.map +1 -1
- package/cjs/poptip/type.d.ts +3 -0
- package/cjs/poptip/type.js.map +1 -1
- package/cjs/scrollbar/index.js.map +1 -1
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/scrollbar/type.js.map +1 -1
- package/cjs/segment/index.js.map +1 -1
- package/cjs/segment/segment.d.ts +11 -6
- package/cjs/segment/segment.js +82 -40
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/segment/type.d.ts +5 -3
- package/cjs/segment/type.js.map +1 -1
- package/cjs/slider/constant.js.map +1 -1
- package/cjs/slider/index.js.map +1 -1
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/slider/type.js.map +1 -1
- package/cjs/tag/index.js.map +1 -1
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/index.js.map +1 -1
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/config.js.map +1 -1
- package/cjs/tooltip/index.js.map +1 -1
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.js.map +1 -1
- package/cjs/util/align.js.map +1 -1
- package/cjs/util/common.js.map +1 -1
- package/cjs/util/index.d.ts +1 -1
- package/cjs/util/index.js +1 -1
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/{labelSmartInvert.d.ts → label-smartInvert.d.ts} +1 -0
- package/cjs/util/{labelSmartInvert.js → label-smartInvert.js} +21 -3
- package/cjs/util/label-smartInvert.js.map +1 -0
- package/cjs/util/limit-shape.d.ts +3 -0
- package/cjs/util/limit-shape.js +14 -0
- package/cjs/util/limit-shape.js.map +1 -0
- package/cjs/util/matrix.js.map +1 -1
- package/cjs/util/text.js +3 -3
- package/cjs/util/text.js.map +1 -1
- package/dist/index.js +787 -484
- package/dist/index.min.js +1 -1
- package/es/axis/animate/group-fade.js.map +1 -1
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/animate/index.js.map +1 -1
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.js.map +1 -1
- package/es/axis/config.js.map +1 -1
- package/es/axis/constant.js.map +1 -1
- package/es/axis/grid/base.js.map +1 -1
- package/es/axis/grid/circle.js.map +1 -1
- package/es/axis/grid/index.js.map +1 -1
- package/es/axis/grid/line.js.map +1 -1
- package/es/axis/grid/type.js.map +1 -1
- package/es/axis/index.js.map +1 -1
- package/es/axis/line.js +50 -2
- package/es/axis/line.js.map +1 -1
- package/es/axis/mixin/circle.js.map +1 -1
- package/es/axis/mixin/line.js.map +1 -1
- 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 +2 -2
- package/es/axis/overlap/auto-rotate.js.map +1 -1
- package/es/axis/type.d.ts +1 -0
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.d.ts +1 -0
- package/es/brush/brush.js +5 -0
- package/es/brush/brush.js.map +1 -1
- package/es/brush/config.js.map +1 -1
- package/es/brush/index.js.map +1 -1
- package/es/brush/type.js.map +1 -1
- package/es/constant.js.map +1 -1
- package/es/core/base.d.ts +2 -1
- package/es/core/base.js +3 -3
- package/es/core/base.js.map +1 -1
- package/es/core/type.js.map +1 -1
- package/es/crosshair/base.js.map +1 -1
- package/es/crosshair/circle.js.map +1 -1
- package/es/crosshair/index.js.map +1 -1
- package/es/crosshair/line.js.map +1 -1
- package/es/crosshair/polygon.js.map +1 -1
- package/es/crosshair/rect.js.map +1 -1
- package/es/crosshair/sector.js.map +1 -1
- package/es/crosshair/type.js.map +1 -1
- package/es/data-zoom/config.js.map +1 -1
- package/es/data-zoom/data-zoom.js.map +1 -1
- package/es/data-zoom/index.js.map +1 -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.map +1 -1
- package/es/indicator/index.js.map +1 -1
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.js.map +1 -1
- package/es/interface.js.map +1 -1
- package/es/jsx/component-type.js.map +1 -1
- package/es/jsx/index.js.map +1 -1
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/animate/index.js.map +1 -1
- package/es/label/arc.d.ts +12 -5
- package/es/label/arc.js +83 -39
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +12 -9
- package/es/label/base.js +124 -135
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +5 -3
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/index.js.map +1 -1
- package/es/label/line.js.map +1 -1
- package/es/label/overlap/bitmap.js.map +1 -1
- package/es/label/overlap/index.js.map +1 -1
- package/es/label/overlap/place.d.ts +2 -2
- package/es/label/overlap/place.js +15 -8
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/scaler.js.map +1 -1
- package/es/label/polygon.d.ts +12 -0
- package/es/label/polygon.js +31 -0
- package/es/label/polygon.js.map +1 -0
- package/es/label/rect.js.map +1 -1
- package/es/label/symbol.js.map +1 -1
- package/es/label/type.d.ts +9 -5
- package/es/label/type.js.map +1 -1
- package/es/label/util.js.map +1 -1
- package/es/legend/base.js.map +1 -1
- package/es/legend/color/color.js.map +1 -1
- package/es/legend/color/index.js.map +1 -1
- package/es/legend/color/type.js.map +1 -1
- package/es/legend/constant.js.map +1 -1
- package/es/legend/discrete/discrete.js +26 -25
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/index.js.map +1 -1
- package/es/legend/discrete/type.js.map +1 -1
- package/es/legend/index.js.map +1 -1
- package/es/legend/size/index.js.map +1 -1
- package/es/legend/size/size.d.ts +2 -2
- package/es/legend/size/size.js.map +1 -1
- package/es/legend/size/type.js.map +1 -1
- package/es/legend/type.js.map +1 -1
- package/es/link-path/index.js +1 -2
- package/es/link-path/index.js.map +1 -1
- package/es/link-path/link-path.js +2 -1
- package/es/link-path/link-path.js.map +1 -1
- package/es/link-path/type.js.map +1 -1
- package/es/marker/area.d.ts +1 -20
- package/es/marker/area.js +38 -36
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -0
- package/es/marker/base.js +27 -19
- package/es/marker/base.js.map +1 -1
- package/es/marker/config.d.ts +1 -1
- package/es/marker/config.js.map +1 -1
- package/es/marker/index.js.map +1 -1
- package/es/marker/line.js +32 -15
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +7 -7
- package/es/marker/point.js +6 -5
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +8 -5
- package/es/marker/type.js.map +1 -1
- package/es/marker/util.d.ts +1 -0
- package/es/marker/util.js +3 -0
- package/es/marker/util.js.map +1 -0
- package/es/pager/index.js.map +1 -1
- package/es/pager/pager.js +4 -2
- package/es/pager/pager.js.map +1 -1
- package/es/pager/type.js.map +1 -1
- package/es/player/base-player.d.ts +9 -1
- package/es/player/base-player.js +25 -22
- package/es/player/base-player.js.map +1 -1
- package/es/player/constant.d.ts +1 -0
- package/es/player/constant.js +1 -0
- package/es/player/constant.js.map +1 -1
- package/es/player/continuous-player.js +6 -6
- package/es/player/continuous-player.js.map +1 -1
- package/es/player/controller/assets/index.js.map +1 -1
- package/es/player/controller/constant.js.map +1 -1
- package/es/player/controller/controller.d.ts +2 -2
- package/es/player/controller/controller.js +15 -7
- package/es/player/controller/controller.js.map +1 -1
- package/es/player/controller/icon/icon.js.map +1 -1
- package/es/player/controller/icon/index.js.map +1 -1
- package/es/player/controller/icon/type.js.map +1 -1
- package/es/player/controller/index.js.map +1 -1
- package/es/player/controller/type.d.ts +14 -6
- package/es/player/controller/type.js.map +1 -1
- package/es/player/discrete-player.js +10 -10
- package/es/player/discrete-player.js.map +1 -1
- package/es/player/index.js.map +1 -1
- package/es/player/type/base.js.map +1 -1
- package/es/player/type/continuous-player.d.ts +2 -2
- package/es/player/type/continuous-player.js.map +1 -1
- package/es/player/type/direction.js.map +1 -1
- package/es/player/type/discrete-player.js.map +1 -1
- package/es/player/type/event.d.ts +12 -6
- package/es/player/type/event.js +5 -3
- package/es/player/type/event.js.map +1 -1
- package/es/player/type/index.js.map +1 -1
- package/es/player/type/layout.d.ts +5 -2
- package/es/player/type/layout.js.map +1 -1
- package/es/player/utils.js.map +1 -1
- package/es/poptip/contribution.js +3 -1
- package/es/poptip/contribution.js.map +1 -1
- package/es/poptip/index.js.map +1 -1
- package/es/poptip/poptip-plugin.js.map +1 -1
- package/es/poptip/poptip.js +31 -9
- package/es/poptip/poptip.js.map +1 -1
- package/es/poptip/register.d.ts +1 -1
- package/es/poptip/register.js +7 -6
- package/es/poptip/register.js.map +1 -1
- package/es/poptip/theme.js.map +1 -1
- package/es/poptip/type.d.ts +3 -0
- package/es/poptip/type.js.map +1 -1
- package/es/scrollbar/index.js.map +1 -1
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/scrollbar/type.js.map +1 -1
- package/es/segment/index.js.map +1 -1
- package/es/segment/segment.d.ts +11 -6
- package/es/segment/segment.js +81 -41
- package/es/segment/segment.js.map +1 -1
- package/es/segment/type.d.ts +5 -3
- package/es/segment/type.js.map +1 -1
- package/es/slider/constant.js.map +1 -1
- package/es/slider/index.js.map +1 -1
- package/es/slider/slider.js.map +1 -1
- package/es/slider/type.js.map +1 -1
- package/es/tag/index.js.map +1 -1
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.js.map +1 -1
- package/es/title/index.js.map +1 -1
- package/es/title/title.js.map +1 -1
- package/es/title/type.js.map +1 -1
- package/es/tooltip/config.js.map +1 -1
- package/es/tooltip/index.js.map +1 -1
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.js.map +1 -1
- package/es/util/align.js.map +1 -1
- package/es/util/common.js.map +1 -1
- package/es/util/index.d.ts +1 -1
- package/es/util/index.js +1 -1
- package/es/util/index.js.map +1 -1
- package/es/util/{labelSmartInvert.d.ts → label-smartInvert.d.ts} +1 -0
- package/es/util/{labelSmartInvert.js → label-smartInvert.js} +18 -1
- package/es/util/label-smartInvert.js.map +1 -0
- package/es/util/limit-shape.d.ts +3 -0
- package/es/util/limit-shape.js +8 -0
- package/es/util/limit-shape.js.map +1 -0
- package/es/util/matrix.js.map +1 -1
- package/es/util/text.js +3 -3
- package/es/util/text.js.map +1 -1
- package/package.json +4 -4
- package/cjs/util/labelSmartInvert.js.map +0 -1
- package/es/util/labelSmartInvert.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
setAttribute(key, value, forceUpdateTag) {
|
|
39
|
-
if (vutils.isPlainObject(this.attribute[key])) {
|
|
39
|
+
if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(value)) {
|
|
40
40
|
vutils.merge(this.attribute[key], value);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
for (let i = 0; i < keys.length; i++) {
|
|
79
79
|
const key = keys[i];
|
|
80
|
-
if (vutils.isPlainObject(this.attribute[key])) {
|
|
80
|
+
if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(params[key])) {
|
|
81
81
|
vutils.merge(this.attribute[key], params[key]);
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -495,6 +495,20 @@
|
|
|
495
495
|
const { r, g, b } = c.color;
|
|
496
496
|
return '#' + vutils.ColorUtil.rgbToHex(r, g, b);
|
|
497
497
|
}
|
|
498
|
+
function smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor) {
|
|
499
|
+
let result;
|
|
500
|
+
switch (fillStrategy) {
|
|
501
|
+
case 'base':
|
|
502
|
+
result = baseColor;
|
|
503
|
+
break;
|
|
504
|
+
case 'invertBase':
|
|
505
|
+
result = invertColor;
|
|
506
|
+
break;
|
|
507
|
+
case 'similarBase':
|
|
508
|
+
result = similarColor;
|
|
509
|
+
}
|
|
510
|
+
return result;
|
|
511
|
+
}
|
|
498
512
|
|
|
499
513
|
function scale(vector, scale) {
|
|
500
514
|
return [vector[0] * scale, vector[1] * scale];
|
|
@@ -561,16 +575,16 @@
|
|
|
561
575
|
}, getTextBounds: useNaiveCanvas ? undefined : vrender.getTextBounds, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
|
|
562
576
|
};
|
|
563
577
|
function measureTextSize(text, textSpec) {
|
|
564
|
-
var _a
|
|
578
|
+
var _a;
|
|
565
579
|
if (!text) {
|
|
566
580
|
return { width: 0, height: 0 };
|
|
567
581
|
}
|
|
568
582
|
const bounds = vrender.getTextBounds({
|
|
569
583
|
text,
|
|
570
|
-
fontFamily:
|
|
584
|
+
fontFamily: textSpec.fontFamily,
|
|
571
585
|
fontSize: textSpec.fontSize || 12,
|
|
572
586
|
fontWeight: textSpec.fontWeight,
|
|
573
|
-
textAlign: (
|
|
587
|
+
textAlign: (_a = textSpec.textAlign) !== null && _a !== void 0 ? _a : 'center',
|
|
574
588
|
textBaseline: textSpec.textBaseline,
|
|
575
589
|
ellipsis: !!textSpec.ellipsis,
|
|
576
590
|
maxLineWidth: textSpec.maxLineWidth || Infinity,
|
|
@@ -696,6 +710,7 @@
|
|
|
696
710
|
}
|
|
697
711
|
};
|
|
698
712
|
|
|
713
|
+
const _tBounds = new vutils.AABBBounds();
|
|
699
714
|
class PopTip extends AbstractComponent {
|
|
700
715
|
constructor(attributes) {
|
|
701
716
|
super(vutils.merge({}, PopTip.defaultAttributes, attributes));
|
|
@@ -703,14 +718,17 @@
|
|
|
703
718
|
this.positionList = ['top', 'tl', 'tr', 'bottom', 'bl', 'br', 'left', 'lt', 'lb', 'right', 'rt', 'rb'];
|
|
704
719
|
}
|
|
705
720
|
render() {
|
|
706
|
-
var _a, _b, _c, _d, _e;
|
|
707
|
-
const {
|
|
721
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
722
|
+
const { titleStyle = {}, position, contentStyle = {}, panel = {}, space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, maxWidthPercent, visible, state, dx = 0, dy = 0 } = this.attribute;
|
|
723
|
+
let { title = '', content = '' } = this.attribute;
|
|
724
|
+
title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title;
|
|
725
|
+
content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;
|
|
708
726
|
const parsedPadding = vutils.normalizePadding(padding);
|
|
709
727
|
const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group');
|
|
710
728
|
const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];
|
|
711
729
|
const titleVisible = vutils.isValid(title) && visible !== false;
|
|
712
|
-
const titleAttrs = Object.assign(Object.assign({ text: title, visible: titleVisible }, titleStyle), { x: parsedPadding[3], y: parsedPadding[0], maxLineWidth, textAlign: 'left', textBaseline: 'top' });
|
|
713
|
-
const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, '
|
|
730
|
+
const titleAttrs = Object.assign(Object.assign({ text: vutils.isArray(title) ? title : [title], visible: titleVisible }, titleStyle), { x: parsedPadding[3], y: parsedPadding[0], maxLineWidth, textAlign: 'left', textBaseline: 'top' });
|
|
731
|
+
const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, 'wrapText');
|
|
714
732
|
if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.title)) {
|
|
715
733
|
titleShape.states = state.title;
|
|
716
734
|
}
|
|
@@ -722,8 +740,8 @@
|
|
|
722
740
|
height = 0;
|
|
723
741
|
}
|
|
724
742
|
const contentVisible = vutils.isValid(content) && visible !== false;
|
|
725
|
-
const contentAttrs = Object.assign(Object.assign({ text: content, visible: contentVisible }, contentStyle), { x: parsedPadding[3], y: parsedPadding[0] + height, maxLineWidth, textAlign: 'left', textBaseline: 'top' });
|
|
726
|
-
const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, '
|
|
743
|
+
const contentAttrs = Object.assign(Object.assign({ text: vutils.isArray(content) ? content : [content], visible: contentVisible }, contentStyle), { x: parsedPadding[3], y: parsedPadding[0] + height, maxLineWidth, textAlign: 'left', textBaseline: 'top' });
|
|
744
|
+
const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, 'wrapText');
|
|
727
745
|
if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.content)) {
|
|
728
746
|
contentShape.states = state.content;
|
|
729
747
|
}
|
|
@@ -740,7 +758,7 @@
|
|
|
740
758
|
else if (popTipWidth < minWidth) {
|
|
741
759
|
popTipWidth = minWidth;
|
|
742
760
|
}
|
|
743
|
-
|
|
761
|
+
let poptipHeight = parsedPadding[0] + parsedPadding[2] + height;
|
|
744
762
|
const { visible: bgVisible } = panel, backgroundStyle = __rest(panel, ["visible"]);
|
|
745
763
|
const symbolSize = (_a = backgroundStyle.size) !== null && _a !== void 0 ? _a : 12;
|
|
746
764
|
const spaceSize = vutils.isArray(symbolSize)
|
|
@@ -748,8 +766,30 @@
|
|
|
748
766
|
: symbolSize + ((_d = backgroundStyle.space) !== null && _d !== void 0 ? _d : 0);
|
|
749
767
|
const lineWidth = (_e = backgroundStyle.lineWidth) !== null && _e !== void 0 ? _e : 1;
|
|
750
768
|
const range = this.stage
|
|
751
|
-
? [
|
|
769
|
+
? [
|
|
770
|
+
(_f = this.stage.viewWidth) !== null && _f !== void 0 ? _f : this.stage.width,
|
|
771
|
+
(_g = this.stage.viewHeight) !== null && _g !== void 0 ? _g : this.stage.height
|
|
772
|
+
]
|
|
752
773
|
: undefined;
|
|
774
|
+
if (range) {
|
|
775
|
+
const b = this.AABBBounds;
|
|
776
|
+
const leftWidth = (_h = this.attribute.x) !== null && _h !== void 0 ? _h : b.x1;
|
|
777
|
+
const rightWidth = range[0] - b.x1;
|
|
778
|
+
let maxSpace = Math.max(leftWidth, rightWidth);
|
|
779
|
+
const buf = (vutils.isArray(symbolSize) ? symbolSize[0] : 12) + 3;
|
|
780
|
+
maxSpace = Math.min(maxSpace - buf, maxSpace * maxWidthPercent);
|
|
781
|
+
if (maxSpace < popTipWidth) {
|
|
782
|
+
popTipWidth = maxSpace;
|
|
783
|
+
const buf = parsedPadding[1] + parsedPadding[3];
|
|
784
|
+
titleShape.setAttribute('maxLineWidth', maxSpace - buf);
|
|
785
|
+
contentShape.setAttribute('maxLineWidth', maxSpace - buf);
|
|
786
|
+
poptipHeight = parsedPadding[0] + parsedPadding[2];
|
|
787
|
+
if (titleVisible) {
|
|
788
|
+
poptipHeight += titleShape.AABBBounds.height() + space;
|
|
789
|
+
}
|
|
790
|
+
poptipHeight += contentShape.AABBBounds.height();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
753
793
|
const layout = position === 'auto';
|
|
754
794
|
let maxBBoxI;
|
|
755
795
|
let maxBBoxSize = -Infinity;
|
|
@@ -772,7 +812,8 @@
|
|
|
772
812
|
y: -offset[1] + dy
|
|
773
813
|
});
|
|
774
814
|
if (layout && range) {
|
|
775
|
-
|
|
815
|
+
_tBounds.setValue(0, 0, popTipWidth, poptipHeight).transformWithMatrix(group.globalTransMatrix);
|
|
816
|
+
const b = _tBounds;
|
|
776
817
|
const stageBounds = new vutils.Bounds().setValue(0, 0, range[0], range[1]);
|
|
777
818
|
if (vutils.rectInsideAnotherRect(b, stageBounds, false)) {
|
|
778
819
|
break;
|
|
@@ -850,6 +891,7 @@
|
|
|
850
891
|
textAlign: 'left',
|
|
851
892
|
textBaseline: 'top'
|
|
852
893
|
},
|
|
894
|
+
maxWidthPercent: 0.8,
|
|
853
895
|
space: 8,
|
|
854
896
|
padding: 10
|
|
855
897
|
};
|
|
@@ -920,8 +962,13 @@
|
|
|
920
962
|
if (visible === false || (visibleCb && visibleCb(graphic) === false)) {
|
|
921
963
|
return;
|
|
922
964
|
}
|
|
965
|
+
const attribute = {};
|
|
966
|
+
vutils.merge(attribute, PopTip.defaultAttributes, graphic.attribute.poptip ? graphic.attribute.poptip : {});
|
|
923
967
|
if (!this.poptipComponent) {
|
|
924
|
-
this.poptipComponent = new PopTip(
|
|
968
|
+
this.poptipComponent = new PopTip(attribute);
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
this.poptipComponent.initAttributes(attribute);
|
|
925
972
|
}
|
|
926
973
|
let poptip = graphic.attribute.poptip || {};
|
|
927
974
|
if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {
|
|
@@ -1056,16 +1103,21 @@
|
|
|
1056
1103
|
injectable()
|
|
1057
1104
|
], PopTipForClipedTextPlugin);
|
|
1058
1105
|
|
|
1059
|
-
const popTipModule = new ContainerModule(bind => {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1106
|
+
const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
1107
|
+
if (!isBound(PopTipRenderContribution)) {
|
|
1108
|
+
bind(PopTipRenderContribution).toSelf().inSingletonScope();
|
|
1109
|
+
bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
|
|
1110
|
+
}
|
|
1111
|
+
if (!isBound(PopTipPlugin)) {
|
|
1112
|
+
bind(PopTipPlugin).toSelf();
|
|
1113
|
+
bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
|
|
1114
|
+
}
|
|
1115
|
+
if (!isBound(PopTipForClipedTextPlugin)) {
|
|
1116
|
+
bind(PopTipForClipedTextPlugin).toSelf();
|
|
1117
|
+
bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
|
|
1118
|
+
}
|
|
1066
1119
|
});
|
|
1067
|
-
function loadPoptip(
|
|
1068
|
-
vutils.merge(theme.poptip, defaultPoptipTheme);
|
|
1120
|
+
function loadPoptip() {
|
|
1069
1121
|
vrender.container.load(popTipModule);
|
|
1070
1122
|
}
|
|
1071
1123
|
function setPoptipTheme(defaultPoptipTheme) {
|
|
@@ -1395,26 +1447,29 @@
|
|
|
1395
1447
|
};
|
|
1396
1448
|
}
|
|
1397
1449
|
|
|
1398
|
-
function canPlace($, bitmap, bound, checkBound = true) {
|
|
1399
|
-
|
|
1450
|
+
function canPlace($, bitmap, bound, checkBound = true, pad = 0) {
|
|
1451
|
+
let range = bound;
|
|
1452
|
+
if (pad > 0) {
|
|
1453
|
+
range = {
|
|
1454
|
+
x1: bound.x1 - pad,
|
|
1455
|
+
x2: bound.x2 + pad,
|
|
1456
|
+
y1: bound.y1 - pad,
|
|
1457
|
+
y2: bound.y2 + pad
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
range = boundToRange($, range);
|
|
1400
1461
|
const outOfBounds = checkBound && bitmap.outOfBounds(range);
|
|
1401
1462
|
if (outOfBounds) {
|
|
1402
1463
|
return false;
|
|
1403
1464
|
}
|
|
1404
1465
|
return !bitmap.getRange(range);
|
|
1405
1466
|
}
|
|
1406
|
-
function
|
|
1407
|
-
if (!textBound || !shapeBound) {
|
|
1408
|
-
return false;
|
|
1409
|
-
}
|
|
1410
|
-
return shapeBound.encloses(textBound);
|
|
1411
|
-
}
|
|
1412
|
-
function placeToCandidates($, bitmap, text, candidates = [], clampForce = true) {
|
|
1467
|
+
function placeToCandidates($, bitmap, text, candidates = [], clampForce = true, pad = 0) {
|
|
1413
1468
|
for (let i = 0; i < candidates.length; i++) {
|
|
1414
1469
|
const tempText = text.clone();
|
|
1415
1470
|
tempText.setAttributes(candidates[i]);
|
|
1416
1471
|
tempText.update();
|
|
1417
|
-
if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce)) {
|
|
1472
|
+
if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce, pad)) {
|
|
1418
1473
|
bitmap.setRange(boundToRange($, tempText.AABBBounds, true));
|
|
1419
1474
|
return candidates[i];
|
|
1420
1475
|
}
|
|
@@ -1422,13 +1477,15 @@
|
|
|
1422
1477
|
return false;
|
|
1423
1478
|
}
|
|
1424
1479
|
function place($, bitmap, s, attrs, text, bounds, labeling) {
|
|
1425
|
-
var _a, _b
|
|
1480
|
+
var _a, _b;
|
|
1481
|
+
const clampForce = (_a = attrs.overlap) === null || _a === void 0 ? void 0 : _a.clampForce;
|
|
1482
|
+
const overlapPadding = (_b = attrs.overlap) === null || _b === void 0 ? void 0 : _b.overlapPadding;
|
|
1426
1483
|
if (s.type === 'bound' || s.type === 'position') {
|
|
1427
1484
|
if (vutils.isFunction(labeling)) {
|
|
1428
1485
|
const userPosition = vutils.isFunction(s.position) ? s.position(text.attribute) : s.position;
|
|
1429
1486
|
const positions = (userPosition || defaultLabelPosition(attrs.type));
|
|
1430
1487
|
const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset));
|
|
1431
|
-
return placeToCandidates($, bitmap, text, candidates,
|
|
1488
|
+
return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
|
|
1432
1489
|
}
|
|
1433
1490
|
return false;
|
|
1434
1491
|
}
|
|
@@ -1437,14 +1494,14 @@
|
|
|
1437
1494
|
const candidates = offset.map(dy => {
|
|
1438
1495
|
return { x: text.attribute.x, y: text.attribute.y + dy };
|
|
1439
1496
|
});
|
|
1440
|
-
return placeToCandidates($, bitmap, text, candidates,
|
|
1497
|
+
return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
|
|
1441
1498
|
}
|
|
1442
1499
|
if (s.type === 'moveX') {
|
|
1443
1500
|
const offset = s.offset ? (vutils.isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];
|
|
1444
1501
|
const candidates = offset.map(dx => {
|
|
1445
1502
|
return { x: text.attribute.x + dx, y: text.attribute.y };
|
|
1446
1503
|
});
|
|
1447
|
-
return placeToCandidates($, bitmap, text, candidates,
|
|
1504
|
+
return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
|
|
1448
1505
|
}
|
|
1449
1506
|
return false;
|
|
1450
1507
|
}
|
|
@@ -1532,8 +1589,14 @@
|
|
|
1532
1589
|
};
|
|
1533
1590
|
|
|
1534
1591
|
class LabelBase extends AbstractComponent {
|
|
1535
|
-
|
|
1536
|
-
|
|
1592
|
+
setBitmap(bitmap) {
|
|
1593
|
+
this._bitmap = bitmap;
|
|
1594
|
+
}
|
|
1595
|
+
setBitmapTool(bmpTool) {
|
|
1596
|
+
this._bmpTool = bmpTool;
|
|
1597
|
+
}
|
|
1598
|
+
constructor(attributes) {
|
|
1599
|
+
super(vutils.merge({}, LabelBase.defaultAttributes, attributes));
|
|
1537
1600
|
this.name = 'label';
|
|
1538
1601
|
this._onHover = (e) => {
|
|
1539
1602
|
const target = e.target;
|
|
@@ -1581,18 +1644,17 @@
|
|
|
1581
1644
|
}
|
|
1582
1645
|
};
|
|
1583
1646
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
setBitmapTool(bmpTool) {
|
|
1588
|
-
this._bmpTool = bmpTool;
|
|
1647
|
+
labeling(textBounds, graphicBounds, position, offset) {
|
|
1648
|
+
return;
|
|
1589
1649
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
return arcs;
|
|
1650
|
+
_labelLine(text) {
|
|
1651
|
+
return;
|
|
1593
1652
|
}
|
|
1594
1653
|
render() {
|
|
1595
1654
|
this._prepare();
|
|
1655
|
+
if (vutils.isNil(this._idToGraphic)) {
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1596
1658
|
const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;
|
|
1597
1659
|
let data = this.attribute.data;
|
|
1598
1660
|
if (vutils.isFunction(dataFilter)) {
|
|
@@ -1603,14 +1665,14 @@
|
|
|
1603
1665
|
labels = customLayoutFunc(data, (d) => this._idToGraphic.get(d.id));
|
|
1604
1666
|
}
|
|
1605
1667
|
else {
|
|
1606
|
-
labels = this.
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1668
|
+
labels = this._layout(data);
|
|
1669
|
+
}
|
|
1670
|
+
if (vutils.isFunction(customOverlapFunc)) {
|
|
1671
|
+
labels = customOverlapFunc(labels, (d) => this._idToGraphic.get(d.id));
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
if (overlap !== false) {
|
|
1675
|
+
labels = this._overlapping(labels);
|
|
1614
1676
|
}
|
|
1615
1677
|
}
|
|
1616
1678
|
if (smartInvert !== false) {
|
|
@@ -1649,8 +1711,14 @@
|
|
|
1649
1711
|
}
|
|
1650
1712
|
_prepare() {
|
|
1651
1713
|
var _a;
|
|
1652
|
-
const baseMarks = getMarksByName(this.getRootNode(), this.attribute.baseMarkGroupName);
|
|
1653
1714
|
const currentBaseMarks = [];
|
|
1715
|
+
let baseMarks;
|
|
1716
|
+
if (vutils.isFunction(this.attribute.getBaseMarks)) {
|
|
1717
|
+
baseMarks = this.attribute.getBaseMarks();
|
|
1718
|
+
}
|
|
1719
|
+
else {
|
|
1720
|
+
baseMarks = getMarksByName(this.getRootNode(), this.attribute.baseMarkGroupName);
|
|
1721
|
+
}
|
|
1654
1722
|
baseMarks.forEach(mark => {
|
|
1655
1723
|
if (mark.releaseStatus !== 'willRelease') {
|
|
1656
1724
|
currentBaseMarks.push(mark);
|
|
@@ -1679,49 +1747,24 @@
|
|
|
1679
1747
|
}
|
|
1680
1748
|
}
|
|
1681
1749
|
}
|
|
1682
|
-
|
|
1750
|
+
_layout(data = []) {
|
|
1683
1751
|
const { textStyle = {}, position, offset } = this.attribute;
|
|
1684
1752
|
const labels = [];
|
|
1685
|
-
const textBoundsArray = [];
|
|
1686
1753
|
for (let i = 0; i < data.length; i++) {
|
|
1687
1754
|
const textData = data[i];
|
|
1688
1755
|
const baseMark = this._idToGraphic.get(textData.id);
|
|
1689
1756
|
const labelAttribute = Object.assign(Object.assign({ fill: baseMark.attribute.fill }, textStyle), textData);
|
|
1690
1757
|
const text = this._createLabelText(labelAttribute);
|
|
1691
1758
|
const textBounds = this.getGraphicBounds(text);
|
|
1692
|
-
textBoundsArray.push(textBounds);
|
|
1693
1759
|
const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
|
|
1694
1760
|
const textLocation = this.labeling(textBounds, graphicBounds, vutils.isFunction(position) ? position(textData) : position, offset);
|
|
1695
|
-
if (
|
|
1696
|
-
|
|
1761
|
+
if (textLocation) {
|
|
1762
|
+
labelAttribute.x = textLocation.x;
|
|
1763
|
+
labelAttribute.y = textLocation.y;
|
|
1764
|
+
text.setAttributes(textLocation);
|
|
1697
1765
|
}
|
|
1698
|
-
labelAttribute.x = textLocation.x;
|
|
1699
|
-
labelAttribute.y = textLocation.y;
|
|
1700
|
-
text.setAttributes(textLocation);
|
|
1701
1766
|
labels.push(text);
|
|
1702
1767
|
}
|
|
1703
|
-
if (this.attribute.type === 'arc') {
|
|
1704
|
-
const ellipsisLabelAttribute = Object.assign(Object.assign({}, this.attribute.textStyle), { text: '...' });
|
|
1705
|
-
const ellipsisText = this._createLabelText(ellipsisLabelAttribute);
|
|
1706
|
-
const ellipsisTextBounds = this.getGraphicBounds(ellipsisText);
|
|
1707
|
-
const ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
|
|
1708
|
-
const arcs = this.layoutArcLabels(position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray, ellipsisWidth);
|
|
1709
|
-
for (let i = 0; i < data.length; i++) {
|
|
1710
|
-
const textData = data[i];
|
|
1711
|
-
const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
|
|
1712
|
-
const labelAttribute = {
|
|
1713
|
-
visible: basedArc.labelVisible,
|
|
1714
|
-
x: basedArc.labelPosition.x,
|
|
1715
|
-
y: basedArc.labelPosition.y,
|
|
1716
|
-
angle: basedArc.angle,
|
|
1717
|
-
maxLineWidth: basedArc.labelLimit,
|
|
1718
|
-
points: (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointA) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointB) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointC)
|
|
1719
|
-
? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
|
|
1720
|
-
: undefined
|
|
1721
|
-
};
|
|
1722
|
-
labels[i].setAttributes(labelAttribute);
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
1768
|
return labels;
|
|
1726
1769
|
}
|
|
1727
1770
|
_overlapping(labels) {
|
|
@@ -1739,7 +1782,7 @@
|
|
|
1739
1782
|
if (size.width === 0 || size.height === 0) {
|
|
1740
1783
|
return labels;
|
|
1741
1784
|
}
|
|
1742
|
-
const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [] } = option;
|
|
1785
|
+
const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
|
|
1743
1786
|
const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
|
|
1744
1787
|
const bitmap = this._bitmap || bmpTool.bitmap();
|
|
1745
1788
|
const checkBounds = strategy.some(s => s.type === 'bound');
|
|
@@ -1767,13 +1810,16 @@
|
|
|
1767
1810
|
const text = labels[i];
|
|
1768
1811
|
const baseMark = this._idToGraphic.get(text.attribute.id);
|
|
1769
1812
|
text.update();
|
|
1770
|
-
if (
|
|
1813
|
+
if (!vutils.isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {
|
|
1814
|
+
continue;
|
|
1815
|
+
}
|
|
1816
|
+
if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
|
|
1771
1817
|
if (!checkBounds) {
|
|
1772
1818
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
1773
1819
|
result.push(text);
|
|
1774
1820
|
continue;
|
|
1775
1821
|
}
|
|
1776
|
-
if (checkBounds && (baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds) &&
|
|
1822
|
+
if (checkBounds && (baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds) && this._canPlaceInside(text.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds)) {
|
|
1777
1823
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
1778
1824
|
result.push(text);
|
|
1779
1825
|
continue;
|
|
@@ -1796,7 +1842,7 @@
|
|
|
1796
1842
|
x2: text.AABBBounds.x2 + dx,
|
|
1797
1843
|
y1: text.AABBBounds.y1 + dy,
|
|
1798
1844
|
y2: text.AABBBounds.y2 + dy
|
|
1799
|
-
})) {
|
|
1845
|
+
}, undefined, overlapPadding)) {
|
|
1800
1846
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
1801
1847
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
1802
1848
|
result.push(text);
|
|
@@ -1827,9 +1873,17 @@
|
|
|
1827
1873
|
});
|
|
1828
1874
|
}
|
|
1829
1875
|
_renderLabels(labels) {
|
|
1876
|
+
const disableAnimation = this._enableAnimation === false || this.attribute.animation === false;
|
|
1877
|
+
if (disableAnimation) {
|
|
1878
|
+
this._renderWithOutAnimation(labels);
|
|
1879
|
+
}
|
|
1880
|
+
else {
|
|
1881
|
+
this._renderWithAnimation(labels);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
_renderWithAnimation(labels) {
|
|
1830
1885
|
var _a, _b, _c, _d, _e;
|
|
1831
1886
|
const animationConfig = ((_a = this.attribute.animation) !== null && _a !== void 0 ? _a : {});
|
|
1832
|
-
const disableAnimation = this._enableAnimation === false || animationConfig === false;
|
|
1833
1887
|
const mode = (_b = animationConfig.mode) !== null && _b !== void 0 ? _b : DefaultLabelAnimation.mode;
|
|
1834
1888
|
const duration = (_c = animationConfig.duration) !== null && _c !== void 0 ? _c : DefaultLabelAnimation.duration;
|
|
1835
1889
|
const easing = (_d = animationConfig.easing) !== null && _d !== void 0 ? _d : DefaultLabelAnimation.easing;
|
|
@@ -1838,27 +1892,18 @@
|
|
|
1838
1892
|
const prevTextMap = this._graphicToText || new Map();
|
|
1839
1893
|
const texts = [];
|
|
1840
1894
|
labels.forEach((text, index) => {
|
|
1841
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
1842
|
-
const labelLine = (
|
|
1843
|
-
? vrender.createLine({
|
|
1844
|
-
visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
|
|
1845
|
-
stroke: (_f = (_e = (_d = text.attribute) === null || _d === void 0 ? void 0 : _d.line) === null || _e === void 0 ? void 0 : _e.stroke) !== null && _f !== void 0 ? _f : (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.fill,
|
|
1846
|
-
lineWidth: (_k = (_j = (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.line) === null || _j === void 0 ? void 0 : _j.lineWidth) !== null && _k !== void 0 ? _k : 1,
|
|
1847
|
-
points: (_l = text.attribute) === null || _l === void 0 ? void 0 : _l.points
|
|
1848
|
-
})
|
|
1849
|
-
: undefined;
|
|
1895
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1896
|
+
const labelLine = this._labelLine(text);
|
|
1850
1897
|
const relatedGraphic = this._idToGraphic.get(text.attribute.id);
|
|
1851
1898
|
const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
|
|
1852
1899
|
if (state === 'enter') {
|
|
1853
1900
|
texts.push(text);
|
|
1854
1901
|
currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
|
|
1855
|
-
if (
|
|
1902
|
+
if (relatedGraphic) {
|
|
1856
1903
|
const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');
|
|
1857
1904
|
this.add(text);
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
}
|
|
1861
|
-
relatedGraphic.onAnimateBind = () => {
|
|
1905
|
+
labelLine && this.add(labelLine);
|
|
1906
|
+
relatedGraphic.once('animate-bind', () => {
|
|
1862
1907
|
text.setAttributes(from);
|
|
1863
1908
|
const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
|
|
1864
1909
|
mode,
|
|
@@ -1868,58 +1913,70 @@
|
|
|
1868
1913
|
delay
|
|
1869
1914
|
});
|
|
1870
1915
|
relatedGraphic.on('afterAttributeUpdate', listener);
|
|
1871
|
-
};
|
|
1872
|
-
}
|
|
1873
|
-
else {
|
|
1874
|
-
this.add(text);
|
|
1875
|
-
if (labelLine) {
|
|
1876
|
-
this.add(labelLine);
|
|
1877
|
-
}
|
|
1916
|
+
});
|
|
1878
1917
|
}
|
|
1879
1918
|
}
|
|
1880
|
-
if (state === 'update') {
|
|
1919
|
+
else if (state === 'update') {
|
|
1881
1920
|
const prevLabel = prevTextMap.get(relatedGraphic);
|
|
1882
1921
|
prevTextMap.delete(relatedGraphic);
|
|
1883
1922
|
currentTextMap.set(relatedGraphic, prevLabel);
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
else {
|
|
1901
|
-
prevLabel.text.setAttributes(text.attribute);
|
|
1902
|
-
if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
|
|
1903
|
-
prevLabel.labelLine.setAttributes({ points: (_o = text.attribute) === null || _o === void 0 ? void 0 : _o.points });
|
|
1904
|
-
}
|
|
1923
|
+
const prevText = prevLabel.text;
|
|
1924
|
+
prevText.animate().to(text.attribute, duration, easing);
|
|
1925
|
+
if (prevLabel.labelLine) {
|
|
1926
|
+
prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
|
|
1927
|
+
visible: (_f = (_d = (((_b = (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.line) === null || _b === void 0 ? void 0 : _b.visible) && ((_c = text.attribute) === null || _c === void 0 ? void 0 : _c.visible))) !== null && _d !== void 0 ? _d : (_e = text.attribute) === null || _e === void 0 ? void 0 : _e.visible) !== null && _f !== void 0 ? _f : true,
|
|
1928
|
+
points: (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.points
|
|
1929
|
+
}), duration, easing);
|
|
1930
|
+
}
|
|
1931
|
+
if (animationConfig.increaseEffect !== false &&
|
|
1932
|
+
prevText.attribute.text !== text.attribute.text &&
|
|
1933
|
+
vutils.isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))) {
|
|
1934
|
+
prevText
|
|
1935
|
+
.animate()
|
|
1936
|
+
.play(new vrender.IncreaseCount({ text: prevText.attribute.text }, { text: text.attribute.text }, duration, easing));
|
|
1905
1937
|
}
|
|
1906
1938
|
}
|
|
1907
1939
|
});
|
|
1908
1940
|
prevTextMap.forEach(label => {
|
|
1909
1941
|
var _a;
|
|
1910
|
-
|
|
1942
|
+
(_a = label.text) === null || _a === void 0 ? void 0 : _a.animate().to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing).onEnd(() => {
|
|
1911
1943
|
this.removeChild(label.text);
|
|
1912
1944
|
if (label === null || label === void 0 ? void 0 : label.labelLine) {
|
|
1913
1945
|
this.removeChild(label.labelLine);
|
|
1914
1946
|
}
|
|
1947
|
+
});
|
|
1948
|
+
});
|
|
1949
|
+
this._graphicToText = currentTextMap;
|
|
1950
|
+
}
|
|
1951
|
+
_renderWithOutAnimation(labels) {
|
|
1952
|
+
const currentTextMap = new Map();
|
|
1953
|
+
const prevTextMap = this._graphicToText || new Map();
|
|
1954
|
+
labels.forEach(text => {
|
|
1955
|
+
var _a;
|
|
1956
|
+
const labelLine = this._labelLine(text);
|
|
1957
|
+
const relatedGraphic = this._idToGraphic.get(text.attribute.id);
|
|
1958
|
+
const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
|
|
1959
|
+
if (state === 'enter') {
|
|
1960
|
+
currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
|
|
1961
|
+
this.add(text);
|
|
1962
|
+
if (labelLine) {
|
|
1963
|
+
this.add(labelLine);
|
|
1964
|
+
}
|
|
1915
1965
|
}
|
|
1916
|
-
else {
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1966
|
+
else if (state === 'update') {
|
|
1967
|
+
const prevLabel = prevTextMap.get(relatedGraphic);
|
|
1968
|
+
prevTextMap.delete(relatedGraphic);
|
|
1969
|
+
currentTextMap.set(relatedGraphic, prevLabel);
|
|
1970
|
+
prevLabel.text.setAttributes(text.attribute);
|
|
1971
|
+
if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
|
|
1972
|
+
prevLabel.labelLine.setAttributes({ points: (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points });
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1976
|
+
prevTextMap.forEach(label => {
|
|
1977
|
+
this.removeChild(label.text);
|
|
1978
|
+
if (label === null || label === void 0 ? void 0 : label.labelLine) {
|
|
1979
|
+
this.removeChild(label.labelLine);
|
|
1923
1980
|
}
|
|
1924
1981
|
});
|
|
1925
1982
|
this._graphicToText = currentTextMap;
|
|
@@ -1990,21 +2047,20 @@
|
|
|
1990
2047
|
continue;
|
|
1991
2048
|
}
|
|
1992
2049
|
const baseMark = this._idToGraphic.get(label.attribute.id);
|
|
1993
|
-
|
|
1994
|
-
if (this.attribute.type === 'arc') {
|
|
1995
|
-
isInside = this.attribute.position === 'inside';
|
|
1996
|
-
}
|
|
2050
|
+
const isInside = this._canPlaceInside(label.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds);
|
|
1997
2051
|
const backgroundColor = baseMark.attribute.fill;
|
|
1998
2052
|
const foregroundColor = label.attribute.fill;
|
|
1999
2053
|
const baseColor = backgroundColor;
|
|
2000
2054
|
const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
|
|
2001
|
-
const
|
|
2055
|
+
const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
|
|
2002
2056
|
if (isInside) {
|
|
2003
|
-
|
|
2057
|
+
const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
|
|
2058
|
+
fill && label.setAttributes({ fill });
|
|
2004
2059
|
if (label.attribute.lineWidth === 0) {
|
|
2005
2060
|
continue;
|
|
2006
2061
|
}
|
|
2007
|
-
|
|
2062
|
+
const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
|
|
2063
|
+
stroke && label.setAttributes({ stroke });
|
|
2008
2064
|
}
|
|
2009
2065
|
else {
|
|
2010
2066
|
if (label.attribute.lineWidth === 0) {
|
|
@@ -2016,47 +2072,18 @@
|
|
|
2016
2072
|
});
|
|
2017
2073
|
continue;
|
|
2018
2074
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2075
|
+
const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
|
|
2076
|
+
fill && label.setAttributes({ fill });
|
|
2077
|
+
const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
|
|
2078
|
+
stroke && label.setAttributes({ stroke });
|
|
2021
2079
|
}
|
|
2022
2080
|
}
|
|
2023
2081
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
label.setAttributes({
|
|
2028
|
-
fill: baseColor
|
|
2029
|
-
});
|
|
2030
|
-
break;
|
|
2031
|
-
case 'invertBase':
|
|
2032
|
-
label.setAttributes({
|
|
2033
|
-
fill: invertColor
|
|
2034
|
-
});
|
|
2035
|
-
break;
|
|
2036
|
-
case 'similarBase':
|
|
2037
|
-
label.setAttributes({
|
|
2038
|
-
fill: simialrColor
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor) {
|
|
2043
|
-
switch (strokeStrategy) {
|
|
2044
|
-
case 'base':
|
|
2045
|
-
label.setAttributes({
|
|
2046
|
-
stroke: baseColor
|
|
2047
|
-
});
|
|
2048
|
-
break;
|
|
2049
|
-
case 'invertBase':
|
|
2050
|
-
label.setAttributes({
|
|
2051
|
-
stroke: invertColor
|
|
2052
|
-
});
|
|
2053
|
-
break;
|
|
2054
|
-
case 'similarBase':
|
|
2055
|
-
label.setAttributes({
|
|
2056
|
-
stroke: simialrColor
|
|
2057
|
-
});
|
|
2058
|
-
break;
|
|
2082
|
+
_canPlaceInside(textBound, shapeBound) {
|
|
2083
|
+
if (!textBound || !shapeBound) {
|
|
2084
|
+
return false;
|
|
2059
2085
|
}
|
|
2086
|
+
return shapeBound.encloses(textBound);
|
|
2060
2087
|
}
|
|
2061
2088
|
setLocation(point) {
|
|
2062
2089
|
this.translateTo(point.x, point.y);
|
|
@@ -2068,6 +2095,16 @@
|
|
|
2068
2095
|
this._enableAnimation = true;
|
|
2069
2096
|
}
|
|
2070
2097
|
}
|
|
2098
|
+
LabelBase.defaultAttributes = {
|
|
2099
|
+
textStyle: {
|
|
2100
|
+
fontSize: 12,
|
|
2101
|
+
textAlign: 'center',
|
|
2102
|
+
textBaseline: 'middle',
|
|
2103
|
+
boundsPadding: [-1, 0, -1, 0]
|
|
2104
|
+
},
|
|
2105
|
+
offset: 0,
|
|
2106
|
+
pickable: false
|
|
2107
|
+
};
|
|
2071
2108
|
|
|
2072
2109
|
class SymbolLabel extends LabelBase {
|
|
2073
2110
|
constructor(attributes) {
|
|
@@ -2383,13 +2420,16 @@
|
|
|
2383
2420
|
}
|
|
2384
2421
|
|
|
2385
2422
|
class ArcInfo {
|
|
2386
|
-
constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle) {
|
|
2423
|
+
constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle, innerRadius, outerRadius, circleCenter) {
|
|
2387
2424
|
this.refDatum = refDatum;
|
|
2388
2425
|
this.center = center;
|
|
2389
2426
|
this.outerCenter = outerCenter;
|
|
2390
2427
|
this.quadrant = quadrant;
|
|
2391
2428
|
this.radian = radian;
|
|
2392
2429
|
this.middleAngle = middleAngle;
|
|
2430
|
+
this.innerRadius = innerRadius;
|
|
2431
|
+
this.outerRadius = outerRadius;
|
|
2432
|
+
this.circleCenter = circleCenter;
|
|
2393
2433
|
this.labelVisible = true;
|
|
2394
2434
|
this.labelLimit = 0;
|
|
2395
2435
|
}
|
|
@@ -2422,18 +2462,45 @@
|
|
|
2422
2462
|
}
|
|
2423
2463
|
return { x: 0, y: 0 };
|
|
2424
2464
|
}
|
|
2465
|
+
_layout(data = []) {
|
|
2466
|
+
const labels = super._layout(data);
|
|
2467
|
+
const textBoundsArray = labels.map(label => this.getGraphicBounds(label));
|
|
2468
|
+
const ellipsisLabelAttribute = Object.assign(Object.assign({}, this.attribute.textStyle), { text: '...' });
|
|
2469
|
+
const ellipsisText = this._createLabelText(ellipsisLabelAttribute);
|
|
2470
|
+
const ellipsisTextBounds = this.getGraphicBounds(ellipsisText);
|
|
2471
|
+
const ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
|
|
2472
|
+
const arcs = this.layoutArcLabels(this.attribute.position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray, ellipsisWidth);
|
|
2473
|
+
for (let i = 0; i < data.length; i++) {
|
|
2474
|
+
const textData = data[i];
|
|
2475
|
+
const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
|
|
2476
|
+
const labelAttribute = {
|
|
2477
|
+
visible: basedArc.labelVisible,
|
|
2478
|
+
x: basedArc.labelPosition.x,
|
|
2479
|
+
y: basedArc.labelPosition.y,
|
|
2480
|
+
angle: basedArc.angle,
|
|
2481
|
+
maxLineWidth: basedArc.labelLimit,
|
|
2482
|
+
points: (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointA) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointB) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointC)
|
|
2483
|
+
? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
|
|
2484
|
+
: undefined,
|
|
2485
|
+
line: basedArc === null || basedArc === void 0 ? void 0 : basedArc.labelLine
|
|
2486
|
+
};
|
|
2487
|
+
labels[i].setAttributes(labelAttribute);
|
|
2488
|
+
}
|
|
2489
|
+
return labels;
|
|
2490
|
+
}
|
|
2425
2491
|
layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
|
|
2426
|
-
var _a;
|
|
2427
2492
|
this._arcLeft.clear();
|
|
2428
2493
|
this._arcRight.clear();
|
|
2429
2494
|
this._ellipsisWidth = ellipsisWidth;
|
|
2430
|
-
|
|
2431
|
-
|
|
2495
|
+
let maxRadius = 0;
|
|
2496
|
+
currentMarks.forEach(currentMarks => {
|
|
2497
|
+
if (currentMarks.attribute.outerRadius > maxRadius) {
|
|
2498
|
+
maxRadius = currentMarks.attribute.outerRadius;
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2432
2501
|
currentMarks.forEach((currentMark, index) => {
|
|
2433
2502
|
var _a, _b;
|
|
2434
2503
|
const graphicAttribute = currentMark.attribute;
|
|
2435
|
-
const radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height);
|
|
2436
|
-
const radius = this.computeRadius(radiusRatio, width, height, centerOffset);
|
|
2437
2504
|
const center = { x: (_a = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.x) !== null && _a !== void 0 ? _a : 0, y: (_b = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.y) !== null && _b !== void 0 ? _b : 0 };
|
|
2438
2505
|
const item = data[index];
|
|
2439
2506
|
const textBounds = textBoundsArray[index];
|
|
@@ -2441,9 +2508,9 @@
|
|
|
2441
2508
|
const intervalAngle = graphicAttribute.endAngle - graphicAttribute.startAngle;
|
|
2442
2509
|
const arcQuadrant = computeQuadrant(graphicAttribute.endAngle - intervalAngle / 2);
|
|
2443
2510
|
const arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle);
|
|
2444
|
-
const outerArcMiddle = circlePoint(center.x, center.y,
|
|
2445
|
-
const arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
|
|
2446
|
-
arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius
|
|
2511
|
+
const outerArcMiddle = circlePoint(center.x, center.y, maxRadius + attribute.line.line1MinLength, arcMiddleAngle);
|
|
2512
|
+
const arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle, graphicAttribute.innerRadius, graphicAttribute.outerRadius, center);
|
|
2513
|
+
arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius), arc.middleAngle);
|
|
2447
2514
|
arc.labelSize = {
|
|
2448
2515
|
width: textBounds.x2 - textBounds.x1,
|
|
2449
2516
|
height: textBounds.y2 - textBounds.y1
|
|
@@ -2469,18 +2536,13 @@
|
|
|
2469
2536
|
return arcs;
|
|
2470
2537
|
}
|
|
2471
2538
|
_layoutInsideLabels(arcs, attribute, currentMarks) {
|
|
2472
|
-
var _a, _b, _c, _d, _e;
|
|
2473
|
-
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2474
|
-
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2475
|
-
const innerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.innerRadius, attribute.width, attribute.height);
|
|
2476
|
-
const outerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
|
|
2477
2539
|
const labelConfig = attribute;
|
|
2478
2540
|
const spaceWidth = labelConfig.spaceWidth;
|
|
2479
2541
|
arcs.forEach((arc) => {
|
|
2480
2542
|
var _a, _b;
|
|
2481
2543
|
const { labelSize, radian } = arc;
|
|
2482
|
-
const innerRadius =
|
|
2483
|
-
const outerRadius =
|
|
2544
|
+
const innerRadius = arc.innerRadius;
|
|
2545
|
+
const outerRadius = arc.outerRadius;
|
|
2484
2546
|
const minRadian = connectLineRadian(outerRadius, labelSize.height);
|
|
2485
2547
|
let limit;
|
|
2486
2548
|
if (radian < minRadian) {
|
|
@@ -2505,7 +2567,7 @@
|
|
|
2505
2567
|
const align = this._computeAlign(arc, attribute);
|
|
2506
2568
|
const alignOffset = align === 'left' ? labelWidth : align === 'right' ? 0 : labelWidth / 2;
|
|
2507
2569
|
const labelRadius = outerRadius - spaceWidth - alignOffset;
|
|
2508
|
-
arc.labelPosition = circlePoint(
|
|
2570
|
+
arc.labelPosition = circlePoint(arc.circleCenter.x, arc.circleCenter.y, labelRadius, arc.middleAngle);
|
|
2509
2571
|
arc.labelLimit = labelWidth;
|
|
2510
2572
|
if (!vutils.isGreater(labelWidth, 0)) {
|
|
2511
2573
|
arc.labelVisible = false;
|
|
@@ -2575,18 +2637,24 @@
|
|
|
2575
2637
|
arc.labelVisible = false;
|
|
2576
2638
|
}
|
|
2577
2639
|
arc.angle = (_b = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : 0;
|
|
2640
|
+
arc.labelLine = Object.assign({}, attribute === null || attribute === void 0 ? void 0 : attribute.line);
|
|
2578
2641
|
});
|
|
2579
2642
|
return arcs;
|
|
2580
2643
|
}
|
|
2581
2644
|
_computeX(arc, attribute, currentMarks) {
|
|
2582
|
-
var _a
|
|
2583
|
-
const center =
|
|
2584
|
-
const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
|
|
2645
|
+
var _a;
|
|
2646
|
+
const center = arc.circleCenter;
|
|
2585
2647
|
const plotLayout = { width: center.x * 2, height: center.y * 2 };
|
|
2586
|
-
|
|
2648
|
+
let maxRadius = 0;
|
|
2649
|
+
currentMarks.forEach((currentMark) => {
|
|
2650
|
+
if (currentMark.attribute.outerRadius > maxRadius) {
|
|
2651
|
+
maxRadius = currentMark.attribute.outerRadius;
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
const radiusRatio = this.computeLayoutOuterRadius(maxRadius, attribute.width, attribute.height);
|
|
2587
2655
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2588
2656
|
const line2MinLength = attribute.line.line2MinLength;
|
|
2589
|
-
const labelLayoutAlign = (
|
|
2657
|
+
const labelLayoutAlign = (_a = attribute.layout) === null || _a === void 0 ? void 0 : _a.align;
|
|
2590
2658
|
const spaceWidth = attribute.spaceWidth;
|
|
2591
2659
|
const { labelPosition, quadrant, pointB } = arc;
|
|
2592
2660
|
if (!vutils.isValidNumber(pointB.x * pointB.y)) {
|
|
@@ -2594,7 +2662,7 @@
|
|
|
2594
2662
|
labelPosition.x = NaN;
|
|
2595
2663
|
arc.labelLimit = 0;
|
|
2596
2664
|
}
|
|
2597
|
-
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height
|
|
2665
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2598
2666
|
const flag = isQuadrantLeft(quadrant) ? -1 : 1;
|
|
2599
2667
|
let cx = 0;
|
|
2600
2668
|
const restWidth = flag > 0 ? plotLayout.width - pointB.x : pointB.x;
|
|
@@ -2812,9 +2880,14 @@
|
|
|
2812
2880
|
return -1;
|
|
2813
2881
|
}
|
|
2814
2882
|
_computePointB(arc, r, attribute, currentMarks) {
|
|
2815
|
-
var _a, _b, _c, _d, _e;
|
|
2816
2883
|
const labelConfig = attribute;
|
|
2817
|
-
|
|
2884
|
+
let maxRadius = 0;
|
|
2885
|
+
currentMarks.forEach((currentMark) => {
|
|
2886
|
+
if (currentMark.attribute.outerRadius > maxRadius) {
|
|
2887
|
+
maxRadius = currentMark.attribute.outerRadius;
|
|
2888
|
+
}
|
|
2889
|
+
});
|
|
2890
|
+
const radiusRatio = this.computeLayoutOuterRadius(maxRadius, attribute.width, attribute.height);
|
|
2818
2891
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
2819
2892
|
const labelLayout = labelConfig.layout;
|
|
2820
2893
|
if (labelLayout.strategy === 'none') {
|
|
@@ -2824,11 +2897,10 @@
|
|
|
2824
2897
|
};
|
|
2825
2898
|
}
|
|
2826
2899
|
else {
|
|
2827
|
-
const center =
|
|
2828
|
-
const
|
|
2829
|
-
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2900
|
+
const center = arc.circleCenter;
|
|
2901
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2830
2902
|
const { labelPosition, quadrant } = arc;
|
|
2831
|
-
const outerR = Math.max(radius + line1MinLength,
|
|
2903
|
+
const outerR = Math.max(radius + line1MinLength, arc.outerRadius);
|
|
2832
2904
|
const rd = r - outerR;
|
|
2833
2905
|
const x = Math.sqrt(r ** 2 - Math.abs(center.y - labelPosition.y) ** 2) - rd;
|
|
2834
2906
|
if (vutils.isValidNumber(x)) {
|
|
@@ -2850,14 +2922,18 @@
|
|
|
2850
2922
|
}
|
|
2851
2923
|
}
|
|
2852
2924
|
_computeYRange(arc, attribute, currentMarks) {
|
|
2853
|
-
|
|
2854
|
-
const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
|
|
2925
|
+
const center = arc.circleCenter;
|
|
2855
2926
|
const plotRect = { width: center.x * 2, height: center.y * 2 };
|
|
2856
|
-
|
|
2927
|
+
let maxRadius = 0;
|
|
2928
|
+
currentMarks.forEach((currentMark) => {
|
|
2929
|
+
if (currentMark.attribute.outerRadius > maxRadius) {
|
|
2930
|
+
maxRadius = currentMark.attribute.outerRadius;
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
const radiusRatio = this.computeLayoutOuterRadius(maxRadius, attribute.width, attribute.height);
|
|
2857
2934
|
const line1MinLength = attribute.line.line1MinLength;
|
|
2858
2935
|
const { width, height } = plotRect;
|
|
2859
|
-
const
|
|
2860
|
-
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
|
|
2936
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2861
2937
|
const r = this._computeLayoutRadius(height / 2, attribute, currentMarks);
|
|
2862
2938
|
const cx = Math.abs(arc.center.x - width / 2);
|
|
2863
2939
|
const cy = arc.center.y - height / 2;
|
|
@@ -2916,13 +2992,17 @@
|
|
|
2916
2992
|
arc.labelYRange = [min, max];
|
|
2917
2993
|
}
|
|
2918
2994
|
_computeLayoutRadius(halfYLength, attribute, currentMarks) {
|
|
2919
|
-
var _a;
|
|
2920
2995
|
const labelConfig = attribute;
|
|
2921
2996
|
const layoutArcGap = labelConfig.layoutArcGap;
|
|
2922
2997
|
const line1MinLength = labelConfig.line.line1MinLength;
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2998
|
+
let maxRadius = 0;
|
|
2999
|
+
currentMarks.forEach((currentMark) => {
|
|
3000
|
+
if (currentMark.attribute.outerRadius > maxRadius) {
|
|
3001
|
+
maxRadius = currentMark.attribute.outerRadius;
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
const radiusRatio = this.computeLayoutOuterRadius(maxRadius, attribute.width, attribute.height);
|
|
3005
|
+
const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
|
|
2926
3006
|
const outerR = radius + line1MinLength;
|
|
2927
3007
|
const a = outerR - layoutArcGap;
|
|
2928
3008
|
return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
|
|
@@ -2988,20 +3068,34 @@
|
|
|
2988
3068
|
}
|
|
2989
3069
|
}
|
|
2990
3070
|
}
|
|
2991
|
-
|
|
2992
|
-
var _a;
|
|
2993
|
-
|
|
3071
|
+
_labelLine(text) {
|
|
3072
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
3073
|
+
const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
|
|
3074
|
+
? vrender.createLine({
|
|
3075
|
+
visible: (_g = (_e = (((_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.line) === null || _c === void 0 ? void 0 : _c.visible) && ((_d = text.attribute) === null || _d === void 0 ? void 0 : _d.visible))) !== null && _e !== void 0 ? _e : (_f = text.attribute) === null || _f === void 0 ? void 0 : _f.visible) !== null && _g !== void 0 ? _g : true,
|
|
3076
|
+
stroke: (_l = (_k = (_j = (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.line) === null || _j === void 0 ? void 0 : _j.style) === null || _k === void 0 ? void 0 : _k.stroke) !== null && _l !== void 0 ? _l : (_m = text.attribute) === null || _m === void 0 ? void 0 : _m.fill,
|
|
3077
|
+
lineWidth: (_r = (_q = (_p = (_o = text.attribute) === null || _o === void 0 ? void 0 : _o.line) === null || _p === void 0 ? void 0 : _p.style) === null || _q === void 0 ? void 0 : _q.lineWidth) !== null && _r !== void 0 ? _r : 1,
|
|
3078
|
+
points: (_s = text.attribute) === null || _s === void 0 ? void 0 : _s.points,
|
|
3079
|
+
curveType: ((_u = (_t = text.attribute) === null || _t === void 0 ? void 0 : _t.line) === null || _u === void 0 ? void 0 : _u.smooth) ? 'basis' : null
|
|
3080
|
+
})
|
|
3081
|
+
: undefined;
|
|
3082
|
+
return labelLine;
|
|
3083
|
+
}
|
|
3084
|
+
computeRadius(r, width, height, k) {
|
|
3085
|
+
return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k);
|
|
2994
3086
|
}
|
|
2995
3087
|
computeLayoutRadius(width, height) {
|
|
2996
3088
|
return Math.min(width / 2, height / 2);
|
|
2997
3089
|
}
|
|
3090
|
+
_canPlaceInside(textBound, shapeBound) {
|
|
3091
|
+
return this.attribute.position === 'inside';
|
|
3092
|
+
}
|
|
2998
3093
|
computeLayoutOuterRadius(r, width, height) {
|
|
2999
3094
|
return r / (Math.min(width, height) / 2);
|
|
3000
3095
|
}
|
|
3001
|
-
computeDatumRadius(width, height, outerRadius
|
|
3002
|
-
var _a;
|
|
3096
|
+
computeDatumRadius(width, height, outerRadius) {
|
|
3003
3097
|
const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
|
|
3004
|
-
return
|
|
3098
|
+
return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio;
|
|
3005
3099
|
}
|
|
3006
3100
|
}
|
|
3007
3101
|
ArcLabel.defaultAttributes = {
|
|
@@ -3059,7 +3153,8 @@
|
|
|
3059
3153
|
const prevComponentMap = this._componentMap;
|
|
3060
3154
|
for (let i = 0; i < dataLabels.length; i++) {
|
|
3061
3155
|
const dataLabel = dataLabels[i];
|
|
3062
|
-
|
|
3156
|
+
const labelComponent = labelComponentMap[dataLabel.type] || LabelBase;
|
|
3157
|
+
if (labelComponent) {
|
|
3063
3158
|
const { baseMarkGroupName } = dataLabel;
|
|
3064
3159
|
let component = this._componentMap.get(baseMarkGroupName);
|
|
3065
3160
|
if (component) {
|
|
@@ -3069,7 +3164,7 @@
|
|
|
3069
3164
|
currentComponentMap.set(baseMarkGroupName, component);
|
|
3070
3165
|
}
|
|
3071
3166
|
else {
|
|
3072
|
-
component = new
|
|
3167
|
+
component = new labelComponent(dataLabel);
|
|
3073
3168
|
component.setBitmap(bitmap);
|
|
3074
3169
|
component.setBitmapTool(tool);
|
|
3075
3170
|
this.add(component);
|
|
@@ -3103,69 +3198,74 @@
|
|
|
3103
3198
|
};
|
|
3104
3199
|
|
|
3105
3200
|
class Segment extends AbstractComponent {
|
|
3201
|
+
getStartAngle() {
|
|
3202
|
+
return this._startAngle;
|
|
3203
|
+
}
|
|
3204
|
+
getEndAngle() {
|
|
3205
|
+
return this._endAngle;
|
|
3206
|
+
}
|
|
3207
|
+
getMainSegmentPoints() {
|
|
3208
|
+
return this._mainSegmentPoints;
|
|
3209
|
+
}
|
|
3106
3210
|
constructor(attributes) {
|
|
3107
3211
|
super(vutils.merge({}, Segment.defaultAttributes, attributes));
|
|
3108
3212
|
this.name = 'segment';
|
|
3109
3213
|
}
|
|
3110
|
-
computeLineAngle() {
|
|
3111
|
-
const { points } = this.attribute;
|
|
3112
|
-
const start = points[0];
|
|
3113
|
-
const startInside = points[1];
|
|
3114
|
-
const endInside = points[points.length - 2];
|
|
3115
|
-
const end = points[points.length - 1];
|
|
3116
|
-
const startVector = [start.x - startInside.x, start.y - startInside.y];
|
|
3117
|
-
const startAngle = Math.atan2(startVector[1], startVector[0]);
|
|
3118
|
-
const endVector = [end.x - endInside.x, end.y - endInside.y];
|
|
3119
|
-
const endAngle = Math.atan2(endVector[1], endVector[0]);
|
|
3120
|
-
this._startAngle = startAngle;
|
|
3121
|
-
this._endAngle = endAngle;
|
|
3122
|
-
}
|
|
3123
3214
|
render() {
|
|
3124
3215
|
this.removeAllChild();
|
|
3125
|
-
|
|
3216
|
+
this._reset();
|
|
3217
|
+
const { startSymbol, endSymbol, lineStyle, state, visible = true, multiSegment, mainSegmentIndex } = this.attribute;
|
|
3126
3218
|
if (!visible) {
|
|
3127
3219
|
return;
|
|
3128
3220
|
}
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
const startSymbolShape = this.renderSymbol(startSymbol, 'start');
|
|
3133
|
-
const endSymbolShape = this.renderSymbol(endSymbol, 'end');
|
|
3221
|
+
this._computeLineAngle();
|
|
3222
|
+
const startSymbolShape = this._renderSymbol(startSymbol, 'start');
|
|
3223
|
+
const endSymbolShape = this._renderSymbol(endSymbol, 'end');
|
|
3134
3224
|
this.startSymbol = startSymbolShape;
|
|
3135
3225
|
this.endSymbol = endSymbolShape;
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3226
|
+
if (multiSegment) {
|
|
3227
|
+
const points = [...this.attribute.points];
|
|
3228
|
+
if (vutils.isValidNumber(mainSegmentIndex)) {
|
|
3229
|
+
points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex]);
|
|
3230
|
+
}
|
|
3231
|
+
else {
|
|
3232
|
+
const clipPoints = this._clipPoints(vutils.flattenArray(points));
|
|
3233
|
+
points[0][0] = clipPoints[0];
|
|
3234
|
+
points[points.length - 1][points[points.length - 1].length - 1] =
|
|
3235
|
+
clipPoints[clipPoints.length - 1];
|
|
3236
|
+
}
|
|
3237
|
+
points.forEach((point, index) => {
|
|
3238
|
+
var _a, _b;
|
|
3239
|
+
const line = vrender.createLine(Object.assign(Object.assign({ points: point }, (vutils.isArray(lineStyle) ? (_a = lineStyle[index]) !== null && _a !== void 0 ? _a : lineStyle[lineStyle.length - 1] : lineStyle)), { fill: false }));
|
|
3240
|
+
line.name = `${this.name}-line`;
|
|
3241
|
+
line.id = this._getNodeId('line' + index);
|
|
3242
|
+
if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
|
|
3243
|
+
line.states = vutils.isArray(state.line) ? (_b = state.line[index]) !== null && _b !== void 0 ? _b : state.line[state.line.length - 1] : state.line;
|
|
3244
|
+
}
|
|
3245
|
+
this.add(line);
|
|
3246
|
+
});
|
|
3152
3247
|
}
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3248
|
+
else {
|
|
3249
|
+
const line = vrender.createLine(Object.assign(Object.assign({ points: this._clipPoints(this.attribute.points) }, vutils.array(lineStyle)[0]), { fill: false }));
|
|
3250
|
+
line.name = `${this.name}-line`;
|
|
3251
|
+
line.id = this._getNodeId('line');
|
|
3252
|
+
if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
|
|
3253
|
+
line.states = [].concat(state.line)[0];
|
|
3254
|
+
}
|
|
3255
|
+
this.add(line);
|
|
3158
3256
|
}
|
|
3159
|
-
this.line = line;
|
|
3160
|
-
this.add(line);
|
|
3161
3257
|
}
|
|
3162
|
-
|
|
3258
|
+
_renderSymbol(attribute, dim) {
|
|
3259
|
+
const points = this._getMainSegmentPoints();
|
|
3260
|
+
if (!points.length) {
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3163
3263
|
const { autoRotate = true } = attribute;
|
|
3164
3264
|
let symbol;
|
|
3165
3265
|
if (attribute === null || attribute === void 0 ? void 0 : attribute.visible) {
|
|
3166
3266
|
const startAngle = this._startAngle;
|
|
3167
3267
|
const endAngle = this._endAngle;
|
|
3168
|
-
const {
|
|
3268
|
+
const { state } = this.attribute;
|
|
3169
3269
|
const start = points[0];
|
|
3170
3270
|
const end = points[points.length - 1];
|
|
3171
3271
|
const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;
|
|
@@ -3173,20 +3273,22 @@
|
|
|
3173
3273
|
let rotate;
|
|
3174
3274
|
if (dim === 'start') {
|
|
3175
3275
|
position = {
|
|
3176
|
-
x: start.x +
|
|
3177
|
-
|
|
3276
|
+
x: start.x +
|
|
3277
|
+
(vutils.isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),
|
|
3278
|
+
y: start.y +
|
|
3279
|
+
(vutils.isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)
|
|
3178
3280
|
};
|
|
3179
3281
|
rotate = startAngle + Math.PI / 2;
|
|
3180
3282
|
}
|
|
3181
3283
|
else {
|
|
3182
3284
|
position = {
|
|
3183
|
-
x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
|
|
3184
|
-
y: end.y + (endAngle ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)
|
|
3285
|
+
x: end.x + (vutils.isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
|
|
3286
|
+
y: end.y + (vutils.isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)
|
|
3185
3287
|
};
|
|
3186
3288
|
rotate = endAngle + Math.PI / 2;
|
|
3187
3289
|
}
|
|
3188
3290
|
symbol = vrender.createSymbol(Object.assign(Object.assign(Object.assign({}, position), { symbolType: symbolType, size, angle: autoRotate ? rotate + refAngle : 0, strokeBoundsBuffer: 0 }), style));
|
|
3189
|
-
symbol.name = `${dim}-symbol`;
|
|
3291
|
+
symbol.name = `${this.name}-${dim}-symbol`;
|
|
3190
3292
|
symbol.id = this._getNodeId(`${dim}-symbol`);
|
|
3191
3293
|
if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.symbol)) {
|
|
3192
3294
|
symbol.states = state.symbol;
|
|
@@ -3195,11 +3297,69 @@
|
|
|
3195
3297
|
}
|
|
3196
3298
|
return symbol;
|
|
3197
3299
|
}
|
|
3198
|
-
|
|
3199
|
-
|
|
3300
|
+
_getMainSegmentPoints() {
|
|
3301
|
+
if (this._mainSegmentPoints) {
|
|
3302
|
+
return this._mainSegmentPoints;
|
|
3303
|
+
}
|
|
3304
|
+
const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute;
|
|
3305
|
+
let points;
|
|
3306
|
+
if (multiSegment) {
|
|
3307
|
+
if (vutils.isValidNumber(mainSegmentIndex)) {
|
|
3308
|
+
points = originPoints[mainSegmentIndex];
|
|
3309
|
+
}
|
|
3310
|
+
else {
|
|
3311
|
+
points = vutils.flattenArray(originPoints);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
else {
|
|
3315
|
+
points = originPoints;
|
|
3316
|
+
}
|
|
3317
|
+
this._mainSegmentPoints = points;
|
|
3318
|
+
return points;
|
|
3200
3319
|
}
|
|
3201
|
-
|
|
3202
|
-
|
|
3320
|
+
_clipPoints(points) {
|
|
3321
|
+
const { startSymbol, endSymbol } = this.attribute;
|
|
3322
|
+
let pointsAfterClip = points;
|
|
3323
|
+
if (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.visible) {
|
|
3324
|
+
const startSize = (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.clip) ? (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.size) || 10 : 0;
|
|
3325
|
+
const pointsStart = {
|
|
3326
|
+
x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),
|
|
3327
|
+
y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)
|
|
3328
|
+
};
|
|
3329
|
+
pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];
|
|
3330
|
+
}
|
|
3331
|
+
if (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.visible) {
|
|
3332
|
+
const endSize = (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.clip) ? (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.size) || 10 : 0;
|
|
3333
|
+
const pointsEnd = {
|
|
3334
|
+
x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),
|
|
3335
|
+
y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)
|
|
3336
|
+
};
|
|
3337
|
+
pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];
|
|
3338
|
+
}
|
|
3339
|
+
return pointsAfterClip;
|
|
3340
|
+
}
|
|
3341
|
+
_computeLineAngle() {
|
|
3342
|
+
const points = this._getMainSegmentPoints();
|
|
3343
|
+
if (points.length <= 1) {
|
|
3344
|
+
return;
|
|
3345
|
+
}
|
|
3346
|
+
const start = points[0];
|
|
3347
|
+
const startInside = points[1];
|
|
3348
|
+
const endInside = points[points.length - 2];
|
|
3349
|
+
const end = points[points.length - 1];
|
|
3350
|
+
const startVector = [start.x - startInside.x, start.y - startInside.y];
|
|
3351
|
+
const startAngle = Math.atan2(startVector[1], startVector[0]);
|
|
3352
|
+
const endVector = [end.x - endInside.x, end.y - endInside.y];
|
|
3353
|
+
const endAngle = Math.atan2(endVector[1], endVector[0]);
|
|
3354
|
+
this._startAngle = startAngle;
|
|
3355
|
+
this._endAngle = endAngle;
|
|
3356
|
+
}
|
|
3357
|
+
_reset() {
|
|
3358
|
+
this.startSymbol = null;
|
|
3359
|
+
this.endSymbol = null;
|
|
3360
|
+
this._startAngle = null;
|
|
3361
|
+
this._endAngle = null;
|
|
3362
|
+
this._mainSegmentPoints = null;
|
|
3203
3363
|
}
|
|
3204
3364
|
}
|
|
3205
3365
|
Segment.defaultAttributes = {
|
|
@@ -3885,12 +4045,14 @@
|
|
|
3885
4045
|
}
|
|
3886
4046
|
function rotateYAxis(orient, items) {
|
|
3887
4047
|
items.forEach((item, i) => {
|
|
3888
|
-
item.
|
|
4048
|
+
item.attribute.angle &&
|
|
4049
|
+
item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
3889
4050
|
});
|
|
3890
4051
|
}
|
|
3891
4052
|
function rotateXAxis(orient, items) {
|
|
3892
4053
|
items.forEach(item => {
|
|
3893
|
-
item.
|
|
4054
|
+
item.attribute.angle &&
|
|
4055
|
+
item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
|
|
3894
4056
|
});
|
|
3895
4057
|
}
|
|
3896
4058
|
function getXAxisLabelAlign(orient, angle = 0) {
|
|
@@ -4256,6 +4418,92 @@
|
|
|
4256
4418
|
};
|
|
4257
4419
|
}
|
|
4258
4420
|
beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
4421
|
+
const { flush = false } = this.attribute.label || {};
|
|
4422
|
+
if (flush && labelShapes.length) {
|
|
4423
|
+
const { orient, start, end } = this.attribute;
|
|
4424
|
+
const isX = orient === 'bottom' || orient === 'top';
|
|
4425
|
+
const first = labelShapes[0];
|
|
4426
|
+
const last = vutils.last(labelShapes);
|
|
4427
|
+
const isInverse = isX ? first.attribute.x > last.attribute.x : first.attribute.y < last.attribute.y;
|
|
4428
|
+
if (isX) {
|
|
4429
|
+
const width = Math.abs(start.x - end.x);
|
|
4430
|
+
if (isInverse) {
|
|
4431
|
+
const start = width;
|
|
4432
|
+
const end = 0;
|
|
4433
|
+
const startBound = first.AABBBounds.x2;
|
|
4434
|
+
const endBound = last.AABBBounds.x1;
|
|
4435
|
+
if (startBound > start) {
|
|
4436
|
+
first.setAttributes({
|
|
4437
|
+
x: start,
|
|
4438
|
+
textAlign: 'right'
|
|
4439
|
+
});
|
|
4440
|
+
}
|
|
4441
|
+
if (endBound < end) {
|
|
4442
|
+
last.setAttributes({
|
|
4443
|
+
x: end,
|
|
4444
|
+
textAlign: 'left'
|
|
4445
|
+
});
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
else {
|
|
4449
|
+
const start = 0;
|
|
4450
|
+
const end = width;
|
|
4451
|
+
const startBound = first.AABBBounds.x1;
|
|
4452
|
+
const endBound = last.AABBBounds.x2;
|
|
4453
|
+
if (startBound < start) {
|
|
4454
|
+
first.setAttributes({
|
|
4455
|
+
x: start,
|
|
4456
|
+
textAlign: 'left'
|
|
4457
|
+
});
|
|
4458
|
+
}
|
|
4459
|
+
if (endBound > end) {
|
|
4460
|
+
last.setAttributes({
|
|
4461
|
+
x: end,
|
|
4462
|
+
textAlign: 'right'
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
else {
|
|
4468
|
+
const height = Math.abs(start.y - end.y);
|
|
4469
|
+
if (isInverse) {
|
|
4470
|
+
const startBound = first.AABBBounds.y1;
|
|
4471
|
+
const endBound = last.AABBBounds.y2;
|
|
4472
|
+
const start = 0;
|
|
4473
|
+
const end = height;
|
|
4474
|
+
if (startBound < start) {
|
|
4475
|
+
first.setAttributes({
|
|
4476
|
+
y: start,
|
|
4477
|
+
textBaseline: 'top'
|
|
4478
|
+
});
|
|
4479
|
+
}
|
|
4480
|
+
if (endBound > end) {
|
|
4481
|
+
last.setAttributes({
|
|
4482
|
+
y: end,
|
|
4483
|
+
textBaseline: 'bottom'
|
|
4484
|
+
});
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
else {
|
|
4488
|
+
const start = height;
|
|
4489
|
+
const end = 0;
|
|
4490
|
+
const startBound = first.AABBBounds.y2;
|
|
4491
|
+
const endBound = last.AABBBounds.y1;
|
|
4492
|
+
if (startBound > start) {
|
|
4493
|
+
first.setAttributes({
|
|
4494
|
+
y: start,
|
|
4495
|
+
textBaseline: 'bottom'
|
|
4496
|
+
});
|
|
4497
|
+
}
|
|
4498
|
+
if (endBound < end) {
|
|
4499
|
+
last.setAttributes({
|
|
4500
|
+
y: end,
|
|
4501
|
+
textBaseline: 'top'
|
|
4502
|
+
});
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4259
4507
|
return;
|
|
4260
4508
|
}
|
|
4261
4509
|
handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
|
|
@@ -5823,25 +6071,41 @@
|
|
|
5823
6071
|
})(exports.IMarkPointItemPosition || (exports.IMarkPointItemPosition = {}));
|
|
5824
6072
|
|
|
5825
6073
|
class Marker extends AbstractComponent {
|
|
6074
|
+
constructor() {
|
|
6075
|
+
super(...arguments);
|
|
6076
|
+
this.name = 'marker';
|
|
6077
|
+
}
|
|
5826
6078
|
_initContainer() {
|
|
5827
|
-
var _a, _b
|
|
5828
|
-
const
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
6079
|
+
var _a, _b;
|
|
6080
|
+
const { limitRect, clipInRange } = this.attribute;
|
|
6081
|
+
let group;
|
|
6082
|
+
if (clipInRange) {
|
|
6083
|
+
const groupClip = vrender.createGroup(Object.assign(Object.assign({}, limitRect), { clip: true, pickable: false }));
|
|
6084
|
+
group = vrender.createGroup({
|
|
6085
|
+
x: -((_a = limitRect === null || limitRect === void 0 ? void 0 : limitRect.x) !== null && _a !== void 0 ? _a : 0),
|
|
6086
|
+
y: -((_b = limitRect === null || limitRect === void 0 ? void 0 : limitRect.y) !== null && _b !== void 0 ? _b : 0)
|
|
6087
|
+
});
|
|
6088
|
+
groupClip.add(group);
|
|
6089
|
+
this._containerClip = groupClip;
|
|
6090
|
+
this.add(groupClip);
|
|
6091
|
+
}
|
|
6092
|
+
else {
|
|
6093
|
+
group = vrender.createGroup({
|
|
6094
|
+
x: 0,
|
|
6095
|
+
y: 0
|
|
6096
|
+
});
|
|
6097
|
+
this.add(group);
|
|
6098
|
+
}
|
|
6099
|
+
group.name = 'marker-container';
|
|
5837
6100
|
this._container = group;
|
|
5838
6101
|
}
|
|
5839
6102
|
_updateContainer() {
|
|
5840
|
-
var _a, _b, _c
|
|
5841
|
-
|
|
6103
|
+
var _a, _b, _c;
|
|
6104
|
+
const { limitRect, clipInRange } = this.attribute;
|
|
6105
|
+
(_a = this._containerClip) === null || _a === void 0 ? void 0 : _a.setAttributes(Object.assign({}, limitRect));
|
|
5842
6106
|
this._container.setAttributes({
|
|
5843
|
-
x:
|
|
5844
|
-
y:
|
|
6107
|
+
x: clipInRange ? -((_b = limitRect === null || limitRect === void 0 ? void 0 : limitRect.x) !== null && _b !== void 0 ? _b : 0) : 0,
|
|
6108
|
+
y: clipInRange ? -((_c = limitRect === null || limitRect === void 0 ? void 0 : limitRect.y) !== null && _c !== void 0 ? _c : 0) : 0
|
|
5845
6109
|
});
|
|
5846
6110
|
}
|
|
5847
6111
|
render() {
|
|
@@ -5853,7 +6117,7 @@
|
|
|
5853
6117
|
this.setAttribute('childrenPickable', false);
|
|
5854
6118
|
}
|
|
5855
6119
|
if (markerVisible) {
|
|
5856
|
-
if (!this.
|
|
6120
|
+
if (!this._container) {
|
|
5857
6121
|
this._initContainer();
|
|
5858
6122
|
this.initMarker(this._container);
|
|
5859
6123
|
}
|
|
@@ -6090,47 +6354,84 @@
|
|
|
6090
6354
|
}
|
|
6091
6355
|
};
|
|
6092
6356
|
|
|
6357
|
+
function limitShapeInBounds(shape, bounds) {
|
|
6358
|
+
const { x1: regionMinX, y1: regionMinY, x2: regionMaxX, y2: regionMaxY } = bounds;
|
|
6359
|
+
const { x1, y1, x2, y2 } = shape.AABBBounds;
|
|
6360
|
+
const { dx: originDx = 0, dy: originDy = 0 } = shape.attribute;
|
|
6361
|
+
let dx = 0;
|
|
6362
|
+
let dy = 0;
|
|
6363
|
+
if (x1 < regionMinX) {
|
|
6364
|
+
dx = regionMinX - x1;
|
|
6365
|
+
}
|
|
6366
|
+
if (y1 < regionMinY) {
|
|
6367
|
+
dy = regionMinY - y1;
|
|
6368
|
+
}
|
|
6369
|
+
if (x2 > regionMaxX) {
|
|
6370
|
+
dx = regionMaxX - x2;
|
|
6371
|
+
}
|
|
6372
|
+
if (y2 > regionMaxY) {
|
|
6373
|
+
dy = regionMaxY - y2;
|
|
6374
|
+
}
|
|
6375
|
+
if (dx) {
|
|
6376
|
+
shape.setAttribute('dx', dx + originDx);
|
|
6377
|
+
}
|
|
6378
|
+
if (dy) {
|
|
6379
|
+
shape.setAttribute('dy', dy + originDy);
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6382
|
+
|
|
6093
6383
|
class MarkLine extends Marker {
|
|
6094
6384
|
constructor(attributes) {
|
|
6095
6385
|
super(vutils.merge({}, MarkLine.defaultAttributes, attributes));
|
|
6096
6386
|
}
|
|
6097
6387
|
setLabelPos() {
|
|
6098
|
-
var _a, _b
|
|
6099
|
-
const {
|
|
6100
|
-
const
|
|
6101
|
-
const
|
|
6102
|
-
const
|
|
6103
|
-
const
|
|
6104
|
-
|
|
6105
|
-
|
|
6388
|
+
var _a, _b;
|
|
6389
|
+
const { label = {}, limitRect } = this.attribute;
|
|
6390
|
+
const { position = 'end', refX = 0, refY = 0, confine } = label;
|
|
6391
|
+
const points = this._line.getMainSegmentPoints();
|
|
6392
|
+
const labelAngle = (_a = this._line.getEndAngle()) !== null && _a !== void 0 ? _a : 0;
|
|
6393
|
+
const labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2);
|
|
6394
|
+
const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);
|
|
6395
|
+
let labelPoint;
|
|
6396
|
+
if (position.includes('start') || position.includes('Start')) {
|
|
6397
|
+
labelPoint = {
|
|
6106
6398
|
x: points[0].x + labelOffsetX,
|
|
6107
6399
|
y: points[0].y + labelOffsetY
|
|
6108
|
-
}
|
|
6400
|
+
};
|
|
6109
6401
|
}
|
|
6110
|
-
else if (
|
|
6111
|
-
|
|
6402
|
+
else if (position.includes('middle') || position.includes('Middle')) {
|
|
6403
|
+
labelPoint = {
|
|
6112
6404
|
x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
|
|
6113
6405
|
y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
|
|
6114
|
-
}
|
|
6406
|
+
};
|
|
6115
6407
|
}
|
|
6116
6408
|
else {
|
|
6117
|
-
|
|
6409
|
+
labelPoint = {
|
|
6118
6410
|
x: points[points.length - 1].x + labelOffsetX,
|
|
6119
6411
|
y: points[points.length - 1].y + labelOffsetY
|
|
6412
|
+
};
|
|
6413
|
+
}
|
|
6414
|
+
this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), { angle: label.autoRotate ? labelAngle + ((_b = label === null || label === void 0 ? void 0 : label.refAngle) !== null && _b !== void 0 ? _b : 0) : 0, textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[position]), label.textStyle) }));
|
|
6415
|
+
if (limitRect && confine) {
|
|
6416
|
+
const { x, y, width, height } = limitRect;
|
|
6417
|
+
limitShapeInBounds(this._label, {
|
|
6418
|
+
x1: x,
|
|
6419
|
+
y1: y,
|
|
6420
|
+
x2: x + width,
|
|
6421
|
+
y2: y + height
|
|
6120
6422
|
});
|
|
6121
6423
|
}
|
|
6122
|
-
this._label.setAttributes({
|
|
6123
|
-
angle: label.autoRotate && labelAngle + ((_e = label === null || label === void 0 ? void 0 : label.refAngle) !== null && _e !== void 0 ? _e : 0),
|
|
6124
|
-
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
6125
|
-
});
|
|
6126
6424
|
}
|
|
6127
6425
|
initMarker(container) {
|
|
6128
|
-
const { points, startSymbol, endSymbol, label, lineStyle } = this
|
|
6426
|
+
const { points, startSymbol, endSymbol, label, lineStyle, mainSegmentIndex, multiSegment } = this
|
|
6427
|
+
.attribute;
|
|
6129
6428
|
const line = new Segment({
|
|
6130
6429
|
points,
|
|
6131
6430
|
startSymbol,
|
|
6132
6431
|
endSymbol,
|
|
6133
|
-
lineStyle
|
|
6432
|
+
lineStyle,
|
|
6433
|
+
mainSegmentIndex,
|
|
6434
|
+
multiSegment
|
|
6134
6435
|
});
|
|
6135
6436
|
line.name = 'mark-line-line';
|
|
6136
6437
|
this._line = line;
|
|
@@ -6143,14 +6444,17 @@
|
|
|
6143
6444
|
}
|
|
6144
6445
|
updateMarker() {
|
|
6145
6446
|
var _a, _b;
|
|
6146
|
-
const { points, startSymbol, endSymbol, label, lineStyle } = this
|
|
6447
|
+
const { points, startSymbol, endSymbol, label, lineStyle, mainSegmentIndex, multiSegment } = this
|
|
6448
|
+
.attribute;
|
|
6147
6449
|
(_a = this._line) === null || _a === void 0 ? void 0 : _a.setAttributes({
|
|
6148
6450
|
points,
|
|
6149
6451
|
startSymbol,
|
|
6150
6452
|
endSymbol,
|
|
6151
|
-
lineStyle
|
|
6453
|
+
lineStyle,
|
|
6454
|
+
mainSegmentIndex,
|
|
6455
|
+
multiSegment
|
|
6152
6456
|
});
|
|
6153
|
-
(_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({}, label));
|
|
6457
|
+
(_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({ dx: 0, dy: 0 }, label));
|
|
6154
6458
|
this.setLabelPos();
|
|
6155
6459
|
}
|
|
6156
6460
|
}
|
|
@@ -6160,58 +6464,54 @@
|
|
|
6160
6464
|
constructor(attributes) {
|
|
6161
6465
|
super(vutils.merge({}, MarkArea.defaultAttributes, attributes));
|
|
6162
6466
|
}
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
return {
|
|
6171
|
-
x: this._area.AABBBounds.x2,
|
|
6172
|
-
y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
|
|
6173
|
-
};
|
|
6174
|
-
}
|
|
6175
|
-
getTopPos() {
|
|
6176
|
-
return {
|
|
6177
|
-
x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
|
|
6178
|
-
y: this._area.AABBBounds.y1
|
|
6179
|
-
};
|
|
6180
|
-
}
|
|
6181
|
-
getBottomPos() {
|
|
6182
|
-
return {
|
|
6183
|
-
x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
|
|
6184
|
-
y: this._area.AABBBounds.y2
|
|
6185
|
-
};
|
|
6186
|
-
}
|
|
6187
|
-
getMiddlePos() {
|
|
6188
|
-
return {
|
|
6189
|
-
x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
|
|
6190
|
-
y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
|
|
6191
|
-
};
|
|
6192
|
-
}
|
|
6193
|
-
setLabelPos() {
|
|
6194
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
6195
|
-
const { label } = this.attribute;
|
|
6196
|
-
const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'middle';
|
|
6197
|
-
if (labelPosition.includes('left') || labelPosition.includes('Left')) {
|
|
6198
|
-
(_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({}, this.getLeftPos()));
|
|
6467
|
+
_getPositionByDirection(area, direction) {
|
|
6468
|
+
const { x1, x2, y1, y2 } = this._area.AABBBounds;
|
|
6469
|
+
if (direction.includes('left') || direction.includes('Left')) {
|
|
6470
|
+
return {
|
|
6471
|
+
x: x1,
|
|
6472
|
+
y: (y1 + y2) / 2
|
|
6473
|
+
};
|
|
6199
6474
|
}
|
|
6200
|
-
|
|
6201
|
-
|
|
6475
|
+
if (direction.includes('right') || direction.includes('Right')) {
|
|
6476
|
+
return {
|
|
6477
|
+
x: x2,
|
|
6478
|
+
y: (y1 + y2) / 2
|
|
6479
|
+
};
|
|
6202
6480
|
}
|
|
6203
|
-
|
|
6204
|
-
|
|
6481
|
+
if (direction.includes('top') || direction.includes('Top')) {
|
|
6482
|
+
return {
|
|
6483
|
+
x: (x1 + x2) / 2,
|
|
6484
|
+
y: y1
|
|
6485
|
+
};
|
|
6205
6486
|
}
|
|
6206
|
-
|
|
6207
|
-
|
|
6487
|
+
if (direction.includes('bottom') || direction.includes('Bottom')) {
|
|
6488
|
+
return {
|
|
6489
|
+
x: (x1 + x2) / 2,
|
|
6490
|
+
y: y2
|
|
6491
|
+
};
|
|
6208
6492
|
}
|
|
6209
|
-
|
|
6210
|
-
(
|
|
6493
|
+
return {
|
|
6494
|
+
x: (x1 + x2) / 2,
|
|
6495
|
+
y: (y1 + y2) / 2
|
|
6496
|
+
};
|
|
6497
|
+
}
|
|
6498
|
+
setLabelPos() {
|
|
6499
|
+
var _a;
|
|
6500
|
+
if (this._label && this._area) {
|
|
6501
|
+
const { label } = this.attribute;
|
|
6502
|
+
const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'middle';
|
|
6503
|
+
const labelPoint = this._getPositionByDirection(this._area, labelPosition);
|
|
6504
|
+
this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), { textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle) }));
|
|
6505
|
+
if (this.attribute.limitRect && (label === null || label === void 0 ? void 0 : label.confine)) {
|
|
6506
|
+
const { x, y, width, height } = this.attribute.limitRect;
|
|
6507
|
+
limitShapeInBounds(this._label, {
|
|
6508
|
+
x1: x,
|
|
6509
|
+
y1: y,
|
|
6510
|
+
x2: x + width,
|
|
6511
|
+
y2: y + height
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6211
6514
|
}
|
|
6212
|
-
(_g = this._label) === null || _g === void 0 ? void 0 : _g.setAttributes({
|
|
6213
|
-
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
|
|
6214
|
-
});
|
|
6215
6515
|
}
|
|
6216
6516
|
initMarker(container) {
|
|
6217
6517
|
const { points, label, areaStyle } = this.attribute;
|
|
@@ -6229,7 +6529,7 @@
|
|
|
6229
6529
|
var _a, _b;
|
|
6230
6530
|
const { points, label, areaStyle } = this.attribute;
|
|
6231
6531
|
(_a = this._area) === null || _a === void 0 ? void 0 : _a.setAttributes(Object.assign({ points: points }, areaStyle));
|
|
6232
|
-
(_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({}, label));
|
|
6532
|
+
(_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({ dx: 0, dy: 0 }, label));
|
|
6233
6533
|
this.setLabelPos();
|
|
6234
6534
|
}
|
|
6235
6535
|
}
|
|
@@ -6243,26 +6543,29 @@
|
|
|
6243
6543
|
}
|
|
6244
6544
|
setItemAttributes(item, itemContent, itemPosition, itemType) {
|
|
6245
6545
|
var _a;
|
|
6546
|
+
if (!item) {
|
|
6547
|
+
return;
|
|
6548
|
+
}
|
|
6246
6549
|
const { autoRotate = true, refX = 0, refY = 0, refAngle = 0, textStyle, richTextStyle, imageStyle, position = exports.IMarkPointItemPosition.middle } = itemContent;
|
|
6247
6550
|
const itemAngle = ((_a = this._line) === null || _a === void 0 ? void 0 : _a.getEndAngle()) || 0;
|
|
6248
6551
|
const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);
|
|
6249
6552
|
const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
|
|
6250
6553
|
if (itemType === 'text') {
|
|
6251
|
-
item
|
|
6554
|
+
item.setAttributes(Object.assign(Object.assign({}, textStyle), { textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(itemContent === null || itemContent === void 0 ? void 0 : itemContent.position) || 'end']), textStyle === null || textStyle === void 0 ? void 0 : textStyle.textStyle) }));
|
|
6252
6555
|
}
|
|
6253
6556
|
else if (itemType === 'richText') {
|
|
6254
|
-
item
|
|
6557
|
+
item.setAttributes({
|
|
6255
6558
|
dx: this.getItemDx(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dx) || 0),
|
|
6256
6559
|
dy: this.getItemDy(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dy) || 0)
|
|
6257
6560
|
});
|
|
6258
6561
|
}
|
|
6259
6562
|
else if (itemType === 'image') {
|
|
6260
|
-
item
|
|
6563
|
+
item.setAttributes({
|
|
6261
6564
|
dx: this.getItemDx(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dx) || 0),
|
|
6262
6565
|
dy: this.getItemDy(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dy) || 0)
|
|
6263
6566
|
});
|
|
6264
6567
|
}
|
|
6265
|
-
item
|
|
6568
|
+
item.setAttributes({
|
|
6266
6569
|
x: itemPosition.x + (itemOffsetX || 0),
|
|
6267
6570
|
y: itemPosition.y + (itemOffsetY || 0),
|
|
6268
6571
|
angle: autoRotate && itemAngle + refAngle
|
|
@@ -6274,7 +6577,7 @@
|
|
|
6274
6577
|
if (position.includes('inside')) {
|
|
6275
6578
|
return -width;
|
|
6276
6579
|
}
|
|
6277
|
-
|
|
6580
|
+
if (position === 'insideTop') {
|
|
6278
6581
|
return 0;
|
|
6279
6582
|
}
|
|
6280
6583
|
return 0;
|
|
@@ -6285,7 +6588,7 @@
|
|
|
6285
6588
|
if (position.includes('top') || position.includes('Top')) {
|
|
6286
6589
|
return -height;
|
|
6287
6590
|
}
|
|
6288
|
-
|
|
6591
|
+
if (position.includes('middle') || position.includes('Middle')) {
|
|
6289
6592
|
return -height / 2;
|
|
6290
6593
|
}
|
|
6291
6594
|
return 0;
|
|
@@ -6481,7 +6784,8 @@
|
|
|
6481
6784
|
const changeEvent = new vrender.CustomEvent('toPrev', {
|
|
6482
6785
|
current: this._current,
|
|
6483
6786
|
total: this._total,
|
|
6484
|
-
direction: 'pre'
|
|
6787
|
+
direction: 'pre',
|
|
6788
|
+
event: e
|
|
6485
6789
|
});
|
|
6486
6790
|
changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
|
|
6487
6791
|
this.dispatchEvent(changeEvent);
|
|
@@ -6500,7 +6804,8 @@
|
|
|
6500
6804
|
const changeEvent = new vrender.CustomEvent('toNext', {
|
|
6501
6805
|
current: this._current,
|
|
6502
6806
|
total: this._total,
|
|
6503
|
-
direction: 'next'
|
|
6807
|
+
direction: 'next',
|
|
6808
|
+
event: e
|
|
6504
6809
|
});
|
|
6505
6810
|
changeEvent.manager = (_b = this.stage) === null || _b === void 0 ? void 0 : _b.eventSystem.manager;
|
|
6506
6811
|
this.dispatchEvent(changeEvent);
|
|
@@ -6726,16 +7031,16 @@
|
|
|
6726
7031
|
const legendItem = target.delegate;
|
|
6727
7032
|
const selected = legendItem.hasState(exports.LegendStateValue.selected);
|
|
6728
7033
|
if (selected) {
|
|
6729
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover);
|
|
7034
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover, e);
|
|
6730
7035
|
}
|
|
6731
7036
|
else {
|
|
6732
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover);
|
|
7037
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover, e);
|
|
6733
7038
|
}
|
|
6734
7039
|
const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
|
|
6735
7040
|
if (focusButton) {
|
|
6736
7041
|
focusButton.setAttribute('visible', true);
|
|
6737
7042
|
}
|
|
6738
|
-
this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem);
|
|
7043
|
+
this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem, e);
|
|
6739
7044
|
}
|
|
6740
7045
|
};
|
|
6741
7046
|
this._onUnHover = (e) => {
|
|
@@ -6766,9 +7071,9 @@
|
|
|
6766
7071
|
focusButton.setAttribute('visible', false);
|
|
6767
7072
|
}
|
|
6768
7073
|
if (attributeUpdate) {
|
|
6769
|
-
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
|
|
7074
|
+
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
|
|
6770
7075
|
}
|
|
6771
|
-
this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem);
|
|
7076
|
+
this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem, e);
|
|
6772
7077
|
}
|
|
6773
7078
|
};
|
|
6774
7079
|
this._onClick = (e) => {
|
|
@@ -6781,25 +7086,17 @@
|
|
|
6781
7086
|
legendItem.toggleState(exports.LegendStateValue.focus);
|
|
6782
7087
|
if (isFocusSelected) {
|
|
6783
7088
|
(_b = this._itemsContainer) === null || _b === void 0 ? void 0 : _b.getChildren().forEach(item => {
|
|
6784
|
-
this._removeLegendItemState(item, [
|
|
6785
|
-
|
|
6786
|
-
exports.LegendStateValue.unSelectedHover,
|
|
6787
|
-
exports.LegendStateValue.focus
|
|
6788
|
-
]);
|
|
6789
|
-
this._setLegendItemState(item, exports.LegendStateValue.selected);
|
|
7089
|
+
this._removeLegendItemState(item, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover, exports.LegendStateValue.focus], e);
|
|
7090
|
+
this._setLegendItemState(item, exports.LegendStateValue.selected, e);
|
|
6790
7091
|
});
|
|
6791
7092
|
}
|
|
6792
7093
|
else {
|
|
6793
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
|
|
6794
|
-
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
|
|
7094
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
|
|
7095
|
+
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
|
|
6795
7096
|
(_c = this._itemsContainer) === null || _c === void 0 ? void 0 : _c.getChildren().forEach(item => {
|
|
6796
7097
|
if (legendItem !== item) {
|
|
6797
|
-
this._removeLegendItemState(item, [
|
|
6798
|
-
|
|
6799
|
-
exports.LegendStateValue.selectedHover,
|
|
6800
|
-
exports.LegendStateValue.focus
|
|
6801
|
-
]);
|
|
6802
|
-
this._setLegendItemState(item, exports.LegendStateValue.unSelected);
|
|
7098
|
+
this._removeLegendItemState(item, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover, exports.LegendStateValue.focus], e);
|
|
7099
|
+
this._setLegendItemState(item, exports.LegendStateValue.unSelected, e);
|
|
6803
7100
|
}
|
|
6804
7101
|
});
|
|
6805
7102
|
}
|
|
@@ -6813,33 +7110,30 @@
|
|
|
6813
7110
|
const currentSelectedItems = this._getSelectedLegends();
|
|
6814
7111
|
if (selectMode === 'multiple') {
|
|
6815
7112
|
if (allowAllCanceled === false && isSelected && currentSelectedItems.length === 1) {
|
|
6816
|
-
this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
|
|
7113
|
+
this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
|
|
6817
7114
|
return;
|
|
6818
7115
|
}
|
|
6819
7116
|
if (isSelected) {
|
|
6820
|
-
this._removeLegendItemState(legendItem, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover]);
|
|
6821
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.unSelected);
|
|
7117
|
+
this._removeLegendItemState(legendItem, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover], e);
|
|
7118
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.unSelected, e);
|
|
6822
7119
|
}
|
|
6823
7120
|
else {
|
|
6824
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
|
|
6825
|
-
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
|
|
7121
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
|
|
7122
|
+
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
|
|
6826
7123
|
}
|
|
6827
7124
|
}
|
|
6828
7125
|
else {
|
|
6829
|
-
this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
|
|
6830
|
-
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
|
|
7126
|
+
this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
|
|
7127
|
+
this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
|
|
6831
7128
|
(_e = this._itemsContainer) === null || _e === void 0 ? void 0 : _e.getChildren().forEach(item => {
|
|
6832
7129
|
if (legendItem !== item) {
|
|
6833
|
-
this._removeLegendItemState(item, [
|
|
6834
|
-
|
|
6835
|
-
exports.LegendStateValue.selectedHover
|
|
6836
|
-
]);
|
|
6837
|
-
this._setLegendItemState(item, exports.LegendStateValue.unSelected);
|
|
7130
|
+
this._removeLegendItemState(item, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover], e);
|
|
7131
|
+
this._setLegendItemState(item, exports.LegendStateValue.unSelected, e);
|
|
6838
7132
|
}
|
|
6839
7133
|
});
|
|
6840
7134
|
}
|
|
6841
7135
|
}
|
|
6842
|
-
this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
|
|
7136
|
+
this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
|
|
6843
7137
|
}
|
|
6844
7138
|
};
|
|
6845
7139
|
}
|
|
@@ -7210,7 +7504,8 @@
|
|
|
7210
7504
|
this._pager.addEventListener('toNext', onPaging);
|
|
7211
7505
|
return true;
|
|
7212
7506
|
}
|
|
7213
|
-
_setLegendItemState(legendItem, stateName,
|
|
7507
|
+
_setLegendItemState(legendItem, stateName, e) {
|
|
7508
|
+
const keepCurrentStates = true;
|
|
7214
7509
|
let attributeUpdate = false;
|
|
7215
7510
|
if (!legendItem.hasState(stateName)) {
|
|
7216
7511
|
attributeUpdate = true;
|
|
@@ -7228,10 +7523,10 @@
|
|
|
7228
7523
|
}
|
|
7229
7524
|
});
|
|
7230
7525
|
if (attributeUpdate) {
|
|
7231
|
-
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
|
|
7526
|
+
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
|
|
7232
7527
|
}
|
|
7233
7528
|
}
|
|
7234
|
-
_removeLegendItemState(legendItem, stateNames) {
|
|
7529
|
+
_removeLegendItemState(legendItem, stateNames, e) {
|
|
7235
7530
|
let attributeUpdate = false;
|
|
7236
7531
|
stateNames.forEach(name => {
|
|
7237
7532
|
if (!attributeUpdate && legendItem.hasState(name)) {
|
|
@@ -7253,7 +7548,7 @@
|
|
|
7253
7548
|
}
|
|
7254
7549
|
});
|
|
7255
7550
|
if (attributeUpdate) {
|
|
7256
|
-
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
|
|
7551
|
+
this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
|
|
7257
7552
|
}
|
|
7258
7553
|
}
|
|
7259
7554
|
_getSelectedLegends() {
|
|
@@ -7272,7 +7567,7 @@
|
|
|
7272
7567
|
shape.delegate = delegateShape;
|
|
7273
7568
|
shape.states = vutils.merge({}, DEFAULT_STATES, states);
|
|
7274
7569
|
}
|
|
7275
|
-
_dispatchEvent(eventName, legendItem) {
|
|
7570
|
+
_dispatchEvent(eventName, legendItem, event) {
|
|
7276
7571
|
var _a;
|
|
7277
7572
|
const currentSelectedItems = this._getSelectedLegends();
|
|
7278
7573
|
currentSelectedItems.sort((pre, next) => pre.index - next.index);
|
|
@@ -7282,7 +7577,8 @@
|
|
|
7282
7577
|
data: legendItem.data,
|
|
7283
7578
|
selected: legendItem.hasState(exports.LegendStateValue.selected),
|
|
7284
7579
|
currentSelectedItems,
|
|
7285
|
-
currentSelected
|
|
7580
|
+
currentSelected,
|
|
7581
|
+
event
|
|
7286
7582
|
});
|
|
7287
7583
|
changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
|
|
7288
7584
|
this.dispatchEvent(changeEvent);
|
|
@@ -8770,16 +9066,16 @@
|
|
|
8770
9066
|
this._isPaused = true;
|
|
8771
9067
|
this.updateAttributes = () => {
|
|
8772
9068
|
this._startAttr = {
|
|
8773
|
-
style: Object.assign(Object.assign({ symbolType: iconPlay }, Controller.defaultControllerAttr), this.attribute.start.style)
|
|
9069
|
+
style: Object.assign(Object.assign(Object.assign({ symbolType: iconPlay }, Controller.defaultControllerAttr), { visible: this.attribute.start.visible }), this.attribute.start.style)
|
|
8774
9070
|
};
|
|
8775
9071
|
this._pauseAttr = {
|
|
8776
|
-
style: Object.assign(Object.assign({ symbolType: iconPause }, Controller.defaultControllerAttr), this.attribute.pause.style)
|
|
9072
|
+
style: Object.assign(Object.assign(Object.assign({ symbolType: iconPause }, Controller.defaultControllerAttr), { visible: this.attribute.pause.visible }), this.attribute.pause.style)
|
|
8777
9073
|
};
|
|
8778
9074
|
this._forwardAttr = {
|
|
8779
|
-
style: Object.assign(Object.assign({}, Controller.defaultControllerAttr), this.attribute.forward.style)
|
|
9075
|
+
style: Object.assign(Object.assign(Object.assign({}, Controller.defaultControllerAttr), { visible: this.attribute.forward.visible }), this.attribute.forward.style)
|
|
8780
9076
|
};
|
|
8781
9077
|
this._backwardAttr = {
|
|
8782
|
-
style: Object.assign(Object.assign({}, Controller.defaultControllerAttr), this.attribute.backward.style)
|
|
9078
|
+
style: Object.assign(Object.assign(Object.assign({}, Controller.defaultControllerAttr), { visible: this.attribute.backward.visible }), this.attribute.backward.style)
|
|
8783
9079
|
};
|
|
8784
9080
|
this.updateLayout();
|
|
8785
9081
|
};
|
|
@@ -8890,6 +9186,7 @@
|
|
|
8890
9186
|
}
|
|
8891
9187
|
}
|
|
8892
9188
|
Controller.defaultControllerAttr = {
|
|
9189
|
+
visible: true,
|
|
8893
9190
|
x: 0,
|
|
8894
9191
|
y: 0,
|
|
8895
9192
|
size: 20,
|
|
@@ -8898,7 +9195,6 @@
|
|
|
8898
9195
|
cursor: 'pointer'
|
|
8899
9196
|
};
|
|
8900
9197
|
Controller.defaultAttributes = {
|
|
8901
|
-
visible: true,
|
|
8902
9198
|
[ControllerTypeEnum.Start]: {},
|
|
8903
9199
|
[ControllerTypeEnum.Pause]: {},
|
|
8904
9200
|
[ControllerTypeEnum.Backward]: {},
|
|
@@ -8906,6 +9202,7 @@
|
|
|
8906
9202
|
};
|
|
8907
9203
|
|
|
8908
9204
|
const defaultControllerAttributes = {
|
|
9205
|
+
visible: true,
|
|
8909
9206
|
style: {
|
|
8910
9207
|
x: 0,
|
|
8911
9208
|
y: 0,
|
|
@@ -8926,12 +9223,18 @@
|
|
|
8926
9223
|
|
|
8927
9224
|
exports.PlayerEventEnum = void 0;
|
|
8928
9225
|
(function (PlayerEventEnum) {
|
|
8929
|
-
PlayerEventEnum["
|
|
8930
|
-
PlayerEventEnum["
|
|
8931
|
-
PlayerEventEnum["
|
|
8932
|
-
PlayerEventEnum["
|
|
8933
|
-
PlayerEventEnum["
|
|
8934
|
-
PlayerEventEnum["
|
|
9226
|
+
PlayerEventEnum["change"] = "change";
|
|
9227
|
+
PlayerEventEnum["play"] = "play";
|
|
9228
|
+
PlayerEventEnum["pause"] = "pause";
|
|
9229
|
+
PlayerEventEnum["backward"] = "backward";
|
|
9230
|
+
PlayerEventEnum["forward"] = "forward";
|
|
9231
|
+
PlayerEventEnum["end"] = "end";
|
|
9232
|
+
PlayerEventEnum["OnChange"] = "change";
|
|
9233
|
+
PlayerEventEnum["OnPlay"] = "play";
|
|
9234
|
+
PlayerEventEnum["OnPause"] = "pause";
|
|
9235
|
+
PlayerEventEnum["OnBackward"] = "backward";
|
|
9236
|
+
PlayerEventEnum["OnForward"] = "forward";
|
|
9237
|
+
PlayerEventEnum["OnEnd"] = "end";
|
|
8935
9238
|
})(exports.PlayerEventEnum || (exports.PlayerEventEnum = {}));
|
|
8936
9239
|
|
|
8937
9240
|
const isReachEndByDefault = ({ direction, maxIndex, dataIndex }) => {
|
|
@@ -8988,6 +9291,7 @@
|
|
|
8988
9291
|
handlerSize = vutils.max(this._handlerStyle.size[0], this._handlerStyle.size[1]);
|
|
8989
9292
|
}
|
|
8990
9293
|
const attrs = {
|
|
9294
|
+
visible: this._sliderVisible,
|
|
8991
9295
|
min: this._minIndex,
|
|
8992
9296
|
max: this._maxIndex,
|
|
8993
9297
|
value: (_a = this.attribute.dataIndex) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -9000,7 +9304,6 @@
|
|
|
9000
9304
|
dy: this.attribute.slider.dy,
|
|
9001
9305
|
dx: this.attribute.slider.dx,
|
|
9002
9306
|
slidable: true,
|
|
9003
|
-
visible: true,
|
|
9004
9307
|
range: false,
|
|
9005
9308
|
handlerText: { visible: false },
|
|
9006
9309
|
startText: { visible: false },
|
|
@@ -9029,11 +9332,12 @@
|
|
|
9029
9332
|
this._initSlider = () => {
|
|
9030
9333
|
const attrs = this._updateSliderAttrs();
|
|
9031
9334
|
this._slider = new Slider(attrs);
|
|
9032
|
-
|
|
9335
|
+
if (this._sliderVisible) {
|
|
9336
|
+
this.add(this._slider);
|
|
9337
|
+
}
|
|
9033
9338
|
};
|
|
9034
9339
|
this._updateControllerAttrs = () => {
|
|
9035
9340
|
const attrs = {
|
|
9036
|
-
visible: true,
|
|
9037
9341
|
start: this._start,
|
|
9038
9342
|
pause: this._pause,
|
|
9039
9343
|
forward: this._forward,
|
|
@@ -9041,40 +9345,26 @@
|
|
|
9041
9345
|
};
|
|
9042
9346
|
if (isHorizontal(this._orient)) {
|
|
9043
9347
|
attrs.layout = 'horizontal';
|
|
9044
|
-
attrs.start = {
|
|
9045
|
-
|
|
9046
|
-
};
|
|
9047
|
-
attrs.
|
|
9048
|
-
style: Object.assign(Object.assign({}, attrs.pause.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y })
|
|
9049
|
-
};
|
|
9050
|
-
attrs.backward = {
|
|
9051
|
-
style: Object.assign(Object.assign({}, attrs.backward.style), { x: this._layoutInfo.backward.x, y: this._layoutInfo.backward.y })
|
|
9052
|
-
};
|
|
9053
|
-
attrs.forward = {
|
|
9054
|
-
style: Object.assign(Object.assign({}, attrs.forward.style), { x: this._layoutInfo.forward.x, y: this._layoutInfo.forward.y })
|
|
9055
|
-
};
|
|
9348
|
+
attrs.start = Object.assign(Object.assign({}, attrs.start), { style: Object.assign(Object.assign({}, attrs.start.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y }) });
|
|
9349
|
+
attrs.pause = Object.assign(Object.assign({}, attrs.pause), { style: Object.assign(Object.assign({}, attrs.pause.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y }) });
|
|
9350
|
+
attrs.backward = Object.assign(Object.assign({}, attrs.backward), { style: Object.assign(Object.assign({}, attrs.backward.style), { x: this._layoutInfo.backward.x, y: this._layoutInfo.backward.y }) });
|
|
9351
|
+
attrs.forward = Object.assign(Object.assign({}, attrs.forward), { style: Object.assign(Object.assign({}, attrs.forward.style), { x: this._layoutInfo.forward.x, y: this._layoutInfo.forward.y }) });
|
|
9056
9352
|
}
|
|
9057
9353
|
else {
|
|
9058
9354
|
attrs.layout = 'vertical';
|
|
9059
|
-
attrs.start = {
|
|
9060
|
-
|
|
9061
|
-
};
|
|
9062
|
-
attrs.
|
|
9063
|
-
style: Object.assign(Object.assign({}, attrs.pause.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y })
|
|
9064
|
-
};
|
|
9065
|
-
attrs.backward = {
|
|
9066
|
-
style: Object.assign(Object.assign({}, attrs.backward.style), { x: this._layoutInfo.backward.x, y: this._layoutInfo.backward.y })
|
|
9067
|
-
};
|
|
9068
|
-
attrs.forward = {
|
|
9069
|
-
style: Object.assign(Object.assign({}, attrs.forward.style), { x: this._layoutInfo.forward.x, y: this._layoutInfo.forward.y })
|
|
9070
|
-
};
|
|
9355
|
+
attrs.start = Object.assign(Object.assign({}, attrs.start), { style: Object.assign(Object.assign({}, attrs.start.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y }) });
|
|
9356
|
+
attrs.pause = Object.assign(Object.assign({}, attrs.pause), { style: Object.assign(Object.assign({}, attrs.pause.style), { x: this._layoutInfo.start.x, y: this._layoutInfo.start.y }) });
|
|
9357
|
+
attrs.backward = Object.assign(Object.assign({}, attrs.backward), { style: Object.assign(Object.assign({}, attrs.backward.style), { x: this._layoutInfo.backward.x, y: this._layoutInfo.backward.y }) });
|
|
9358
|
+
attrs.forward = Object.assign(Object.assign({}, attrs.forward), { style: Object.assign(Object.assign({}, attrs.forward.style), { x: this._layoutInfo.forward.x, y: this._layoutInfo.forward.y }) });
|
|
9071
9359
|
}
|
|
9072
9360
|
return attrs;
|
|
9073
9361
|
};
|
|
9074
9362
|
this._initController = () => {
|
|
9075
9363
|
const attrs = this._updateControllerAttrs();
|
|
9076
9364
|
this._controller = new Controller(attrs);
|
|
9077
|
-
|
|
9365
|
+
if (this._controllerVisible) {
|
|
9366
|
+
this.add(this._controller);
|
|
9367
|
+
}
|
|
9078
9368
|
};
|
|
9079
9369
|
this._initAttributes();
|
|
9080
9370
|
this._initLayoutInfo();
|
|
@@ -9082,19 +9372,21 @@
|
|
|
9082
9372
|
this._initSlider();
|
|
9083
9373
|
}
|
|
9084
9374
|
_initAttributes() {
|
|
9085
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
9375
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
9086
9376
|
this._size = this.attribute.size;
|
|
9087
9377
|
this._orient = this.attribute.orient;
|
|
9088
9378
|
this._data = this.attribute.data;
|
|
9089
9379
|
this._minIndex = 0;
|
|
9090
9380
|
this._maxIndex = this._data.length - 1;
|
|
9091
|
-
this.
|
|
9092
|
-
this.
|
|
9093
|
-
this.
|
|
9094
|
-
this.
|
|
9095
|
-
this.
|
|
9096
|
-
this.
|
|
9097
|
-
this.
|
|
9381
|
+
this._sliderVisible = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.slider) === null || _b === void 0 ? void 0 : _b.visible;
|
|
9382
|
+
this._railStyle = Object.assign({}, (_d = (_c = this.attribute) === null || _c === void 0 ? void 0 : _c.slider) === null || _d === void 0 ? void 0 : _d.railStyle);
|
|
9383
|
+
this._trackStyle = Object.assign({}, (_f = (_e = this.attribute) === null || _e === void 0 ? void 0 : _e.slider) === null || _f === void 0 ? void 0 : _f.trackStyle);
|
|
9384
|
+
this._handlerStyle = Object.assign({}, (_h = (_g = this.attribute) === null || _g === void 0 ? void 0 : _g.slider) === null || _h === void 0 ? void 0 : _h.handlerStyle);
|
|
9385
|
+
this._controllerVisible = (_k = (_j = this.attribute) === null || _j === void 0 ? void 0 : _j.controller) === null || _k === void 0 ? void 0 : _k.visible;
|
|
9386
|
+
this._start = Object.assign({}, (_m = (_l = this.attribute) === null || _l === void 0 ? void 0 : _l.controller) === null || _m === void 0 ? void 0 : _m.start);
|
|
9387
|
+
this._pause = Object.assign({}, (_p = (_o = this.attribute) === null || _o === void 0 ? void 0 : _o.controller) === null || _p === void 0 ? void 0 : _p.pause);
|
|
9388
|
+
this._forward = Object.assign({}, (_r = (_q = this.attribute) === null || _q === void 0 ? void 0 : _q.controller) === null || _r === void 0 ? void 0 : _r.forward);
|
|
9389
|
+
this._backward = Object.assign({}, (_t = (_s = this.attribute) === null || _s === void 0 ? void 0 : _s.controller) === null || _t === void 0 ? void 0 : _t.backward);
|
|
9098
9390
|
}
|
|
9099
9391
|
_initLayoutInfo() {
|
|
9100
9392
|
var _a, _b, _c;
|
|
@@ -9107,7 +9399,9 @@
|
|
|
9107
9399
|
const maxSize = vutils.isNumber(size) ? size : vutils.max(size[0], size[1]);
|
|
9108
9400
|
return len + controller.space + maxSize;
|
|
9109
9401
|
}, 0);
|
|
9110
|
-
const sliderPx =
|
|
9402
|
+
const sliderPx = this._sliderVisible
|
|
9403
|
+
? (isHorizontal(this._orient) ? (_b = this._size) === null || _b === void 0 ? void 0 : _b.width : (_c = this._size) === null || _c === void 0 ? void 0 : _c.height) - controllerPx
|
|
9404
|
+
: 0;
|
|
9111
9405
|
const railPx = sliderPx - this.attribute.slider.space;
|
|
9112
9406
|
const startPx = startControllers.reduce((px, controller) => {
|
|
9113
9407
|
const { key, space, style: { size } } = controller;
|
|
@@ -9162,6 +9456,7 @@
|
|
|
9162
9456
|
width: 300
|
|
9163
9457
|
},
|
|
9164
9458
|
slider: {
|
|
9459
|
+
visible: true,
|
|
9165
9460
|
space: 10,
|
|
9166
9461
|
dx: 0,
|
|
9167
9462
|
dy: 0,
|
|
@@ -9172,6 +9467,7 @@
|
|
|
9172
9467
|
handlerStyle: {}
|
|
9173
9468
|
},
|
|
9174
9469
|
controller: {
|
|
9470
|
+
visible: true,
|
|
9175
9471
|
start: Object.assign(Object.assign({}, defaultControllerAttributes), { key: 'start', position: 'start', space: 0 }),
|
|
9176
9472
|
pause: Object.assign(Object.assign({}, defaultControllerAttributes), { key: 'pause', position: 'start' }),
|
|
9177
9473
|
forward: Object.assign(Object.assign({}, defaultControllerAttributes), { key: 'forward', position: 'end' }),
|
|
@@ -9218,7 +9514,7 @@
|
|
|
9218
9514
|
const middle = Math.floor(e.detail.value) + 0.5;
|
|
9219
9515
|
this._dataIndex = e.detail.value >= middle ? Math.ceil(e.detail.value) : Math.floor(e.detail.value);
|
|
9220
9516
|
this._slider.setValue(this._dataIndex);
|
|
9221
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9517
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9222
9518
|
});
|
|
9223
9519
|
};
|
|
9224
9520
|
this.play = () => {
|
|
@@ -9249,7 +9545,7 @@
|
|
|
9249
9545
|
this._updateDataIndex(this._maxIndex);
|
|
9250
9546
|
}
|
|
9251
9547
|
}
|
|
9252
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9548
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.play);
|
|
9253
9549
|
this._isReachEnd = false;
|
|
9254
9550
|
this._tickTime = Date.now();
|
|
9255
9551
|
this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this, true));
|
|
@@ -9262,14 +9558,14 @@
|
|
|
9262
9558
|
return;
|
|
9263
9559
|
}
|
|
9264
9560
|
if (isFirstPlay && this._activeIndex !== this._dataIndex) {
|
|
9265
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9561
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9266
9562
|
this._activeIndex = this._dataIndex;
|
|
9267
9563
|
}
|
|
9268
9564
|
else if (now - this._tickTime >= this._interval) {
|
|
9269
9565
|
this._tickTime = now;
|
|
9270
9566
|
this._updateDataIndex(forwardStep(this._direction, this._dataIndex, this._minIndex, this._maxIndex));
|
|
9271
9567
|
this._activeIndex = this._dataIndex;
|
|
9272
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9568
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9273
9569
|
}
|
|
9274
9570
|
if ((this._direction === 'default' && this._dataIndex >= this._maxIndex) ||
|
|
9275
9571
|
(this._direction === 'reverse' && this._dataIndex <= this._minIndex)) {
|
|
@@ -9286,7 +9582,7 @@
|
|
|
9286
9582
|
this._controller.togglePlay();
|
|
9287
9583
|
vrender.vglobal.getCancelAnimationFrame()(this._rafId);
|
|
9288
9584
|
this._activeIndex = -1;
|
|
9289
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9585
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.end);
|
|
9290
9586
|
};
|
|
9291
9587
|
this.pause = () => {
|
|
9292
9588
|
if (!this._isPlaying) {
|
|
@@ -9295,19 +9591,19 @@
|
|
|
9295
9591
|
this._isPlaying = false;
|
|
9296
9592
|
vrender.vglobal.getCancelAnimationFrame()(this._rafId);
|
|
9297
9593
|
this._controller.togglePlay();
|
|
9298
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9594
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.pause);
|
|
9299
9595
|
};
|
|
9300
9596
|
this.backward = () => {
|
|
9301
9597
|
const index = Math.max(this._dataIndex - 1, this._minIndex);
|
|
9302
9598
|
this._updateDataIndex(index);
|
|
9303
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9304
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9599
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9600
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.backward);
|
|
9305
9601
|
};
|
|
9306
9602
|
this.forward = () => {
|
|
9307
9603
|
const index = Math.min(this._dataIndex + 1, this._maxIndex);
|
|
9308
9604
|
this._updateDataIndex(index);
|
|
9309
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9310
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9605
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9606
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.forward);
|
|
9311
9607
|
};
|
|
9312
9608
|
this._initAttributes();
|
|
9313
9609
|
this._initEvents();
|
|
@@ -9388,7 +9684,7 @@
|
|
|
9388
9684
|
this._dataIndex = index;
|
|
9389
9685
|
this._activeIndex = index;
|
|
9390
9686
|
if (index !== this._maxIndex) {
|
|
9391
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9687
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.change);
|
|
9392
9688
|
}
|
|
9393
9689
|
}
|
|
9394
9690
|
};
|
|
@@ -9402,7 +9698,7 @@
|
|
|
9402
9698
|
this._elapsed = 0;
|
|
9403
9699
|
}
|
|
9404
9700
|
this._startTime = Date.now() - this._elapsed;
|
|
9405
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9701
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.play);
|
|
9406
9702
|
this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this));
|
|
9407
9703
|
});
|
|
9408
9704
|
this._play = () => {
|
|
@@ -9419,7 +9715,7 @@
|
|
|
9419
9715
|
this._isPlaying = false;
|
|
9420
9716
|
vrender.vglobal.getCancelAnimationFrame()(this._rafId);
|
|
9421
9717
|
this._controller.togglePlay();
|
|
9422
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9718
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.end);
|
|
9423
9719
|
};
|
|
9424
9720
|
this.pause = () => {
|
|
9425
9721
|
if (!this._isPlaying) {
|
|
@@ -9429,7 +9725,7 @@
|
|
|
9429
9725
|
this._elapsed = Date.now() - this._startTime;
|
|
9430
9726
|
vrender.vglobal.getCancelAnimationFrame()(this._rafId);
|
|
9431
9727
|
this._controller.togglePlay();
|
|
9432
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9728
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.pause);
|
|
9433
9729
|
};
|
|
9434
9730
|
this.backward = () => {
|
|
9435
9731
|
const now = Date.now();
|
|
@@ -9444,7 +9740,7 @@
|
|
|
9444
9740
|
this._startTime = this._startTime + this._interval;
|
|
9445
9741
|
}
|
|
9446
9742
|
this._updateSlider();
|
|
9447
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9743
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.backward);
|
|
9448
9744
|
};
|
|
9449
9745
|
this.forward = () => {
|
|
9450
9746
|
const now = Date.now();
|
|
@@ -9459,7 +9755,7 @@
|
|
|
9459
9755
|
this._elapsed = elapsed;
|
|
9460
9756
|
}
|
|
9461
9757
|
this._updateSlider();
|
|
9462
|
-
this.dispatchCustomEvent(exports.PlayerEventEnum.
|
|
9758
|
+
this.dispatchCustomEvent(exports.PlayerEventEnum.forward);
|
|
9463
9759
|
};
|
|
9464
9760
|
this._initAttributes();
|
|
9465
9761
|
this._initEvents();
|
|
@@ -9773,6 +10069,13 @@
|
|
|
9773
10069
|
setUpdateDragMaskCallback(callback) {
|
|
9774
10070
|
vutils.isFunction(callback) && (this._updateDragMaskCallback = callback);
|
|
9775
10071
|
}
|
|
10072
|
+
releaseBrushEvents() {
|
|
10073
|
+
const { delayType = 'throttle', delayTime = 0 } = this.attribute;
|
|
10074
|
+
this.stage.removeEventListener('pointerdown', this._onBrushStart);
|
|
10075
|
+
this.stage.removeEventListener('pointermove', delayMap[delayType](this._onBrushing, delayTime));
|
|
10076
|
+
this.stage.removeEventListener('pointerup', this._onBrushEnd);
|
|
10077
|
+
this.stage.removeEventListener('pointerupoutside', this._onBrushEnd);
|
|
10078
|
+
}
|
|
9776
10079
|
}
|
|
9777
10080
|
Brush.defaultAttributes = DEFAULT_BRUSH_ATTRIBUTES;
|
|
9778
10081
|
|
|
@@ -10162,7 +10465,7 @@
|
|
|
10162
10465
|
return new Tag(params ? params.attribute : {});
|
|
10163
10466
|
}
|
|
10164
10467
|
|
|
10165
|
-
const version = "0.15.
|
|
10468
|
+
const version = "0.15.1";
|
|
10166
10469
|
|
|
10167
10470
|
exports.AbstractComponent = AbstractComponent;
|
|
10168
10471
|
exports.ArcInfo = ArcInfo;
|