@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,18 @@
|
|
|
1
|
+
import { AbstractComponent } from '../core/base';
|
|
2
|
+
import { TooltipAttributes, TooltipRowAttrs, TooltipRowStyleAttrs } from './type';
|
|
3
|
+
export declare class Tooltip extends AbstractComponent<Required<TooltipAttributes>> {
|
|
4
|
+
name: string;
|
|
5
|
+
private _tooltipPanel;
|
|
6
|
+
private _tooltipTitleContainer;
|
|
7
|
+
private _tooltipTitleSymbol;
|
|
8
|
+
private _tooltipTitle;
|
|
9
|
+
private _tooltipContent;
|
|
10
|
+
static defaultAttributes: Partial<TooltipAttributes>;
|
|
11
|
+
constructor(attributes: TooltipAttributes);
|
|
12
|
+
protected render(): void;
|
|
13
|
+
setAttributes(params: Partial<Required<TooltipAttributes>>, forceUpdateTag?: boolean | undefined): void;
|
|
14
|
+
static calculateTooltipPosition(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes>;
|
|
15
|
+
static measureTooltip(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes>;
|
|
16
|
+
static getTitleAttr(attribute: Partial<TooltipAttributes>): TooltipRowAttrs & TooltipRowStyleAttrs;
|
|
17
|
+
static getContentAttr(attribute: Partial<TooltipAttributes>, index: number): TooltipRowAttrs & TooltipRowStyleAttrs;
|
|
18
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { builtinSymbolsMap } from "@visactor/vrender";
|
|
2
|
+
|
|
3
|
+
import { merge, isValid, normalizePadding, isNil } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import { AbstractComponent } from "../core/base";
|
|
6
|
+
|
|
7
|
+
import { initTextMeasure } from "../util/text";
|
|
8
|
+
|
|
9
|
+
import { isVisible } from "../util";
|
|
10
|
+
|
|
11
|
+
import { mergeRowAttrs } from "./util";
|
|
12
|
+
|
|
13
|
+
import { defaultAttributes, TOOLTIP_POSITION_ATTRIBUTES } from "./config";
|
|
14
|
+
|
|
15
|
+
const TOOLTIP_BACKGROUND_NAME = "tooltip-background", TOOLTIP_TITLE_NAME = "tooltip-title", TOOLTIP_CONTENT_NAME = "tooltip-content", TOOLTIP_SHAPE_NAME_SUFFIX = "shape", TOOLTIP_KEY_NAME_SUFFIX = "key", TOOLTIP_VALUE_NAME_SUFFIX = "value";
|
|
16
|
+
|
|
17
|
+
export class Tooltip extends AbstractComponent {
|
|
18
|
+
constructor(attributes) {
|
|
19
|
+
super(merge({}, Tooltip.defaultAttributes, attributes)), this.name = "tooltip";
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const {visible: visible, content: content, panel: panel, keyWidth: keyWidth, valueWidth: valueWidth, hasContentShape: hasContentShape, autoCalculatePosition: autoCalculatePosition, autoMeasure: autoMeasure} = this.attribute;
|
|
23
|
+
if (!visible) return void this.hideAll();
|
|
24
|
+
autoMeasure && Tooltip.measureTooltip(this.attribute), autoCalculatePosition && Tooltip.calculateTooltipPosition(this.attribute);
|
|
25
|
+
const padding = normalizePadding(this.attribute.padding);
|
|
26
|
+
this._tooltipPanel = this.createOrUpdateChild("tooltip-background", Object.assign({
|
|
27
|
+
visible: !0
|
|
28
|
+
}, panel), "rect"), this._tooltipTitleContainer = this.createOrUpdateChild("tooltip-title", {
|
|
29
|
+
visible: !0,
|
|
30
|
+
x: padding[3],
|
|
31
|
+
y: padding[0]
|
|
32
|
+
}, "group");
|
|
33
|
+
const titleAttr = Tooltip.getTitleAttr(this.attribute);
|
|
34
|
+
this._tooltipTitleSymbol = this._tooltipTitleContainer.createOrUpdateChild("tooltip-title-shape", merge({
|
|
35
|
+
symbolType: "circle"
|
|
36
|
+
}, titleAttr.shape, {
|
|
37
|
+
visible: isVisible(titleAttr) && isVisible(titleAttr.shape)
|
|
38
|
+
}), "symbol");
|
|
39
|
+
const titlePaddingLeft = isVisible(titleAttr.shape) ? titleAttr.shape.size + titleAttr.shape.spacing : 0;
|
|
40
|
+
this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild("tooltip-title-value", merge({
|
|
41
|
+
text: ""
|
|
42
|
+
}, titleAttr.value, {
|
|
43
|
+
visible: isVisible(titleAttr) && isVisible(titleAttr.value)
|
|
44
|
+
}), "text");
|
|
45
|
+
const {textAlign: textAlign, textBaseline: textBaseline} = titleAttr.value, contentWidth = panel.width - padding[3] - padding[0] - titlePaddingLeft;
|
|
46
|
+
"center" === textAlign ? this._tooltipTitle.setAttribute("x", titlePaddingLeft + contentWidth / 2) : "right" === textAlign || "end" === textAlign ? this._tooltipTitle.setAttribute("x", titlePaddingLeft + contentWidth) : this._tooltipTitle.setAttribute("x", titlePaddingLeft),
|
|
47
|
+
"bottom" === textBaseline ? this._tooltipTitle.setAttribute("y", titleAttr.height) : "middle" === textBaseline ? this._tooltipTitle.setAttribute("y", titleAttr.height / 2) : this._tooltipTitle.setAttribute("y", 0);
|
|
48
|
+
const titleHeight = isVisible(titleAttr) ? titleAttr.height + titleAttr.spaceRow : 0;
|
|
49
|
+
if (this._tooltipContent = this.createOrUpdateChild("tooltip-content", {
|
|
50
|
+
visible: !0
|
|
51
|
+
}, "group"), this._tooltipContent.removeAllChild(), null == content ? void 0 : content.length) {
|
|
52
|
+
this._tooltipContent.setAttribute("x", padding[3]), this._tooltipContent.setAttribute("y", padding[0] + titleHeight);
|
|
53
|
+
let lastYPos = 0;
|
|
54
|
+
content.forEach(((item, i) => {
|
|
55
|
+
const itemAttr = Tooltip.getContentAttr(this.attribute, i);
|
|
56
|
+
if (!isVisible(itemAttr)) return;
|
|
57
|
+
const itemGroupName = `tooltip-content-${i}`, itemGroup = this._tooltipContent.createOrUpdateChild(itemGroupName, {
|
|
58
|
+
visible: !0,
|
|
59
|
+
x: 0,
|
|
60
|
+
y: lastYPos
|
|
61
|
+
}, "group");
|
|
62
|
+
let x = 0;
|
|
63
|
+
if (isVisible(itemAttr.shape)) {
|
|
64
|
+
itemGroup.createOrUpdateChild(`${itemGroupName}-shape`, Object.assign({
|
|
65
|
+
visible: !0
|
|
66
|
+
}, itemAttr.shape), "symbol").setAttribute("y", itemAttr.height / 2);
|
|
67
|
+
}
|
|
68
|
+
if (hasContentShape && (x += itemAttr.shape.size + itemAttr.shape.spacing), isVisible(itemAttr.key)) {
|
|
69
|
+
const element = itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign({
|
|
70
|
+
visible: !0
|
|
71
|
+
}, itemAttr.key), "text"), {textAlign: textAlign} = itemAttr.key;
|
|
72
|
+
"center" === textAlign ? element.setAttribute("x", x + keyWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + keyWidth) : element.setAttribute("x", x),
|
|
73
|
+
element.setAttribute("y", itemAttr.height / 2), x += keyWidth + itemAttr.key.spacing;
|
|
74
|
+
}
|
|
75
|
+
if (isVisible(itemAttr.value)) {
|
|
76
|
+
const element = itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign({
|
|
77
|
+
visible: !0
|
|
78
|
+
}, itemAttr.value), "text");
|
|
79
|
+
let textAlign = "right";
|
|
80
|
+
isValid(itemAttr.value.textAlign) ? textAlign = itemAttr.value.textAlign : isVisible(itemAttr.key) || (textAlign = "left"),
|
|
81
|
+
element.setAttribute("textAlign", textAlign), "center" === textAlign ? element.setAttribute("x", x + valueWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + valueWidth) : element.setAttribute("x", x),
|
|
82
|
+
x += valueWidth, element.setAttribute("y", itemAttr.height / 2), itemGroup.add(element);
|
|
83
|
+
}
|
|
84
|
+
lastYPos += itemAttr.height + itemAttr.spaceRow;
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
setAttributes(params, forceUpdateTag) {
|
|
89
|
+
const keys = Object.keys(params);
|
|
90
|
+
this.attribute.autoCalculatePosition && keys.every((key => TOOLTIP_POSITION_ATTRIBUTES.includes(key))) ? (this._mergeAttributes(params, keys),
|
|
91
|
+
isNil(this.attribute.panel.width) && this.attribute.autoMeasure && Tooltip.measureTooltip(this.attribute),
|
|
92
|
+
Tooltip.calculateTooltipPosition(this.attribute), super.setAttributes({
|
|
93
|
+
x: this.attribute.x,
|
|
94
|
+
y: this.attribute.y
|
|
95
|
+
}, forceUpdateTag)) : super.setAttributes(params, forceUpdateTag);
|
|
96
|
+
}
|
|
97
|
+
static calculateTooltipPosition(attribute) {
|
|
98
|
+
const {width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0} = attribute.panel, {offsetX: offsetX, offsetY: offsetY, pointerX: pointerX, pointerY: pointerY, positionX: positionX, positionY: positionY, parentBounds: parentBounds} = attribute;
|
|
99
|
+
let x = pointerX, y = pointerY;
|
|
100
|
+
return "left" === positionX ? x -= tooltipBoxWidth + offsetX : "center" === positionX ? x -= tooltipBoxWidth / 2 : x += offsetX,
|
|
101
|
+
"top" === positionY ? y -= tooltipBoxHeight + offsetY : "middle" === positionY ? y -= tooltipBoxHeight / 2 : y += offsetY,
|
|
102
|
+
x + tooltipBoxWidth > parentBounds.x2 && (x -= tooltipBoxWidth + offsetX), y + tooltipBoxHeight > parentBounds.y2 && (y -= tooltipBoxHeight + offsetY),
|
|
103
|
+
x < parentBounds.x1 && (x = parentBounds.x1), y < parentBounds.y1 && (y = parentBounds.y1),
|
|
104
|
+
attribute.x = x, attribute.y = y, attribute;
|
|
105
|
+
}
|
|
106
|
+
static measureTooltip(attribute) {
|
|
107
|
+
const {content: content, contentStyle: contentStyle} = attribute, padding = normalizePadding(attribute.padding), titleAttr = Tooltip.getTitleAttr(attribute);
|
|
108
|
+
let maxWidth = 0, containerHeight = padding[0] + padding[2], titleMaxHeight = 0;
|
|
109
|
+
const {value: titleValue, shape: titleShape} = titleAttr, {visible: titleHasShape = !1, symbolType: titleShapeType = ""} = null != titleShape ? titleShape : {};
|
|
110
|
+
if (isValid(titleValue)) {
|
|
111
|
+
const {width: width, height: height} = initTextMeasure(titleValue).quickMeasure(titleValue.text);
|
|
112
|
+
maxWidth = width, titleMaxHeight = height;
|
|
113
|
+
}
|
|
114
|
+
if (titleHasShape && builtinSymbolsMap[titleShapeType] && (maxWidth += titleShape.size + titleShape.spacing,
|
|
115
|
+
titleMaxHeight = Math.max(titleShape.size, titleMaxHeight)), attribute.title.width = maxWidth,
|
|
116
|
+
attribute.title.height = titleMaxHeight, isVisible(titleAttr) && (containerHeight += titleMaxHeight + titleAttr.spaceRow),
|
|
117
|
+
null == content ? void 0 : content.length) {
|
|
118
|
+
const filteredContent = [];
|
|
119
|
+
if (content.forEach(((item, i) => {
|
|
120
|
+
const itemAttr = Tooltip.getContentAttr(attribute, i);
|
|
121
|
+
(item.key || item.value) && isVisible(itemAttr) && filteredContent.push([ item, itemAttr ]);
|
|
122
|
+
})), filteredContent.length) {
|
|
123
|
+
let hasContentShape = !1;
|
|
124
|
+
const shapeWidths = [], keyWidths = [], valueWidths = [];
|
|
125
|
+
filteredContent.forEach((([item, itemAttr], i) => {
|
|
126
|
+
var _a;
|
|
127
|
+
const {key: key, value: value, shape: shape, spaceRow: spaceRow} = itemAttr, itemHasShape = isVisible(shape), itemShapeType = null !== (_a = null == shape ? void 0 : shape.symbolType) && void 0 !== _a ? _a : "", keyTextMeasure = initTextMeasure(key), valueTextMeasure = initTextMeasure(value);
|
|
128
|
+
let itemHeight = 0;
|
|
129
|
+
if (isVisible(key)) {
|
|
130
|
+
const {width: width, height: height} = keyTextMeasure.quickMeasure(key.text);
|
|
131
|
+
keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
132
|
+
}
|
|
133
|
+
if (isVisible(value)) {
|
|
134
|
+
const {width: width, height: height} = valueTextMeasure.quickMeasure(value.text);
|
|
135
|
+
valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
136
|
+
}
|
|
137
|
+
itemHasShape && builtinSymbolsMap[itemShapeType] && (hasContentShape = !0, shapeWidths.push(shape.size),
|
|
138
|
+
itemHeight = Math.max(shape.size, itemHeight)), item.height = itemHeight, containerHeight += itemHeight,
|
|
139
|
+
i < filteredContent.length - 1 && (containerHeight += null != spaceRow ? spaceRow : contentStyle.spaceRow);
|
|
140
|
+
}));
|
|
141
|
+
const maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) : 0, maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
|
|
142
|
+
maxWidth = Math.max(maxKeyWidth + maxValueWidth + contentStyle.key.spacing + contentStyle.value.spacing + (hasContentShape ? maxShapeWidth + contentStyle.shape.spacing : 0), maxWidth),
|
|
143
|
+
content.forEach((item => {
|
|
144
|
+
item.width = maxWidth;
|
|
145
|
+
})), attribute.hasContentShape = hasContentShape, attribute.keyWidth = maxKeyWidth,
|
|
146
|
+
attribute.valueWidth = maxValueWidth;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return attribute.panel.width = maxWidth + padding[1] + padding[3], attribute.panel.height = containerHeight,
|
|
150
|
+
attribute;
|
|
151
|
+
}
|
|
152
|
+
static getTitleAttr(attribute) {
|
|
153
|
+
return mergeRowAttrs({}, Tooltip.defaultAttributes.titleStyle, Tooltip.defaultAttributes.title, attribute.titleStyle, attribute.title);
|
|
154
|
+
}
|
|
155
|
+
static getContentAttr(attribute, index) {
|
|
156
|
+
return mergeRowAttrs({}, Tooltip.defaultAttributes.contentStyle, attribute.contentStyle, attribute.content[index]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
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Q,CAAC;gBACxB,CAAC,CAAC,CAAC;gBACH,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;gBAC5C,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC;gBACjC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC;aACtC;SACF;QAED,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3D,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC;QAEzC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,SAAqC;QACvD,OAAO,aAAa,CAClB,EAAE,EACF,OAAO,CAAC,iBAAiB,CAAC,UAAU,EACpC,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAC/B,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,KAAK,CAChB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,SAAqC,EAAE,KAAa;QACxE,OAAO,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACrH,CAAC;;AA3XM,yBAAiB,GAA+B,iBAAiB,CAAC","file":"tooltip.js","sourcesContent":["/**\n * @description 标题组件\n */\nimport { IGroup, IText, IRect, ISymbol, builtinSymbolsMap } from '@visactor/vrender';\nimport { merge, isValid, normalizePadding, isNil } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { initTextMeasure } from '../util/text';\nimport { isVisible } from '../util';\nimport { TooltipAttributes, TooltipRowAttrs, TooltipRowStyleAttrs } from './type';\nimport { mergeRowAttrs } from './util';\nimport { defaultAttributes, TOOLTIP_POSITION_ATTRIBUTES } from './config';\n\nconst TOOLTIP_BACKGROUND_NAME = 'tooltip-background';\nconst TOOLTIP_TITLE_NAME = 'tooltip-title';\nconst TOOLTIP_CONTENT_NAME = 'tooltip-content';\n\nconst TOOLTIP_SHAPE_NAME_SUFFIX = 'shape';\nconst TOOLTIP_KEY_NAME_SUFFIX = 'key';\nconst TOOLTIP_VALUE_NAME_SUFFIX = 'value';\n\nexport class Tooltip extends AbstractComponent<Required<TooltipAttributes>> {\n name = 'tooltip';\n\n // tooltip 背景\n private _tooltipPanel!: IRect;\n // tooltip title 容器\n private _tooltipTitleContainer!: IGroup;\n // tooltip title shape\n private _tooltipTitleSymbol!: ISymbol;\n // tooltip title 文本\n private _tooltipTitle!: IText;\n // tooltip 内容项容器\n private _tooltipContent!: IGroup;\n\n static defaultAttributes: Partial<TooltipAttributes> = defaultAttributes;\n\n constructor(attributes: TooltipAttributes) {\n super(merge({}, Tooltip.defaultAttributes, attributes));\n }\n\n protected render() {\n const { visible, content, panel, keyWidth, valueWidth, hasContentShape, autoCalculatePosition, autoMeasure } =\n this.attribute;\n\n if (!visible) {\n this.hideAll();\n return;\n }\n\n if (autoMeasure) {\n Tooltip.measureTooltip(this.attribute);\n }\n if (autoCalculatePosition) {\n Tooltip.calculateTooltipPosition(this.attribute);\n }\n\n const padding = normalizePadding(this.attribute.padding);\n\n // 创建背景层\n this._tooltipPanel = this.createOrUpdateChild(\n TOOLTIP_BACKGROUND_NAME,\n {\n visible: true,\n ...panel\n },\n 'rect'\n ) as IRect;\n\n // 创建标题层\n this._tooltipTitleContainer = this.createOrUpdateChild(\n TOOLTIP_TITLE_NAME,\n { visible: true, x: padding[3], y: padding[0] },\n 'group'\n ) as IGroup;\n\n // 合并样式\n const titleAttr = Tooltip.getTitleAttr(this.attribute);\n\n // 创建标题 shape\n // 创建 symbol\n this._tooltipTitleSymbol = this._tooltipTitleContainer.createOrUpdateChild(\n `${TOOLTIP_TITLE_NAME}-${TOOLTIP_SHAPE_NAME_SUFFIX}`,\n merge({ symbolType: 'circle' }, titleAttr.shape, {\n visible: isVisible(titleAttr) && isVisible(titleAttr.shape)\n }),\n 'symbol'\n ) as ISymbol;\n\n // 文本\n const titlePaddingLeft = isVisible(titleAttr.shape) ? titleAttr.shape.size + titleAttr.shape.spacing : 0;\n this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild(\n `${TOOLTIP_TITLE_NAME}-${TOOLTIP_VALUE_NAME_SUFFIX}`,\n merge({ text: '' }, titleAttr.value, {\n visible: isVisible(titleAttr) && isVisible(titleAttr.value)\n }),\n 'text'\n ) as IText;\n\n // 调整标题的位置\n const { textAlign, textBaseline } = titleAttr.value;\n const contentWidth = panel.width - padding[3] - padding[0] - titlePaddingLeft;\n if (textAlign === 'center') {\n this._tooltipTitle.setAttribute('x', titlePaddingLeft + contentWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n this._tooltipTitle.setAttribute('x', titlePaddingLeft + contentWidth);\n } else {\n // 默认左对齐\n this._tooltipTitle.setAttribute('x', titlePaddingLeft);\n }\n if (textBaseline === 'bottom') {\n this._tooltipTitle.setAttribute('y', titleAttr.height);\n } else if (textBaseline === 'middle') {\n this._tooltipTitle.setAttribute('y', titleAttr.height / 2);\n } else {\n this._tooltipTitle.setAttribute('y', 0);\n }\n const titleHeight = isVisible(titleAttr) ? titleAttr.height + titleAttr.spaceRow : 0;\n\n // 创建内容层\n this._tooltipContent = this.createOrUpdateChild(TOOLTIP_CONTENT_NAME, { visible: true }, 'group') as IGroup;\n this._tooltipContent.removeAllChild(); // 清空内容区\n\n if (content?.length) {\n this._tooltipContent.setAttribute('x', padding[3]);\n this._tooltipContent.setAttribute('y', padding[0] + titleHeight);\n\n let lastYPos = 0;\n content.forEach((item, i) => {\n // 合并样式\n const itemAttr = Tooltip.getContentAttr(this.attribute, i);\n\n if (!isVisible(itemAttr)) {\n return;\n }\n\n const itemGroupName = `${TOOLTIP_CONTENT_NAME}-${i}`;\n const itemGroup = this._tooltipContent.createOrUpdateChild(\n itemGroupName,\n { visible: true, x: 0, y: lastYPos },\n 'group'\n ) as IGroup;\n\n let x = 0;\n if (isVisible(itemAttr.shape)) {\n // 存在 symbol\n const element = itemGroup.createOrUpdateChild(\n `${itemGroupName}-${TOOLTIP_SHAPE_NAME_SUFFIX}`,\n {\n visible: true,\n ...itemAttr.shape\n },\n 'symbol'\n ) as ISymbol;\n // shape.setAttribute('x', itemAttr.shape.size / 2);\n element.setAttribute('y', itemAttr.height / 2);\n }\n if (hasContentShape) {\n x += itemAttr.shape.size + itemAttr.shape.spacing;\n }\n\n if (isVisible(itemAttr.key)) {\n const element = itemGroup.createOrUpdateChild(\n `${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`,\n {\n visible: true,\n ...itemAttr.key\n },\n 'text'\n ) as IText;\n\n const { textAlign } = itemAttr.key;\n if (textAlign === 'center') {\n element.setAttribute('x', x + keyWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n element.setAttribute('x', x + keyWidth);\n } else {\n // 默认左对齐\n element.setAttribute('x', x);\n }\n\n element.setAttribute('y', itemAttr.height / 2);\n x += keyWidth + itemAttr.key.spacing;\n }\n\n if (isVisible(itemAttr.value)) {\n const element = itemGroup.createOrUpdateChild(\n `${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`,\n {\n visible: true,\n ...itemAttr.value\n },\n 'text'\n ) as IText;\n\n let textAlign = 'right';\n if (isValid(itemAttr.value.textAlign)) {\n textAlign = itemAttr.value.textAlign;\n } else if (!isVisible(itemAttr.key)) {\n textAlign = 'left';\n }\n element.setAttribute('textAlign', textAlign);\n\n if (textAlign === 'center') {\n element.setAttribute('x', x + valueWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n element.setAttribute('x', x + valueWidth);\n } else {\n // 默认左对齐\n element.setAttribute('x', x);\n }\n x += valueWidth;\n\n element.setAttribute('y', itemAttr.height / 2);\n\n itemGroup.add(element);\n }\n\n lastYPos += itemAttr.height + itemAttr.spaceRow;\n });\n }\n }\n\n setAttributes(params: Partial<Required<TooltipAttributes>>, forceUpdateTag?: boolean | undefined): void {\n const keys = Object.keys(params) as (keyof TooltipAttributes)[];\n // 优化:只更改 tooltip 位置\n if (this.attribute.autoCalculatePosition && keys.every(key => TOOLTIP_POSITION_ATTRIBUTES.includes(key))) {\n this._mergeAttributes(params, keys);\n // 计算 x y\n if (isNil(this.attribute.panel.width) && this.attribute.autoMeasure) {\n Tooltip.measureTooltip(this.attribute);\n }\n Tooltip.calculateTooltipPosition(this.attribute);\n // 应用 x y\n super.setAttributes(\n {\n x: this.attribute.x,\n y: this.attribute.y\n },\n forceUpdateTag\n );\n } else {\n super.setAttributes(params, forceUpdateTag);\n }\n }\n\n static calculateTooltipPosition(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes> {\n const { width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0 } = attribute.panel;\n\n const { offsetX, offsetY, pointerX, pointerY, positionX, positionY, parentBounds } = attribute;\n\n let x = pointerX;\n let y = pointerY;\n if (positionX === 'left') {\n x -= tooltipBoxWidth + offsetX;\n } else if (positionX === 'center') {\n x -= tooltipBoxWidth / 2;\n } else {\n x += offsetX;\n }\n if (positionY === 'top') {\n y -= tooltipBoxHeight + offsetY;\n } else if (positionY === 'middle') {\n y -= tooltipBoxHeight / 2;\n } else {\n y += offsetY;\n }\n\n /* 确保tooltip在视区内 */\n if (x + tooltipBoxWidth > parentBounds.x2) {\n // 位置不超出视区右界\n x -= tooltipBoxWidth + offsetX;\n }\n if (y + tooltipBoxHeight > parentBounds.y2) {\n // 位置不超出视区下界\n y -= tooltipBoxHeight + offsetY;\n }\n if (x < parentBounds.x1) {\n // 位置不超出视区左界\n x = parentBounds.x1;\n }\n if (y < parentBounds.y1) {\n // 位置不超出视区上界\n y = parentBounds.y1;\n }\n\n attribute.x = x;\n attribute.y = y;\n\n return attribute;\n }\n\n static measureTooltip(attribute: Partial<TooltipAttributes>): Partial<TooltipAttributes> {\n const { content, contentStyle } = attribute;\n const padding = normalizePadding(attribute.padding);\n // 合并样式\n const titleAttr = Tooltip.getTitleAttr(attribute);\n\n let maxWidth = 0;\n let containerHeight = padding[0] + padding[2];\n\n // calculate title\n let titleMaxHeight = 0;\n const { value: titleValue, shape: titleShape } = titleAttr;\n const { visible: titleHasShape = false, symbolType: titleShapeType = '' } = titleShape ?? {};\n\n if (isValid(titleValue)) {\n const { width, height } = initTextMeasure(titleValue).quickMeasure(titleValue.text);\n maxWidth = width;\n titleMaxHeight = height;\n }\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n maxWidth += titleShape.size + titleShape.spacing;\n titleMaxHeight = Math.max(titleShape.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n if (isVisible(titleAttr)) {\n containerHeight += titleMaxHeight + titleAttr.spaceRow;\n }\n\n // calculate content\n if (content?.length) {\n // filter content\n const filteredContent: [TooltipRowAttrs, TooltipRowAttrs][] = [];\n content.forEach((item, i) => {\n // 合并样式\n const itemAttr = Tooltip.getContentAttr(attribute, i);\n if ((item.key || item.value) && isVisible(itemAttr)) {\n filteredContent.push([item, itemAttr]);\n }\n });\n\n if (filteredContent.length) {\n let hasContentShape = false;\n const shapeWidths: number[] = [];\n const keyWidths: number[] = [];\n const valueWidths: number[] = [];\n\n filteredContent.forEach(([item, itemAttr], i) => {\n const { key, value, shape, spaceRow } = itemAttr;\n const itemHasShape = isVisible(shape);\n const itemShapeType = shape?.symbolType ?? '';\n\n const keyTextMeasure = initTextMeasure(key);\n const valueTextMeasure = initTextMeasure(value);\n\n let itemHeight = 0;\n if (isVisible(key)) {\n const { width, height } = keyTextMeasure.quickMeasure(key.text);\n keyWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (isVisible(value)) {\n const { width, height } = valueTextMeasure.quickMeasure(value.text);\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (itemHasShape && builtinSymbolsMap[itemShapeType]) {\n hasContentShape = true;\n shapeWidths.push(shape.size);\n itemHeight = Math.max(shape.size, itemHeight);\n }\n\n item.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += spaceRow ?? contentStyle.spaceRow;\n }\n });\n\n const maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) : 0; // shape 需要对齐\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n maxWidth = Math.max(\n maxKeyWidth +\n maxValueWidth +\n contentStyle.key.spacing +\n contentStyle.value.spacing +\n (hasContentShape ? maxShapeWidth + contentStyle.shape.spacing : 0),\n maxWidth\n );\n content.forEach(item => {\n item.width = maxWidth;\n });\n attribute.hasContentShape = hasContentShape;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n attribute.panel.width = maxWidth + padding[1] + padding[3];\n attribute.panel.height = containerHeight;\n\n return attribute;\n }\n\n static getTitleAttr(attribute: Partial<TooltipAttributes>): TooltipRowAttrs & TooltipRowStyleAttrs {\n return mergeRowAttrs(\n {},\n Tooltip.defaultAttributes.titleStyle,\n Tooltip.defaultAttributes.title,\n attribute.titleStyle,\n attribute.title\n );\n }\n\n static getContentAttr(attribute: Partial<TooltipAttributes>, index: number): TooltipRowAttrs & TooltipRowStyleAttrs {\n return mergeRowAttrs({}, Tooltip.defaultAttributes.contentStyle, attribute.contentStyle, attribute.content[index]);\n }\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { IGraphicAttribute, IGroupGraphicAttribute, IRectGraphicAttribute, ITextAttribute } from '@visactor/vrender';
|
|
2
|
+
import { IBounds, IPadding } from '@visactor/vutils';
|
|
3
|
+
export interface IContainerSize {
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
}
|
|
7
|
+
export type TooltipAttributes = IGroupGraphicAttribute & TooltipComponentAttrs;
|
|
8
|
+
export type TooltipComponentAttrs = TooltipPositionAttrs & {
|
|
9
|
+
panel?: TooltipPanelAttrs;
|
|
10
|
+
title?: TooltipRowAttrs;
|
|
11
|
+
content?: TooltipRowAttrs[];
|
|
12
|
+
titleStyle?: TooltipRowStyleAttrs;
|
|
13
|
+
contentStyle?: TooltipRowStyleAttrs;
|
|
14
|
+
autoMeasure?: boolean;
|
|
15
|
+
autoCalculatePosition?: boolean;
|
|
16
|
+
padding?: number | number[] | IPadding;
|
|
17
|
+
minWidth?: number;
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
enterable?: boolean;
|
|
20
|
+
transitionDuration?: number;
|
|
21
|
+
hasContentShape?: boolean;
|
|
22
|
+
keyWidth?: number;
|
|
23
|
+
valueWidth?: number;
|
|
24
|
+
};
|
|
25
|
+
export type TooltipTextAttrs = Partial<ITextAttribute & IGraphicAttribute>;
|
|
26
|
+
export type TooltipSymbolAttrs = Partial<IGraphicAttribute> & {
|
|
27
|
+
path?: string;
|
|
28
|
+
size?: number;
|
|
29
|
+
symbolType?: string;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
};
|
|
32
|
+
export type TooltipPanelAttrs = Partial<IRectGraphicAttribute> & {
|
|
33
|
+
shadow?: boolean;
|
|
34
|
+
shadowSpread?: number;
|
|
35
|
+
};
|
|
36
|
+
export type TooltipRowAttrs = IContainerSize & {
|
|
37
|
+
visible?: boolean;
|
|
38
|
+
key?: TooltipTextAttrs;
|
|
39
|
+
value?: TooltipTextAttrs;
|
|
40
|
+
shape?: TooltipSymbolAttrs;
|
|
41
|
+
spaceRow?: number;
|
|
42
|
+
};
|
|
43
|
+
export type TooltipRowStyleAttrs = {
|
|
44
|
+
key?: Omit<TooltipTextAttrs, 'text'> & TooltipColumnStyleAttrs;
|
|
45
|
+
value?: Omit<TooltipTextAttrs, 'text'> & TooltipColumnStyleAttrs;
|
|
46
|
+
shape?: TooltipSymbolAttrs & TooltipColumnStyleAttrs;
|
|
47
|
+
spaceRow?: number;
|
|
48
|
+
};
|
|
49
|
+
export type TooltipColumnStyleAttrs = {
|
|
50
|
+
spacing?: number;
|
|
51
|
+
};
|
|
52
|
+
export type TooltipPositionAttrs = {
|
|
53
|
+
pointerX?: number;
|
|
54
|
+
pointerY?: number;
|
|
55
|
+
offsetX?: number;
|
|
56
|
+
offsetY?: number;
|
|
57
|
+
positionX?: 'left' | 'right' | 'center';
|
|
58
|
+
positionY?: 'top' | 'bottom' | 'middle';
|
|
59
|
+
parentBounds?: IBounds;
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tooltip/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ITextAttribute\n} from '@visactor/vrender';\nimport { IBounds, IPadding } from '@visactor/vutils';\n\nexport interface IContainerSize {\n width?: number;\n height?: number;\n}\n\nexport type TooltipAttributes = IGroupGraphicAttribute & TooltipComponentAttrs;\n\nexport type TooltipComponentAttrs = TooltipPositionAttrs & {\n /** tooltip 背景 */\n panel?: TooltipPanelAttrs;\n\n /** tooltip 标题 */\n title?: TooltipRowAttrs;\n /** tooltip 内容 */\n content?: TooltipRowAttrs[];\n\n /** 标题样式 */\n titleStyle?: TooltipRowStyleAttrs;\n /** 内容样式 */\n contentStyle?: TooltipRowStyleAttrs;\n\n /** 是否自动计算 tooltip 大小 */\n autoMeasure?: boolean;\n\n /** 是否自动计算 tooltip 位置 */\n autoCalculatePosition?: boolean;\n\n /** 整体边距 */\n padding?: number | number[] | IPadding;\n\n /** 最小宽度 */\n minWidth?: number;\n /** 最大宽度 */\n maxWidth?: number;\n\n /** 是否可交互 */\n enterable?: boolean;\n\n /** 缓动 duration */\n transitionDuration?: number;\n\n // 以下为组件自动计算的属性\n /** 内容项是否有 shape */\n hasContentShape?: boolean;\n /** 内容项 key 的最大宽度,用于布局,因为 key 需要按照列对齐 */\n keyWidth?: number;\n /** 内容项 value 的最大宽度,用于布局,因为 value 需要按照列对齐 */\n valueWidth?: number;\n};\n\n/** tooltip 文本样式 */\nexport type TooltipTextAttrs = Partial<ITextAttribute & IGraphicAttribute>;\n\n/** tooltip symbol 样式 */\nexport type TooltipSymbolAttrs = Partial<IGraphicAttribute> & {\n /** 图形 path */\n path?: string;\n size?: number;\n symbolType?: string;\n /** 其他图形样式,暂时这么处理 */\n [key: string]: any;\n};\n\n/** tooltip 背景样式 */\nexport type TooltipPanelAttrs = Partial<IRectGraphicAttribute> & {\n shadow?: boolean;\n shadowSpread?: number;\n};\n\n/** tooltip 内容行配置 */\nexport type TooltipRowAttrs = IContainerSize & {\n visible?: boolean;\n /** key 对应图形样式(title 没有这个属性) */\n key?: TooltipTextAttrs;\n /** value 对应图形样式 */\n value?: TooltipTextAttrs;\n /** shape 对应图形样式 */\n shape?: TooltipSymbolAttrs;\n /** 行间距 */\n spaceRow?: number;\n};\n\n/** tooltip 内容行样式 */\nexport type TooltipRowStyleAttrs = {\n /** key 对应图形样式(title 没有这个属性) */\n key?: Omit<TooltipTextAttrs, 'text'> & TooltipColumnStyleAttrs;\n /** value 对应图形样式 */\n value?: Omit<TooltipTextAttrs, 'text'> & TooltipColumnStyleAttrs;\n /** shape 对应图形样式 */\n shape?: TooltipSymbolAttrs & TooltipColumnStyleAttrs;\n /** 行间距 */\n spaceRow?: number;\n};\n\nexport type TooltipColumnStyleAttrs = {\n /** 右边距 */\n spacing?: number;\n};\n\nexport type TooltipPositionAttrs = {\n /** 光标位置 x */\n pointerX?: number;\n /** 光标位置 y */\n pointerY?: number;\n\n /** tooltip 偏移 x */\n offsetX?: number;\n /** tooltip 偏移 y */\n offsetY?: number;\n\n /** tooltip 相对 pointer 位置(x 轴) */\n positionX?: 'left' | 'right' | 'center';\n /** tooltip 相对 pointer 位置(y 轴) */\n positionY?: 'top' | 'bottom' | 'middle';\n\n /** 父级 bounds */\n parentBounds?: IBounds;\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isNil, merge } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
export const mergeRowAttrs = (target, ...sources) => {
|
|
4
|
+
const shapeList = [ target.shape, ...sources.map((s => null == s ? void 0 : s.shape)) ], keyList = [ target.key, ...sources.map((s => null == s ? void 0 : s.key)) ], valueList = [ target.value, ...sources.map((s => null == s ? void 0 : s.value)) ];
|
|
5
|
+
return merge(target, ...sources, {
|
|
6
|
+
shape: shapeList.every(isNil) ? void 0 : merge({}, ...shapeList),
|
|
7
|
+
key: keyList.every(isNil) ? void 0 : merge({}, ...keyList),
|
|
8
|
+
value: valueList.every(isNil) ? void 0 : merge({}, ...valueList)
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tooltip/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAA8C,EAC9C,GAAG,OAAmD,EACd,EAAE;IAC1C,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,CAAC,CAAC;IAEhE,OAAO,KAAK,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE;QAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;QACnE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC;QAC7D,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;KACpE,CAA2C,CAAC;AAC/C,CAAC,CAAC","file":"util.js","sourcesContent":["import { isNil, merge } from '@visactor/vutils';\nimport { TooltipRowAttrs, TooltipRowStyleAttrs } from './type';\n\nexport const mergeRowAttrs = (\n target: TooltipRowAttrs | TooltipRowStyleAttrs,\n ...sources: (TooltipRowAttrs | TooltipRowStyleAttrs)[]\n): TooltipRowAttrs | TooltipRowStyleAttrs => {\n const shapeList = [target.shape, ...sources.map(s => s?.shape)];\n const keyList = [target.key, ...sources.map(s => s?.key)];\n const valueList = [target.value, ...sources.map(s => s?.value)];\n\n return merge(target, ...sources, {\n shape: shapeList.every(isNil) ? undefined : merge({}, ...shapeList),\n key: keyList.every(isNil) ? undefined : merge({}, ...keyList),\n value: valueList.every(isNil) ? undefined : merge({}, ...valueList)\n }) as TooltipRowAttrs | TooltipRowStyleAttrs;\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isNil } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
export function traverseGroup(group, cb) {
|
|
4
|
+
group.forEachChildren((node => {
|
|
5
|
+
const stopped = cb(node);
|
|
6
|
+
node.isContainer && !stopped && traverseGroup(node, cb);
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const isVisible = obj => !isNil(obj) && !1 !== obj.visible;
|
|
11
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/common.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,aAAa,CAAC,KAAe,EAAE,EAAsC;IACnF,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC,IAAgB,CAAC,CAAC;QACrC,IAAK,IAAe,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE;YAC5C,aAAa,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;SACrC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAgC,EAAW,EAAE;IACrE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAC/B,CAAC,CAAC","file":"common.js","sourcesContent":["/**\n * @description 存放工具函数\n */\nimport { IGraphicAttribute, IGraphic, IGroup } from '@visactor/vrender';\nimport { isNil } from '@visactor/vutils';\n\nexport function traverseGroup(group: IGraphic, cb: (node: IGraphic) => boolean | void) {\n group.forEachChildren(node => {\n const stopped = cb(node as IGraphic);\n if ((node as IGroup).isContainer && !stopped) {\n traverseGroup(node as IGraphic, cb);\n }\n });\n}\n\nexport const isVisible = (obj?: Partial<IGraphicAttribute>): boolean => {\n if (isNil(obj)) {\n return false;\n }\n return obj.visible !== false;\n};\n"]}
|
package/es/util/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './common';\nexport * from './labelSmartInvert';\nexport * from './matrix';\nexport * from './text';\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { IColor } from '@visactor/vrender';
|
|
2
|
+
export declare function labelSmartInvert(foregroundColorOrigin: IColor | undefined, backgroundColorOrogin: IColor | undefined, textType?: string | undefined, contrastRatiosThreshold?: number, alternativeColors?: string | string[]): IColor | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ColorUtil } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
const defaultAlternativeColors = [ "#ffffff", "#000000" ];
|
|
4
|
+
|
|
5
|
+
export function labelSmartInvert(foregroundColorOrigin, backgroundColorOrogin, textType, contrastRatiosThreshold, alternativeColors) {
|
|
6
|
+
const foregroundColor = formatColorToHex(foregroundColorOrigin), backgroundColor = formatColorToHex(backgroundColorOrogin);
|
|
7
|
+
return contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold) ? foregroundColor : improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function improveContrastReverse(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors) {
|
|
11
|
+
const alternativeColorPalletes = [];
|
|
12
|
+
alternativeColors && (alternativeColors instanceof Array ? alternativeColorPalletes.push(...alternativeColors) : alternativeColorPalletes.push(alternativeColors)),
|
|
13
|
+
alternativeColorPalletes.push(...defaultAlternativeColors);
|
|
14
|
+
for (const alternativeColor of alternativeColorPalletes) if (foregroundColor !== alternativeColor && contrastAccessibilityChecker(alternativeColor, backgroundColor, textType, contrastRatiosThreshold)) return alternativeColor;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold) {
|
|
18
|
+
return contrastRatiosThreshold ? contrastRatios(foregroundColor, backgroundColor) > contrastRatiosThreshold : "largeText" === textType ? contrastRatios(foregroundColor, backgroundColor) > 3 : contrastRatios(foregroundColor, backgroundColor) > 4.5;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function contrastRatios(foregroundColor, backgroundColor) {
|
|
22
|
+
const foregroundColorLuminance = getColorLuminance(foregroundColor), backgroundColorLuminance = getColorLuminance(backgroundColor);
|
|
23
|
+
return ((foregroundColorLuminance > backgroundColorLuminance ? foregroundColorLuminance : backgroundColorLuminance) + .05) / ((foregroundColorLuminance > backgroundColorLuminance ? backgroundColorLuminance : foregroundColorLuminance) + .05);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getColorLuminance(color) {
|
|
27
|
+
const rgb8bit = ColorUtil.hexToRgb(color), RsRGB = rgb8bit[0] / 255, GsRGB = rgb8bit[1] / 255, BsRGB = rgb8bit[2] / 255;
|
|
28
|
+
let R, G, B;
|
|
29
|
+
R = RsRGB <= .03928 ? RsRGB / 12.92 : Math.pow((RsRGB + .055) / 1.055, 2.4), G = GsRGB <= .03928 ? GsRGB / 12.92 : Math.pow((GsRGB + .055) / 1.055, 2.4),
|
|
30
|
+
B = BsRGB <= .03928 ? BsRGB / 12.92 : Math.pow((BsRGB + .055) / 1.055, 2.4);
|
|
31
|
+
return .2126 * R + .7152 * G + .0722 * B;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function formatColorToHex(originColor) {
|
|
35
|
+
if (null == originColor ? void 0 : originColor.includes("#")) return originColor;
|
|
36
|
+
const c = new ColorUtil.Color(originColor), {r: r, g: g, b: b} = c.color;
|
|
37
|
+
return "#" + ColorUtil.rgbToHex(r, g, b);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=labelSmartInvert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/labelSmartInvert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,wBAAwB,GAAa,CAAC,SAAS,EAAE,SAAS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} from '@visactor/vrender';\nimport { ColorUtil } from '@visactor/vutils';\n\nconst defaultAlternativeColors: string[] = ['#ffffff', '#000000'];\n\n/**\n * 标签智能反色\n * @param foregroundColorOrigin\n * @param backgroundColorOrogin\n * @returns\n */\nexport function labelSmartInvert(\n foregroundColorOrigin: IColor | undefined,\n backgroundColorOrogin: IColor | undefined,\n textType?: string | undefined,\n contrastRatiosThreshold?: number,\n alternativeColors?: string | string[]\n): IColor | undefined {\n const foregroundColor = formatColorToHex(foregroundColorOrigin);\n const backgroundColor = formatColorToHex(backgroundColorOrogin);\n if (!contrastAccessibilityChecker(foregroundColor, backgroundColor, textType, contrastRatiosThreshold)) {\n return improveContrastReverse(\n foregroundColor,\n backgroundColor,\n textType,\n contrastRatiosThreshold,\n alternativeColors\n );\n }\n return foregroundColor;\n}\n\n/**\n * 提升对比度\n * 对于对比度不足阈值的情况,推荐备选颜色色板中的颜色提升对比\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nfunction improveContrastReverse(\n foregroundColor: IColor | undefined,\n backgroundColor: IColor | undefined,\n textType?: IColor | undefined,\n contrastRatiosThreshold?: number,\n alternativeColors?: string | string[]\n) {\n const alternativeColorPalletes: string[] = [];\n if (alternativeColors) {\n if (alternativeColors instanceof Array) {\n alternativeColorPalletes.push(...alternativeColors);\n } else {\n alternativeColorPalletes.push(alternativeColors);\n }\n }\n alternativeColorPalletes.push(...defaultAlternativeColors);\n for (const alternativeColor of alternativeColorPalletes) {\n if (foregroundColor === alternativeColor) {\n continue;\n }\n if (contrastAccessibilityChecker(alternativeColor, backgroundColor, textType, contrastRatiosThreshold)) {\n return alternativeColor;\n }\n }\n return undefined;\n}\n\n/**\n * 颜色对比度可行性检查 https://webaim.org/articles/contrast/\n * - WCAG 2.0 AA 级要求普通文本的对比度至少为 4.5:1,大文本的对比度至少为 3:1。(目前按照此标准)\n * - WCAG 2.1 要求图形和用户界面组件(例如表单输入边框)的对比度至少为 3:1。\n * - WCAG AAA 级要求普通文本的对比度至少为 7:1,大文本的对比度至少为 4.5:1。\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nfunction contrastAccessibilityChecker(\n foregroundColor: IColor | undefined,\n backgroundColor: IColor | undefined,\n textType?: IColor | undefined,\n contrastRatiosThreshold?: number\n): boolean {\n //Contrast ratios can range from 1 to 21\n if (contrastRatiosThreshold) {\n if (contrastRatios(foregroundColor, backgroundColor) > contrastRatiosThreshold) {\n return true;\n }\n return false;\n } else if (textType === 'largeText') {\n if (contrastRatios(foregroundColor, backgroundColor) > 3) {\n return true;\n }\n return false;\n }\n if (contrastRatios(foregroundColor, backgroundColor) > 4.5) {\n return true;\n }\n return false;\n}\n\n/**\n * 计算颜色对比度 https://webaim.org/articles/contrast/\n * Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1).\n * (L1 + 0.05) / (L2 + 0.05), whereby:\n * L1 is the relative luminance of the lighter of the colors, and\n * L2 is the relative luminance of the darker of the colors.\n * @param foregroundColor\n * @param backgroundColor\n * @returns\n */\nfunction contrastRatios(foregroundColor: IColor | undefined, backgroundColor: IColor | undefined): number {\n const foregroundColorLuminance = getColorLuminance(foregroundColor as string);\n const backgroundColorLuminance = getColorLuminance(backgroundColor as string);\n const L1 = foregroundColorLuminance > backgroundColorLuminance ? foregroundColorLuminance : backgroundColorLuminance;\n const L2 = foregroundColorLuminance > backgroundColorLuminance ? backgroundColorLuminance : foregroundColorLuminance;\n const contrastRatios = (L1 + 0.05) / (L2 + 0.05);\n return contrastRatios;\n}\n\n/**\n * 计算相对亮度 https://webaim.org/articles/contrast/\n * the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white\n * Note 1: For the sRGB colorspace, the relative luminance of a color is defined as\n * L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as:\n * if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4\n * if GsRGB <= 0.03928 then G = GsRGB/12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4\n * if BsRGB <= 0.03928 then B = BsRGB/12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4\n * and RsRGB, GsRGB, and BsRGB are defined as:\n * RsRGB = R8bit/255\n * GsRGB = G8bit/255\n * BsRGB = B8bit/255\n * @param color\n * @returns\n */\nfunction getColorLuminance(color: string): number {\n const rgb8bit = ColorUtil.hexToRgb(color);\n const RsRGB = rgb8bit[0] / 255;\n const GsRGB = rgb8bit[1] / 255;\n const BsRGB = rgb8bit[2] / 255;\n let R;\n let G;\n let B;\n if (RsRGB <= 0.03928) {\n R = RsRGB / 12.92;\n } else {\n R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);\n }\n if (GsRGB <= 0.03928) {\n G = GsRGB / 12.92;\n } else {\n G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);\n }\n if (BsRGB <= 0.03928) {\n B = BsRGB / 12.92;\n } else {\n B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);\n }\n const L = 0.2126 * R + 0.7152 * G + 0.0722 * B;\n return L;\n}\n\n/**\n * 规范化color格式为hex\n * 当color为颜色名称或rgb时,对其进行规范化处理\n * @param originColor\n * @returns\n */\nfunction formatColorToHex(originColor: IColor | undefined) {\n if ((originColor as string)?.includes('#')) {\n return originColor;\n }\n const c = new ColorUtil.Color(originColor as string);\n const { r, g, b } = c.color;\n return '#' + ColorUtil.rgbToHex(r, g, b);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { vec2 } from "gl-matrix";
|
|
2
|
+
|
|
3
|
+
export { vec2 };
|
|
4
|
+
|
|
5
|
+
export function direction(v1, v2) {
|
|
6
|
+
return v1[0] * v2[1] - v2[0] * v1[1];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function angleTo(v1, v2, direct) {
|
|
10
|
+
const ang = vec2.angle(v1, v2), angleLargeThanPI = direction(v1, v2) >= 0;
|
|
11
|
+
return direct ? angleLargeThanPI ? 2 * Math.PI - ang : ang : angleLargeThanPI ? ang : 2 * Math.PI - ang;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,CAAC;AAQhB,MAAM,UAAU,SAAS,CAAC,EAAY,EAAE,EAAY;IAClD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAQD,MAAM,UAAU,OAAO,CAAC,EAAoB,EAAE,EAAoB,EAAE,MAAe;IACjF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/B,MAAM,gBAAgB,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,MAAM,EAAE;QACV,IAAI,gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;SAC1B;QACD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC","file":"matrix.js","sourcesContent":["import { vec2 } from 'gl-matrix';\n\nexport { vec2 };\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = vec2.angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITextGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import { ITextMeasureOption, TextMeasure } from '@visactor/vutils';
|
|
3
|
+
export declare const initTextMeasure: (textSpec?: Partial<ITextGraphicAttribute>, option?: Partial<ITextMeasureOption>, useNaiveCanvas?: boolean) => TextMeasure<ITextGraphicAttribute>;
|
|
4
|
+
export declare function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>): {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
package/es/util/text.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getTextBounds } from "@visactor/vrender";
|
|
2
|
+
|
|
3
|
+
import { TextMeasure } from "@visactor/vutils";
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from "../constant";
|
|
6
|
+
|
|
7
|
+
export const initTextMeasure = (textSpec, option, useNaiveCanvas) => new TextMeasure(Object.assign({
|
|
8
|
+
defaultFontParams: {
|
|
9
|
+
fontFamily: DEFAULT_TEXT_FONT_FAMILY,
|
|
10
|
+
fontSize: DEFAULT_TEXT_FONT_SIZE
|
|
11
|
+
},
|
|
12
|
+
getTextBounds: useNaiveCanvas ? void 0 : getTextBounds,
|
|
13
|
+
specialCharSet: "-/: .,@%'\"~" + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase()
|
|
14
|
+
}, null != option ? option : {}), textSpec);
|
|
15
|
+
|
|
16
|
+
export function measureTextSize(text, textSpec) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if (!text) return {
|
|
19
|
+
width: 0,
|
|
20
|
+
height: 0
|
|
21
|
+
};
|
|
22
|
+
const bounds = getTextBounds({
|
|
23
|
+
text: text,
|
|
24
|
+
fontFamily: null !== (_a = textSpec.fontFamily) && void 0 !== _a ? _a : "",
|
|
25
|
+
fontSize: textSpec.fontSize || 12,
|
|
26
|
+
fontWeight: textSpec.fontWeight,
|
|
27
|
+
textAlign: null !== (_b = textSpec.textAlign) && void 0 !== _b ? _b : "center",
|
|
28
|
+
textBaseline: textSpec.textBaseline,
|
|
29
|
+
ellipsis: !!textSpec.ellipsis,
|
|
30
|
+
maxLineWidth: textSpec.maxLineWidth || 1 / 0,
|
|
31
|
+
lineHeight: textSpec.fontSize || 12
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
width: bounds.width(),
|
|
35
|
+
height: bounds.height()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAsB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACY,EAAE;IACtC,OAAO,IAAI,WAAW,iBAElB,iBAAiB,EAAE;YACjB,UAAU,EAAE,wBAAwB;YACpC,QAAQ,EAAE,sBAAsB;SACjC,EACD,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EACzD,cAAc,EAAE,cAAc,GAAG,WAAW,CAAC,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAGF,MAAM,UAAU,eAAe,CAAC,IAA2C,EAAE,QAAwC;;IACnH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAChC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC;QAC3B,IAAI;QACJ,UAAU,EAAE,MAAA,QAAQ,CAAC,UAAU,mCAAI,EAAE;QACrC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAiB;QACtC,SAAS,EAAE,MAAA,QAAQ,CAAC,SAAS,mCAAI,QAAQ;QACzC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ;QAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,QAAQ;QAC/C,UAAU,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5D,CAAC","file":"text.js","sourcesContent":["import { getTextBounds, ITextGraphicAttribute } from '@visactor/vrender';\nimport { ITextMeasureOption, TextMeasure } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily ?? '',\n fontSize: textSpec.fontSize || 12,\n fontWeight: textSpec.fontWeight as any,\n textAlign: textSpec.textAlign ?? 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@visactor/vrender-components",
|
|
3
|
+
"version": "0.0.38-brush.2-alpha.0",
|
|
4
|
+
"description": "components library for dp visualization",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "cjs/index.js",
|
|
8
|
+
"module": "es/index.js",
|
|
9
|
+
"types": "es/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"cjs",
|
|
12
|
+
"es",
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@visactor/vutils": "0.9.0-alpha.2",
|
|
17
|
+
"gl-matrix": "^3.4.3"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@visactor/vrender": "0.9.0-alpha.0",
|
|
21
|
+
"@visactor/vscale": "0.9.0-alpha.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rushstack/eslint-patch": "~1.1.4",
|
|
25
|
+
"@visactor/vrender": "0.9.0-alpha.0",
|
|
26
|
+
"@visactor/vscale": "0.9.0-alpha.2",
|
|
27
|
+
"react": "16.13.0",
|
|
28
|
+
"react-dom": "16.13.0",
|
|
29
|
+
"@types/react": "16.9.49",
|
|
30
|
+
"@types/react-dom": "16.9.8",
|
|
31
|
+
"@vitejs/plugin-react": "3.1.0",
|
|
32
|
+
"eslint": "~8.18.0",
|
|
33
|
+
"vite": "3.2.6",
|
|
34
|
+
"typescript": "4.9.5",
|
|
35
|
+
"@internal/ts-config": "0.0.1",
|
|
36
|
+
"@internal/bundler": "0.0.1",
|
|
37
|
+
"@internal/eslint-config": "0.0.1"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"compile": "tsc --noEmit",
|
|
44
|
+
"eslint": "eslint --debug --fix src/",
|
|
45
|
+
"build": "bundle",
|
|
46
|
+
"dev": "bundle --clean -f es -w",
|
|
47
|
+
"start": "vite ./vite"
|
|
48
|
+
}
|
|
49
|
+
}
|