@antv/g2 5.0.0-beta.4 → 5.0.0-beta.6
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-lite.min.js +5 -2
- package/dist/g2.min.js +5 -2
- package/esm/api/chart.d.ts +4 -0
- package/esm/api/chart.js +26 -4
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/mark.js +1 -2
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -2
- package/esm/component/axis.js +23 -9
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +2 -0
- package/esm/component/index.js +2 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/scrollbar.d.ts +9 -0
- package/esm/component/scrollbar.js +36 -0
- package/esm/component/scrollbar.js.map +1 -0
- package/esm/component/scrollbarX.d.ts +7 -0
- package/esm/component/scrollbarX.js +9 -0
- package/esm/component/scrollbarX.js.map +1 -0
- package/esm/component/scrollbarY.d.ts +7 -0
- package/esm/component/scrollbarY.js +9 -0
- package/esm/component/scrollbarY.js.map +1 -0
- package/esm/component/slider.js +2 -4
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js +46 -22
- package/esm/component/title.js.map +1 -1
- package/esm/composition/mark.js +2 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/data/fold.js +4 -10
- package/esm/data/fold.js.map +1 -1
- package/esm/data/index.d.ts +2 -2
- package/esm/data/index.js +1 -1
- package/esm/data/index.js.map +1 -1
- package/esm/data/pick.js +10 -2
- package/esm/data/pick.js.map +1 -1
- package/esm/data/slice.d.ts +8 -0
- package/esm/data/slice.js +10 -0
- package/esm/data/slice.js.map +1 -0
- package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
- package/esm/interaction/index.d.ts +8 -0
- package/esm/interaction/index.js +7 -30
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/esm/interaction/native/brushAxisHighlight.js +159 -0
- package/esm/interaction/native/brushAxisHighlight.js.map +1 -0
- package/esm/interaction/native/brushFilter.d.ts +12 -0
- package/esm/interaction/native/brushFilter.js +147 -0
- package/esm/interaction/native/brushFilter.js.map +1 -0
- package/esm/interaction/native/brushHighlight.d.ts +40 -0
- package/esm/interaction/native/brushHighlight.js +341 -0
- package/esm/interaction/native/brushHighlight.js.map +1 -0
- package/esm/interaction/native/brushXFilter.d.ts +1 -0
- package/esm/interaction/native/brushXFilter.js +6 -0
- package/esm/interaction/native/brushXFilter.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +6 -0
- package/esm/interaction/native/brushXHighlight.js +9 -0
- package/esm/interaction/native/brushXHighlight.js.map +1 -0
- package/esm/interaction/native/brushYFilter.d.ts +1 -0
- package/esm/interaction/native/brushYFilter.js +6 -0
- package/esm/interaction/native/brushYFilter.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +6 -0
- package/esm/interaction/native/brushYHighlight.js +9 -0
- package/esm/interaction/native/brushYHighlight.js.map +1 -0
- package/esm/interaction/native/legendFilter.js +3 -12
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/tooltip.js +101 -32
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +8 -0
- package/esm/interaction/native/utils.js +31 -0
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/contrastReverse.d.ts +9 -0
- package/esm/label-transform/contrastReverse.js +48 -0
- package/esm/label-transform/contrastReverse.js.map +1 -0
- package/esm/label-transform/index.d.ts +8 -8
- package/esm/label-transform/index.js +4 -4
- package/esm/label-transform/index.js.map +1 -1
- package/esm/label-transform/overflowHide.d.ts +7 -0
- package/esm/label-transform/overflowHide.js +18 -0
- package/esm/label-transform/overflowHide.js.map +1 -0
- package/esm/label-transform/overlapDodgeY.d.ts +7 -0
- package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
- package/esm/label-transform/overlapDodgeY.js.map +1 -0
- package/esm/label-transform/overlapHide.d.ts +7 -0
- package/esm/label-transform/overlapHide.js +24 -0
- package/esm/label-transform/overlapHide.js.map +1 -0
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/boxplot.js +5 -18
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/runtime/component.js +33 -38
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +7 -7
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +28 -6
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +0 -1
- package/esm/runtime/render.js +4 -34
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js +17 -5
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +16 -6
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +27 -9
- package/esm/runtime/types/options.d.ts +3 -5
- package/esm/runtime/types/theme.d.ts +2 -5
- package/esm/shape/area/curve.js +15 -8
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/box/box.js +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/connector/connector.js +2 -2
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/image/image.js +2 -2
- package/esm/shape/image/image.js.map +1 -1
- package/esm/shape/interval/color.js +3 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/label/label.js +3 -3
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/area.d.ts +13 -0
- package/esm/shape/label/position/area.js +28 -0
- package/esm/shape/label/position/area.js.map +1 -0
- package/esm/shape/label/position/bottom.d.ts +1 -0
- package/esm/shape/label/position/bottom.js +2 -0
- package/esm/shape/label/position/bottom.js.map +1 -0
- package/esm/shape/label/position/bottomLeft.d.ts +1 -0
- package/esm/shape/label/position/bottomLeft.js +2 -0
- package/esm/shape/label/position/bottomLeft.js.map +1 -0
- package/esm/shape/label/position/bottomRight.d.ts +1 -0
- package/esm/shape/label/position/bottomRight.js +2 -0
- package/esm/shape/label/position/bottomRight.js.map +1 -0
- package/esm/shape/label/position/default.d.ts +18 -0
- package/esm/shape/label/position/default.js +107 -0
- package/esm/shape/label/position/default.js.map +1 -0
- package/esm/shape/label/position/index.d.ts +13 -0
- package/esm/shape/label/position/index.js +14 -0
- package/esm/shape/label/position/index.js.map +1 -0
- package/esm/shape/label/position/inside.d.ts +1 -0
- package/esm/shape/label/position/inside.js +2 -0
- package/esm/shape/label/position/inside.js.map +1 -0
- package/esm/shape/label/position/left.d.ts +1 -0
- package/esm/shape/label/position/left.js +2 -0
- package/esm/shape/label/position/left.js.map +1 -0
- package/esm/shape/label/position/outside.d.ts +18 -0
- package/esm/shape/label/position/outside.js +67 -0
- package/esm/shape/label/position/outside.js.map +1 -0
- package/esm/shape/label/position/right.d.ts +1 -0
- package/esm/shape/label/position/right.js +2 -0
- package/esm/shape/label/position/right.js.map +1 -0
- package/esm/shape/label/position/spider.d.ts +7 -0
- package/esm/shape/label/position/spider.js +34 -0
- package/esm/shape/label/position/spider.js.map +1 -0
- package/esm/shape/label/position/surround.d.ts +7 -0
- package/esm/shape/label/position/surround.js +35 -0
- package/esm/shape/label/position/surround.js.map +1 -0
- package/esm/shape/label/position/top.d.ts +1 -0
- package/esm/shape/label/position/top.js +2 -0
- package/esm/shape/label/position/top.js.map +1 -0
- package/esm/shape/label/position/topLeft.d.ts +1 -0
- package/esm/shape/label/position/topLeft.js +2 -0
- package/esm/shape/label/position/topLeft.js.map +1 -0
- package/esm/shape/label/position/topRight.d.ts +1 -0
- package/esm/shape/label/position/topRight.js +2 -0
- package/esm/shape/label/position/topRight.js.map +1 -0
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/lineXY/line.js +2 -2
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/link/arc.js +2 -2
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/link.js +2 -2
- package/esm/shape/link/link.js.map +1 -1
- package/esm/shape/link/smooth.js +2 -2
- package/esm/shape/link/smooth.js.map +1 -1
- package/esm/shape/link/vhv.js +2 -2
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/point/color.js +1 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/polygon/polygon.js +3 -3
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js +3 -3
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +3 -3
- package/esm/shape/text/badge.js.map +1 -1
- package/esm/shape/text/text.js +1 -1
- package/esm/shape/text/text.js.map +1 -1
- package/esm/shape/utils.d.ts +4 -0
- package/esm/shape/utils.js +6 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js +3 -3
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/composition.d.ts +2 -0
- package/esm/spec/data.d.ts +24 -9
- package/esm/spec/geometry.d.ts +2 -1
- package/esm/spec/interaction.d.ts +41 -6
- package/esm/spec/labelTransform.d.ts +24 -11
- package/esm/spec/theme.d.ts +5 -2
- package/esm/stdlib/index.js +8 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.d.ts +3 -0
- package/esm/theme/academy.js +398 -0
- package/esm/theme/academy.js.map +1 -0
- package/esm/theme/dark.js +14 -20
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/index.js.map +1 -1
- package/esm/theme/light.js +29 -22
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/maybeTooltip.js +3 -1
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/utils/bounds.d.ts +26 -0
- package/esm/utils/bounds.js +41 -0
- package/esm/utils/bounds.js.map +1 -0
- package/esm/utils/color.d.ts +6 -0
- package/esm/utils/color.js +7 -0
- package/esm/utils/color.js.map +1 -0
- package/esm/utils/coordinate.d.ts +1 -0
- package/esm/utils/coordinate.js +12 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +3 -0
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/chart.d.ts +4 -0
- package/lib/api/chart.js +26 -4
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/mark.js +1 -2
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -2
- package/lib/component/axis.js +23 -9
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +2 -0
- package/lib/component/index.js +5 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/scrollbar.d.ts +9 -0
- package/lib/component/scrollbar.js +40 -0
- package/lib/component/scrollbar.js.map +1 -0
- package/lib/component/scrollbarX.d.ts +7 -0
- package/lib/component/scrollbarX.js +13 -0
- package/lib/component/scrollbarX.js.map +1 -0
- package/lib/component/scrollbarY.d.ts +7 -0
- package/lib/component/scrollbarY.js +13 -0
- package/lib/component/scrollbarY.js.map +1 -0
- package/lib/component/slider.js +2 -4
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js +46 -22
- package/lib/component/title.js.map +1 -1
- package/lib/composition/mark.js +2 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/data/fold.js +4 -10
- package/lib/data/fold.js.map +1 -1
- package/lib/data/index.d.ts +2 -2
- package/lib/data/index.js +3 -3
- package/lib/data/index.js.map +1 -1
- package/lib/data/pick.js +10 -2
- package/lib/data/pick.js.map +1 -1
- package/lib/data/slice.d.ts +8 -0
- package/lib/data/slice.js +14 -0
- package/lib/data/slice.js.map +1 -0
- package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
- package/lib/interaction/index.d.ts +8 -0
- package/lib/interaction/index.js +15 -31
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/lib/interaction/native/brushAxisHighlight.js +164 -0
- package/lib/interaction/native/brushAxisHighlight.js.map +1 -0
- package/lib/interaction/native/brushFilter.d.ts +12 -0
- package/lib/interaction/native/brushFilter.js +152 -0
- package/lib/interaction/native/brushFilter.js.map +1 -0
- package/lib/interaction/native/brushHighlight.d.ts +40 -0
- package/lib/interaction/native/brushHighlight.js +347 -0
- package/lib/interaction/native/brushHighlight.js.map +1 -0
- package/lib/interaction/native/brushXFilter.d.ts +1 -0
- package/lib/interaction/native/brushXFilter.js +10 -0
- package/lib/interaction/native/brushXFilter.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +6 -0
- package/lib/interaction/native/brushXHighlight.js +14 -0
- package/lib/interaction/native/brushXHighlight.js.map +1 -0
- package/lib/interaction/native/brushYFilter.d.ts +1 -0
- package/lib/interaction/native/brushYFilter.js +10 -0
- package/lib/interaction/native/brushYFilter.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +6 -0
- package/lib/interaction/native/brushYHighlight.js +14 -0
- package/lib/interaction/native/brushYHighlight.js.map +1 -0
- package/lib/interaction/native/legendFilter.js +4 -13
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/tooltip.js +98 -29
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +8 -0
- package/lib/interaction/native/utils.js +37 -1
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/contrastReverse.d.ts +9 -0
- package/lib/label-transform/contrastReverse.js +52 -0
- package/lib/label-transform/contrastReverse.js.map +1 -0
- package/lib/label-transform/index.d.ts +8 -8
- package/lib/label-transform/index.js +9 -9
- package/lib/label-transform/index.js.map +1 -1
- package/lib/label-transform/overflowHide.d.ts +7 -0
- package/lib/label-transform/overflowHide.js +22 -0
- package/lib/label-transform/overflowHide.js.map +1 -0
- package/lib/label-transform/overlapDodgeY.d.ts +7 -0
- package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
- package/lib/label-transform/overlapDodgeY.js.map +1 -0
- package/lib/label-transform/overlapHide.d.ts +7 -0
- package/lib/label-transform/overlapHide.js +28 -0
- package/lib/label-transform/overlapHide.js.map +1 -0
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/boxplot.js +5 -18
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/runtime/component.js +33 -38
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +7 -7
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +28 -6
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +0 -1
- package/lib/runtime/render.js +4 -35
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +16 -4
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +16 -6
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +27 -9
- package/lib/runtime/types/options.d.ts +3 -5
- package/lib/runtime/types/theme.d.ts +2 -5
- package/lib/shape/area/curve.js +14 -7
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/box/box.js +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/connector/connector.js +2 -2
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/image/image.js +2 -2
- package/lib/shape/image/image.js.map +1 -1
- package/lib/shape/interval/color.js +3 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/label/label.js +3 -3
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.d.ts +13 -0
- package/lib/shape/label/position/area.js +32 -0
- package/lib/shape/label/position/area.js.map +1 -0
- package/lib/shape/label/position/bottom.d.ts +1 -0
- package/lib/shape/label/position/bottom.js +6 -0
- package/lib/shape/label/position/bottom.js.map +1 -0
- package/lib/shape/label/position/bottomLeft.d.ts +1 -0
- package/lib/shape/label/position/bottomLeft.js +6 -0
- package/lib/shape/label/position/bottomLeft.js.map +1 -0
- package/lib/shape/label/position/bottomRight.d.ts +1 -0
- package/lib/shape/label/position/bottomRight.js +6 -0
- package/lib/shape/label/position/bottomRight.js.map +1 -0
- package/lib/shape/label/position/default.d.ts +18 -0
- package/lib/shape/label/{position.js → position/default.js} +24 -81
- package/lib/shape/label/position/default.js.map +1 -0
- package/lib/shape/label/position/index.d.ts +13 -0
- package/lib/shape/label/position/index.js +30 -0
- package/lib/shape/label/position/index.js.map +1 -0
- package/lib/shape/label/position/inside.d.ts +1 -0
- package/lib/shape/label/position/inside.js +6 -0
- package/lib/shape/label/position/inside.js.map +1 -0
- package/lib/shape/label/position/left.d.ts +1 -0
- package/lib/shape/label/position/left.js +6 -0
- package/lib/shape/label/position/left.js.map +1 -0
- package/lib/shape/label/position/outside.d.ts +18 -0
- package/lib/shape/label/position/outside.js +75 -0
- package/lib/shape/label/position/outside.js.map +1 -0
- package/lib/shape/label/position/right.d.ts +1 -0
- package/lib/shape/label/position/right.js +6 -0
- package/lib/shape/label/position/right.js.map +1 -0
- package/lib/shape/label/position/spider.d.ts +7 -0
- package/lib/shape/label/position/spider.js +38 -0
- package/lib/shape/label/position/spider.js.map +1 -0
- package/lib/shape/label/position/surround.d.ts +7 -0
- package/lib/shape/label/position/surround.js +39 -0
- package/lib/shape/label/position/surround.js.map +1 -0
- package/lib/shape/label/position/top.d.ts +1 -0
- package/lib/shape/label/position/top.js +6 -0
- package/lib/shape/label/position/top.js.map +1 -0
- package/lib/shape/label/position/topLeft.d.ts +1 -0
- package/lib/shape/label/position/topLeft.js +6 -0
- package/lib/shape/label/position/topLeft.js.map +1 -0
- package/lib/shape/label/position/topRight.d.ts +1 -0
- package/lib/shape/label/position/topRight.js +6 -0
- package/lib/shape/label/position/topRight.js.map +1 -0
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/lineXY/line.js +2 -2
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/link/arc.js +2 -2
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/link.js +2 -2
- package/lib/shape/link/link.js.map +1 -1
- package/lib/shape/link/smooth.js +2 -2
- package/lib/shape/link/smooth.js.map +1 -1
- package/lib/shape/link/vhv.js +2 -2
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/point/color.js +1 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/polygon/polygon.js +3 -3
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js +3 -3
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +3 -3
- package/lib/shape/text/badge.js.map +1 -1
- package/lib/shape/text/text.js +1 -1
- package/lib/shape/text/text.js.map +1 -1
- package/lib/shape/utils.d.ts +4 -0
- package/lib/shape/utils.js +6 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js +3 -3
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/composition.d.ts +2 -0
- package/lib/spec/data.d.ts +24 -9
- package/lib/spec/geometry.d.ts +2 -1
- package/lib/spec/interaction.d.ts +41 -6
- package/lib/spec/labelTransform.d.ts +24 -11
- package/lib/spec/theme.d.ts +5 -2
- package/lib/stdlib/index.js +3 -4
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.d.ts +3 -0
- package/lib/theme/academy.js +402 -0
- package/lib/theme/academy.js.map +1 -0
- package/lib/theme/dark.js +14 -20
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +3 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/light.js +29 -22
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/maybeTooltip.js +3 -1
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/utils/bounds.d.ts +26 -0
- package/lib/utils/bounds.js +48 -0
- package/lib/utils/bounds.js.map +1 -0
- package/lib/utils/color.d.ts +6 -0
- package/lib/utils/color.js +11 -0
- package/lib/utils/color.js.map +1 -0
- package/lib/utils/coordinate.d.ts +1 -0
- package/lib/utils/coordinate.js +14 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +5 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +2 -2
- package/src/api/chart.ts +29 -8
- package/src/api/mark/mark.ts +1 -2
- package/src/api/mark/types.ts +1 -2
- package/src/component/axis.ts +38 -16
- package/src/component/index.ts +2 -0
- package/src/component/scrollbar.ts +41 -0
- package/src/component/scrollbarX.ts +16 -0
- package/src/component/scrollbarY.ts +16 -0
- package/src/component/slider.ts +1 -3
- package/src/component/title.ts +69 -30
- package/src/composition/mark.ts +2 -0
- package/src/data/fold.ts +6 -10
- package/src/data/index.ts +2 -2
- package/src/data/pick.ts +11 -2
- package/src/data/slice.ts +15 -0
- package/src/interaction/index.ts +23 -16
- package/src/interaction/native/brushAxisHighlight.ts +194 -0
- package/src/interaction/native/brushFilter.ts +163 -0
- package/src/interaction/native/brushHighlight.ts +419 -0
- package/src/interaction/native/brushXFilter.ts +9 -0
- package/src/interaction/native/brushXHighlight.ts +13 -0
- package/src/interaction/native/brushYFilter.ts +9 -0
- package/src/interaction/native/brushYHighlight.ts +13 -0
- package/src/interaction/native/legendFilter.ts +3 -14
- package/src/interaction/native/tooltip.ts +128 -38
- package/src/interaction/native/utils.ts +40 -0
- package/src/label-transform/contrastReverse.ts +56 -0
- package/src/label-transform/index.ts +8 -8
- package/src/label-transform/overflowHide.ts +23 -0
- package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
- package/src/label-transform/overlapHide.ts +32 -0
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +3 -1
- package/src/runtime/component.ts +46 -47
- package/src/runtime/layout.ts +6 -6
- package/src/runtime/plot.ts +40 -6
- package/src/runtime/render.ts +6 -58
- package/src/runtime/scale.ts +15 -7
- package/src/runtime/transform.ts +19 -6
- package/src/runtime/types/common.ts +27 -10
- package/src/runtime/types/options.ts +3 -5
- package/src/runtime/types/theme.ts +2 -5
- package/src/shape/area/curve.ts +15 -8
- package/src/shape/box/box.ts +6 -6
- package/src/shape/connector/connector.ts +2 -3
- package/src/shape/image/image.ts +2 -2
- package/src/shape/interval/color.ts +2 -1
- package/src/shape/label/label.ts +4 -3
- package/src/shape/label/position/area.ts +39 -0
- package/src/shape/label/position/bottom.ts +1 -0
- package/src/shape/label/position/bottomLeft.ts +1 -0
- package/src/shape/label/position/bottomRight.ts +1 -0
- package/src/shape/label/{position.ts → position/default.ts} +26 -110
- package/src/shape/label/position/index.ts +13 -0
- package/src/shape/label/position/inside.ts +1 -0
- package/src/shape/label/position/left.ts +1 -0
- package/src/shape/label/position/outside.ts +121 -0
- package/src/shape/label/position/right.ts +1 -0
- package/src/shape/label/position/spider.ts +39 -0
- package/src/shape/label/position/surround.ts +40 -0
- package/src/shape/label/position/top.ts +1 -0
- package/src/shape/label/position/topLeft.ts +1 -0
- package/src/shape/label/position/topRight.ts +1 -0
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/lineXY/line.ts +2 -2
- package/src/shape/link/arc.ts +2 -2
- package/src/shape/link/link.ts +2 -2
- package/src/shape/link/smooth.ts +2 -2
- package/src/shape/link/vhv.ts +2 -2
- package/src/shape/point/color.ts +6 -5
- package/src/shape/polygon/polygon.ts +3 -3
- package/src/shape/polygon/ribbon.ts +3 -3
- package/src/shape/text/advance.ts +4 -1
- package/src/shape/text/badge.ts +8 -3
- package/src/shape/text/text.ts +1 -1
- package/src/shape/utils.ts +6 -5
- package/src/shape/vector/vector.ts +3 -3
- package/src/spec/action.ts +0 -1
- package/src/spec/composition.ts +2 -0
- package/src/spec/data.ts +25 -10
- package/src/spec/geometry.ts +3 -1
- package/src/spec/interaction.ts +59 -5
- package/src/spec/labelTransform.ts +29 -11
- package/src/spec/theme.ts +6 -2
- package/src/stdlib/index.ts +33 -9
- package/src/theme/academy.ts +404 -0
- package/src/theme/dark.ts +14 -20
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +29 -22
- package/src/transform/maybeTooltip.ts +3 -1
- package/src/utils/bounds.ts +52 -0
- package/src/utils/color.ts +12 -0
- package/src/utils/coordinate.ts +12 -0
- package/src/utils/helper.ts +4 -0
- package/esm/data/subset.d.ts +0 -7
- package/esm/data/subset.js +0 -26
- package/esm/data/subset.js.map +0 -1
- package/esm/label-transform/dodgeY.d.ts +0 -7
- package/esm/label-transform/dodgeY.js.map +0 -1
- package/esm/label-transform/hideOverlap.d.ts +0 -4
- package/esm/label-transform/hideOverlap.js +0 -48
- package/esm/label-transform/hideOverlap.js.map +0 -1
- package/esm/label-transform/spider.d.ts +0 -7
- package/esm/label-transform/spider.js +0 -30
- package/esm/label-transform/spider.js.map +0 -1
- package/esm/label-transform/surround.d.ts +0 -7
- package/esm/label-transform/surround.js +0 -30
- package/esm/label-transform/surround.js.map +0 -1
- package/esm/shape/label/position.d.ts +0 -25
- package/esm/shape/label/position.js +0 -169
- package/esm/shape/label/position.js.map +0 -1
- package/lib/data/subset.d.ts +0 -7
- package/lib/data/subset.js +0 -30
- package/lib/data/subset.js.map +0 -1
- package/lib/label-transform/dodgeY.d.ts +0 -7
- package/lib/label-transform/dodgeY.js.map +0 -1
- package/lib/label-transform/hideOverlap.d.ts +0 -4
- package/lib/label-transform/hideOverlap.js +0 -52
- package/lib/label-transform/hideOverlap.js.map +0 -1
- package/lib/label-transform/spider.d.ts +0 -7
- package/lib/label-transform/spider.js +0 -34
- package/lib/label-transform/spider.js.map +0 -1
- package/lib/label-transform/surround.d.ts +0 -7
- package/lib/label-transform/surround.js +0 -34
- package/lib/label-transform/surround.js.map +0 -1
- package/lib/shape/label/position.d.ts +0 -25
- package/lib/shape/label/position.js.map +0 -1
- package/src/data/subset.ts +0 -35
- package/src/label-transform/hideOverlap.ts +0 -62
- package/src/label-transform/spider.ts +0 -37
- package/src/label-transform/surround.ts +0 -37
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { deepMix } from '@antv/util';
|
|
2
|
+
import { bisectLeft, sort } from 'd3-array';
|
|
3
|
+
import { subObject } from '../../utils/helper';
|
|
4
|
+
import { selectPlotArea } from './utils';
|
|
5
|
+
import { brush as createBrush } from './brushHighlight';
|
|
6
|
+
|
|
7
|
+
// Mock dblclick events.
|
|
8
|
+
function dblclick(interval = 300) {
|
|
9
|
+
let preTimeStamp = null;
|
|
10
|
+
return (e) => {
|
|
11
|
+
const { timeStamp } = e;
|
|
12
|
+
if (preTimeStamp !== null && timeStamp - preTimeStamp < interval) {
|
|
13
|
+
preTimeStamp = timeStamp;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
preTimeStamp = timeStamp;
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function brushFilter(
|
|
22
|
+
root,
|
|
23
|
+
{
|
|
24
|
+
filter,
|
|
25
|
+
reset,
|
|
26
|
+
brushRegion,
|
|
27
|
+
extent: optionalExtent,
|
|
28
|
+
reverse,
|
|
29
|
+
series = false,
|
|
30
|
+
...rest
|
|
31
|
+
},
|
|
32
|
+
) {
|
|
33
|
+
const brushStyle = subObject(rest, 'mask');
|
|
34
|
+
const { width: rootWidth, height: rootHeight } = root.getBBox();
|
|
35
|
+
const extent = optionalExtent
|
|
36
|
+
? optionalExtent
|
|
37
|
+
: [0, 0, rootWidth, rootHeight];
|
|
38
|
+
const isDblclick = dblclick();
|
|
39
|
+
|
|
40
|
+
const brush = createBrush(root, {
|
|
41
|
+
...brushStyle,
|
|
42
|
+
extent,
|
|
43
|
+
brushRegion,
|
|
44
|
+
reverse,
|
|
45
|
+
brushcreated,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
root.addEventListener('click', click);
|
|
49
|
+
|
|
50
|
+
// Filter when brush created.
|
|
51
|
+
function brushcreated(x, y, x1, y1) {
|
|
52
|
+
filter(x, y, x1, y1);
|
|
53
|
+
brush.remove();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Reset when dblclick.
|
|
57
|
+
function click(e) {
|
|
58
|
+
if (isDblclick(e)) reset();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
brush.destroy();
|
|
63
|
+
root.removeEventListener('dblclick', click);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isOrdinalScale(scale) {
|
|
68
|
+
return scale.getBandWidth;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function constrain(x, lo, hi) {
|
|
72
|
+
return Math.min(hi, Math.max(lo, x));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function invert(scale, x, start) {
|
|
76
|
+
if (!isOrdinalScale(scale)) return scale.invert(x);
|
|
77
|
+
const { adjustedRange } = scale;
|
|
78
|
+
const { domain } = scale.getOptions();
|
|
79
|
+
const offset = start ? -1 : 0;
|
|
80
|
+
const step = scale.getStep();
|
|
81
|
+
const range = start ? adjustedRange : adjustedRange.map((d) => d + step);
|
|
82
|
+
// R[i0 - 1] < x <= R[i0]
|
|
83
|
+
const i0 = bisectLeft(range, x);
|
|
84
|
+
const i1 = constrain(i0 + offset, 0, domain.length - 1);
|
|
85
|
+
return domain[i1];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function domainOf(scale, values) {
|
|
89
|
+
if (!isOrdinalScale(scale)) return sort(values);
|
|
90
|
+
const { domain } = scale.getOptions();
|
|
91
|
+
const [v1, v2] = values;
|
|
92
|
+
const start = domain.indexOf(v1);
|
|
93
|
+
const end = domain.indexOf(v2);
|
|
94
|
+
return domain.slice(start, end + 1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function BrushFilter({ ...rest }) {
|
|
98
|
+
return (target, viewInstances) => {
|
|
99
|
+
const { container, view, options: viewOptions, update } = target;
|
|
100
|
+
const plotArea = selectPlotArea(container);
|
|
101
|
+
const defaultOptions = {
|
|
102
|
+
maskFill: '#777',
|
|
103
|
+
maskFillOpacity: '0.3',
|
|
104
|
+
maskStroke: '#fff',
|
|
105
|
+
unhighlightedOpacity: 0.5,
|
|
106
|
+
reverse: false,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
let filtered = false;
|
|
110
|
+
let filtering = false;
|
|
111
|
+
let newView = view;
|
|
112
|
+
|
|
113
|
+
return brushFilter(plotArea, {
|
|
114
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
115
|
+
filter: async (x, y, x1, y1) => {
|
|
116
|
+
// Avoid redundant filter.
|
|
117
|
+
if (filtering) return;
|
|
118
|
+
filtering = true;
|
|
119
|
+
|
|
120
|
+
// Invert visual range to abstract domain.
|
|
121
|
+
const { scale, coordinate } = newView;
|
|
122
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
123
|
+
const abstractDomain = (point, start) => {
|
|
124
|
+
const [x, y] = coordinate.invert(point);
|
|
125
|
+
return [invert(scaleX, x, start), invert(scaleY, y, start)];
|
|
126
|
+
};
|
|
127
|
+
const p0 = abstractDomain([x, y], true);
|
|
128
|
+
const p1 = abstractDomain([x1, y1], false);
|
|
129
|
+
|
|
130
|
+
// Update the domain of x and y scale to filter data.
|
|
131
|
+
const { marks } = viewOptions;
|
|
132
|
+
const newMarks = marks.map((mark) =>
|
|
133
|
+
deepMix({}, mark, {
|
|
134
|
+
scale: {
|
|
135
|
+
x: { domain: domainOf(scaleX, [p0[0], p1[0]]) },
|
|
136
|
+
y: { domain: domainOf(scaleY, [p0[1], p1[1]]) },
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// Rerender and update view.
|
|
142
|
+
const newOptions = {
|
|
143
|
+
...viewOptions,
|
|
144
|
+
marks: newMarks,
|
|
145
|
+
clip: true, // Clip shapes out of plot area.
|
|
146
|
+
};
|
|
147
|
+
const newState = await update(newOptions);
|
|
148
|
+
newView = newState.view;
|
|
149
|
+
filtering = false;
|
|
150
|
+
filtered = true;
|
|
151
|
+
},
|
|
152
|
+
reset: () => {
|
|
153
|
+
if (filtering || !filtered) return;
|
|
154
|
+
filtered = false;
|
|
155
|
+
newView = view;
|
|
156
|
+
update(viewOptions);
|
|
157
|
+
},
|
|
158
|
+
extent: undefined,
|
|
159
|
+
...defaultOptions,
|
|
160
|
+
...rest,
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { DisplayObject, Rect, Path } from '@antv/g';
|
|
2
|
+
import { subObject } from '../../utils/helper';
|
|
3
|
+
import {
|
|
4
|
+
selectG2Elements,
|
|
5
|
+
selectPlotArea,
|
|
6
|
+
createDatumof,
|
|
7
|
+
useState,
|
|
8
|
+
createValueof,
|
|
9
|
+
setCursor,
|
|
10
|
+
brushMousePosition,
|
|
11
|
+
selectFacetG2Elements,
|
|
12
|
+
} from './utils';
|
|
13
|
+
|
|
14
|
+
function intersect(bbox1: any, bbox2: any) {
|
|
15
|
+
const [minX1, minY1, maxX1, maxY1] = bbox1;
|
|
16
|
+
const [minX2, minY2, maxX2, maxY2] = bbox2;
|
|
17
|
+
return !(minX2 > maxX1 || maxX2 < minX1 || minY2 > maxY1 || maxY2 < minY1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeBounds(x, y, x1, y1, extent) {
|
|
21
|
+
const [minX, minY, maxX, maxY] = extent;
|
|
22
|
+
return [
|
|
23
|
+
Math.max(minX, Math.min(x, x1)),
|
|
24
|
+
Math.max(minY, Math.min(y, y1)),
|
|
25
|
+
Math.min(maxX, Math.max(x, x1)),
|
|
26
|
+
Math.min(maxY, Math.max(y, y1)),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function bboxOf(root: DisplayObject) {
|
|
31
|
+
const { width, height } = root.getBBox();
|
|
32
|
+
return [0, 0, width, height];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function brush(
|
|
36
|
+
root: DisplayObject,
|
|
37
|
+
{
|
|
38
|
+
brushed = () => {},
|
|
39
|
+
brushended = () => {},
|
|
40
|
+
brushcreated = () => {},
|
|
41
|
+
extent = bboxOf(root),
|
|
42
|
+
brushRegion = (x, y, x1, y1, extent) => [x, y, x1, y1],
|
|
43
|
+
reverse = false,
|
|
44
|
+
fill = '#777',
|
|
45
|
+
fillOpacity = '0.3',
|
|
46
|
+
stroke = '#fff',
|
|
47
|
+
...style
|
|
48
|
+
}: Record<string, any>,
|
|
49
|
+
) {
|
|
50
|
+
let start = null; // Start point of mask.
|
|
51
|
+
let end = null; // End point of mask.
|
|
52
|
+
let moveStart = null; // Start point of moving mask.
|
|
53
|
+
let mask = null; // Mask instance.
|
|
54
|
+
let background = null;
|
|
55
|
+
let resizing = false;
|
|
56
|
+
|
|
57
|
+
const [originX, originY, width, height] = extent;
|
|
58
|
+
|
|
59
|
+
setCursor(root, 'crosshair');
|
|
60
|
+
root.style.draggable = true; // Make it response to drag event.
|
|
61
|
+
|
|
62
|
+
// Remove old mask and init new mask.
|
|
63
|
+
const initMask = (x, y) => {
|
|
64
|
+
if (mask) mask.remove();
|
|
65
|
+
if (background) background.remove();
|
|
66
|
+
start = [x, y];
|
|
67
|
+
if (reverse) return initReverseMask();
|
|
68
|
+
initNormalMask();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const initReverseMask = () => {
|
|
72
|
+
background = new Path({
|
|
73
|
+
style: {
|
|
74
|
+
...style,
|
|
75
|
+
fill,
|
|
76
|
+
fillOpacity,
|
|
77
|
+
stroke,
|
|
78
|
+
pointerEvents: 'none',
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
mask = new Rect({
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
style: {
|
|
84
|
+
draggable: true,
|
|
85
|
+
fill: 'transparent',
|
|
86
|
+
},
|
|
87
|
+
className: 'mask',
|
|
88
|
+
});
|
|
89
|
+
root.appendChild(background);
|
|
90
|
+
root.appendChild(mask);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const initNormalMask = () => {
|
|
94
|
+
mask = new Rect({
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
style: {
|
|
97
|
+
...style,
|
|
98
|
+
fill,
|
|
99
|
+
fillOpacity,
|
|
100
|
+
stroke,
|
|
101
|
+
draggable: true, // Make it response to drag event.
|
|
102
|
+
},
|
|
103
|
+
className: 'mask',
|
|
104
|
+
});
|
|
105
|
+
root.appendChild(mask);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Remove mask and reset states.
|
|
109
|
+
const removeMask = () => {
|
|
110
|
+
if (mask) mask.remove();
|
|
111
|
+
if (background) background.remove();
|
|
112
|
+
start = null;
|
|
113
|
+
end = null;
|
|
114
|
+
moveStart = null;
|
|
115
|
+
resizing = false;
|
|
116
|
+
mask = null;
|
|
117
|
+
background = null;
|
|
118
|
+
brushended();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Update mask and invoke brushended callback.
|
|
122
|
+
const updateMask = (start, end) => {
|
|
123
|
+
const [x, y, x1, y1] = normalizeBounds(
|
|
124
|
+
start[0],
|
|
125
|
+
start[1],
|
|
126
|
+
end[0],
|
|
127
|
+
end[1],
|
|
128
|
+
extent,
|
|
129
|
+
);
|
|
130
|
+
const [fx, fy, fx1, fy1] = brushRegion(x, y, x1, y1, extent);
|
|
131
|
+
if (reverse) updateReverseMask(fx, fy, fx1, fy1);
|
|
132
|
+
else updateNormalMask(fx, fy, fx1, fy1);
|
|
133
|
+
brushed(fx, fy, fx1, fy1);
|
|
134
|
+
return [fx, fy, fx1, fy1];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const updateNormalMask = (x, y, x1, y1) => {
|
|
138
|
+
mask.style.x = x;
|
|
139
|
+
mask.style.y = y;
|
|
140
|
+
mask.style.width = x1 - x;
|
|
141
|
+
mask.style.height = y1 - y;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const updateReverseMask = (x, y, x1, y1) => {
|
|
145
|
+
background.style.d = `
|
|
146
|
+
M${originX},${originY}L${width},${originY}L${width},${height}L${originX},${height}Z
|
|
147
|
+
M${x},${y}L${x},${y1}L${x1},${y1}L${x1},${y}Z
|
|
148
|
+
`;
|
|
149
|
+
mask.style.x = x;
|
|
150
|
+
mask.style.y = y;
|
|
151
|
+
mask.style.width = x1 - x;
|
|
152
|
+
mask.style.height = y1 - y;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// Move and update mask.
|
|
156
|
+
const moveMask = (current) => {
|
|
157
|
+
const clip = (dt, start, end, min, max) => {
|
|
158
|
+
if (dt + start < min) return min - start;
|
|
159
|
+
if (dt + end > max) return max - end;
|
|
160
|
+
return dt;
|
|
161
|
+
};
|
|
162
|
+
const dx = current[0] - moveStart[0];
|
|
163
|
+
const dy = current[1] - moveStart[1];
|
|
164
|
+
const dx1 = clip(dx, start[0], end[0], originX, width);
|
|
165
|
+
const dy1 = clip(dy, start[1], end[1], originY, height);
|
|
166
|
+
const currentStart = [start[0] + dx1, start[1] + dy1];
|
|
167
|
+
const currentEnd = [end[0] + dx1, end[1] + dy1];
|
|
168
|
+
updateMask(currentStart, currentEnd);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// If target is plot area, create mask.
|
|
172
|
+
// If target is mask, about to update position.
|
|
173
|
+
const dragstart = (event) => {
|
|
174
|
+
const { target } = event;
|
|
175
|
+
const [offsetX, offsetY] = brushMousePosition(root, event);
|
|
176
|
+
if (target === mask) {
|
|
177
|
+
moveStart = [offsetX, offsetY];
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
initMask(offsetX, offsetY);
|
|
181
|
+
resizing = true;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// If target is plot area, resize mask.
|
|
185
|
+
// If target is mask, move mask.
|
|
186
|
+
const drag = (event) => {
|
|
187
|
+
const mouse = brushMousePosition(root, event);
|
|
188
|
+
if (!start) return;
|
|
189
|
+
if (moveStart) return moveMask(mouse);
|
|
190
|
+
updateMask(start, mouse);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// If target is plot area, finish resizing.
|
|
194
|
+
// If target is mask, finish moving mask.
|
|
195
|
+
const dragend = (event) => {
|
|
196
|
+
if (moveStart) {
|
|
197
|
+
moveStart = null;
|
|
198
|
+
// Update start and end;
|
|
199
|
+
const { x, y, width, height } = mask.style;
|
|
200
|
+
start = [x, y];
|
|
201
|
+
end = [x + width, y + height];
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
end = brushMousePosition(root, event);
|
|
205
|
+
const [fx, fy, fx1, fy1] = updateMask(start, end);
|
|
206
|
+
resizing = false;
|
|
207
|
+
brushcreated(fx, fy, fx1, fy1);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Hide mask.
|
|
211
|
+
const click = (event) => {
|
|
212
|
+
const { target } = event;
|
|
213
|
+
if (mask && target !== mask) removeMask();
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Update cursor depends on hovered element.
|
|
217
|
+
const pointermove = (event) => {
|
|
218
|
+
const { target } = event;
|
|
219
|
+
if (target === mask && !resizing) setCursor(root, 'move');
|
|
220
|
+
else setCursor(root, 'crosshair');
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const pointerleave = () => {
|
|
224
|
+
setCursor(root, 'default');
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
root.addEventListener('dragstart', dragstart);
|
|
228
|
+
root.addEventListener('drag', drag);
|
|
229
|
+
root.addEventListener('dragend', dragend);
|
|
230
|
+
root.addEventListener('click', click);
|
|
231
|
+
root.addEventListener('pointermove', pointermove);
|
|
232
|
+
root.addEventListener('pointerleave', pointerleave);
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
mask,
|
|
236
|
+
remove() {
|
|
237
|
+
if (mask) removeMask();
|
|
238
|
+
},
|
|
239
|
+
destroy() {
|
|
240
|
+
if (mask) removeMask();
|
|
241
|
+
root.removeEventListener('dragstart', dragstart);
|
|
242
|
+
root.removeEventListener('drag', drag);
|
|
243
|
+
root.removeEventListener('dragend', dragend);
|
|
244
|
+
root.removeEventListener('click', click);
|
|
245
|
+
root.removeEventListener('pointermove', pointermove);
|
|
246
|
+
root.removeEventListener('pointerleave', pointerleave);
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function selectSiblingContainers(target, viewInstances, brushKey) {
|
|
252
|
+
return viewInstances
|
|
253
|
+
.filter((d) => {
|
|
254
|
+
if (d === target) return false;
|
|
255
|
+
const { interactions = [] } = d.options;
|
|
256
|
+
return interactions.find((d) => d.brushKey === brushKey);
|
|
257
|
+
})
|
|
258
|
+
.map((d) => selectPlotArea(d.container));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @todo Brush over view for series view.
|
|
263
|
+
* @todo Test perf.
|
|
264
|
+
*/
|
|
265
|
+
export function brushHighlight(
|
|
266
|
+
root,
|
|
267
|
+
{
|
|
268
|
+
elements: elementof,
|
|
269
|
+
siblings: siblingsof = (root) => [],
|
|
270
|
+
datum,
|
|
271
|
+
brushRegion,
|
|
272
|
+
extent: optionalExtent,
|
|
273
|
+
reverse,
|
|
274
|
+
series = false,
|
|
275
|
+
key = (d) => d,
|
|
276
|
+
bboxOf = (root) => {
|
|
277
|
+
const { x, y, width, height } = root.style;
|
|
278
|
+
return { x, y, width, height };
|
|
279
|
+
},
|
|
280
|
+
...rest
|
|
281
|
+
},
|
|
282
|
+
) {
|
|
283
|
+
const elements = elementof(root);
|
|
284
|
+
const siblings = siblingsof(root);
|
|
285
|
+
const siblingElements = siblings.flatMap(elementof);
|
|
286
|
+
const valueof = createValueof(elements, datum);
|
|
287
|
+
const brushStyle = subObject(rest, 'mask');
|
|
288
|
+
const { setState, removeState } = useState(rest, valueof);
|
|
289
|
+
const clonedElement = new Map();
|
|
290
|
+
const {
|
|
291
|
+
width: rootWidth,
|
|
292
|
+
height: rootHeight,
|
|
293
|
+
x: ordinalX,
|
|
294
|
+
y: ordinalY,
|
|
295
|
+
} = bboxOf(root);
|
|
296
|
+
const extent = optionalExtent
|
|
297
|
+
? optionalExtent
|
|
298
|
+
: [0, 0, rootWidth, rootHeight];
|
|
299
|
+
|
|
300
|
+
const brushended = () => {
|
|
301
|
+
for (const element of [...elements, ...siblingElements]) {
|
|
302
|
+
removeState(element, 'highlighted', 'unhighlighted');
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const brushed = (x, y, x1, y1) => {
|
|
307
|
+
// Hide brush for the sibling view.
|
|
308
|
+
for (const sibling of siblings) sibling.brush?.remove();
|
|
309
|
+
|
|
310
|
+
// Store the key of the highlighted element.
|
|
311
|
+
const keys = new Set();
|
|
312
|
+
|
|
313
|
+
// Highlight and store selected elements.
|
|
314
|
+
for (const element of elements) {
|
|
315
|
+
const { min, max } = element.getLocalBounds();
|
|
316
|
+
const [ex, ey] = min;
|
|
317
|
+
const [ex1, ey1] = max;
|
|
318
|
+
if (!intersect([ex, ey, ex1, ey1], [x, y, x1, y1])) {
|
|
319
|
+
setState(element, 'unhighlighted');
|
|
320
|
+
} else {
|
|
321
|
+
setState(element, 'highlighted');
|
|
322
|
+
keys.add(key(element));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Highlight elements with same key in sibling view.
|
|
327
|
+
for (const element of siblingElements) {
|
|
328
|
+
if (keys.has(key(element))) setState(element, 'highlighted');
|
|
329
|
+
else setState(element, 'unhighlighted');
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const seriesBrushend = () => {
|
|
334
|
+
for (const element of elements) removeState(element, 'unhighlighted');
|
|
335
|
+
for (const cloned of clonedElement.values()) cloned.remove();
|
|
336
|
+
clonedElement.clear();
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const seriesBrushed = (x, y, x1, y1) => {
|
|
340
|
+
const clone = (element) => {
|
|
341
|
+
const cloned = element.cloneNode();
|
|
342
|
+
element.parentNode.appendChild(cloned);
|
|
343
|
+
clonedElement.set(element, cloned);
|
|
344
|
+
return cloned;
|
|
345
|
+
};
|
|
346
|
+
for (const element of elements) {
|
|
347
|
+
const cloned = clonedElement.get(element) || clone(element);
|
|
348
|
+
cloned.style.clipPath = new Rect({
|
|
349
|
+
style: {
|
|
350
|
+
x: x + ordinalX,
|
|
351
|
+
y: y + ordinalY,
|
|
352
|
+
width: x1 - x,
|
|
353
|
+
height: y1 - y,
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
setState(element, 'unhighlighted');
|
|
357
|
+
setState(cloned, 'highlighted');
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
return brush(root, {
|
|
362
|
+
...brushStyle,
|
|
363
|
+
extent,
|
|
364
|
+
brushRegion,
|
|
365
|
+
reverse,
|
|
366
|
+
brushended: series ? seriesBrushend : brushended,
|
|
367
|
+
brushed: series ? seriesBrushed : brushed,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export function BrushHighlight({ facet, brushKey, ...rest }) {
|
|
372
|
+
return (target, viewInstances) => {
|
|
373
|
+
const { container, view } = target;
|
|
374
|
+
const plotArea = selectPlotArea(container);
|
|
375
|
+
const defaultOptions = {
|
|
376
|
+
maskFill: '#777',
|
|
377
|
+
maskFillOpacity: '0.3',
|
|
378
|
+
maskStroke: '#fff',
|
|
379
|
+
unhighlightedOpacity: 0.5,
|
|
380
|
+
reverse: false,
|
|
381
|
+
};
|
|
382
|
+
if (facet) {
|
|
383
|
+
const bbox = plotArea.getBounds();
|
|
384
|
+
const x = bbox.min[0];
|
|
385
|
+
const y = bbox.min[1];
|
|
386
|
+
const x1 = bbox.max[0];
|
|
387
|
+
const y1 = bbox.max[1];
|
|
388
|
+
return brushHighlight(plotArea.parentNode.parentNode, {
|
|
389
|
+
elements: () => selectFacetG2Elements(target, viewInstances),
|
|
390
|
+
datum: createDatumof(view),
|
|
391
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
392
|
+
maskFill: '#777',
|
|
393
|
+
maskFillOpacity: '0.3',
|
|
394
|
+
maskStroke: '#fff',
|
|
395
|
+
unhighlightedOpacity: 0.5,
|
|
396
|
+
extent: [x, y, x1, y1],
|
|
397
|
+
...defaultOptions,
|
|
398
|
+
...rest,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const brush = brushHighlight(plotArea, {
|
|
403
|
+
elements: selectG2Elements,
|
|
404
|
+
key: (element) => element.__data__.key,
|
|
405
|
+
siblings: () => selectSiblingContainers(target, viewInstances, brushKey),
|
|
406
|
+
datum: createDatumof(view),
|
|
407
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
408
|
+
extent: undefined,
|
|
409
|
+
...defaultOptions,
|
|
410
|
+
...rest,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// Bind brush to the view it belongs to.
|
|
414
|
+
//@ts-ignore
|
|
415
|
+
plotArea.brush = brush;
|
|
416
|
+
|
|
417
|
+
return () => brush.destroy();
|
|
418
|
+
};
|
|
419
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BrushHighlight } from './brushHighlight';
|
|
2
|
+
|
|
3
|
+
export function brushXRegion(x, y, x1, y1, extent) {
|
|
4
|
+
const [, minY, , maxY] = extent;
|
|
5
|
+
return [x, minY, x1, maxY];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function BrushXHighlight(options) {
|
|
9
|
+
return BrushHighlight({
|
|
10
|
+
...options,
|
|
11
|
+
brushRegion: brushXRegion,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BrushHighlight } from './brushHighlight';
|
|
2
|
+
|
|
3
|
+
export function brushYRegion(x, y, x1, y1, extent) {
|
|
4
|
+
const [minX, , maxX] = extent;
|
|
5
|
+
return [minX, y, maxX, y1];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function BrushYHighlight(options) {
|
|
9
|
+
return BrushHighlight({
|
|
10
|
+
...options,
|
|
11
|
+
brushRegion: brushYRegion,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { deepMix } from '@antv/util';
|
|
3
3
|
import { subObject } from '../../utils/helper';
|
|
4
|
-
import {
|
|
4
|
+
import { useState, setCursor, restoreCursor } from './utils';
|
|
5
5
|
|
|
6
6
|
export const CATEGORY_LEGEND_CLASS_NAME = 'legend-category';
|
|
7
7
|
|
|
@@ -11,17 +11,6 @@ export const LEGEND_MAKER_CLASS_NAME = 'legend-category-item-marker';
|
|
|
11
11
|
|
|
12
12
|
export const LEGEND_LABEL_CLASS_NAME = 'legend-category-item-label';
|
|
13
13
|
|
|
14
|
-
function setCursor(root, cursor) {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
const canvas = root.getRootNode().defaultView;
|
|
17
|
-
const dom = canvas.getContextService().getDomElement();
|
|
18
|
-
dom.style.cursor = cursor;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function restoreCursor(root) {
|
|
22
|
-
setCursor(root, 'default');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
14
|
function markerOf(item) {
|
|
26
15
|
return item.getElementsByClassName(LEGEND_MAKER_CLASS_NAME)[0];
|
|
27
16
|
}
|
|
@@ -43,8 +32,8 @@ function builtInAccessors(selectedLegend) {
|
|
|
43
32
|
channel,
|
|
44
33
|
{
|
|
45
34
|
legends: legendsOf,
|
|
46
|
-
marker:
|
|
47
|
-
label:
|
|
35
|
+
marker: markerOf,
|
|
36
|
+
label: labelOf,
|
|
48
37
|
datum: (d) => {
|
|
49
38
|
const { __data__: datum } = d;
|
|
50
39
|
const { index } = datum;
|