@visactor/vrender-components 0.0.38-brush.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/cjs/axis/animate/group-fade.d.ts +17 -0
- package/cjs/axis/animate/group-fade.js +72 -0
- package/cjs/axis/animate/group-fade.js.map +1 -0
- package/cjs/axis/animate/group-transition.d.ts +10 -0
- package/cjs/axis/animate/group-transition.js +76 -0
- package/cjs/axis/animate/group-transition.js.map +1 -0
- package/cjs/axis/animate/index.d.ts +2 -0
- package/cjs/axis/animate/index.js +21 -0
- package/cjs/axis/animate/index.js.map +1 -0
- package/cjs/axis/base.d.ts +53 -0
- package/cjs/axis/base.js +305 -0
- package/cjs/axis/base.js.map +1 -0
- package/cjs/axis/circle.d.ts +88 -0
- package/cjs/axis/circle.js +182 -0
- package/cjs/axis/circle.js.map +1 -0
- package/cjs/axis/config.d.ts +71 -0
- package/cjs/axis/config.js +76 -0
- package/cjs/axis/config.js.map +1 -0
- package/cjs/axis/constant.d.ts +27 -0
- package/cjs/axis/constant.js +26 -0
- package/cjs/axis/constant.js.map +1 -0
- package/cjs/axis/grid.d.ts +9 -0
- package/cjs/axis/grid.js +106 -0
- package/cjs/axis/grid.js.map +1 -0
- package/cjs/axis/index.d.ts +6 -0
- package/cjs/axis/index.js +23 -0
- package/cjs/axis/index.js.map +1 -0
- package/cjs/axis/line.d.ts +89 -0
- package/cjs/axis/line.js +199 -0
- package/cjs/axis/line.js.map +1 -0
- package/cjs/axis/type.d.ts +177 -0
- package/cjs/axis/type.js +6 -0
- package/cjs/axis/type.js.map +1 -0
- package/cjs/brush/brush.d.ts +65 -0
- package/cjs/brush/brush.js +169 -0
- package/cjs/brush/brush.js.map +1 -0
- package/cjs/brush/config.d.ts +21 -0
- package/cjs/brush/config.js +26 -0
- package/cjs/brush/config.js.map +1 -0
- package/cjs/brush/index.d.ts +2 -0
- package/cjs/brush/index.js +21 -0
- package/cjs/brush/index.js.map +1 -0
- package/cjs/brush/type.d.ts +21 -0
- package/cjs/brush/type.js +6 -0
- package/cjs/brush/type.js.map +1 -0
- package/cjs/constant.d.ts +16 -0
- package/cjs/constant.js +18 -0
- package/cjs/constant.js.map +1 -0
- package/cjs/core/base.d.ts +12 -0
- package/cjs/core/base.js +44 -0
- package/cjs/core/base.js.map +1 -0
- package/cjs/core/type.d.ts +28 -0
- package/cjs/core/type.js +5 -0
- package/cjs/core/type.js.map +1 -0
- package/cjs/crosshair/base.d.ts +10 -0
- package/cjs/crosshair/base.js +19 -0
- package/cjs/crosshair/base.js.map +1 -0
- package/cjs/crosshair/circle.d.ts +17 -0
- package/cjs/crosshair/circle.js +33 -0
- package/cjs/crosshair/circle.js.map +1 -0
- package/cjs/crosshair/index.d.ts +6 -0
- package/cjs/crosshair/index.js +23 -0
- package/cjs/crosshair/index.js.map +1 -0
- package/cjs/crosshair/line.d.ts +17 -0
- package/cjs/crosshair/line.js +36 -0
- package/cjs/crosshair/line.js.map +1 -0
- package/cjs/crosshair/polygon.d.ts +17 -0
- package/cjs/crosshair/polygon.js +39 -0
- package/cjs/crosshair/polygon.js.map +1 -0
- package/cjs/crosshair/rect.d.ts +20 -0
- package/cjs/crosshair/rect.js +37 -0
- package/cjs/crosshair/rect.js.map +1 -0
- package/cjs/crosshair/sector.d.ts +15 -0
- package/cjs/crosshair/sector.js +38 -0
- package/cjs/crosshair/sector.js.map +1 -0
- package/cjs/crosshair/type.d.ts +37 -0
- package/cjs/crosshair/type.js +6 -0
- package/cjs/crosshair/type.js.map +1 -0
- package/cjs/data-zoom/config.d.ts +104 -0
- package/cjs/data-zoom/config.js +109 -0
- package/cjs/data-zoom/config.js.map +1 -0
- package/cjs/data-zoom/data-zoom.d.ts +193 -0
- package/cjs/data-zoom/data-zoom.js +447 -0
- package/cjs/data-zoom/data-zoom.js.map +1 -0
- package/cjs/data-zoom/index.d.ts +2 -0
- package/cjs/data-zoom/index.js +21 -0
- package/cjs/data-zoom/index.js.map +1 -0
- package/cjs/data-zoom/type.d.ts +59 -0
- package/cjs/data-zoom/type.js +6 -0
- package/cjs/data-zoom/type.js.map +1 -0
- package/cjs/index.d.ts +20 -0
- package/cjs/index.js +30 -0
- package/cjs/index.js.map +1 -0
- package/cjs/indicator/config.d.ts +2 -0
- package/cjs/indicator/config.js +31 -0
- package/cjs/indicator/config.js.map +1 -0
- package/cjs/indicator/index.d.ts +2 -0
- package/cjs/indicator/index.js +21 -0
- package/cjs/indicator/index.js.map +1 -0
- package/cjs/indicator/indicator.d.ts +9 -0
- package/cjs/indicator/indicator.js +73 -0
- package/cjs/indicator/indicator.js.map +1 -0
- package/cjs/indicator/type.d.ts +21 -0
- package/cjs/indicator/type.js +5 -0
- package/cjs/indicator/type.js.map +1 -0
- package/cjs/interface.d.ts +6 -0
- package/cjs/interface.js +6 -0
- package/cjs/interface.js.map +1 -0
- package/cjs/label/animate/animate.d.ts +7 -0
- package/cjs/label/animate/animate.js +53 -0
- package/cjs/label/animate/animate.js.map +1 -0
- package/cjs/label/animate/index.d.ts +1 -0
- package/cjs/label/animate/index.js +3 -0
- package/cjs/label/animate/index.js.map +1 -0
- package/cjs/label/base.d.ts +43 -0
- package/cjs/label/base.js +263 -0
- package/cjs/label/base.js.map +1 -0
- package/cjs/label/dataLabel.d.ts +13 -0
- package/cjs/label/dataLabel.js +56 -0
- package/cjs/label/dataLabel.js.map +1 -0
- package/cjs/label/index.d.ts +6 -0
- package/cjs/label/index.js +23 -0
- package/cjs/label/index.js.map +1 -0
- package/cjs/label/line.d.ts +15 -0
- package/cjs/label/line.js +47 -0
- package/cjs/label/line.js.map +1 -0
- package/cjs/label/overlap/bitmap.d.ts +13 -0
- package/cjs/label/overlap/bitmap.js +73 -0
- package/cjs/label/overlap/bitmap.js.map +1 -0
- package/cjs/label/overlap/index.d.ts +3 -0
- package/cjs/label/overlap/index.js +22 -0
- package/cjs/label/overlap/index.js.map +1 -0
- package/cjs/label/overlap/place.d.ts +14 -0
- package/cjs/label/overlap/place.js +61 -0
- package/cjs/label/overlap/place.js.map +1 -0
- package/cjs/label/overlap/scaler.d.ts +27 -0
- package/cjs/label/overlap/scaler.js +26 -0
- package/cjs/label/overlap/scaler.js.map +1 -0
- package/cjs/label/rect.d.ts +10 -0
- package/cjs/label/rect.js +59 -0
- package/cjs/label/rect.js.map +1 -0
- package/cjs/label/symbol.d.ts +10 -0
- package/cjs/label/symbol.js +69 -0
- package/cjs/label/symbol.js.map +1 -0
- package/cjs/label/type.d.ts +90 -0
- package/cjs/label/type.js +6 -0
- package/cjs/label/type.js.map +1 -0
- package/cjs/legend/base.d.ts +14 -0
- package/cjs/legend/base.js +58 -0
- package/cjs/legend/base.js.map +1 -0
- package/cjs/legend/color/color.d.ts +37 -0
- package/cjs/legend/color/color.js +128 -0
- package/cjs/legend/color/color.js.map +1 -0
- package/cjs/legend/color/index.d.ts +2 -0
- package/cjs/legend/color/index.js +21 -0
- package/cjs/legend/color/index.js.map +1 -0
- package/cjs/legend/color/type.d.ts +5 -0
- package/cjs/legend/color/type.js +6 -0
- package/cjs/legend/color/type.js.map +1 -0
- package/cjs/legend/constant.d.ts +29 -0
- package/cjs/legend/constant.js +24 -0
- package/cjs/legend/constant.js.map +1 -0
- package/cjs/legend/discrete/discrete.d.ts +26 -0
- package/cjs/legend/discrete/discrete.js +413 -0
- package/cjs/legend/discrete/discrete.js.map +1 -0
- package/cjs/legend/discrete/index.d.ts +2 -0
- package/cjs/legend/discrete/index.js +21 -0
- package/cjs/legend/discrete/index.js.map +1 -0
- package/cjs/legend/discrete/type.d.ts +65 -0
- package/cjs/legend/discrete/type.js +6 -0
- package/cjs/legend/discrete/type.js.map +1 -0
- package/cjs/legend/index.d.ts +8 -0
- package/cjs/legend/index.js +24 -0
- package/cjs/legend/index.js.map +1 -0
- package/cjs/legend/size/index.d.ts +1 -0
- package/cjs/legend/size/index.js +3 -0
- package/cjs/legend/size/index.js.map +1 -0
- package/cjs/legend/size/size.d.ts +34 -0
- package/cjs/legend/size/size.js +106 -0
- package/cjs/legend/size/size.js.map +1 -0
- package/cjs/legend/size/type.d.ts +6 -0
- package/cjs/legend/size/type.js +6 -0
- package/cjs/legend/size/type.js.map +1 -0
- package/cjs/legend/type.d.ts +27 -0
- package/cjs/legend/type.js +6 -0
- package/cjs/legend/type.js.map +1 -0
- package/cjs/link-path/index.d.ts +2 -0
- package/cjs/link-path/index.js +21 -0
- package/cjs/link-path/index.js.map +1 -0
- package/cjs/link-path/link-path.d.ts +15 -0
- package/cjs/link-path/link-path.js +65 -0
- package/cjs/link-path/link-path.js.map +1 -0
- package/cjs/link-path/type.d.ts +17 -0
- package/cjs/link-path/type.js +6 -0
- package/cjs/link-path/type.js.map +1 -0
- package/cjs/marker/area.d.ts +56 -0
- package/cjs/marker/area.js +64 -0
- package/cjs/marker/area.js.map +1 -0
- package/cjs/marker/base.d.ts +11 -0
- package/cjs/marker/base.js +22 -0
- package/cjs/marker/base.js.map +1 -0
- package/cjs/marker/config.d.ts +154 -0
- package/cjs/marker/config.js +240 -0
- package/cjs/marker/config.js.map +1 -0
- package/cjs/marker/index.d.ts +4 -0
- package/cjs/marker/index.js +22 -0
- package/cjs/marker/index.js.map +1 -0
- package/cjs/marker/line.d.ts +10 -0
- package/cjs/marker/line.js +45 -0
- package/cjs/marker/line.js.map +1 -0
- package/cjs/marker/point.d.ts +80 -0
- package/cjs/marker/point.js +102 -0
- package/cjs/marker/point.js.map +1 -0
- package/cjs/marker/type.d.ts +93 -0
- package/cjs/marker/type.js +26 -0
- package/cjs/marker/type.js.map +1 -0
- package/cjs/pager/index.d.ts +2 -0
- package/cjs/pager/index.js +21 -0
- package/cjs/pager/index.js.map +1 -0
- package/cjs/pager/pager.d.ts +20 -0
- package/cjs/pager/pager.js +132 -0
- package/cjs/pager/pager.js.map +1 -0
- package/cjs/pager/type.d.ts +19 -0
- package/cjs/pager/type.js +6 -0
- package/cjs/pager/type.js.map +1 -0
- package/cjs/player/base-player.d.ts +103 -0
- package/cjs/player/base-player.js +199 -0
- package/cjs/player/base-player.js.map +1 -0
- package/cjs/player/constant.d.ts +12 -0
- package/cjs/player/constant.js +16 -0
- package/cjs/player/constant.js.map +1 -0
- package/cjs/player/continuous-player.d.ts +34 -0
- package/cjs/player/continuous-player.js +107 -0
- package/cjs/player/continuous-player.js.map +1 -0
- package/cjs/player/controller/assets/index.d.ts +6 -0
- package/cjs/player/controller/assets/index.js +12 -0
- package/cjs/player/controller/assets/index.js.map +1 -0
- package/cjs/player/controller/constant.d.ts +12 -0
- package/cjs/player/controller/constant.js +15 -0
- package/cjs/player/controller/constant.js.map +1 -0
- package/cjs/player/controller/controller.d.ts +32 -0
- package/cjs/player/controller/controller.js +93 -0
- package/cjs/player/controller/controller.js.map +1 -0
- package/cjs/player/controller/icon/icon.d.ts +4 -0
- package/cjs/player/controller/icon/icon.js +16 -0
- package/cjs/player/controller/icon/icon.js.map +1 -0
- package/cjs/player/controller/icon/index.d.ts +1 -0
- package/cjs/player/controller/icon/index.js +21 -0
- package/cjs/player/controller/icon/index.js.map +1 -0
- package/cjs/player/controller/icon/type.d.ts +1 -0
- package/cjs/player/controller/icon/type.js +3 -0
- package/cjs/player/controller/icon/type.js.map +1 -0
- package/cjs/player/controller/index.d.ts +2 -0
- package/cjs/player/controller/index.js +21 -0
- package/cjs/player/controller/index.js.map +1 -0
- package/cjs/player/controller/type.d.ts +11 -0
- package/cjs/player/controller/type.js +6 -0
- package/cjs/player/controller/type.js.map +1 -0
- package/cjs/player/discrete-player.d.ts +32 -0
- package/cjs/player/discrete-player.js +85 -0
- package/cjs/player/discrete-player.js.map +1 -0
- package/cjs/player/index.d.ts +4 -0
- package/cjs/player/index.js +22 -0
- package/cjs/player/index.js.map +1 -0
- package/cjs/player/type/base.d.ts +7 -0
- package/cjs/player/type/base.js +6 -0
- package/cjs/player/type/base.js.map +1 -0
- package/cjs/player/type/continuous-player.d.ts +7 -0
- package/cjs/player/type/continuous-player.js +6 -0
- package/cjs/player/type/continuous-player.js.map +1 -0
- package/cjs/player/type/direction.d.ts +5 -0
- package/cjs/player/type/direction.js +10 -0
- package/cjs/player/type/direction.js.map +1 -0
- package/cjs/player/type/discrete-player.d.ts +9 -0
- package/cjs/player/type/discrete-player.js +6 -0
- package/cjs/player/type/discrete-player.js.map +1 -0
- package/cjs/player/type/event.d.ts +8 -0
- package/cjs/player/type/event.js +12 -0
- package/cjs/player/type/event.js.map +1 -0
- package/cjs/player/type/index.d.ts +9 -0
- package/cjs/player/type/index.js +23 -0
- package/cjs/player/type/index.js.map +1 -0
- package/cjs/player/type/layout.d.ts +35 -0
- package/cjs/player/type/layout.js +6 -0
- package/cjs/player/type/layout.js.map +1 -0
- package/cjs/player/utils.d.ts +20 -0
- package/cjs/player/utils.js +74 -0
- package/cjs/player/utils.js.map +1 -0
- package/cjs/scrollbar/index.d.ts +2 -0
- package/cjs/scrollbar/index.js +21 -0
- package/cjs/scrollbar/index.js.map +1 -0
- package/cjs/scrollbar/scrollbar.d.ts +43 -0
- package/cjs/scrollbar/scrollbar.js +161 -0
- package/cjs/scrollbar/scrollbar.js.map +1 -0
- package/cjs/scrollbar/type.d.ts +16 -0
- package/cjs/scrollbar/type.js +6 -0
- package/cjs/scrollbar/type.js.map +1 -0
- package/cjs/segment/index.d.ts +2 -0
- package/cjs/segment/index.js +21 -0
- package/cjs/segment/index.js.map +1 -0
- package/cjs/segment/segment.d.ts +18 -0
- package/cjs/segment/segment.js +105 -0
- package/cjs/segment/segment.js.map +1 -0
- package/cjs/segment/type.d.ts +22 -0
- package/cjs/segment/type.js +6 -0
- package/cjs/segment/type.js.map +1 -0
- package/cjs/slider/constant.d.ts +13 -0
- package/cjs/slider/constant.js +15 -0
- package/cjs/slider/constant.js.map +1 -0
- package/cjs/slider/index.d.ts +3 -0
- package/cjs/slider/index.js +22 -0
- package/cjs/slider/index.js.map +1 -0
- package/cjs/slider/slider.d.ts +96 -0
- package/cjs/slider/slider.js +405 -0
- package/cjs/slider/slider.js.map +1 -0
- package/cjs/slider/type.d.ts +44 -0
- package/cjs/slider/type.js +6 -0
- package/cjs/slider/type.js.map +1 -0
- package/cjs/tag/index.d.ts +2 -0
- package/cjs/tag/index.js +21 -0
- package/cjs/tag/index.js.map +1 -0
- package/cjs/tag/tag.d.ts +8 -0
- package/cjs/tag/tag.js +103 -0
- package/cjs/tag/tag.js.map +1 -0
- package/cjs/tag/type.d.ts +24 -0
- package/cjs/tag/type.js +6 -0
- package/cjs/tag/type.js.map +1 -0
- package/cjs/title/index.d.ts +2 -0
- package/cjs/title/index.js +21 -0
- package/cjs/title/index.js.map +1 -0
- package/cjs/title/title.d.ts +10 -0
- package/cjs/title/title.js +133 -0
- package/cjs/title/title.js.map +1 -0
- package/cjs/title/type.d.ts +41 -0
- package/cjs/title/type.js +6 -0
- package/cjs/title/type.js.map +1 -0
- package/cjs/tooltip/config.d.ts +3 -0
- package/cjs/tooltip/config.js +78 -0
- package/cjs/tooltip/config.js.map +1 -0
- package/cjs/tooltip/index.d.ts +2 -0
- package/cjs/tooltip/index.js +21 -0
- package/cjs/tooltip/index.js.map +1 -0
- package/cjs/tooltip/tooltip.d.ts +18 -0
- package/cjs/tooltip/tooltip.js +160 -0
- package/cjs/tooltip/tooltip.js.map +1 -0
- package/cjs/tooltip/type.d.ts +60 -0
- package/cjs/tooltip/type.js +6 -0
- package/cjs/tooltip/type.js.map +1 -0
- package/cjs/tooltip/util.d.ts +2 -0
- package/cjs/tooltip/util.js +17 -0
- package/cjs/tooltip/util.js.map +1 -0
- package/cjs/util/common.d.ts +3 -0
- package/cjs/util/common.js +21 -0
- package/cjs/util/common.js.map +1 -0
- package/cjs/util/index.d.ts +4 -0
- package/cjs/util/index.js +22 -0
- package/cjs/util/index.js.map +1 -0
- package/cjs/util/labelSmartInvert.d.ts +2 -0
- package/cjs/util/labelSmartInvert.js +45 -0
- package/cjs/util/labelSmartInvert.js.map +1 -0
- package/cjs/util/matrix.d.ts +4 -0
- package/cjs/util/matrix.js +24 -0
- package/cjs/util/matrix.js.map +1 -0
- package/cjs/util/text.d.ts +7 -0
- package/cjs/util/text.js +40 -0
- package/cjs/util/text.js.map +1 -0
- package/dist/vrender-components.js.js +1 -0
- package/dist/vrender-components.js.min.js +1 -0
- package/es/axis/animate/group-fade.d.ts +17 -0
- package/es/axis/animate/group-fade.js +62 -0
- package/es/axis/animate/group-fade.js.map +1 -0
- package/es/axis/animate/group-transition.d.ts +10 -0
- package/es/axis/animate/group-transition.js +72 -0
- package/es/axis/animate/group-transition.js.map +1 -0
- package/es/axis/animate/index.d.ts +2 -0
- package/es/axis/animate/index.js +4 -0
- package/es/axis/animate/index.js.map +1 -0
- package/es/axis/base.d.ts +53 -0
- package/es/axis/base.js +306 -0
- package/es/axis/base.js.map +1 -0
- package/es/axis/circle.d.ts +88 -0
- package/es/axis/circle.js +186 -0
- package/es/axis/circle.js.map +1 -0
- package/es/axis/config.d.ts +71 -0
- package/es/axis/config.js +72 -0
- package/es/axis/config.js.map +1 -0
- package/es/axis/constant.d.ts +27 -0
- package/es/axis/constant.js +26 -0
- package/es/axis/constant.js.map +1 -0
- package/es/axis/grid.d.ts +9 -0
- package/es/axis/grid.js +102 -0
- package/es/axis/grid.js.map +1 -0
- package/es/axis/index.d.ts +6 -0
- package/es/axis/index.js +12 -0
- package/es/axis/index.js.map +1 -0
- package/es/axis/line.d.ts +89 -0
- package/es/axis/line.js +204 -0
- package/es/axis/line.js.map +1 -0
- package/es/axis/type.d.ts +177 -0
- package/es/axis/type.js +2 -0
- package/es/axis/type.js.map +1 -0
- package/es/brush/brush.d.ts +65 -0
- package/es/brush/brush.js +171 -0
- package/es/brush/brush.js.map +1 -0
- package/es/brush/config.d.ts +21 -0
- package/es/brush/config.js +22 -0
- package/es/brush/config.js.map +1 -0
- package/es/brush/index.d.ts +2 -0
- package/es/brush/index.js +4 -0
- package/es/brush/index.js.map +1 -0
- package/es/brush/type.d.ts +21 -0
- package/es/brush/type.js +2 -0
- package/es/brush/type.js.map +1 -0
- package/es/constant.d.ts +16 -0
- package/es/constant.js +21 -0
- package/es/constant.js.map +1 -0
- package/es/core/base.d.ts +12 -0
- package/es/core/base.js +40 -0
- package/es/core/base.js.map +1 -0
- package/es/core/type.d.ts +28 -0
- package/es/core/type.js +1 -0
- package/es/core/type.js.map +1 -0
- package/es/crosshair/base.d.ts +10 -0
- package/es/crosshair/base.js +11 -0
- package/es/crosshair/base.js.map +1 -0
- package/es/crosshair/circle.d.ts +17 -0
- package/es/crosshair/circle.js +29 -0
- package/es/crosshair/circle.js.map +1 -0
- package/es/crosshair/index.d.ts +6 -0
- package/es/crosshair/index.js +12 -0
- package/es/crosshair/index.js.map +1 -0
- package/es/crosshair/line.d.ts +17 -0
- package/es/crosshair/line.js +32 -0
- package/es/crosshair/line.js.map +1 -0
- package/es/crosshair/polygon.d.ts +17 -0
- package/es/crosshair/polygon.js +35 -0
- package/es/crosshair/polygon.js.map +1 -0
- package/es/crosshair/rect.d.ts +20 -0
- package/es/crosshair/rect.js +33 -0
- package/es/crosshair/rect.js.map +1 -0
- package/es/crosshair/sector.d.ts +15 -0
- package/es/crosshair/sector.js +35 -0
- package/es/crosshair/sector.js.map +1 -0
- package/es/crosshair/type.d.ts +37 -0
- package/es/crosshair/type.js +2 -0
- package/es/crosshair/type.js.map +1 -0
- package/es/data-zoom/config.d.ts +104 -0
- package/es/data-zoom/config.js +106 -0
- package/es/data-zoom/config.js.map +1 -0
- package/es/data-zoom/data-zoom.d.ts +193 -0
- package/es/data-zoom/data-zoom.js +444 -0
- package/es/data-zoom/data-zoom.js.map +1 -0
- package/es/data-zoom/index.d.ts +2 -0
- package/es/data-zoom/index.js +4 -0
- package/es/data-zoom/index.js.map +1 -0
- package/es/data-zoom/type.d.ts +59 -0
- package/es/data-zoom/type.js +2 -0
- package/es/data-zoom/type.js.map +1 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +40 -0
- package/es/index.js.map +1 -0
- package/es/indicator/config.d.ts +2 -0
- package/es/indicator/config.js +27 -0
- package/es/indicator/config.js.map +1 -0
- package/es/indicator/index.d.ts +2 -0
- package/es/indicator/index.js +4 -0
- package/es/indicator/index.js.map +1 -0
- package/es/indicator/indicator.d.ts +9 -0
- package/es/indicator/indicator.js +69 -0
- package/es/indicator/indicator.js.map +1 -0
- package/es/indicator/type.d.ts +21 -0
- package/es/indicator/type.js +1 -0
- package/es/indicator/type.js.map +1 -0
- package/es/interface.d.ts +6 -0
- package/es/interface.js +2 -0
- package/es/interface.js.map +1 -0
- package/es/label/animate/animate.d.ts +7 -0
- package/es/label/animate/animate.js +47 -0
- package/es/label/animate/animate.js.map +1 -0
- package/es/label/animate/index.d.ts +1 -0
- package/es/label/animate/index.js +3 -0
- package/es/label/animate/index.js.map +1 -0
- package/es/label/base.d.ts +43 -0
- package/es/label/base.js +263 -0
- package/es/label/base.js.map +1 -0
- package/es/label/dataLabel.d.ts +13 -0
- package/es/label/dataLabel.js +60 -0
- package/es/label/dataLabel.js.map +1 -0
- package/es/label/index.d.ts +6 -0
- package/es/label/index.js +12 -0
- package/es/label/index.js.map +1 -0
- package/es/label/line.d.ts +15 -0
- package/es/label/line.js +43 -0
- package/es/label/line.js.map +1 -0
- package/es/label/overlap/bitmap.d.ts +13 -0
- package/es/label/overlap/bitmap.js +65 -0
- package/es/label/overlap/bitmap.js.map +1 -0
- package/es/label/overlap/index.d.ts +3 -0
- package/es/label/overlap/index.js +6 -0
- package/es/label/overlap/index.js.map +1 -0
- package/es/label/overlap/place.d.ts +14 -0
- package/es/label/overlap/place.js +57 -0
- package/es/label/overlap/place.js.map +1 -0
- package/es/label/overlap/scaler.d.ts +27 -0
- package/es/label/overlap/scaler.js +18 -0
- package/es/label/overlap/scaler.js.map +1 -0
- package/es/label/rect.d.ts +10 -0
- package/es/label/rect.js +55 -0
- package/es/label/rect.js.map +1 -0
- package/es/label/symbol.d.ts +10 -0
- package/es/label/symbol.js +65 -0
- package/es/label/symbol.js.map +1 -0
- package/es/label/type.d.ts +90 -0
- package/es/label/type.js +2 -0
- package/es/label/type.js.map +1 -0
- package/es/legend/base.d.ts +14 -0
- package/es/legend/base.js +56 -0
- package/es/legend/base.js.map +1 -0
- package/es/legend/color/color.d.ts +37 -0
- package/es/legend/color/color.js +128 -0
- package/es/legend/color/color.js.map +1 -0
- package/es/legend/color/index.d.ts +2 -0
- package/es/legend/color/index.js +4 -0
- package/es/legend/color/index.js.map +1 -0
- package/es/legend/color/type.d.ts +5 -0
- package/es/legend/color/type.js +2 -0
- package/es/legend/color/type.js.map +1 -0
- package/es/legend/constant.d.ts +29 -0
- package/es/legend/constant.js +40 -0
- package/es/legend/constant.js.map +1 -0
- package/es/legend/discrete/discrete.d.ts +26 -0
- package/es/legend/discrete/discrete.js +409 -0
- package/es/legend/discrete/discrete.js.map +1 -0
- package/es/legend/discrete/index.d.ts +2 -0
- package/es/legend/discrete/index.js +4 -0
- package/es/legend/discrete/index.js.map +1 -0
- package/es/legend/discrete/type.d.ts +65 -0
- package/es/legend/discrete/type.js +2 -0
- package/es/legend/discrete/type.js.map +1 -0
- package/es/legend/index.d.ts +8 -0
- package/es/legend/index.js +16 -0
- package/es/legend/index.js.map +1 -0
- package/es/legend/size/index.d.ts +1 -0
- package/es/legend/size/index.js +3 -0
- package/es/legend/size/index.js.map +1 -0
- package/es/legend/size/size.d.ts +34 -0
- package/es/legend/size/size.js +105 -0
- package/es/legend/size/size.js.map +1 -0
- package/es/legend/size/type.d.ts +6 -0
- package/es/legend/size/type.js +2 -0
- package/es/legend/size/type.js.map +1 -0
- package/es/legend/type.d.ts +27 -0
- package/es/legend/type.js +2 -0
- package/es/legend/type.js.map +1 -0
- package/es/link-path/index.d.ts +2 -0
- package/es/link-path/index.js +4 -0
- package/es/link-path/index.js.map +1 -0
- package/es/link-path/link-path.d.ts +15 -0
- package/es/link-path/link-path.js +59 -0
- package/es/link-path/link-path.js.map +1 -0
- package/es/link-path/type.d.ts +17 -0
- package/es/link-path/type.js +2 -0
- package/es/link-path/type.js.map +1 -0
- package/es/marker/area.d.ts +56 -0
- package/es/marker/area.js +65 -0
- package/es/marker/area.js.map +1 -0
- package/es/marker/base.d.ts +11 -0
- package/es/marker/base.js +15 -0
- package/es/marker/base.js.map +1 -0
- package/es/marker/config.d.ts +154 -0
- package/es/marker/config.js +244 -0
- package/es/marker/config.js.map +1 -0
- package/es/marker/index.d.ts +4 -0
- package/es/marker/index.js +8 -0
- package/es/marker/index.js.map +1 -0
- package/es/marker/line.d.ts +10 -0
- package/es/marker/line.js +47 -0
- package/es/marker/line.js.map +1 -0
- package/es/marker/point.d.ts +80 -0
- package/es/marker/point.js +106 -0
- package/es/marker/point.js.map +1 -0
- package/es/marker/type.d.ts +93 -0
- package/es/marker/type.js +27 -0
- package/es/marker/type.js.map +1 -0
- package/es/pager/index.d.ts +2 -0
- package/es/pager/index.js +4 -0
- package/es/pager/index.js.map +1 -0
- package/es/pager/pager.d.ts +20 -0
- package/es/pager/pager.js +132 -0
- package/es/pager/pager.js.map +1 -0
- package/es/pager/type.d.ts +19 -0
- package/es/pager/type.js +2 -0
- package/es/pager/type.js.map +1 -0
- package/es/player/base-player.d.ts +103 -0
- package/es/player/base-player.js +200 -0
- package/es/player/base-player.js.map +1 -0
- package/es/player/constant.d.ts +12 -0
- package/es/player/constant.js +14 -0
- package/es/player/constant.js.map +1 -0
- package/es/player/continuous-player.d.ts +34 -0
- package/es/player/continuous-player.js +104 -0
- package/es/player/continuous-player.js.map +1 -0
- package/es/player/controller/assets/index.d.ts +6 -0
- package/es/player/controller/assets/index.js +12 -0
- package/es/player/controller/assets/index.js.map +1 -0
- package/es/player/controller/constant.d.ts +12 -0
- package/es/player/controller/constant.js +14 -0
- package/es/player/controller/constant.js.map +1 -0
- package/es/player/controller/controller.d.ts +32 -0
- package/es/player/controller/controller.js +97 -0
- package/es/player/controller/controller.js.map +1 -0
- package/es/player/controller/icon/icon.d.ts +4 -0
- package/es/player/controller/icon/icon.js +8 -0
- package/es/player/controller/icon/icon.js.map +1 -0
- package/es/player/controller/icon/index.d.ts +1 -0
- package/es/player/controller/icon/index.js +2 -0
- package/es/player/controller/icon/index.js.map +1 -0
- package/es/player/controller/icon/type.d.ts +1 -0
- package/es/player/controller/icon/type.js +3 -0
- package/es/player/controller/icon/type.js.map +1 -0
- package/es/player/controller/index.d.ts +2 -0
- package/es/player/controller/index.js +4 -0
- package/es/player/controller/index.js.map +1 -0
- package/es/player/controller/type.d.ts +11 -0
- package/es/player/controller/type.js +2 -0
- package/es/player/controller/type.js.map +1 -0
- package/es/player/discrete-player.d.ts +32 -0
- package/es/player/discrete-player.js +86 -0
- package/es/player/discrete-player.js.map +1 -0
- package/es/player/index.d.ts +4 -0
- package/es/player/index.js +8 -0
- package/es/player/index.js.map +1 -0
- package/es/player/type/base.d.ts +7 -0
- package/es/player/type/base.js +2 -0
- package/es/player/type/base.js.map +1 -0
- package/es/player/type/continuous-player.d.ts +7 -0
- package/es/player/type/continuous-player.js +2 -0
- package/es/player/type/continuous-player.js.map +1 -0
- package/es/player/type/direction.d.ts +5 -0
- package/es/player/type/direction.js +6 -0
- package/es/player/type/direction.js.map +1 -0
- package/es/player/type/discrete-player.d.ts +9 -0
- package/es/player/type/discrete-player.js +2 -0
- package/es/player/type/discrete-player.js.map +1 -0
- package/es/player/type/event.d.ts +8 -0
- package/es/player/type/event.js +8 -0
- package/es/player/type/event.js.map +1 -0
- package/es/player/type/index.d.ts +9 -0
- package/es/player/type/index.js +12 -0
- package/es/player/type/index.js.map +1 -0
- package/es/player/type/layout.d.ts +35 -0
- package/es/player/type/layout.js +2 -0
- package/es/player/type/layout.js.map +1 -0
- package/es/player/utils.d.ts +20 -0
- package/es/player/utils.js +45 -0
- package/es/player/utils.js.map +1 -0
- package/es/scrollbar/index.d.ts +2 -0
- package/es/scrollbar/index.js +4 -0
- package/es/scrollbar/index.js.map +1 -0
- package/es/scrollbar/scrollbar.d.ts +43 -0
- package/es/scrollbar/scrollbar.js +154 -0
- package/es/scrollbar/scrollbar.js.map +1 -0
- package/es/scrollbar/type.d.ts +16 -0
- package/es/scrollbar/type.js +2 -0
- package/es/scrollbar/type.js.map +1 -0
- package/es/segment/index.d.ts +2 -0
- package/es/segment/index.js +4 -0
- package/es/segment/index.js.map +1 -0
- package/es/segment/segment.d.ts +18 -0
- package/es/segment/segment.js +103 -0
- package/es/segment/segment.js.map +1 -0
- package/es/segment/type.d.ts +22 -0
- package/es/segment/type.js +2 -0
- package/es/segment/type.js.map +1 -0
- package/es/slider/constant.d.ts +13 -0
- package/es/slider/constant.js +11 -0
- package/es/slider/constant.js.map +1 -0
- package/es/slider/index.d.ts +3 -0
- package/es/slider/index.js +6 -0
- package/es/slider/index.js.map +1 -0
- package/es/slider/slider.d.ts +96 -0
- package/es/slider/slider.js +399 -0
- package/es/slider/slider.js.map +1 -0
- package/es/slider/type.d.ts +44 -0
- package/es/slider/type.js +2 -0
- package/es/slider/type.js.map +1 -0
- package/es/tag/index.d.ts +2 -0
- package/es/tag/index.js +4 -0
- package/es/tag/index.js.map +1 -0
- package/es/tag/tag.d.ts +8 -0
- package/es/tag/tag.js +97 -0
- package/es/tag/tag.js.map +1 -0
- package/es/tag/type.d.ts +24 -0
- package/es/tag/type.js +2 -0
- package/es/tag/type.js.map +1 -0
- package/es/title/index.d.ts +2 -0
- package/es/title/index.js +4 -0
- package/es/title/index.js.map +1 -0
- package/es/title/title.d.ts +10 -0
- package/es/title/title.js +125 -0
- package/es/title/title.js.map +1 -0
- package/es/title/type.d.ts +41 -0
- package/es/title/type.js +2 -0
- package/es/title/type.js.map +1 -0
- package/es/tooltip/config.d.ts +3 -0
- package/es/tooltip/config.js +76 -0
- package/es/tooltip/config.js.map +1 -0
- package/es/tooltip/index.d.ts +2 -0
- package/es/tooltip/index.js +4 -0
- package/es/tooltip/index.js.map +1 -0
- package/es/tooltip/tooltip.d.ts +18 -0
- package/es/tooltip/tooltip.js +161 -0
- package/es/tooltip/tooltip.js.map +1 -0
- package/es/tooltip/type.d.ts +60 -0
- package/es/tooltip/type.js +2 -0
- package/es/tooltip/type.js.map +1 -0
- package/es/tooltip/util.d.ts +2 -0
- package/es/tooltip/util.js +11 -0
- package/es/tooltip/util.js.map +1 -0
- package/es/util/common.d.ts +3 -0
- package/es/util/common.js +11 -0
- package/es/util/common.js.map +1 -0
- package/es/util/index.d.ts +4 -0
- package/es/util/index.js +8 -0
- package/es/util/index.js.map +1 -0
- package/es/util/labelSmartInvert.d.ts +2 -0
- package/es/util/labelSmartInvert.js +39 -0
- package/es/util/labelSmartInvert.js.map +1 -0
- package/es/util/matrix.d.ts +4 -0
- package/es/util/matrix.js +13 -0
- package/es/util/matrix.js.map +1 -0
- package/es/util/text.d.ts +7 -0
- package/es/util/text.js +38 -0
- package/es/util/text.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const DIV = 5, MOD = 31, SIZE = 32, RIGHT0 = new Uint32Array(33), RIGHT1 = new Uint32Array(33);
|
|
2
|
+
|
|
3
|
+
RIGHT1[0] = 0, RIGHT0[0] = ~RIGHT1[0];
|
|
4
|
+
|
|
5
|
+
for (let i = 1; i <= 32; ++i) RIGHT1[i] = RIGHT1[i - 1] << 1 | 1, RIGHT0[i] = ~RIGHT1[i];
|
|
6
|
+
|
|
7
|
+
export function bitmap(w, h) {
|
|
8
|
+
const array = new Uint32Array(~~((w * h + 32) / 32));
|
|
9
|
+
function _set(index, mask) {
|
|
10
|
+
array[index] |= mask;
|
|
11
|
+
}
|
|
12
|
+
function _clear(index, mask) {
|
|
13
|
+
array[index] &= mask;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
array: array,
|
|
17
|
+
get: (x, y) => {
|
|
18
|
+
const index = y * w + x;
|
|
19
|
+
return array[index >>> 5] & 1 << (31 & index);
|
|
20
|
+
},
|
|
21
|
+
set: (x, y) => {
|
|
22
|
+
const index = y * w + x;
|
|
23
|
+
_set(index >>> 5, 1 << (31 & index));
|
|
24
|
+
},
|
|
25
|
+
clear: (x, y) => {
|
|
26
|
+
const index = y * w + x;
|
|
27
|
+
_clear(index >>> 5, ~(1 << (31 & index)));
|
|
28
|
+
},
|
|
29
|
+
getRange: ({x1: x1, y1: y1, x2: x2, y2: y2}) => {
|
|
30
|
+
let start, end, indexStart, indexEnd, r = y2;
|
|
31
|
+
for (;r >= y1; --r) if (start = r * w + x1, end = r * w + x2, indexStart = start >>> 5,
|
|
32
|
+
indexEnd = end >>> 5, indexStart === indexEnd) {
|
|
33
|
+
if (array[indexStart] & RIGHT0[31 & start] & RIGHT1[1 + (31 & end)]) return !0;
|
|
34
|
+
} else {
|
|
35
|
+
if (array[indexStart] & RIGHT0[31 & start]) return !0;
|
|
36
|
+
if (array[indexEnd] & RIGHT1[1 + (31 & end)]) return !0;
|
|
37
|
+
for (let i = indexStart + 1; i < indexEnd; ++i) if (array[i]) return !0;
|
|
38
|
+
}
|
|
39
|
+
return !1;
|
|
40
|
+
},
|
|
41
|
+
setRange: ({x1: x1, y1: y1, x2: x2, y2: y2}) => {
|
|
42
|
+
let start, end, indexStart, indexEnd, i;
|
|
43
|
+
for (;y1 <= y2; ++y1) if (start = y1 * w + x1, end = y1 * w + x2, indexStart = start >>> 5,
|
|
44
|
+
indexEnd = end >>> 5, indexStart === indexEnd) _set(indexStart, RIGHT0[31 & start] & RIGHT1[1 + (31 & end)]); else for (_set(indexStart, RIGHT0[31 & start]),
|
|
45
|
+
_set(indexEnd, RIGHT1[1 + (31 & end)]), i = indexStart + 1; i < indexEnd; ++i) _set(i, 4294967295);
|
|
46
|
+
},
|
|
47
|
+
clearRange: ({x1: x1, y1: y1, x2: x2, y2: y2}) => {
|
|
48
|
+
let start, end, indexStart, indexEnd, i;
|
|
49
|
+
for (;y1 <= y2; ++y1) if (start = y1 * w + x1, end = y1 * w + x2, indexStart = start >>> 5,
|
|
50
|
+
indexEnd = end >>> 5, indexStart === indexEnd) _clear(indexStart, RIGHT1[31 & start] | RIGHT0[1 + (31 & end)]); else for (_clear(indexStart, RIGHT1[31 & start]),
|
|
51
|
+
_clear(indexEnd, RIGHT0[1 + (31 & end)]), i = indexStart + 1; i < indexEnd; ++i) _clear(i, 0);
|
|
52
|
+
},
|
|
53
|
+
outOfBounds: ({x1: x1, y1: y1, x2: x2, y2: y2}) => x1 < 0 || y1 < 0 || y2 >= h || x2 >= w,
|
|
54
|
+
toImageData: ctx => {
|
|
55
|
+
const imageData = ctx.createImageData(w, h), data = imageData.data;
|
|
56
|
+
for (let y = 0; y < h; ++y) for (let x = 0; x < w; ++x) {
|
|
57
|
+
const index = y * w + x, offset = 4 * index, occupied = array[index >>> 5] & 1 << (31 & index);
|
|
58
|
+
data[offset + 0] = 255 * occupied, data[offset + 1] = 255 * occupied, data[offset + 2] = 255 * occupied,
|
|
59
|
+
data[offset + 3] = 31;
|
|
60
|
+
}
|
|
61
|
+
return imageData;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=bitmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/overlap/bitmap.ts"],"names":[],"mappings":"AAiCA,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,EAAE,CAAC;AACf,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AAEzC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACd,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,EAAE;IAC9B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,CAAC,CAA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oBAC1B,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACxB,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC;oBACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;oBAC7D,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;iBACzB;aACF;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","file":"bitmap.js","sourcesContent":["import { IBoundsLike } from '@visactor/vutils';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nconst DIV = 5; // bit shift from x, y index to bit vector array index\nconst MOD = 31; // bit mask for index lookup within a bit vector\nconst SIZE = 32; // individual bit vector size\nconst RIGHT0 = new Uint32Array(SIZE + 1); // left-anchored bit vectors, full -> 0\nconst RIGHT1 = new Uint32Array(SIZE + 1); // right-anchored bit vectors, 0 -> full\n\nRIGHT1[0] = 0;\nRIGHT0[0] = ~RIGHT1[0];\nfor (let i = 1; i <= SIZE; ++i) {\n RIGHT1[i] = (RIGHT1[i - 1] << 1) | 1;\n RIGHT0[i] = ~RIGHT1[i];\n}\n\nexport function bitmap(w: number, h: number) {\n const array = new Uint32Array(~~((w * h + SIZE) / SIZE));\n\n function _set(index: number, mask: number) {\n array[index] |= mask;\n }\n\n function _clear(index: number, mask: number) {\n array[index] &= mask;\n }\n\n return {\n array: array,\n\n get: (x: number, y: number) => {\n const index = y * w + x;\n return array[index >>> DIV] & (1 << (index & MOD));\n },\n\n set: (x: number, y: number) => {\n const index = y * w + x;\n _set(index >>> DIV, 1 << (index & MOD));\n },\n\n clear: (x: number, y: number) => {\n const index = y * w + x;\n _clear(index >>> DIV, ~(1 << (index & MOD)));\n },\n /**\n * 给定范围内是否发生碰撞\n * @param 范围\n * @returns boolean\n */\n getRange: ({ x1, y1, x2, y2 }: IBoundsLike) => {\n let r = y2;\n let start;\n let end;\n let indexStart;\n let indexEnd;\n for (; r >= y1; --r) {\n start = r * w + x1;\n end = r * w + x2;\n indexStart = start >>> DIV;\n indexEnd = end >>> DIV;\n if (indexStart === indexEnd) {\n if (array[indexStart] & RIGHT0[start & MOD] & RIGHT1[(end & MOD) + 1]) {\n return true;\n }\n } else {\n if (array[indexStart] & RIGHT0[start & MOD]) {\n return true;\n }\n if (array[indexEnd] & RIGHT1[(end & MOD) + 1]) {\n return true;\n }\n for (let i = indexStart + 1; i < indexEnd; ++i) {\n if (array[i]) {\n return true;\n }\n }\n }\n }\n return false;\n },\n\n setRange: ({ x1, y1, x2, y2 }: IBoundsLike) => {\n let start;\n let end;\n let indexStart;\n let indexEnd;\n let i;\n for (; y1 <= y2; ++y1) {\n start = y1 * w + x1;\n end = y1 * w + x2;\n indexStart = start >>> DIV;\n indexEnd = end >>> DIV;\n if (indexStart === indexEnd) {\n _set(indexStart, RIGHT0[start & MOD] & RIGHT1[(end & MOD) + 1]);\n } else {\n _set(indexStart, RIGHT0[start & MOD]);\n _set(indexEnd, RIGHT1[(end & MOD) + 1]);\n for (i = indexStart + 1; i < indexEnd; ++i) {\n _set(i, 0xffffffff);\n }\n }\n }\n },\n\n clearRange: ({ x1, y1, x2, y2 }: IBoundsLike) => {\n let start;\n let end;\n let indexStart;\n let indexEnd;\n let i;\n for (; y1 <= y2; ++y1) {\n start = y1 * w + x1;\n end = y1 * w + x2;\n indexStart = start >>> DIV;\n indexEnd = end >>> DIV;\n if (indexStart === indexEnd) {\n _clear(indexStart, RIGHT1[start & MOD] | RIGHT0[(end & MOD) + 1]);\n } else {\n _clear(indexStart, RIGHT1[start & MOD]);\n _clear(indexEnd, RIGHT0[(end & MOD) + 1]);\n for (i = indexStart + 1; i < indexEnd; ++i) {\n _clear(i, 0);\n }\n }\n }\n },\n\n outOfBounds: ({ x1, y1, x2, y2 }: IBoundsLike) => x1 < 0 || y1 < 0 || y2 >= h || x2 >= w,\n toImageData: (ctx: CanvasRenderingContext2D) => {\n const imageData = ctx.createImageData(w, h);\n const data = imageData.data;\n for (let y = 0; y < h; ++y) {\n for (let x = 0; x < w; ++x) {\n const index = y * w + x;\n const offset = 4 * index;\n const occupied = array[index >>> DIV] & (1 << (index & MOD));\n data[offset + 0] = occupied * 0xff;\n data[offset + 1] = occupied * 0xff;\n data[offset + 2] = occupied * 0xff;\n data[offset + 3] = 0x1f; // alpha\n }\n }\n return imageData;\n }\n };\n}\n\nexport type Bitmap = ReturnType<typeof bitmap>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/overlap/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC","file":"index.js","sourcesContent":["export * from './bitmap';\nexport * from './place';\nexport * from './scaler';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Text } from '@visactor/vrender';
|
|
2
|
+
import { IAABBBounds, IBoundsLike } from '@visactor/vutils';
|
|
3
|
+
import { PointLocationCfg } from '../../core/type';
|
|
4
|
+
import type { LabelBase } from '../base';
|
|
5
|
+
import type { BaseLabelAttrs, Strategy } from '../type';
|
|
6
|
+
import type { Bitmap } from './bitmap';
|
|
7
|
+
import { BitmapTool } from './scaler';
|
|
8
|
+
export declare function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound?: boolean): boolean;
|
|
9
|
+
export declare function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
|
|
10
|
+
export declare function placeToCandidates($: BitmapTool, bitmap: Bitmap, text: Text, candidates?: PointLocationCfg[], clampForce?: boolean): boolean;
|
|
11
|
+
export declare function place<T extends BaseLabelAttrs>($: BitmapTool, bitmap: Bitmap, s: Strategy, attrs: T, text: Text, bounds: IBoundsLike, labeling?: LabelBase<T>['labeling']): boolean;
|
|
12
|
+
export declare const DefaultPositions: string[];
|
|
13
|
+
export declare const DefaultRectPositions: string[];
|
|
14
|
+
export declare function defaultLabelPosition(type?: string): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createText } from "@visactor/vrender";
|
|
2
|
+
|
|
3
|
+
import { isFunction } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import { boundToRange } from "./scaler";
|
|
6
|
+
|
|
7
|
+
export function canPlace($, bitmap, bound, checkBound = !0) {
|
|
8
|
+
const range = boundToRange($, bound);
|
|
9
|
+
return !(checkBound && bitmap.outOfBounds(range)) && !bitmap.getRange(range);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function canPlaceInside(textBound, shapeBound) {
|
|
13
|
+
return !(!textBound || !shapeBound) && shapeBound.encloses(textBound);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function placeToCandidates($, bitmap, text, candidates = [], clampForce = !0) {
|
|
17
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
18
|
+
const tempText = createText(text.attribute);
|
|
19
|
+
if (tempText.setAttributes(candidates[i]), tempText.update(), canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce)) return bitmap.setRange(boundToRange($, tempText.AABBBounds)),
|
|
20
|
+
text.setAttributes(candidates[i]), !0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function place($, bitmap, s, attrs, text, bounds, labeling) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
if ("bound" === s.type || "position" === s.type) {
|
|
27
|
+
if (isFunction(labeling)) {
|
|
28
|
+
const candidates = ((isFunction(s.position) ? s.position(text.attribute) : s.position) || defaultLabelPosition(attrs.type)).map((p => labeling(text.AABBBounds, bounds, p, attrs.offset)));
|
|
29
|
+
return !!placeToCandidates($, bitmap, text, candidates, null === (_a = attrs.overlap) || void 0 === _a ? void 0 : _a.clampForce);
|
|
30
|
+
}
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
if ("moveY" === s.type) {
|
|
34
|
+
const candidates = (s.offset ? isFunction(s.offset) ? s.offset(text.attribute) : s.offset : []).map((dy => ({
|
|
35
|
+
x: text.attribute.x,
|
|
36
|
+
y: text.attribute.y + dy
|
|
37
|
+
})));
|
|
38
|
+
return !!placeToCandidates($, bitmap, text, candidates, null === (_b = attrs.overlap) || void 0 === _b ? void 0 : _b.clampForce);
|
|
39
|
+
}
|
|
40
|
+
if ("moveX" === s.type) {
|
|
41
|
+
const candidates = (s.offset ? isFunction(s.offset) ? s.offset(text.attribute) : s.offset : []).map((dx => ({
|
|
42
|
+
x: text.attribute.x + dx,
|
|
43
|
+
y: text.attribute.y
|
|
44
|
+
})));
|
|
45
|
+
return !!placeToCandidates($, bitmap, text, candidates, null === (_c = attrs.overlap) || void 0 === _c ? void 0 : _c.clampForce);
|
|
46
|
+
}
|
|
47
|
+
return !1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const DefaultPositions = [ "top", "bottom", "right", "left", "top-right", "bottom-right", "top-left", "bottom-left" ];
|
|
51
|
+
|
|
52
|
+
export const DefaultRectPositions = [ "top", "inside-top", "inside" ];
|
|
53
|
+
|
|
54
|
+
export function defaultLabelPosition(type) {
|
|
55
|
+
return "rect" === type ? DefaultRectPositions : DefaultPositions;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/overlap/place.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA4B,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKxE,OAAO,EAAc,YAAY,EAAE,MAAM,UAAU,CAAC;AAiCpD,MAAM,UAAU,QAAQ,CAAC,CAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAAU,GAAG,IAAI;IAC3F,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,UAAU,IAAI,MAAM,CAAC,WAAW,CA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EAAE,UAAU,EAAE,MAAC,KAAK,CAAC,OAAwB,0CAAE,UAAU,CAAC,CAAC;KACtG;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;QACtB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACjC,OAAO,EAAE,CAAC,EAAG,IAAI,CAAC,SAAS,CAAC,CAAY,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAW,EAAE,CAAC;QACjF,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAC,KAAK,CAAC,OAAwB,0CAAE,UAAU,CAAC,CAAC;KACtG;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK;IACL,QAAQ;IACR,OAAO;IACP,MAAM;IACN,WAAW;IACX,cAAc;IACd,UAAU;IACV,aAAa;CACd,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAEpE,MAAM,UAAU,oBAAoB,CAAC,IAAa;IAChD,QAAQ,IAAI,EAAE;QACZ,KAAK,MAAM;YACT,OAAO,oBAAoB,CAAC;QAC9B;YACE,OAAO,gBAAgB,CAAC;KAC3B;AACH,CAAC","file":"place.js","sourcesContent":["import { Text, createText } from '@visactor/vrender';\nimport { IAABBBounds, IBoundsLike, isFunction } from '@visactor/vutils';\nimport { PointLocationCfg } from '../../core/type';\nimport type { LabelBase } from '../base';\nimport type { BaseLabelAttrs, OverlapAttrs, Strategy } from '../type';\nimport type { Bitmap } from './bitmap';\nimport { BitmapTool, boundToRange } from './scaler';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function canPlace($: BitmapTool, bitmap: Bitmap, bound: IBoundsLike, checkBound = true) {\n const range = boundToRange($, bound);\n const outOfBounds = checkBound && bitmap.outOfBounds(range);\n\n if (outOfBounds) {\n return false;\n }\n\n return !bitmap.getRange(range);\n}\n\n/**\n * 是否在图形内部\n * @param textBound\n * @param shapeBound\n * @returns\n */\nexport function canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds) {\n if (!textBound || !shapeBound) {\n return false;\n }\n return shapeBound.encloses(textBound);\n}\n\nexport function placeToCandidates(\n $: BitmapTool,\n bitmap: Bitmap,\n text: Text,\n candidates: PointLocationCfg[] = [],\n clampForce = true\n) {\n for (let i = 0; i < candidates.length; i++) {\n const tempText = createText(text.attribute) as Text;\n tempText.setAttributes(candidates[i]);\n tempText.update();\n\n if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce)) {\n bitmap.setRange(boundToRange($, tempText.AABBBounds));\n text.setAttributes(candidates[i]);\n return true;\n }\n }\n}\n\nexport function place<T extends BaseLabelAttrs>(\n $: BitmapTool,\n bitmap: Bitmap,\n s: Strategy,\n attrs: T,\n text: Text,\n bounds: IBoundsLike,\n labeling?: LabelBase<T>['labeling']\n): boolean {\n if (s.type === 'bound' || s.type === 'position') {\n if (isFunction(labeling)) {\n // TODO:这里可以 filter 掉初始位置,提升一部分性能\n const userPosition = isFunction(s.position) ? s.position(text.attribute) : s.position;\n const positions = (userPosition || defaultLabelPosition(attrs.type)) as string[];\n const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset) as PointLocationCfg);\n return !!placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n return false;\n }\n\n if (s.type === 'moveY') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dy => {\n return { x: text.attribute.x as number, y: (text.attribute.y as number) + dy };\n });\n return !!placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n\n if (s.type === 'moveX') {\n const offset = s.offset ? (isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];\n const candidates = offset.map(dx => {\n return { x: (text.attribute.x as number) + dx, y: text.attribute.y as number };\n });\n return !!placeToCandidates($, bitmap, text, candidates, (attrs.overlap as OverlapAttrs)?.clampForce);\n }\n return false;\n}\n\nexport const DefaultPositions = [\n 'top',\n 'bottom',\n 'right',\n 'left',\n 'top-right',\n 'bottom-right',\n 'top-left',\n 'bottom-left'\n];\nexport const DefaultRectPositions = ['top', 'inside-top', 'inside'];\n\nexport function defaultLabelPosition(type?: string) {\n switch (type) {\n case 'rect':\n return DefaultRectPositions;\n default:\n return DefaultPositions;\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IBoundsLike } from '@visactor/vutils';
|
|
2
|
+
export declare function bitmapTool(width: number, height: number, padding?: number): {
|
|
3
|
+
(_: number): number;
|
|
4
|
+
invert(_: number): number;
|
|
5
|
+
bitmap(): {
|
|
6
|
+
array: Uint32Array;
|
|
7
|
+
get: (x: number, y: number) => number;
|
|
8
|
+
set: (x: number, y: number) => void;
|
|
9
|
+
clear: (x: number, y: number) => void;
|
|
10
|
+
getRange: ({ x1, y1, x2, y2 }: IBoundsLike) => boolean;
|
|
11
|
+
setRange: ({ x1, y1, x2, y2 }: IBoundsLike) => void;
|
|
12
|
+
clearRange: ({ x1, y1, x2, y2 }: IBoundsLike) => void;
|
|
13
|
+
outOfBounds: ({ x1, y1, x2, y2 }: IBoundsLike) => boolean;
|
|
14
|
+
toImageData: (ctx: CanvasRenderingContext2D) => ImageData;
|
|
15
|
+
};
|
|
16
|
+
ratio: number;
|
|
17
|
+
padding: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function boundToRange($: BitmapTool, bound: IBoundsLike): {
|
|
22
|
+
x1: number;
|
|
23
|
+
x2: number;
|
|
24
|
+
y1: number;
|
|
25
|
+
y2: number;
|
|
26
|
+
};
|
|
27
|
+
export type BitmapTool = ReturnType<typeof bitmapTool>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { bitmap } from "./bitmap";
|
|
2
|
+
|
|
3
|
+
export function bitmapTool(width, height, padding = 0) {
|
|
4
|
+
const ratio = Math.max(1, Math.sqrt(width * height / 1e6)), w = ~~((width + 2 * padding + ratio) / ratio), h = ~~((height + 2 * padding + ratio) / ratio), scale = _ => ~~((_ + padding) / ratio);
|
|
5
|
+
return scale.invert = _ => _ * ratio - padding, scale.bitmap = () => bitmap(w, h),
|
|
6
|
+
scale.ratio = ratio, scale.padding = padding, scale.width = width, scale.height = height,
|
|
7
|
+
scale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function boundToRange($, bound) {
|
|
11
|
+
return {
|
|
12
|
+
x1: $(bound.x1),
|
|
13
|
+
x2: $(bound.x2),
|
|
14
|
+
y1: $(bound.y1),
|
|
15
|
+
y2: $(bound.y2)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=scaler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/overlap/scaler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAiClC,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,MAAc,EAAE,OAAO,GAAG,CAAC;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAEvD,KAAK,CAAC,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC;IAClD,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAEtB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAa,EAAE,KAAkB;IAC5D,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;KAChB,CAAC;AACJ,CAAC","file":"scaler.js","sourcesContent":["import { IBoundsLike } from '@visactor/vutils';\nimport { bitmap } from './bitmap';\n\n/**\n * 防重叠逻辑参考 https://github.com/vega/vega/\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function bitmapTool(width: number, height: number, padding = 0) {\n const ratio = Math.max(1, Math.sqrt((width * height) / 1e6));\n const w = ~~((width + 2 * padding + ratio) / ratio);\n const h = ~~((height + 2 * padding + ratio) / ratio);\n const scale = (_: number) => ~~((_ + padding) / ratio);\n\n scale.invert = (_: number) => _ * ratio - padding;\n scale.bitmap = () => bitmap(w, h);\n scale.ratio = ratio;\n scale.padding = padding;\n scale.width = width;\n scale.height = height;\n\n return scale;\n}\n\nexport function boundToRange($: BitmapTool, bound: IBoundsLike) {\n return {\n x1: $(bound.x1),\n x2: $(bound.x2),\n y1: $(bound.y1),\n y2: $(bound.y2)\n };\n}\n\nexport type BitmapTool = ReturnType<typeof bitmapTool>;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBoundsLike } from '@visactor/vutils';
|
|
2
|
+
import type { ITextGraphicAttribute } from '@visactor/vrender';
|
|
3
|
+
import type { RectLabelAttrs } from './type';
|
|
4
|
+
import { LabelBase } from './base';
|
|
5
|
+
export declare class RectLabel extends LabelBase<RectLabelAttrs> {
|
|
6
|
+
static tag: string;
|
|
7
|
+
static defaultAttributes: Partial<RectLabelAttrs>;
|
|
8
|
+
constructor(attributes: RectLabelAttrs);
|
|
9
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): Partial<ITextGraphicAttribute> | undefined;
|
|
10
|
+
}
|
package/es/label/rect.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { merge } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { LabelBase } from "./base";
|
|
4
|
+
|
|
5
|
+
export class RectLabel extends LabelBase {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
super(merge({}, RectLabel.defaultAttributes, attributes));
|
|
8
|
+
}
|
|
9
|
+
labeling(textBounds, graphicBounds, position = "top", offset = 0) {
|
|
10
|
+
if (!textBounds || !graphicBounds) return;
|
|
11
|
+
const {x1: x1, y1: y1, x2: x2, y2: y2} = textBounds, width = Math.abs(x2 - x1), height = Math.abs(y2 - y1), rectWidth = Math.abs(graphicBounds.x2 - graphicBounds.x1), rectHeight = Math.abs(graphicBounds.y2 - graphicBounds.y1);
|
|
12
|
+
let anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2, anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2, sx = 0, sy = 0;
|
|
13
|
+
switch (position) {
|
|
14
|
+
case "top":
|
|
15
|
+
case "inside-top":
|
|
16
|
+
sy = -.5;
|
|
17
|
+
break;
|
|
18
|
+
|
|
19
|
+
case "bottom":
|
|
20
|
+
case "inside-bottom":
|
|
21
|
+
sy = .5;
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case "left":
|
|
25
|
+
case "inside-left":
|
|
26
|
+
sx = -.5;
|
|
27
|
+
break;
|
|
28
|
+
|
|
29
|
+
case "right":
|
|
30
|
+
case "inside-right":
|
|
31
|
+
sx = .5;
|
|
32
|
+
}
|
|
33
|
+
anchorX += sx * rectWidth, anchorY += sy * rectHeight;
|
|
34
|
+
let vx = 0, vy = 0;
|
|
35
|
+
const isInside = position.includes("inside");
|
|
36
|
+
position.includes("top") ? vy = isInside ? 1 : -1 : position.includes("bottom") ? vy = isInside ? -1 : 1 : position.includes("left") ? vx = isInside ? 1 : -1 : position.includes("right") && (vx = isInside ? -1 : 1);
|
|
37
|
+
return {
|
|
38
|
+
x: anchorX + vx * offset + vx * width / 2,
|
|
39
|
+
y: anchorY + vy * offset + vy * height / 2
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
RectLabel.tag = "rect-label", RectLabel.defaultAttributes = {
|
|
45
|
+
textStyle: {
|
|
46
|
+
fontSize: 12,
|
|
47
|
+
fillColor: "#000",
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
textBaseline: "middle"
|
|
50
|
+
},
|
|
51
|
+
position: "top",
|
|
52
|
+
offset: 5,
|
|
53
|
+
pickable: !1
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=rect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/rect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,OAAO,SAAU,SAAQ,SAAyB;IAetD,YAAY,UAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;IAES,QAAQ,CAChB,UAAuB,EACvB,aAA0B,EAC1B,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,CAAC;QAEV,IAAI,CAAC,UAAU,IAAI,CAAC,aAAa,EAAE;YACjC,OAAO;SACR;QAED,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,UAAU,CAAC;QACtC,MAAM,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QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC5B,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACtC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACpC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACrC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEpD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;;AAjFM,aAAG,GAAG,YAAY,CAAC;AAEnB,2BAAiB,GAA4B;IAClD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"rect.js","sourcesContent":["import { merge, IBoundsLike } from '@visactor/vutils';\nimport type { ITextGraphicAttribute } from '@visactor/vrender';\nimport type { RectLabelAttrs } from './type';\nimport { LabelBase } from './base';\n\nexport class RectLabel extends LabelBase<RectLabelAttrs> {\n static tag = 'rect-label';\n\n static defaultAttributes: Partial<RectLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fillColor: '#000',\n textAlign: 'center',\n textBaseline: 'middle'\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: RectLabelAttrs) {\n super(merge({}, RectLabel.defaultAttributes, attributes));\n }\n\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position = 'top',\n offset = 0\n ): Partial<ITextGraphicAttribute> | undefined {\n if (!textBounds || !graphicBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const rectWidth = Math.abs(graphicBounds.x2 - graphicBounds.x1);\n const rectHeight = Math.abs(graphicBounds.y2 - graphicBounds.y1);\n let anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n let anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n\n switch (position) {\n case 'top':\n case 'inside-top':\n sy = -0.5;\n break;\n case 'bottom':\n case 'inside-bottom':\n sy = 0.5;\n break;\n case 'left':\n case 'inside-left':\n sx = -0.5;\n break;\n case 'right':\n case 'inside-right':\n sx = 0.5;\n break;\n }\n\n anchorX += sx * rectWidth;\n anchorY += sy * rectHeight;\n\n let vx = 0;\n let vy = 0;\n\n const isInside = position.includes('inside');\n\n if (position.includes('top')) {\n vy = isInside ? 1 : -1;\n } else if (position.includes('bottom')) {\n vy = isInside ? -1 : 1;\n } else if (position.includes('left')) {\n vx = isInside ? 1 : -1;\n } else if (position.includes('right')) {\n vx = isInside ? -1 : 1;\n }\n\n const x = anchorX + vx * offset + (vx * width) / 2;\n const y = anchorY + vy * offset + (vy * height) / 2;\n\n return { x, y };\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBoundsLike } from '@visactor/vutils';
|
|
2
|
+
import type { ITextGraphicAttribute } from '@visactor/vrender';
|
|
3
|
+
import type { SymbolLabelAttrs } from './type';
|
|
4
|
+
import { LabelBase } from './base';
|
|
5
|
+
export declare class SymbolLabel extends LabelBase<SymbolLabelAttrs> {
|
|
6
|
+
name: string;
|
|
7
|
+
static defaultAttributes: Partial<SymbolLabelAttrs>;
|
|
8
|
+
constructor(attributes: SymbolLabelAttrs);
|
|
9
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): Partial<ITextGraphicAttribute> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { merge } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { LabelBase } from "./base";
|
|
4
|
+
|
|
5
|
+
export class SymbolLabel extends LabelBase {
|
|
6
|
+
constructor(attributes) {
|
|
7
|
+
super(merge({}, SymbolLabel.defaultAttributes, attributes)), this.name = "symbol-label";
|
|
8
|
+
}
|
|
9
|
+
labeling(textBounds, graphicBounds, position = "top", offset = 0) {
|
|
10
|
+
if (!textBounds) return;
|
|
11
|
+
const {x1: x1, y1: y1, x2: x2, y2: y2} = textBounds, width = Math.abs(x2 - x1), height = Math.abs(y2 - y1), anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2, anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;
|
|
12
|
+
let sx = 0, sy = 0, offsetX = 0, offsetY = 0;
|
|
13
|
+
graphicBounds && (offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2, offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2);
|
|
14
|
+
const angle = {
|
|
15
|
+
"top-right": -235,
|
|
16
|
+
"top-left": 235,
|
|
17
|
+
"bottom-right": 45,
|
|
18
|
+
"bottom-left": -45
|
|
19
|
+
};
|
|
20
|
+
switch (position) {
|
|
21
|
+
case "top":
|
|
22
|
+
sy = -1;
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case "bottom":
|
|
26
|
+
sy = 1;
|
|
27
|
+
break;
|
|
28
|
+
|
|
29
|
+
case "left":
|
|
30
|
+
sx = -1;
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
case "right":
|
|
34
|
+
sx = 1;
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case "bottom-left":
|
|
38
|
+
case "bottom-right":
|
|
39
|
+
case "top-left":
|
|
40
|
+
case "top-right":
|
|
41
|
+
sx = Math.sin(angle[position] * (Math.PI / 180)), sy = Math.cos(angle[position] * (Math.PI / 180));
|
|
42
|
+
break;
|
|
43
|
+
|
|
44
|
+
case "center":
|
|
45
|
+
sx = 0, sy = 0;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
x: anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2),
|
|
49
|
+
y: anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
SymbolLabel.defaultAttributes = {
|
|
55
|
+
textStyle: {
|
|
56
|
+
fontSize: 12,
|
|
57
|
+
fillColor: "#000",
|
|
58
|
+
textAlign: "center",
|
|
59
|
+
textBaseline: "middle"
|
|
60
|
+
},
|
|
61
|
+
position: "top",
|
|
62
|
+
offset: 5,
|
|
63
|
+
pickable: !1
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=symbol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,OAAO,WAAY,SAAQ,SAA2B;IAe1D,YAAY,UAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,WAAW,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAf9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,EAAE,KAAK;CAChB,CAAC","file":"symbol.js","sourcesContent":["import { merge, IBoundsLike } from '@visactor/vutils';\nimport type { ITextGraphicAttribute } from '@visactor/vrender';\nimport type { SymbolLabelAttrs } from './type';\nimport { LabelBase } from './base';\n\nexport class SymbolLabel extends LabelBase<SymbolLabelAttrs> {\n name = 'symbol-label';\n\n static defaultAttributes: Partial<SymbolLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fillColor: '#000',\n textAlign: 'center',\n textBaseline: 'middle'\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: SymbolLabelAttrs) {\n super(merge({}, SymbolLabel.defaultAttributes, attributes));\n }\n\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position = 'top',\n offset = 0\n ): Partial<ITextGraphicAttribute> | undefined {\n if (!textBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n let offsetX = 0;\n let offsetY = 0;\n if (graphicBounds) {\n offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;\n offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;\n }\n\n const angle = {\n 'top-right': -235,\n 'top-left': 235,\n 'bottom-right': 45,\n 'bottom-left': -45\n };\n\n switch (position) {\n case 'top':\n sy = -1;\n break;\n case 'bottom':\n sy = 1;\n break;\n case 'left':\n sx = -1;\n break;\n case 'right':\n sx = 1;\n break;\n case 'bottom-left':\n case 'bottom-right':\n case 'top-left':\n case 'top-right':\n sx = Math.sin(angle[position] * (Math.PI / 180));\n sy = Math.cos(angle[position] * (Math.PI / 180));\n break;\n case 'center':\n sx = 0;\n sy = 0;\n break;\n }\n\n const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);\n const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);\n\n return { x, y };\n }\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { EasingType, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import type { Bounds } from '@visactor/vutils';
|
|
3
|
+
export type LabelItemStateStyle<T> = {
|
|
4
|
+
hover?: T;
|
|
5
|
+
hover_reverse?: T;
|
|
6
|
+
selected?: T;
|
|
7
|
+
selected_reverse?: T;
|
|
8
|
+
};
|
|
9
|
+
export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
10
|
+
type: string;
|
|
11
|
+
select?: boolean;
|
|
12
|
+
hover?: boolean;
|
|
13
|
+
data: Functional<(ITextGraphicAttribute & Record<string, any>)[]>;
|
|
14
|
+
sort?: (graphicA: any, graphicB: any) => number;
|
|
15
|
+
baseMarkGroupName?: string;
|
|
16
|
+
textStyle?: Partial<ITextGraphicAttribute>;
|
|
17
|
+
state?: LabelItemStateStyle<ITextGraphicAttribute>;
|
|
18
|
+
position?: Functional<string>;
|
|
19
|
+
offset?: number;
|
|
20
|
+
overlap?: OverlapAttrs | false;
|
|
21
|
+
smartInvert?: SmartInvertAttrs | false;
|
|
22
|
+
animation?: ILabelAnimation | false;
|
|
23
|
+
}
|
|
24
|
+
export interface OverlapAttrs {
|
|
25
|
+
size?: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
hideOnHit?: boolean;
|
|
30
|
+
clampForce?: boolean;
|
|
31
|
+
avoidBaseMark?: boolean;
|
|
32
|
+
strategy?: Strategy[];
|
|
33
|
+
}
|
|
34
|
+
export interface SmartInvertAttrs {
|
|
35
|
+
textType?: string;
|
|
36
|
+
contrastRatiosThreshold?: number;
|
|
37
|
+
alternativeColors?: string | string[];
|
|
38
|
+
}
|
|
39
|
+
export type PositionStrategy = {
|
|
40
|
+
type: 'position';
|
|
41
|
+
position?: Functional<LabelPosition[]>;
|
|
42
|
+
};
|
|
43
|
+
export type BoundStrategy = {
|
|
44
|
+
type: 'bound';
|
|
45
|
+
position?: Functional<LabelPosition[]>;
|
|
46
|
+
};
|
|
47
|
+
export type MoveYStrategy = {
|
|
48
|
+
type: 'moveY';
|
|
49
|
+
offset: Functional<number[]>;
|
|
50
|
+
};
|
|
51
|
+
export type MoveXStrategy = {
|
|
52
|
+
type: 'moveX';
|
|
53
|
+
offset: Functional<number[]>;
|
|
54
|
+
};
|
|
55
|
+
export type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;
|
|
56
|
+
export type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];
|
|
57
|
+
export interface SymbolLabelAttrs extends BaseLabelAttrs {
|
|
58
|
+
type: 'symbol';
|
|
59
|
+
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'>;
|
|
60
|
+
}
|
|
61
|
+
export interface RectLabelAttrs extends BaseLabelAttrs {
|
|
62
|
+
type: 'rect';
|
|
63
|
+
baseMarkGroupName: string;
|
|
64
|
+
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left'>;
|
|
65
|
+
}
|
|
66
|
+
export interface LineLabelAttrs extends BaseLabelAttrs {
|
|
67
|
+
type: 'line';
|
|
68
|
+
baseMarkGroupName: string;
|
|
69
|
+
position?: Functional<'start' | 'end'>;
|
|
70
|
+
}
|
|
71
|
+
export interface DataLabelAttrs extends IGroupGraphicAttribute {
|
|
72
|
+
dataLabels: (RectLabelAttrs | SymbolLabelAttrs)[];
|
|
73
|
+
size: {
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export type Functional<T> = T | ((data: any) => T);
|
|
79
|
+
export interface ILabelGraphicAttribute extends ITextGraphicAttribute {
|
|
80
|
+
_insideGraphic?: boolean;
|
|
81
|
+
_relatedIndex?: number;
|
|
82
|
+
_computedBound?: Bounds;
|
|
83
|
+
}
|
|
84
|
+
export interface ILabelAnimation {
|
|
85
|
+
mode?: 'same-time' | 'after' | 'after-all';
|
|
86
|
+
duration?: number;
|
|
87
|
+
delay?: number;
|
|
88
|
+
easing?: EasingType;
|
|
89
|
+
increaseEffect?: boolean;
|
|
90
|
+
}
|
package/es/label/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { EasingType, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';\nimport type { Bounds } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: Functional<(ITextGraphicAttribute & Record<string, any>)[]>;\n\n sort?: (graphicA: any, graphicB: any) => number;\n\n /**\n * 图元 group 名称\n * 如果不配置,需要在 data 里指定标签定位 x/y\n */\n baseMarkGroupName?: string;\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | false;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | false;\n\n /** 动画配置 */\n animation?: ILabelAnimation | false;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: { width: number; height: number };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 发生重叠后的躲避策略\n */\n strategy?: Strategy[];\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n}\n\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type MoveYStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'\n >;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left'\n >;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\nexport interface ILabelGraphicAttribute extends ITextGraphicAttribute {\n _insideGraphic?: boolean;\n _relatedIndex?: number;\n _computedBound?: Bounds;\n}\n\nexport interface ILabelAnimation {\n mode?: 'same-time' | 'after' | 'after-all';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n /** 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IGroup } from '@visactor/vrender';
|
|
2
|
+
import { AbstractComponent } from '../core/base';
|
|
3
|
+
import { Tag } from '../tag';
|
|
4
|
+
import { LegendBaseAttributes } from './type';
|
|
5
|
+
export declare abstract class LegendBase<T extends LegendBaseAttributes> extends AbstractComponent<Required<T>> {
|
|
6
|
+
name: string;
|
|
7
|
+
protected _innerView: IGroup;
|
|
8
|
+
protected _title: Tag | null;
|
|
9
|
+
render(): void;
|
|
10
|
+
protected abstract _renderContent(): void;
|
|
11
|
+
protected abstract _bindEvents(): void;
|
|
12
|
+
private _renderTitle;
|
|
13
|
+
private _adjustLayout;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isValid, normalizePadding } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { createGroup } from "@visactor/vrender";
|
|
4
|
+
|
|
5
|
+
import { AbstractComponent } from "../core/base";
|
|
6
|
+
|
|
7
|
+
import { Tag } from "../tag";
|
|
8
|
+
|
|
9
|
+
import { LEGEND_ELEMENT_NAME } from "./constant";
|
|
10
|
+
|
|
11
|
+
export class LegendBase extends AbstractComponent {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.name = "legend", this._title = null;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
this.removeAllChild();
|
|
17
|
+
const {interactive: interactive = !0, title: title, padding: padding = 0} = this.attribute, parsedPadding = normalizePadding(padding), innerView = createGroup({
|
|
18
|
+
x: parsedPadding[3],
|
|
19
|
+
y: parsedPadding[0],
|
|
20
|
+
pickable: interactive,
|
|
21
|
+
childrenPickable: interactive
|
|
22
|
+
});
|
|
23
|
+
innerView.name = LEGEND_ELEMENT_NAME.innerView, this.add(innerView), this._innerView = innerView,
|
|
24
|
+
(null == title ? void 0 : title.visible) && this._renderTitle(title), this._renderContent(),
|
|
25
|
+
this._adjustLayout(), interactive && this._bindEvents();
|
|
26
|
+
const viewBounds = this._innerView.AABBBounds;
|
|
27
|
+
this.attribute.width = viewBounds.width() + parsedPadding[1] + parsedPadding[3],
|
|
28
|
+
this.attribute.height = viewBounds.height() + parsedPadding[0] + parsedPadding[2];
|
|
29
|
+
}
|
|
30
|
+
_renderTitle(title) {
|
|
31
|
+
const {text: text = "", textStyle: textStyle, padding: padding = 0, background: background, minWidth: minWidth, maxWidth: maxWidth, shape: shape} = title, tagAttrs = {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
text: text,
|
|
35
|
+
textStyle: textStyle,
|
|
36
|
+
padding: normalizePadding(padding),
|
|
37
|
+
minWidth: minWidth,
|
|
38
|
+
maxWidth: maxWidth
|
|
39
|
+
};
|
|
40
|
+
shape && shape.visible && (tagAttrs.shape = Object.assign({
|
|
41
|
+
visible: !0
|
|
42
|
+
}, shape.style), isValid(shape.space) && (tagAttrs.space = shape.space)), background && background.visible && (tagAttrs.panel = Object.assign({
|
|
43
|
+
visible: !0
|
|
44
|
+
}, background.style));
|
|
45
|
+
const titleTag = new Tag(tagAttrs);
|
|
46
|
+
titleTag.name = LEGEND_ELEMENT_NAME.title, this._title = titleTag, this._innerView.add(titleTag);
|
|
47
|
+
}
|
|
48
|
+
_adjustLayout() {
|
|
49
|
+
var _a;
|
|
50
|
+
if (this._title) {
|
|
51
|
+
const innerViewWidth = this._innerView.AABBBounds.width(), titleWidth = this._title.AABBBounds.width(), align = null === (_a = this.attribute.title) || void 0 === _a ? void 0 : _a.align;
|
|
52
|
+
"center" === align ? this._title.setAttribute("x", (innerViewWidth - titleWidth) / 2) : "end" === align && this._title.setAttribute("x", innerViewWidth - titleWidth);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/legend/base.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,GAAG,EAAiB,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,OAAgB,UAA2C,SAAQ,iBAA8B;IAAvG;;QACE,SAAI,GAAG,QAAQ,CAAC;QAEN,WAAM,GAAe,IAAI,CAAC;IAgGtC,CAAC;IA9FC,MAAM;QACJ,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,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AE;gBAC1B,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC;aAC5D;SACF;IACH,CAAC;CACF","file":"base.js","sourcesContent":["/**\n * TODO:\n * align 为 'top' 时,操作区域同标题的间距有问题\n */\nimport { isValid, normalizePadding } from '@visactor/vutils';\nimport { createGroup, IGroup, INode } from '@visactor/vrender';\nimport { AbstractComponent } from '../core/base';\nimport { Tag, TagAttributes } from '../tag';\nimport { LegendBaseAttributes, LegendTitle } from './type';\nimport { LEGEND_ELEMENT_NAME } from './constant';\n\nexport abstract class LegendBase<T extends LegendBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'legend';\n protected _innerView!: IGroup;\n protected _title: Tag | null = null;\n\n render() {\n this.removeAllChild();\n\n const { interactive = true, title, padding = 0 } = this.attribute;\n const parsedPadding = normalizePadding(padding);\n\n // 创建一个内部的 container 用于存储所有的元素\n const innerView = createGroup({\n x: parsedPadding[3],\n y: parsedPadding[0],\n pickable: interactive,\n childrenPickable: interactive\n });\n innerView.name = LEGEND_ELEMENT_NAME.innerView;\n this.add(innerView);\n this._innerView = innerView;\n\n if (title?.visible) {\n // 渲染标题\n this._renderTitle(title);\n }\n\n this._renderContent();\n\n this._adjustLayout();\n\n if (interactive) {\n this._bindEvents();\n }\n\n const viewBounds = this._innerView.AABBBounds;\n this.attribute.width = viewBounds.width() + parsedPadding[1] + parsedPadding[3];\n this.attribute.height = viewBounds.height() + parsedPadding[0] + parsedPadding[2];\n }\n /**\n * 图例主体内容渲染\n */\n protected abstract _renderContent(): void;\n /**\n * 事件绑定逻辑\n */\n protected abstract _bindEvents(): void;\n\n private _renderTitle(title: LegendTitle) {\n const { text = '', textStyle, padding = 0, background, minWidth, maxWidth, shape } = title;\n\n const tagAttrs: TagAttributes = {\n x: 0,\n y: 0,\n text,\n textStyle,\n padding: normalizePadding(padding),\n minWidth,\n maxWidth\n };\n\n if (shape && shape.visible) {\n tagAttrs.shape = {\n visible: true,\n ...shape.style\n };\n if (isValid(shape.space)) {\n tagAttrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n tagAttrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n const titleTag = new Tag(tagAttrs);\n titleTag.name = LEGEND_ELEMENT_NAME.title;\n this._title = titleTag;\n\n this._innerView.add(titleTag as unknown as INode);\n }\n\n private _adjustLayout() {\n // 调整 title\n if (this._title) {\n const innerViewWidth = this._innerView.AABBBounds.width();\n const titleWidth = this._title.AABBBounds.width();\n\n const align = this.attribute.title?.align;\n if (align === 'center') {\n this._title.setAttribute('x', (innerViewWidth - titleWidth) / 2);\n } else if (align === 'end') {\n this._title.setAttribute('x', innerViewWidth - titleWidth);\n }\n }\n }\n}\n"]}
|