@antv/g2 4.1.49 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2.min.js +3 -31
- package/dist/g2.min.js.map +1 -1
- package/esm/animate/animation/sector-path-update.js +3 -3
- package/esm/animate/animation/sector-path-update.js.map +1 -1
- package/esm/animate/animation/util.js +2 -1
- package/esm/animate/animation/util.js.map +1 -1
- package/esm/chart/chart.js +1 -1
- package/esm/chart/chart.js.map +1 -1
- package/esm/chart/controller/annotation.js +20 -10
- package/esm/chart/controller/annotation.js.map +1 -1
- package/esm/chart/controller/coordinate.js +3 -3
- package/esm/chart/controller/coordinate.js.map +1 -1
- package/esm/chart/controller/legend.js +3 -3
- package/esm/chart/controller/legend.js.map +1 -1
- package/esm/chart/controller/scrollbar.js +8 -8
- package/esm/chart/controller/scrollbar.js.map +1 -1
- package/esm/chart/controller/slider.js +8 -8
- package/esm/chart/controller/slider.js.map +1 -1
- package/esm/chart/controller/tooltip.js +82 -34
- package/esm/chart/controller/tooltip.js.map +1 -1
- package/esm/chart/layout/auto.js +2 -2
- package/esm/chart/layout/auto.js.map +1 -1
- package/esm/chart/layout/constraint/constraint.js +2 -1
- package/esm/chart/layout/constraint/constraint.js.map +1 -1
- package/esm/chart/layout/constraint/solver.js +2 -1
- package/esm/chart/layout/constraint/solver.js.map +1 -1
- package/esm/chart/layout/padding-cal.js +4 -4
- package/esm/chart/layout/padding-cal.js.map +1 -1
- package/esm/chart/view.js +2 -2
- package/esm/chart/view.js.map +1 -1
- package/esm/component/labels.d.ts +1 -2
- package/esm/component/labels.js +134 -103
- package/esm/component/labels.js.map +1 -1
- package/esm/constant.d.ts +3 -1
- package/esm/constant.js +2 -0
- package/esm/constant.js.map +1 -1
- package/esm/core.d.ts +1 -1
- package/esm/core.js +1 -1
- package/esm/core.js.map +1 -1
- package/esm/facet/circle.js +2 -2
- package/esm/facet/circle.js.map +1 -1
- package/esm/facet/facet.js +3 -2
- package/esm/facet/facet.js.map +1 -1
- package/esm/facet/list.js +2 -2
- package/esm/facet/list.js.map +1 -1
- package/esm/facet/mirror.js +2 -2
- package/esm/facet/mirror.js.map +1 -1
- package/esm/facet/rect.js +2 -2
- package/esm/facet/rect.js.map +1 -1
- package/esm/facet/tree.js +20 -10
- package/esm/facet/tree.js.map +1 -1
- package/esm/geometry/base.d.ts +3 -0
- package/esm/geometry/base.js +151 -82
- package/esm/geometry/base.js.map +1 -1
- package/esm/geometry/element/index.js +3 -1
- package/esm/geometry/element/index.js.map +1 -1
- package/esm/geometry/heatmap.js +17 -7
- package/esm/geometry/heatmap.js.map +1 -1
- package/esm/geometry/label/base.d.ts +1 -1
- package/esm/geometry/label/base.js +20 -8
- package/esm/geometry/label/base.js.map +1 -1
- package/esm/geometry/label/layout/hide-overlap.d.ts +1 -1
- package/esm/geometry/label/layout/hide-overlap.js +65 -19
- package/esm/geometry/label/layout/hide-overlap.js.map +1 -1
- package/esm/geometry/label/layout/interval/hide-overlap.js +3 -2
- package/esm/geometry/label/layout/interval/hide-overlap.js.map +1 -1
- package/esm/geometry/label/layout/path/adjust-position.js +3 -2
- package/esm/geometry/label/layout/path/adjust-position.js.map +1 -1
- package/esm/geometry/label/layout/pie/distribute.js +14 -3
- package/esm/geometry/label/layout/pie/distribute.js.map +1 -1
- package/esm/geometry/label/layout/pie/outer.js +14 -3
- package/esm/geometry/label/layout/pie/outer.js.map +1 -1
- package/esm/geometry/label/layout/pie/spider.js +14 -3
- package/esm/geometry/label/layout/pie/spider.js.map +1 -1
- package/esm/geometry/label/layout/point/adjust-position.js +3 -2
- package/esm/geometry/label/layout/point/adjust-position.js.map +1 -1
- package/esm/geometry/label/layout/worker/hide-overlap.d.ts +2 -0
- package/esm/geometry/label/layout/worker/hide-overlap.js +155 -0
- package/esm/geometry/label/layout/worker/hide-overlap.js.map +1 -0
- package/esm/geometry/label/util/createWorker.d.ts +1 -0
- package/esm/geometry/label/util/createWorker.js +16 -0
- package/esm/geometry/label/util/createWorker.js.map +1 -0
- package/esm/geometry/label/util/index.d.ts +4 -2
- package/esm/geometry/label/util/index.js +3 -2
- package/esm/geometry/label/util/index.js.map +1 -1
- package/esm/geometry/path.js +65 -37
- package/esm/geometry/path.js.map +1 -1
- package/esm/geometry/shape/interval/tick.js +3 -2
- package/esm/geometry/shape/interval/tick.js.map +1 -1
- package/esm/geometry/shape/interval/util.js +14 -13
- package/esm/geometry/shape/interval/util.js.map +1 -1
- package/esm/geometry/shape/point/image.js +22 -11
- package/esm/geometry/shape/point/image.js.map +1 -1
- package/esm/geometry/shape/point/util.js +17 -7
- package/esm/geometry/shape/point/util.js.map +1 -1
- package/esm/geometry/shape/util/path.js +3 -1
- package/esm/geometry/shape/util/path.js.map +1 -1
- package/esm/geometry/util/group-data.js +17 -6
- package/esm/geometry/util/group-data.js.map +1 -1
- package/esm/index.js +7 -0
- package/esm/index.js.map +1 -1
- package/esm/interaction/action/active-region.js +42 -14
- package/esm/interaction/action/active-region.js.map +1 -1
- package/esm/interaction/action/component/axis/axis-description.d.ts +9 -0
- package/esm/interaction/action/component/axis/axis-description.js +77 -0
- package/esm/interaction/action/component/axis/axis-description.js.map +1 -0
- package/esm/interaction/action/component/list-focus.js +50 -13
- package/esm/interaction/action/component/list-focus.js.map +1 -1
- package/esm/interaction/action/data/filter.js +2 -2
- package/esm/interaction/action/data/filter.js.map +1 -1
- package/esm/interaction/action/data/range-filter.js +2 -2
- package/esm/interaction/action/data/range-filter.js.map +1 -1
- package/esm/interaction/action/element/filter.js +2 -2
- package/esm/interaction/action/element/filter.js.map +1 -1
- package/esm/interface.d.ts +6 -2
- package/esm/interface.js.map +1 -1
- package/esm/theme/style-sheet/dark.d.ts +2 -0
- package/esm/theme/style-sheet/dark.js +2 -0
- package/esm/theme/style-sheet/dark.js.map +1 -1
- package/esm/theme/style-sheet/light.d.ts +2 -0
- package/esm/theme/style-sheet/light.js +2 -0
- package/esm/theme/style-sheet/light.js.map +1 -1
- package/esm/theme/util/create-by-style-sheet.js +3 -0
- package/esm/theme/util/create-by-style-sheet.js.map +1 -1
- package/esm/util/attr.js +2 -2
- package/esm/util/attr.js.map +1 -1
- package/esm/util/bbox.js +3 -2
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/collision-detect.d.ts +8 -4
- package/esm/util/collision-detect.js +13 -11
- package/esm/util/collision-detect.js.map +1 -1
- package/esm/util/color.js +2 -1
- package/esm/util/color.js.map +1 -1
- package/esm/util/helper.js +16 -5
- package/esm/util/helper.js.map +1 -1
- package/esm/util/padding.js +3 -3
- package/esm/util/padding.js.map +1 -1
- package/esm/util/scale.js +2 -2
- package/esm/util/scale.js.map +1 -1
- package/esm/util/stat.js +2 -2
- package/esm/util/stat.js.map +1 -1
- package/esm/util/text.js +2 -2
- package/esm/util/text.js.map +1 -1
- package/esm/util/tooltip.js +109 -59
- package/esm/util/tooltip.js.map +1 -1
- package/lib/animate/animation/sector-path-update.js +4 -4
- package/lib/animate/animation/sector-path-update.js.map +1 -1
- package/lib/animate/animation/util.js +2 -1
- package/lib/animate/animation/util.js.map +1 -1
- package/lib/animate/animation/wave-in.js +1 -1
- package/lib/animate/animation/wave-in.js.map +1 -1
- package/lib/animate/animation/zoom.js +1 -1
- package/lib/animate/animation/zoom.js.map +1 -1
- package/lib/animate/index.js +1 -1
- package/lib/animate/index.js.map +1 -1
- package/lib/api.js +1 -1
- package/lib/api.js.map +1 -1
- package/lib/base.js +2 -2
- package/lib/base.js.map +1 -1
- package/lib/chart/chart.js +4 -4
- package/lib/chart/chart.js.map +1 -1
- package/lib/chart/controller/annotation.js +52 -42
- package/lib/chart/controller/annotation.js.map +1 -1
- package/lib/chart/controller/axis.js +4 -4
- package/lib/chart/controller/axis.js.map +1 -1
- package/lib/chart/controller/coordinate.js +4 -4
- package/lib/chart/controller/coordinate.js.map +1 -1
- package/lib/chart/controller/gesture.js +1 -1
- package/lib/chart/controller/gesture.js.map +1 -1
- package/lib/chart/controller/legend.js +3 -3
- package/lib/chart/controller/legend.js.map +1 -1
- package/lib/chart/controller/scrollbar.js +15 -15
- package/lib/chart/controller/scrollbar.js.map +1 -1
- package/lib/chart/controller/slider.js +13 -13
- package/lib/chart/controller/slider.js.map +1 -1
- package/lib/chart/controller/tooltip.js +87 -39
- package/lib/chart/controller/tooltip.js.map +1 -1
- package/lib/chart/layout/auto.js +1 -1
- package/lib/chart/layout/auto.js.map +1 -1
- package/lib/chart/layout/constraint/constraint.js +2 -1
- package/lib/chart/layout/constraint/constraint.js.map +1 -1
- package/lib/chart/layout/constraint/solver.js +2 -1
- package/lib/chart/layout/constraint/solver.js.map +1 -1
- package/lib/chart/layout/padding-cal.js +3 -3
- package/lib/chart/layout/padding-cal.js.map +1 -1
- package/lib/chart/view.js +13 -13
- package/lib/chart/view.js.map +1 -1
- package/lib/component/labels.d.ts +1 -2
- package/lib/component/labels.js +137 -106
- package/lib/component/labels.js.map +1 -1
- package/lib/constant.d.ts +3 -1
- package/lib/constant.js +2 -0
- package/lib/constant.js.map +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/core.js +7 -7
- package/lib/core.js.map +1 -1
- package/lib/facet/circle.js +2 -2
- package/lib/facet/circle.js.map +1 -1
- package/lib/facet/facet.js +3 -2
- package/lib/facet/facet.js.map +1 -1
- package/lib/facet/list.js +4 -4
- package/lib/facet/list.js.map +1 -1
- package/lib/facet/matrix.js +5 -5
- package/lib/facet/matrix.js.map +1 -1
- package/lib/facet/mirror.js +3 -3
- package/lib/facet/mirror.js.map +1 -1
- package/lib/facet/rect.js +8 -8
- package/lib/facet/rect.js.map +1 -1
- package/lib/facet/tree.js +22 -12
- package/lib/facet/tree.js.map +1 -1
- package/lib/geometry/area.js +2 -2
- package/lib/geometry/area.js.map +1 -1
- package/lib/geometry/base.d.ts +3 -0
- package/lib/geometry/base.js +155 -86
- package/lib/geometry/base.js.map +1 -1
- package/lib/geometry/edge.js +2 -2
- package/lib/geometry/edge.js.map +1 -1
- package/lib/geometry/element/index.js +8 -6
- package/lib/geometry/element/index.js.map +1 -1
- package/lib/geometry/heatmap.js +20 -10
- package/lib/geometry/heatmap.js.map +1 -1
- package/lib/geometry/interval.js +2 -2
- package/lib/geometry/interval.js.map +1 -1
- package/lib/geometry/label/base.d.ts +1 -1
- package/lib/geometry/label/base.js +22 -10
- package/lib/geometry/label/base.js.map +1 -1
- package/lib/geometry/label/interval.js +5 -5
- package/lib/geometry/label/interval.js.map +1 -1
- package/lib/geometry/label/layout/hide-overlap.d.ts +1 -1
- package/lib/geometry/label/layout/hide-overlap.js +62 -16
- package/lib/geometry/label/layout/hide-overlap.js.map +1 -1
- package/lib/geometry/label/layout/interval/hide-overlap.js +3 -2
- package/lib/geometry/label/layout/interval/hide-overlap.js.map +1 -1
- package/lib/geometry/label/layout/path/adjust-position.js +3 -2
- package/lib/geometry/label/layout/path/adjust-position.js.map +1 -1
- package/lib/geometry/label/layout/pie/distribute.js +14 -3
- package/lib/geometry/label/layout/pie/distribute.js.map +1 -1
- package/lib/geometry/label/layout/pie/outer.js +14 -3
- package/lib/geometry/label/layout/pie/outer.js.map +1 -1
- package/lib/geometry/label/layout/pie/spider.js +14 -3
- package/lib/geometry/label/layout/pie/spider.js.map +1 -1
- package/lib/geometry/label/layout/point/adjust-position.js +3 -2
- package/lib/geometry/label/layout/point/adjust-position.js.map +1 -1
- package/lib/geometry/label/layout/worker/hide-overlap.d.ts +2 -0
- package/lib/geometry/label/layout/worker/hide-overlap.js +158 -0
- package/lib/geometry/label/layout/worker/hide-overlap.js.map +1 -0
- package/lib/geometry/label/pie.js +3 -3
- package/lib/geometry/label/pie.js.map +1 -1
- package/lib/geometry/label/polar.js +4 -4
- package/lib/geometry/label/polar.js.map +1 -1
- package/lib/geometry/label/util/createWorker.d.ts +1 -0
- package/lib/geometry/label/util/createWorker.js +20 -0
- package/lib/geometry/label/util/createWorker.js.map +1 -0
- package/lib/geometry/label/util/index.d.ts +4 -2
- package/lib/geometry/label/util/index.js +5 -4
- package/lib/geometry/label/util/index.js.map +1 -1
- package/lib/geometry/line.js +2 -2
- package/lib/geometry/line.js.map +1 -1
- package/lib/geometry/path.js +67 -39
- package/lib/geometry/path.js.map +1 -1
- package/lib/geometry/point.js +3 -3
- package/lib/geometry/point.js.map +1 -1
- package/lib/geometry/polygon.js +2 -2
- package/lib/geometry/polygon.js.map +1 -1
- package/lib/geometry/schema.js +2 -2
- package/lib/geometry/schema.js.map +1 -1
- package/lib/geometry/shape/base.js +2 -2
- package/lib/geometry/shape/base.js.map +1 -1
- package/lib/geometry/shape/edge/arc.js +3 -3
- package/lib/geometry/shape/edge/arc.js.map +1 -1
- package/lib/geometry/shape/edge/index.js +1 -1
- package/lib/geometry/shape/edge/index.js.map +1 -1
- package/lib/geometry/shape/edge/smooth.js +1 -1
- package/lib/geometry/shape/edge/smooth.js.map +1 -1
- package/lib/geometry/shape/edge/vhv.js +1 -1
- package/lib/geometry/shape/edge/vhv.js.map +1 -1
- package/lib/geometry/shape/interval/funnel.js +1 -1
- package/lib/geometry/shape/interval/funnel.js.map +1 -1
- package/lib/geometry/shape/interval/hollow-rect.js +2 -2
- package/lib/geometry/shape/interval/hollow-rect.js.map +1 -1
- package/lib/geometry/shape/interval/index.js +2 -2
- package/lib/geometry/shape/interval/index.js.map +1 -1
- package/lib/geometry/shape/interval/line.js +2 -2
- package/lib/geometry/shape/interval/line.js.map +1 -1
- package/lib/geometry/shape/interval/pyramid.js +1 -1
- package/lib/geometry/shape/interval/pyramid.js.map +1 -1
- package/lib/geometry/shape/interval/tick.js +3 -2
- package/lib/geometry/shape/interval/tick.js.map +1 -1
- package/lib/geometry/shape/interval/util.js +13 -12
- package/lib/geometry/shape/interval/util.js.map +1 -1
- package/lib/geometry/shape/line/step.js +1 -1
- package/lib/geometry/shape/line/step.js.map +1 -1
- package/lib/geometry/shape/point/image.js +22 -11
- package/lib/geometry/shape/point/image.js.map +1 -1
- package/lib/geometry/shape/point/util.js +17 -7
- package/lib/geometry/shape/point/util.js.map +1 -1
- package/lib/geometry/shape/polygon/index.js +1 -1
- package/lib/geometry/shape/polygon/index.js.map +1 -1
- package/lib/geometry/shape/polygon/square.js +1 -1
- package/lib/geometry/shape/polygon/square.js.map +1 -1
- package/lib/geometry/shape/schema/box.js +1 -1
- package/lib/geometry/shape/schema/box.js.map +1 -1
- package/lib/geometry/shape/schema/candle.js +1 -1
- package/lib/geometry/shape/schema/candle.js.map +1 -1
- package/lib/geometry/shape/util/get-style.js +1 -1
- package/lib/geometry/shape/util/get-style.js.map +1 -1
- package/lib/geometry/shape/util/path.js +3 -1
- package/lib/geometry/shape/util/path.js.map +1 -1
- package/lib/geometry/shape/violin/hollow.js +2 -2
- package/lib/geometry/shape/violin/hollow.js.map +1 -1
- package/lib/geometry/shape/violin/index.js +1 -1
- package/lib/geometry/shape/violin/index.js.map +1 -1
- package/lib/geometry/shape/violin/smooth.js +1 -1
- package/lib/geometry/shape/violin/smooth.js.map +1 -1
- package/lib/geometry/util/group-data.js +17 -6
- package/lib/geometry/util/group-data.js.map +1 -1
- package/lib/geometry/violin.js +2 -2
- package/lib/geometry/violin.js.map +1 -1
- package/lib/index.js +76 -69
- package/lib/index.js.map +1 -1
- package/lib/interaction/action/active-region.js +44 -16
- package/lib/interaction/action/active-region.js.map +1 -1
- package/lib/interaction/action/callback.js +2 -2
- package/lib/interaction/action/callback.js.map +1 -1
- package/lib/interaction/action/component/axis/axis-description.d.ts +9 -0
- package/lib/interaction/action/component/axis/axis-description.js +79 -0
- package/lib/interaction/action/component/axis/axis-description.js.map +1 -0
- package/lib/interaction/action/component/list-active.js +2 -2
- package/lib/interaction/action/component/list-active.js.map +1 -1
- package/lib/interaction/action/component/list-checked.js +2 -2
- package/lib/interaction/action/component/list-checked.js.map +1 -1
- package/lib/interaction/action/component/list-focus.js +51 -14
- package/lib/interaction/action/component/list-focus.js.map +1 -1
- package/lib/interaction/action/component/list-highlight.js +2 -2
- package/lib/interaction/action/component/list-highlight.js.map +1 -1
- package/lib/interaction/action/component/list-radio.js +3 -3
- package/lib/interaction/action/component/list-radio.js.map +1 -1
- package/lib/interaction/action/component/list-selected.js +2 -2
- package/lib/interaction/action/component/list-selected.js.map +1 -1
- package/lib/interaction/action/component/list-state.js +2 -2
- package/lib/interaction/action/component/list-state.js.map +1 -1
- package/lib/interaction/action/component/list-unchecked.js +2 -2
- package/lib/interaction/action/component/list-unchecked.js.map +1 -1
- package/lib/interaction/action/component/tooltip/ellipsis-text.js +4 -4
- package/lib/interaction/action/component/tooltip/ellipsis-text.js.map +1 -1
- package/lib/interaction/action/component/tooltip/geometry.js +2 -2
- package/lib/interaction/action/component/tooltip/geometry.js.map +1 -1
- package/lib/interaction/action/component/tooltip/sibling.js +2 -2
- package/lib/interaction/action/component/tooltip/sibling.js.map +1 -1
- package/lib/interaction/action/cursor.js +2 -2
- package/lib/interaction/action/cursor.js.map +1 -1
- package/lib/interaction/action/data/filter.js +3 -3
- package/lib/interaction/action/data/filter.js.map +1 -1
- package/lib/interaction/action/data/range-filter.js +3 -3
- package/lib/interaction/action/data/range-filter.js.map +1 -1
- package/lib/interaction/action/data/sibling-filter.js +2 -2
- package/lib/interaction/action/data/sibling-filter.js.map +1 -1
- package/lib/interaction/action/element/active.js +2 -2
- package/lib/interaction/action/element/active.js.map +1 -1
- package/lib/interaction/action/element/filter.js +3 -3
- package/lib/interaction/action/element/filter.js.map +1 -1
- package/lib/interaction/action/element/highlight-by-color.js +2 -2
- package/lib/interaction/action/element/highlight-by-color.js.map +1 -1
- package/lib/interaction/action/element/highlight-by-x.js +2 -2
- package/lib/interaction/action/element/highlight-by-x.js.map +1 -1
- package/lib/interaction/action/element/highlight.js +2 -2
- package/lib/interaction/action/element/highlight.js.map +1 -1
- package/lib/interaction/action/element/link-by-color.js +3 -3
- package/lib/interaction/action/element/link-by-color.js.map +1 -1
- package/lib/interaction/action/element/range-active.js +2 -2
- package/lib/interaction/action/element/range-active.js.map +1 -1
- package/lib/interaction/action/element/range-highlight.js +2 -2
- package/lib/interaction/action/element/range-highlight.js.map +1 -1
- package/lib/interaction/action/element/range-selected.js +2 -2
- package/lib/interaction/action/element/range-selected.js.map +1 -1
- package/lib/interaction/action/element/range-state.js +2 -2
- package/lib/interaction/action/element/range-state.js.map +1 -1
- package/lib/interaction/action/element/selected.js +2 -2
- package/lib/interaction/action/element/selected.js.map +1 -1
- package/lib/interaction/action/element/sibling-filter.js +2 -2
- package/lib/interaction/action/element/sibling-filter.js.map +1 -1
- package/lib/interaction/action/element/single-active.js +2 -2
- package/lib/interaction/action/element/single-active.js.map +1 -1
- package/lib/interaction/action/element/single-highlight.js +2 -2
- package/lib/interaction/action/element/single-highlight.js.map +1 -1
- package/lib/interaction/action/element/single-selected.js +2 -2
- package/lib/interaction/action/element/single-selected.js.map +1 -1
- package/lib/interaction/action/element/single-state.js +2 -2
- package/lib/interaction/action/element/single-state.js.map +1 -1
- package/lib/interaction/action/element/state-base.js +2 -2
- package/lib/interaction/action/element/state-base.js.map +1 -1
- package/lib/interaction/action/element/state.js +2 -2
- package/lib/interaction/action/element/state.js.map +1 -1
- package/lib/interaction/action/mask/base.js +3 -3
- package/lib/interaction/action/mask/base.js.map +1 -1
- package/lib/interaction/action/mask/circle.js +2 -2
- package/lib/interaction/action/mask/circle.js.map +1 -1
- package/lib/interaction/action/mask/dim-rect.js +2 -2
- package/lib/interaction/action/mask/dim-rect.js.map +1 -1
- package/lib/interaction/action/mask/path.js +2 -2
- package/lib/interaction/action/mask/path.js.map +1 -1
- package/lib/interaction/action/mask/rect.js +2 -2
- package/lib/interaction/action/mask/rect.js.map +1 -1
- package/lib/interaction/action/mask/smooth-path.js +2 -2
- package/lib/interaction/action/mask/smooth-path.js.map +1 -1
- package/lib/interaction/action/register.js +1 -1
- package/lib/interaction/action/register.js.map +1 -1
- package/lib/interaction/action/view/button.js +4 -4
- package/lib/interaction/action/view/button.js.map +1 -1
- package/lib/interaction/action/view/drag.js +2 -2
- package/lib/interaction/action/view/drag.js.map +1 -1
- package/lib/interaction/action/view/mousewheel-scroll.js +1 -1
- package/lib/interaction/action/view/mousewheel-scroll.js.map +1 -1
- package/lib/interaction/action/view/move.js +1 -1
- package/lib/interaction/action/view/move.js.map +1 -1
- package/lib/interaction/action/view/scale-transform.js +1 -1
- package/lib/interaction/action/view/scale-transform.js.map +1 -1
- package/lib/interaction/action/view/scale-translate.js +2 -2
- package/lib/interaction/action/view/scale-translate.js.map +1 -1
- package/lib/interaction/action/view/scale-zoom.js +2 -2
- package/lib/interaction/action/view/scale-zoom.js.map +1 -1
- package/lib/interaction/grammar-interaction.js +3 -3
- package/lib/interaction/grammar-interaction.js.map +1 -1
- package/lib/interaction/index.js +2 -2
- package/lib/interaction/index.js.map +1 -1
- package/lib/interface.d.ts +6 -2
- package/lib/interface.js.map +1 -1
- package/lib/theme/style-sheet/dark.d.ts +2 -0
- package/lib/theme/style-sheet/dark.js +3 -1
- package/lib/theme/style-sheet/dark.js.map +1 -1
- package/lib/theme/style-sheet/light.d.ts +2 -0
- package/lib/theme/style-sheet/light.js +3 -1
- package/lib/theme/style-sheet/light.js.map +1 -1
- package/lib/theme/util/create-by-style-sheet.js +11 -8
- package/lib/theme/util/create-by-style-sheet.js.map +1 -1
- package/lib/theme/util/create-theme.js +1 -1
- package/lib/theme/util/create-theme.js.map +1 -1
- package/lib/util/attr.js +1 -1
- package/lib/util/attr.js.map +1 -1
- package/lib/util/bbox.js +3 -2
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/collision-detect.d.ts +8 -4
- package/lib/util/collision-detect.js +14 -12
- package/lib/util/collision-detect.js.map +1 -1
- package/lib/util/color.js +2 -2
- package/lib/util/color.js.map +1 -1
- package/lib/util/helper.js +16 -5
- package/lib/util/helper.js.map +1 -1
- package/lib/util/legend.js +2 -2
- package/lib/util/legend.js.map +1 -1
- package/lib/util/padding.js +2 -2
- package/lib/util/padding.js.map +1 -1
- package/lib/util/scale.js +2 -2
- package/lib/util/scale.js.map +1 -1
- package/lib/util/stat.js +1 -1
- package/lib/util/stat.js.map +1 -1
- package/lib/util/text.js +1 -1
- package/lib/util/text.js.map +1 -1
- package/lib/util/tooltip.js +109 -59
- package/lib/util/tooltip.js.map +1 -1
- package/package.json +2 -2
- package/src/chart/chart.ts +1 -1
- package/src/component/labels.ts +37 -40
- package/src/constant.ts +3 -0
- package/src/core.ts +1 -1
- package/src/geometry/base.ts +42 -30
- package/src/geometry/element/index.ts +2 -2
- package/src/geometry/label/base.ts +3 -3
- package/src/geometry/label/layout/hide-overlap.ts +73 -21
- package/src/geometry/label/layout/path/adjust-position.ts +1 -2
- package/src/geometry/label/layout/worker/hide-overlap.ts +192 -0
- package/src/geometry/label/util/createWorker.ts +15 -0
- package/src/geometry/label/util/index.ts +5 -4
- package/src/index.ts +8 -0
- package/src/interaction/action/component/axis/axis-description.ts +86 -0
- package/src/interface.ts +6 -3
- package/src/theme/style-sheet/dark.ts +2 -0
- package/src/theme/style-sheet/light.ts +2 -0
- package/src/theme/util/create-by-style-sheet.ts +3 -0
- package/src/util/collision-detect.ts +24 -14
- package/CHANGELOG.md +0 -1331
|
@@ -1,33 +1,85 @@
|
|
|
1
|
-
import { get } from '@antv/util';
|
|
1
|
+
import { get, each } from '@antv/util';
|
|
2
2
|
import { BBox, IGroup, IShape } from '../../../dependents';
|
|
3
|
-
import {
|
|
3
|
+
import { intersect } from '../../../util/collision-detect';
|
|
4
4
|
import { LabelItem } from '../interface';
|
|
5
|
-
import {
|
|
5
|
+
import { getLabelBackgroundInfo } from '../util';
|
|
6
|
+
import { createWorker } from '../util/createWorker';
|
|
7
|
+
import { code as layoutCode } from './worker/hide-overlap';
|
|
8
|
+
|
|
9
|
+
type Item = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
rotation?: number;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const layout = (items: Item[]): Item[] => {
|
|
19
|
+
const boxes = items.slice();
|
|
20
|
+
for (let i = 0; i < boxes.length; i++) {
|
|
21
|
+
const box1 = boxes[i];
|
|
22
|
+
if (box1.visible) {
|
|
23
|
+
for (let j = i + 1; j < boxes.length; j++) {
|
|
24
|
+
const box2 = boxes[j];
|
|
25
|
+
if (box1 !== box2 && box2.visible) {
|
|
26
|
+
if (intersect(box1, box2)) {
|
|
27
|
+
box2.visible = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return boxes;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const cache: Map<string, any> = new Map();
|
|
37
|
+
const worker = createWorker(layoutCode);
|
|
6
38
|
|
|
7
39
|
/**
|
|
8
40
|
* label 防遮挡布局:在不改变 label 位置的情况下对相互重叠的 label 进行隐藏(非移除)
|
|
9
41
|
* 不同于 'overlap' 类型的布局,该布局不会对 label 的位置进行偏移调整。
|
|
10
42
|
* @param labels 参与布局调整的 label 数组集合
|
|
11
43
|
*/
|
|
12
|
-
export function hideOverlap(
|
|
13
|
-
// todo 添加
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
44
|
+
export function hideOverlap(labelItems: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {
|
|
45
|
+
// todo 添加 label rank
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
const boxes = labels.map((d, idx) => ({
|
|
48
|
+
...getLabelBackgroundInfo(d, labelItems[idx], get(labelItems[idx], 'background.padding')),
|
|
49
|
+
visible: true,
|
|
50
|
+
}));
|
|
51
|
+
const memoKey = JSON.stringify(boxes);
|
|
52
|
+
const cb = (items: Item[]) => {
|
|
53
|
+
cache.set(memoKey, items);
|
|
54
|
+
each(items, ({ visible }, idx) => {
|
|
55
|
+
const labelShape = labels[idx];
|
|
56
|
+
if (visible) {
|
|
57
|
+
labelShape?.show()
|
|
58
|
+
} else {
|
|
59
|
+
labelShape?.hide();
|
|
29
60
|
}
|
|
61
|
+
});
|
|
62
|
+
return resolve(items);
|
|
63
|
+
}
|
|
64
|
+
if (cache.get(memoKey)) {
|
|
65
|
+
cb(cache.get(memoKey))
|
|
66
|
+
} else if (worker) {
|
|
67
|
+
// Do layout in worker.
|
|
68
|
+
try {
|
|
69
|
+
worker.postMessage(JSON.stringify({ type: 'hide-overlap', items: boxes }));
|
|
70
|
+
worker.onmessage = (e) => cb(Array.isArray(e.data) ? e.data : []);
|
|
71
|
+
worker.onmessageerror = (e) => {
|
|
72
|
+
console.warn('[AntV G2] Web worker is not available');
|
|
73
|
+
// Normal layout in main thread.
|
|
74
|
+
cb(layout(boxes));
|
|
75
|
+
};
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.error(e);
|
|
78
|
+
cb(layout(boxes));
|
|
30
79
|
}
|
|
80
|
+
} else {
|
|
81
|
+
// Normal layout in main thread.
|
|
82
|
+
cb(layout(boxes));
|
|
31
83
|
}
|
|
32
|
-
}
|
|
84
|
+
});
|
|
33
85
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { groupBy, keys, map } from '@antv/util';
|
|
2
|
-
import {
|
|
3
|
-
import { isIntersect } from '../../../../util/collision-detect';
|
|
2
|
+
import { IGroup, IShape, BBox } from '../../../../dependents';
|
|
4
3
|
import Geometry from '../../../base';
|
|
5
4
|
import Element from '../../../element';
|
|
6
5
|
import { LabelItem } from '../../interface';
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const onmessage = function (e) {
|
|
2
|
+
type Item = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
rotation?: number;
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Copy from src/util/collision-detect.ts
|
|
12
|
+
function generateUtils() {
|
|
13
|
+
type Vec2 = [number, number];
|
|
14
|
+
|
|
15
|
+
type Point = { x: number; y: number };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 定义投影对象
|
|
19
|
+
*/
|
|
20
|
+
type Projection = { min: number; max: number };
|
|
21
|
+
|
|
22
|
+
function dot(a, b) {
|
|
23
|
+
return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 1. 获取投影轴
|
|
27
|
+
*/
|
|
28
|
+
function getAxes(points: Point[] /** 多边形的关键点 */): Vec2[] {
|
|
29
|
+
// 目前先处理 平行矩形 的场景, 其他多边形不处理
|
|
30
|
+
if (points.length > 4) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
// 获取向量
|
|
34
|
+
const vector = (start: Point, end: Point): Vec2 => {
|
|
35
|
+
return [end.x - start.x, end.y - start.y];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// 由于 矩形的平行原理,所以只有 2 条投影轴: A -> B, B -> C
|
|
39
|
+
const AB = vector(points[0], points[1]);
|
|
40
|
+
const BC = vector(points[1], points[2]);
|
|
41
|
+
|
|
42
|
+
return [AB, BC];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 绕指定点顺时针旋转后的点坐标
|
|
47
|
+
* 默认绕原点旋转
|
|
48
|
+
*/
|
|
49
|
+
function rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {
|
|
50
|
+
const { x, y } = point;
|
|
51
|
+
return {
|
|
52
|
+
x: (x - origin.x) * Math.cos(-deg) + (y - origin.y) * Math.sin(-deg) + origin.x,
|
|
53
|
+
y: (origin.x - x) * Math.sin(-deg) + (y - origin.y) * Math.cos(-deg) + origin.y,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @private
|
|
59
|
+
* 转化为顶点坐标数组
|
|
60
|
+
*
|
|
61
|
+
* @param {Object} box
|
|
62
|
+
*/
|
|
63
|
+
function getRectPoints(box: Item): Point[] {
|
|
64
|
+
const points = [
|
|
65
|
+
{ x: box.x, y: box.y },
|
|
66
|
+
{ x: box.x + box.width, y: box.y },
|
|
67
|
+
{ x: box.x + box.width, y: box.y + box.height },
|
|
68
|
+
{ x: box.x, y: box.y + box.height },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const rotation = box.rotation;
|
|
72
|
+
if (rotation) {
|
|
73
|
+
return [
|
|
74
|
+
rotateAtPoint(points[0], rotation, points[0]),
|
|
75
|
+
rotateAtPoint(points[1], rotation, points[0]),
|
|
76
|
+
rotateAtPoint(points[2], rotation, points[0]),
|
|
77
|
+
rotateAtPoint(points[3], rotation, points[0]),
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return points;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 2. 获取多边形在投影轴上的投影
|
|
86
|
+
*
|
|
87
|
+
* 向量的点积的其中一个几何含义是:一个向量在平行于另一个向量方向上的投影的数值乘积。
|
|
88
|
+
* 由于投影轴是单位向量(长度为1),投影的长度为 x1 * x2 + y1 * y2
|
|
89
|
+
*/
|
|
90
|
+
function getProjection(points: Point[] /** 多边形的关键点 */, axis: Vec2): Projection {
|
|
91
|
+
// 目前先处理矩形的场景
|
|
92
|
+
if (points.length > 4) {
|
|
93
|
+
return { min: 0, max: 0 };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const scalars = [];
|
|
97
|
+
points.forEach((point) => {
|
|
98
|
+
scalars.push(dot([point.x, point.y], axis));
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return { min: Math.min.apply(null, scalars), max: Math.max.apply(null, scalars) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isProjectionOverlap(projection1: Projection, projection2: Projection): boolean {
|
|
105
|
+
return projection1.max > projection2.min && projection1.min < projection2.max;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isValidNumber(d: number) {
|
|
109
|
+
return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isValidBox(box: Item) {
|
|
113
|
+
return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {
|
|
117
|
+
return !(
|
|
118
|
+
box2.x > box1.x + box1.width + margin ||
|
|
119
|
+
box2.x + box2.width < box1.x - margin ||
|
|
120
|
+
box2.y > box1.y + box1.height + margin ||
|
|
121
|
+
box2.y + box2.height < box1.y - margin
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function intersect(box1: Item, box2: Item, margin: number = 0) {
|
|
125
|
+
if (!isValidBox(box1) || !isValidBox(box2)) return false;
|
|
126
|
+
|
|
127
|
+
// Quick detect, if rotation is null or zero.
|
|
128
|
+
if (!box1.rotation && !box2.rotation) {
|
|
129
|
+
return isIntersectRect(box1, box2, margin);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 分别获取 4 个关键点
|
|
133
|
+
const rect1Points = getRectPoints(box1);
|
|
134
|
+
const rect2Points = getRectPoints(box2);
|
|
135
|
+
|
|
136
|
+
// 获取所有投影轴
|
|
137
|
+
const axes = getAxes(rect1Points).concat(getAxes(rect2Points));
|
|
138
|
+
|
|
139
|
+
for (let i = 0; i < axes.length; i++) {
|
|
140
|
+
const axis = axes[i];
|
|
141
|
+
const projection1 = getProjection(rect1Points, axis);
|
|
142
|
+
const projection2 = getProjection(rect2Points, axis);
|
|
143
|
+
|
|
144
|
+
if (!isProjectionOverlap(projection1, projection2)) return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return { intersect }
|
|
150
|
+
}
|
|
151
|
+
const { intersect } = generateUtils();
|
|
152
|
+
|
|
153
|
+
// Label layouts.
|
|
154
|
+
function hideOverlap(items: Item[]) {
|
|
155
|
+
const boxes = items.slice();
|
|
156
|
+
for (let i = 0; i < boxes.length; i++) {
|
|
157
|
+
const box1 = boxes[i];
|
|
158
|
+
if (box1.visible) {
|
|
159
|
+
for (let j = i + 1; j < boxes.length; j++) {
|
|
160
|
+
const box2 = boxes[j];
|
|
161
|
+
if (box1 !== box2 && box2.visible) {
|
|
162
|
+
if (intersect(box1, box2)) {
|
|
163
|
+
box2.visible = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return boxes;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const methods = {
|
|
173
|
+
'hide-overlap': hideOverlap,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Main
|
|
177
|
+
try {
|
|
178
|
+
const eventData = JSON.parse(e.data);
|
|
179
|
+
if (!eventData || !eventData.type || !methods[eventData.type]) return;
|
|
180
|
+
|
|
181
|
+
const { type, items } = eventData;
|
|
182
|
+
const result = methods[type](items);
|
|
183
|
+
self.postMessage(result);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const code = `
|
|
190
|
+
self.onmessage = ${onmessage.toString()}
|
|
191
|
+
`
|
|
192
|
+
export { code };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createWorker(f: any) {
|
|
2
|
+
if (typeof window === "undefined") return;
|
|
3
|
+
|
|
4
|
+
let blob;
|
|
5
|
+
try {
|
|
6
|
+
blob = new Blob([f.toString()], { type: 'application/javascript' });
|
|
7
|
+
} catch (e) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
blob = new window.BlobBuilder();
|
|
10
|
+
blob.append(f.toString());
|
|
11
|
+
blob = blob.getBlob();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return new Worker(URL.createObjectURL(blob));
|
|
15
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { isNil, isNumber, some } from '@antv/util';
|
|
6
6
|
import { IElement, IGroup, BBox } from '../../../dependents';
|
|
7
7
|
import { rotate } from '../../../util/transform';
|
|
8
|
-
import { LabelItem } from '../interface';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* 查找 Label Group 中的文本 shape 对象
|
|
@@ -18,12 +17,12 @@ export function findLabelTextShape(label: IGroup): IElement {
|
|
|
18
17
|
/**
|
|
19
18
|
* 获取标签背景信息: box (无旋转) + rotation (旋转角度)
|
|
20
19
|
*/
|
|
21
|
-
export function
|
|
20
|
+
export function getLabelBackgroundInfo(
|
|
22
21
|
labelGroup: IGroup,
|
|
23
|
-
labelItem:
|
|
22
|
+
labelItem: { rotate?: number;[key: string]: any },
|
|
24
23
|
padding: number | number[] = [0, 0, 0, 0]
|
|
25
24
|
): { x: number; y: number; width: number; height: number; rotation: number } {
|
|
26
|
-
const content = labelGroup.getChildren()[0];
|
|
25
|
+
const content = labelGroup && labelGroup.getChildren()[0];
|
|
27
26
|
if (content) {
|
|
28
27
|
const labelShape = content.clone();
|
|
29
28
|
|
|
@@ -52,6 +51,8 @@ export function getlLabelBackgroundInfo(
|
|
|
52
51
|
rotation: labelItem?.rotate || 0,
|
|
53
52
|
};
|
|
54
53
|
}
|
|
54
|
+
|
|
55
|
+
return { x: 0, y: 0, width: 0, height: 0, rotation: 0 };
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
package/src/index.ts
CHANGED
|
@@ -220,6 +220,7 @@ import ViewMove from './interaction/action/view/move';
|
|
|
220
220
|
import ScaleTranslate from './interaction/action/view/scale-translate';
|
|
221
221
|
import ScaleZoom from './interaction/action/view/scale-zoom';
|
|
222
222
|
import MousewheelScroll from './interaction/action/view/mousewheel-scroll';
|
|
223
|
+
import AxisDescription from './interaction/action/component/axis/axis-description'
|
|
223
224
|
|
|
224
225
|
registerAction('tooltip', TooltipAction);
|
|
225
226
|
registerAction('sibling-tooltip', SiblingTooltip);
|
|
@@ -260,6 +261,7 @@ registerAction('legend-item-highlight', ListHighlight, {
|
|
|
260
261
|
registerAction('axis-label-highlight', ListHighlight, {
|
|
261
262
|
componentNames: ['axis'],
|
|
262
263
|
});
|
|
264
|
+
registerAction('axis-description', AxisDescription)
|
|
263
265
|
|
|
264
266
|
registerAction('rect-mask', RectMask);
|
|
265
267
|
registerAction('x-rect-mask', DimMask, { dim: 'x' });
|
|
@@ -615,6 +617,12 @@ registerInteraction('active-region', {
|
|
|
615
617
|
end: [{ trigger: 'plot:mouseleave', action: 'active-region:hide' }],
|
|
616
618
|
});
|
|
617
619
|
|
|
620
|
+
// 显示坐标轴标题详情信息
|
|
621
|
+
registerInteraction('axis-description', {
|
|
622
|
+
start: [{ trigger: 'axis-description:mousemove', action: 'axis-description:show' }],
|
|
623
|
+
end: [{ trigger: 'axis-description:mouseleave', action: 'axis-description:hide' }]
|
|
624
|
+
})
|
|
625
|
+
|
|
618
626
|
function isWheelDown(event) {
|
|
619
627
|
event.gEvent.preventDefault();
|
|
620
628
|
return event.gEvent.originalEvent.deltaY > 0;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { TOOLTIP_CSS_CONST } from "@antv/component";
|
|
2
|
+
import { deepMix } from "@antv/util";
|
|
3
|
+
import { HtmlTooltip } from "../../../../dependents";
|
|
4
|
+
import Action from "../../base";
|
|
5
|
+
import { getDelegationObject } from "../../util";
|
|
6
|
+
|
|
7
|
+
const AXIS_DESCRIPTION_TOOLTIP = 'aixs-description-tooltip'
|
|
8
|
+
|
|
9
|
+
class AxisDescription extends Action {
|
|
10
|
+
private tooltip;
|
|
11
|
+
|
|
12
|
+
public show() {
|
|
13
|
+
const context = this.context;
|
|
14
|
+
const { axis } = getDelegationObject(context);
|
|
15
|
+
const { description, text } = axis.cfg.title;
|
|
16
|
+
const { x, y } = context.event;
|
|
17
|
+
if(!this.tooltip) {
|
|
18
|
+
this.renderTooltip()
|
|
19
|
+
};
|
|
20
|
+
this.tooltip.update({
|
|
21
|
+
title: text || '',
|
|
22
|
+
customContent: () => {
|
|
23
|
+
return (`
|
|
24
|
+
<div class="${TOOLTIP_CSS_CONST.CONTAINER_CLASS}">
|
|
25
|
+
<div class="${TOOLTIP_CSS_CONST.TITLE_CLASS}">
|
|
26
|
+
${text}
|
|
27
|
+
</div>
|
|
28
|
+
<div class="${TOOLTIP_CSS_CONST.LIST_CLASS}">
|
|
29
|
+
${description}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
`)
|
|
33
|
+
},
|
|
34
|
+
x,
|
|
35
|
+
y
|
|
36
|
+
});
|
|
37
|
+
this.tooltip.show()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public destroy() {
|
|
41
|
+
super.destroy();
|
|
42
|
+
this.tooltip && this.tooltip.destroy();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public hide() {
|
|
46
|
+
this.tooltip && this.tooltip.hide()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public renderTooltip() {
|
|
50
|
+
const view = this.context.view;
|
|
51
|
+
const canvas = view.canvas;
|
|
52
|
+
const region = {
|
|
53
|
+
start: { x: 0, y: 0 },
|
|
54
|
+
end: { x: canvas.get('width'), y: canvas.get('height') },
|
|
55
|
+
};
|
|
56
|
+
const tooltip = new HtmlTooltip({
|
|
57
|
+
parent: canvas.get('el').parentNode,
|
|
58
|
+
region,
|
|
59
|
+
visible: false,
|
|
60
|
+
containerId: AXIS_DESCRIPTION_TOOLTIP,
|
|
61
|
+
domStyles: {
|
|
62
|
+
...deepMix({}, {
|
|
63
|
+
// 超长的时候,tooltip tip 最大宽度为 50%,然后可以换行
|
|
64
|
+
[TOOLTIP_CSS_CONST.CONTAINER_CLASS]: {
|
|
65
|
+
'max-width': '50%',
|
|
66
|
+
'padding': '5px',
|
|
67
|
+
'line-height': '15px'
|
|
68
|
+
},
|
|
69
|
+
[TOOLTIP_CSS_CONST.TITLE_CLASS]: {
|
|
70
|
+
'word-break': 'break-all',
|
|
71
|
+
'font-size': '14px',
|
|
72
|
+
'margin-bottom': '3px'
|
|
73
|
+
},
|
|
74
|
+
[TOOLTIP_CSS_CONST.LIST_CLASS]: {
|
|
75
|
+
'word-break': 'break-all',
|
|
76
|
+
'opacity': '.5'
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
tooltip.init();
|
|
82
|
+
tooltip.setCapture(false);
|
|
83
|
+
this.tooltip = tooltip
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export default AxisDescription
|
package/src/interface.ts
CHANGED
|
@@ -1066,8 +1066,8 @@ export interface ScaleOption extends ScaleConfig {
|
|
|
1066
1066
|
*/
|
|
1067
1067
|
sync?: boolean | string;
|
|
1068
1068
|
/**
|
|
1069
|
-
* @title
|
|
1070
|
-
* @description 只对 type: 'time' 的 scale 生效,强制显示最后的日期 tick。
|
|
1069
|
+
* @title 是否显示最后的 tick
|
|
1070
|
+
* @description 只对 `type: 'cat'` 以及 `type: 'time-cat'` 的 scale 生效,强制显示最后的日期 tick。
|
|
1071
1071
|
*/
|
|
1072
1072
|
showLast?: boolean;
|
|
1073
1073
|
/**
|
|
@@ -2768,7 +2768,10 @@ export interface StyleSheet {
|
|
|
2768
2768
|
* @title 坐标轴标题距离坐标轴文本的间距
|
|
2769
2769
|
*/
|
|
2770
2770
|
axisTitleSpacing?: number;
|
|
2771
|
-
|
|
2771
|
+
/**
|
|
2772
|
+
* @title 坐标轴详细说明icon颜色
|
|
2773
|
+
*/
|
|
2774
|
+
axisDescriptionIconFillColor?: string;
|
|
2772
2775
|
/**
|
|
2773
2776
|
* @title 坐标轴刻度线颜色
|
|
2774
2777
|
*/
|
|
@@ -117,6 +117,8 @@ export const createDarkStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
117
117
|
axisTitleTextFontWeight: 'normal',
|
|
118
118
|
/** 坐标轴标题距离坐标轴文本的间距 */
|
|
119
119
|
axisTitleSpacing: 12,
|
|
120
|
+
/** 坐标轴标题详细说明icon颜色 */
|
|
121
|
+
axisDescriptionIconFillColor: WHITE_COLORS[85],
|
|
120
122
|
|
|
121
123
|
/** 坐标轴刻度线颜色 */
|
|
122
124
|
axisTickLineBorderColor: BLACK_COLORS[25],
|
|
@@ -117,6 +117,8 @@ export const createLightStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
117
117
|
axisTitleTextFontWeight: 'normal',
|
|
118
118
|
/** 坐标轴标题距离坐标轴文本的间距 */
|
|
119
119
|
axisTitleSpacing: 12,
|
|
120
|
+
/** 坐标轴标题详细说明icon颜色 */
|
|
121
|
+
axisDescriptionIconFillColor: WHITE_COLORS[85],
|
|
120
122
|
|
|
121
123
|
/** 坐标轴刻度线颜色 */
|
|
122
124
|
axisTickLineBorderColor: BLACK_COLORS[25],
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { isNumber } from '@antv/util';
|
|
2
|
-
import {
|
|
3
|
-
import { BBox, Point } from '../dependents';
|
|
2
|
+
import { Point } from '../dependents';
|
|
4
3
|
|
|
5
|
-
const { dot } = vec2;
|
|
6
4
|
type Vec2 = [number, number];
|
|
7
5
|
|
|
8
|
-
type
|
|
9
|
-
|
|
6
|
+
type Item = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
rotation?: number;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
};
|
|
10
14
|
/**
|
|
11
15
|
* 定义投影对象
|
|
12
16
|
*/
|
|
13
17
|
type Projection = { min: number; max: number };
|
|
14
18
|
|
|
19
|
+
function dot(a, b) {
|
|
20
|
+
return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
/**
|
|
16
24
|
* @private
|
|
17
25
|
* 1. 获取投影轴
|
|
@@ -52,7 +60,7 @@ function rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {
|
|
|
52
60
|
*
|
|
53
61
|
* @param {Object} box
|
|
54
62
|
*/
|
|
55
|
-
function getRectPoints(box:
|
|
63
|
+
function getRectPoints(box: Item): Point[] {
|
|
56
64
|
const points = [
|
|
57
65
|
{ x: box.x, y: box.y },
|
|
58
66
|
{ x: box.x + box.width, y: box.y },
|
|
@@ -99,17 +107,17 @@ function isProjectionOverlap(projection1: Projection, projection2: Projection):
|
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
function isValidNumber(d: number) {
|
|
102
|
-
return
|
|
110
|
+
return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
function isValidBox(box:
|
|
106
|
-
return
|
|
113
|
+
function isValidBox(box: Item) {
|
|
114
|
+
return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
/**
|
|
110
118
|
* 快速判断两个无旋转矩形是否遮挡
|
|
111
119
|
*/
|
|
112
|
-
export function isIntersectRect(box1:
|
|
120
|
+
export function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {
|
|
113
121
|
return !(
|
|
114
122
|
box2.x > box1.x + box1.width + margin ||
|
|
115
123
|
box2.x + box2.width < box1.x - margin ||
|
|
@@ -124,13 +132,13 @@ export function isIntersectRect(box1: Box, box2: Box, margin: number = 0): boole
|
|
|
124
132
|
*
|
|
125
133
|
* - 原理: 分离轴定律
|
|
126
134
|
*/
|
|
127
|
-
export function
|
|
135
|
+
export function intersect(box1: Item, box2: Item, margin: number = 0) {
|
|
128
136
|
// 如果两个 box 中有一个是不合法的 box,也就是不会被渲染出来的,那么它们就不相交。
|
|
129
137
|
if (!isValidBox(box1) || !isValidBox(box2)) return false;
|
|
130
138
|
|
|
131
139
|
// 如果两个矩形没有旋转,使用快速判断
|
|
132
140
|
if (!box1.rotation && !box2.rotation) {
|
|
133
|
-
return isIntersectRect(box1, box2);
|
|
141
|
+
return isIntersectRect(box1, box2, margin);
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
// 分别获取 4 个关键点
|
|
@@ -138,7 +146,7 @@ export function isIntersect(box1: Box, box2: Box) {
|
|
|
138
146
|
const rect2Points = getRectPoints(box2);
|
|
139
147
|
|
|
140
148
|
// 获取所有投影轴
|
|
141
|
-
const axes =
|
|
149
|
+
const axes = getAxes(rect1Points).concat(getAxes(rect2Points));
|
|
142
150
|
|
|
143
151
|
for (let i = 0; i < axes.length; i++) {
|
|
144
152
|
const axis = axes[i];
|
|
@@ -146,7 +154,9 @@ export function isIntersect(box1: Box, box2: Box) {
|
|
|
146
154
|
const projection2 = getProjection(rect2Points, axis);
|
|
147
155
|
|
|
148
156
|
// 判断投影轴上的投影是否存在重叠,若检测到存在间隙则立刻退出判断,消除不必要的运算。
|
|
149
|
-
if (!isProjectionOverlap(projection1, projection2))
|
|
157
|
+
if (!isProjectionOverlap(projection1, projection2)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
return true;
|