@antv/g2 5.0.0-beta.5 → 5.0.0-beta.7
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 +4 -4
- package/dist/g2.min.js +4 -4
- package/esm/api/chart.d.ts +6 -2
- package/esm/api/chart.js +28 -7
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +4 -0
- package/esm/api/composition/base.js +16 -0
- package/esm/api/composition/base.js.map +1 -0
- package/esm/api/composition/facetCircle.d.ts +2 -3
- package/esm/api/composition/facetCircle.js +2 -2
- package/esm/api/composition/facetCircle.js.map +1 -1
- package/esm/api/composition/facetRect.d.ts +2 -3
- package/esm/api/composition/facetRect.js +2 -2
- package/esm/api/composition/facetRect.js.map +1 -1
- package/esm/api/composition/geoPath.d.ts +2 -3
- package/esm/api/composition/geoPath.js +2 -2
- package/esm/api/composition/geoPath.js.map +1 -1
- package/esm/api/composition/geoView.d.ts +2 -3
- package/esm/api/composition/geoView.js +2 -2
- package/esm/api/composition/geoView.js.map +1 -1
- package/esm/api/composition/index.d.ts +2 -1
- package/esm/api/composition/index.js +2 -1
- package/esm/api/composition/index.js.map +1 -1
- package/esm/api/composition/repeatMatrix.d.ts +2 -3
- package/esm/api/composition/repeatMatrix.js +2 -2
- package/esm/api/composition/repeatMatrix.js.map +1 -1
- package/esm/api/composition/spaceFlex.d.ts +2 -3
- package/esm/api/composition/spaceFlex.js +2 -2
- package/esm/api/composition/spaceFlex.js.map +1 -1
- package/esm/api/composition/spaceLayer.d.ts +2 -3
- package/esm/api/composition/spaceLayer.js +2 -2
- package/esm/api/composition/spaceLayer.js.map +1 -1
- package/esm/api/composition/timingKeyframe.d.ts +2 -3
- package/esm/api/composition/timingKeyframe.js +2 -2
- package/esm/api/composition/timingKeyframe.js.map +1 -1
- package/esm/api/composition/view.d.ts +3 -3
- package/esm/api/composition/view.js +4 -4
- package/esm/api/composition/view.js.map +1 -1
- package/esm/api/mark/mark.d.ts +34 -28
- package/esm/api/mark/mark.js +39 -26
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -0
- package/esm/api/node.d.ts +2 -1
- package/esm/api/node.js +8 -9
- package/esm/api/node.js.map +1 -1
- package/esm/component/axis.js +18 -5
- 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 +3 -13
- 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/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/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
- package/esm/geo/{d3-projection.js → d3Projection.js} +1 -1
- package/esm/geo/d3Projection.js.map +1 -0
- package/esm/geo/geoView.js +1 -1
- package/esm/geo/geoView.js.map +1 -1
- package/esm/interaction/index.d.ts +6 -0
- package/esm/interaction/index.js +5 -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 +14 -0
- package/esm/interaction/native/brushFilter.js +122 -0
- package/esm/interaction/native/brushFilter.js.map +1 -0
- package/esm/interaction/native/brushHighlight.d.ts +30 -5
- package/esm/interaction/native/brushHighlight.js +92 -34
- package/esm/interaction/native/brushHighlight.js.map +1 -1
- 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 -1
- package/esm/interaction/native/brushXHighlight.js +5 -4
- package/esm/interaction/native/brushXHighlight.js.map +1 -1
- 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 -1
- package/esm/interaction/native/brushYHighlight.js +5 -4
- package/esm/interaction/native/brushYHighlight.js.map +1 -1
- package/esm/interaction/native/elementHighlight.js +1 -0
- package/esm/interaction/native/elementHighlight.js.map +1 -1
- package/esm/interaction/native/elementSelect.js +1 -0
- package/esm/interaction/native/elementSelect.js.map +1 -1
- package/esm/interaction/native/sliderFilter.d.ts +5 -0
- package/esm/interaction/native/sliderFilter.js +87 -0
- package/esm/interaction/native/sliderFilter.js.map +1 -0
- package/esm/interaction/native/tooltip.js +16 -4
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +5 -1
- package/esm/interaction/native/utils.js +11 -3
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/overlapDodgeY.js +8 -0
- package/esm/label-transform/overlapDodgeY.js.map +1 -1
- 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.d.ts +1 -1
- package/esm/runtime/component.js +38 -41
- 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.d.ts +1 -1
- package/esm/runtime/plot.js +70 -27
- 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.d.ts +2 -1
- package/esm/runtime/scale.js +7 -0
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +6 -2
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +26 -9
- package/esm/runtime/types/options.d.ts +2 -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/position/default.d.ts +5 -7
- package/esm/shape/label/position/default.js +14 -40
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/label/position/outside.d.ts +18 -1
- package/esm/shape/label/position/outside.js +66 -1
- package/esm/shape/label/position/outside.js.map +1 -1
- package/esm/shape/label/position/spider.d.ts +1 -1
- package/esm/shape/label/position/spider.js +12 -18
- package/esm/shape/label/position/spider.js.map +1 -1
- package/esm/shape/label/position/surround.d.ts +1 -1
- package/esm/shape/label/position/surround.js +12 -14
- package/esm/shape/label/position/surround.js.map +1 -1
- 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/data.d.ts +24 -9
- package/esm/spec/geometry.d.ts +2 -0
- package/esm/spec/interaction.d.ts +28 -3
- package/esm/spec/transform.d.ts +2 -2
- package/esm/stdlib/index.js +5 -5
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.js +11 -15
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/dark.js +11 -18
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/light.js +25 -19
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/select.js +1 -13
- package/esm/transform/select.js.map +1 -1
- package/esm/transform/selectX.js +1 -1
- package/esm/transform/selectX.js.map +1 -1
- package/esm/transform/selectY.js +1 -1
- package/esm/transform/selectY.js.map +1 -1
- package/esm/utils/scale.d.ts +2 -0
- package/esm/utils/scale.js +30 -0
- package/esm/utils/scale.js.map +1 -0
- package/lib/api/chart.d.ts +6 -2
- package/lib/api/chart.js +27 -6
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +4 -0
- package/lib/api/composition/base.js +19 -0
- package/lib/api/composition/base.js.map +1 -0
- package/lib/api/composition/facetCircle.d.ts +2 -3
- package/lib/api/composition/facetCircle.js +2 -2
- package/lib/api/composition/facetCircle.js.map +1 -1
- package/lib/api/composition/facetRect.d.ts +2 -3
- package/lib/api/composition/facetRect.js +2 -2
- package/lib/api/composition/facetRect.js.map +1 -1
- package/lib/api/composition/geoPath.d.ts +2 -3
- package/lib/api/composition/geoPath.js +2 -2
- package/lib/api/composition/geoPath.js.map +1 -1
- package/lib/api/composition/geoView.d.ts +2 -3
- package/lib/api/composition/geoView.js +2 -2
- package/lib/api/composition/geoView.js.map +1 -1
- package/lib/api/composition/index.d.ts +2 -1
- package/lib/api/composition/index.js +3 -1
- package/lib/api/composition/index.js.map +1 -1
- package/lib/api/composition/repeatMatrix.d.ts +2 -3
- package/lib/api/composition/repeatMatrix.js +2 -2
- package/lib/api/composition/repeatMatrix.js.map +1 -1
- package/lib/api/composition/spaceFlex.d.ts +2 -3
- package/lib/api/composition/spaceFlex.js +2 -2
- package/lib/api/composition/spaceFlex.js.map +1 -1
- package/lib/api/composition/spaceLayer.d.ts +2 -3
- package/lib/api/composition/spaceLayer.js +2 -2
- package/lib/api/composition/spaceLayer.js.map +1 -1
- package/lib/api/composition/timingKeyframe.d.ts +2 -3
- package/lib/api/composition/timingKeyframe.js +2 -2
- package/lib/api/composition/timingKeyframe.js.map +1 -1
- package/lib/api/composition/view.d.ts +3 -3
- package/lib/api/composition/view.js +4 -4
- package/lib/api/composition/view.js.map +1 -1
- package/lib/api/mark/mark.d.ts +34 -28
- package/lib/api/mark/mark.js +41 -27
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -0
- package/lib/api/node.d.ts +2 -1
- package/lib/api/node.js +8 -9
- package/lib/api/node.js.map +1 -1
- package/lib/component/axis.js +18 -5
- 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 +3 -13
- 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/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/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
- package/lib/geo/{d3-projection.js → d3Projection.js} +1 -1
- package/lib/geo/d3Projection.js.map +1 -0
- package/lib/geo/geoView.js +1 -1
- package/lib/geo/geoView.js.map +1 -1
- package/lib/interaction/index.d.ts +6 -0
- package/lib/interaction/index.js +11 -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 +14 -0
- package/lib/interaction/native/brushFilter.js +127 -0
- package/lib/interaction/native/brushFilter.js.map +1 -0
- package/lib/interaction/native/brushHighlight.d.ts +30 -5
- package/lib/interaction/native/brushHighlight.js +91 -33
- package/lib/interaction/native/brushHighlight.js.map +1 -1
- 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 -1
- package/lib/interaction/native/brushXHighlight.js +7 -5
- package/lib/interaction/native/brushXHighlight.js.map +1 -1
- 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 -1
- package/lib/interaction/native/brushYHighlight.js +7 -5
- package/lib/interaction/native/brushYHighlight.js.map +1 -1
- package/lib/interaction/native/elementHighlight.js +1 -0
- package/lib/interaction/native/elementHighlight.js.map +1 -1
- package/lib/interaction/native/elementSelect.js +1 -0
- package/lib/interaction/native/elementSelect.js.map +1 -1
- package/lib/interaction/native/sliderFilter.d.ts +5 -0
- package/lib/interaction/native/sliderFilter.js +91 -0
- package/lib/interaction/native/sliderFilter.js.map +1 -0
- package/lib/interaction/native/tooltip.js +16 -4
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +5 -1
- package/lib/interaction/native/utils.js +14 -5
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/overlapDodgeY.js +8 -0
- package/lib/label-transform/overlapDodgeY.js.map +1 -1
- 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.d.ts +1 -1
- package/lib/runtime/component.js +37 -40
- 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.d.ts +1 -1
- package/lib/runtime/plot.js +67 -24
- 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.d.ts +2 -1
- package/lib/runtime/scale.js +9 -1
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +6 -2
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +26 -9
- package/lib/runtime/types/options.d.ts +2 -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/position/default.d.ts +5 -7
- package/lib/shape/label/position/default.js +16 -40
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/label/position/outside.d.ts +18 -1
- package/lib/shape/label/position/outside.js +72 -3
- package/lib/shape/label/position/outside.js.map +1 -1
- package/lib/shape/label/position/spider.d.ts +1 -1
- package/lib/shape/label/position/spider.js +12 -18
- package/lib/shape/label/position/spider.js.map +1 -1
- package/lib/shape/label/position/surround.d.ts +1 -1
- package/lib/shape/label/position/surround.js +11 -13
- package/lib/shape/label/position/surround.js.map +1 -1
- 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/data.d.ts +24 -9
- package/lib/spec/geometry.d.ts +2 -0
- package/lib/spec/interaction.d.ts +28 -3
- package/lib/spec/transform.d.ts +2 -2
- package/lib/stdlib/index.js +2 -2
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.js +11 -15
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/dark.js +11 -18
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/light.js +25 -19
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/select.js +1 -13
- package/lib/transform/select.js.map +1 -1
- package/lib/transform/selectX.js +1 -1
- package/lib/transform/selectX.js.map +1 -1
- package/lib/transform/selectY.js +1 -1
- package/lib/transform/selectY.js.map +1 -1
- package/lib/utils/scale.d.ts +2 -0
- package/lib/utils/scale.js +35 -0
- package/lib/utils/scale.js.map +1 -0
- package/package.json +1 -1
- package/src/api/chart.ts +31 -10
- package/src/api/composition/base.ts +11 -0
- package/src/api/composition/facetCircle.ts +2 -3
- package/src/api/composition/facetRect.ts +2 -3
- package/src/api/composition/geoPath.ts +2 -3
- package/src/api/composition/geoView.ts +2 -3
- package/src/api/composition/index.ts +2 -0
- package/src/api/composition/repeatMatrix.ts +2 -3
- package/src/api/composition/spaceFlex.ts +2 -3
- package/src/api/composition/spaceLayer.ts +2 -3
- package/src/api/composition/timingKeyframe.ts +2 -3
- package/src/api/composition/view.ts +6 -4
- package/src/api/mark/mark.ts +48 -27
- package/src/api/mark/types.ts +1 -0
- package/src/api/node.ts +9 -11
- package/src/component/axis.ts +22 -5
- 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 +3 -12
- package/src/component/title.ts +69 -30
- 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/geo/{d3-projection.ts → d3Projection.ts} +0 -0
- package/src/geo/geoView.ts +1 -1
- package/src/interaction/index.ts +21 -16
- package/src/interaction/native/brushAxisHighlight.ts +194 -0
- package/src/interaction/native/brushFilter.ts +143 -0
- package/src/interaction/native/brushHighlight.ts +104 -31
- package/src/interaction/native/brushXFilter.ts +10 -0
- package/src/interaction/native/brushXHighlight.ts +6 -4
- package/src/interaction/native/brushYFilter.ts +10 -0
- package/src/interaction/native/brushYHighlight.ts +6 -4
- package/src/interaction/native/elementHighlight.ts +1 -0
- package/src/interaction/native/elementSelect.ts +1 -0
- package/src/interaction/native/sliderFilter.ts +112 -0
- package/src/interaction/native/tooltip.ts +18 -4
- package/src/interaction/native/utils.ts +15 -6
- package/src/label-transform/overlapDodgeY.ts +8 -1
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +3 -1
- package/src/runtime/component.ts +64 -72
- package/src/runtime/layout.ts +6 -6
- package/src/runtime/plot.ts +126 -73
- package/src/runtime/render.ts +6 -58
- package/src/runtime/scale.ts +14 -0
- package/src/runtime/transform.ts +6 -2
- package/src/runtime/types/common.ts +26 -10
- package/src/runtime/types/options.ts +2 -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/position/default.ts +15 -55
- package/src/shape/label/position/outside.ts +121 -1
- package/src/shape/label/position/spider.ts +12 -19
- package/src/shape/label/position/surround.ts +13 -15
- 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/data.ts +25 -10
- package/src/spec/geometry.ts +2 -0
- package/src/spec/interaction.ts +41 -2
- package/src/spec/transform.ts +3 -1
- package/src/stdlib/index.ts +16 -2
- package/src/theme/academy.ts +11 -15
- package/src/theme/dark.ts +11 -18
- package/src/theme/light.ts +25 -19
- package/src/transform/select.ts +1 -2
- package/src/transform/selectX.ts +1 -1
- package/src/transform/selectY.ts +1 -1
- package/src/utils/scale.ts +31 -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/geo/d3-projection.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/geo/d3-projection.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/data/.DS_Store +0 -0
- package/src/data/subset.ts +0 -35
- package/src/shape/.DS_Store +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { deepMix } from '@antv/util';
|
|
2
|
+
import { subObject } from '../../utils/helper';
|
|
3
|
+
import { invert, domainOf } from '../../utils/scale';
|
|
4
|
+
import { brush as createBrush } from './brushHighlight';
|
|
5
|
+
import { selectPlotArea } from './utils';
|
|
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
|
+
export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
68
|
+
return (target, viewInstances) => {
|
|
69
|
+
const { container, view, options: viewOptions, update } = target;
|
|
70
|
+
const plotArea = selectPlotArea(container);
|
|
71
|
+
const defaultOptions = {
|
|
72
|
+
maskFill: '#777',
|
|
73
|
+
maskFillOpacity: '0.3',
|
|
74
|
+
maskStroke: '#fff',
|
|
75
|
+
unhighlightedOpacity: 0.5,
|
|
76
|
+
reverse: false,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
let filtered = false;
|
|
80
|
+
let filtering = false;
|
|
81
|
+
let newView = view;
|
|
82
|
+
|
|
83
|
+
return brushFilter(plotArea, {
|
|
84
|
+
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
85
|
+
filter: async (x, y, x1, y1) => {
|
|
86
|
+
// Avoid redundant filter.
|
|
87
|
+
if (filtering) return;
|
|
88
|
+
filtering = true;
|
|
89
|
+
|
|
90
|
+
// Invert visual range to abstract domain.
|
|
91
|
+
const { scale, coordinate } = newView;
|
|
92
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
93
|
+
const abstractDomain = (point, start) => {
|
|
94
|
+
const [x, y] = coordinate.invert(point);
|
|
95
|
+
return [invert(scaleX, x, start), invert(scaleY, y, start)];
|
|
96
|
+
};
|
|
97
|
+
const p0 = abstractDomain([x, y], true);
|
|
98
|
+
const p1 = abstractDomain([x1, y1], false);
|
|
99
|
+
|
|
100
|
+
// Update the domain of x and y scale to filter data.
|
|
101
|
+
const { marks } = viewOptions;
|
|
102
|
+
const newMarks = marks.map((mark) =>
|
|
103
|
+
deepMix(
|
|
104
|
+
{
|
|
105
|
+
// Hide label to keep smooth transition.
|
|
106
|
+
axis: {
|
|
107
|
+
...(hideX && { x: { labelTransforms: [{ type: 'hide' }] } }),
|
|
108
|
+
...(hideY && { y: { labelTransforms: [{ type: 'hide' }] } }),
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
mark,
|
|
112
|
+
{
|
|
113
|
+
scale: {
|
|
114
|
+
x: { domain: domainOf(scaleX, [p0[0], p1[0]]) },
|
|
115
|
+
y: { domain: domainOf(scaleY, [p0[1], p1[1]]) },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Rerender and update view.
|
|
122
|
+
const newOptions = {
|
|
123
|
+
...viewOptions,
|
|
124
|
+
marks: newMarks,
|
|
125
|
+
clip: true, // Clip shapes out of plot area.
|
|
126
|
+
};
|
|
127
|
+
const newState = await update(newOptions);
|
|
128
|
+
newView = newState.view;
|
|
129
|
+
filtering = false;
|
|
130
|
+
filtered = true;
|
|
131
|
+
},
|
|
132
|
+
reset: () => {
|
|
133
|
+
if (filtering || !filtered) return;
|
|
134
|
+
filtered = false;
|
|
135
|
+
newView = view;
|
|
136
|
+
update(viewOptions);
|
|
137
|
+
},
|
|
138
|
+
extent: undefined,
|
|
139
|
+
...defaultOptions,
|
|
140
|
+
...rest,
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
useState,
|
|
8
8
|
createValueof,
|
|
9
9
|
setCursor,
|
|
10
|
-
|
|
10
|
+
brushMousePosition,
|
|
11
11
|
selectFacetG2Elements,
|
|
12
12
|
} from './utils';
|
|
13
13
|
|
|
@@ -27,14 +27,23 @@ function normalizeBounds(x, y, x1, y1, extent) {
|
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function bboxOf(root: DisplayObject) {
|
|
31
|
+
const { width, height } = root.getBBox();
|
|
32
|
+
return [0, 0, width, height];
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
export function brush(
|
|
31
36
|
root: DisplayObject,
|
|
32
37
|
{
|
|
33
|
-
brushed,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
extent,
|
|
38
|
+
brushed = () => {},
|
|
39
|
+
brushended = () => {},
|
|
40
|
+
brushcreated = () => {},
|
|
41
|
+
extent = bboxOf(root),
|
|
42
|
+
brushRegion = (x, y, x1, y1, extent) => [x, y, x1, y1],
|
|
37
43
|
reverse = false,
|
|
44
|
+
fill = '#777',
|
|
45
|
+
fillOpacity = '0.3',
|
|
46
|
+
stroke = '#fff',
|
|
38
47
|
...style
|
|
39
48
|
}: Record<string, any>,
|
|
40
49
|
) {
|
|
@@ -63,6 +72,9 @@ export function brush(
|
|
|
63
72
|
background = new Path({
|
|
64
73
|
style: {
|
|
65
74
|
...style,
|
|
75
|
+
fill,
|
|
76
|
+
fillOpacity,
|
|
77
|
+
stroke,
|
|
66
78
|
pointerEvents: 'none',
|
|
67
79
|
},
|
|
68
80
|
});
|
|
@@ -83,6 +95,9 @@ export function brush(
|
|
|
83
95
|
// @ts-ignore
|
|
84
96
|
style: {
|
|
85
97
|
...style,
|
|
98
|
+
fill,
|
|
99
|
+
fillOpacity,
|
|
100
|
+
stroke,
|
|
86
101
|
draggable: true, // Make it response to drag event.
|
|
87
102
|
},
|
|
88
103
|
className: 'mask',
|
|
@@ -100,10 +115,10 @@ export function brush(
|
|
|
100
115
|
resizing = false;
|
|
101
116
|
mask = null;
|
|
102
117
|
background = null;
|
|
103
|
-
|
|
118
|
+
brushended();
|
|
104
119
|
};
|
|
105
120
|
|
|
106
|
-
// Update mask and invoke
|
|
121
|
+
// Update mask and invoke brushended callback.
|
|
107
122
|
const updateMask = (start, end) => {
|
|
108
123
|
const [x, y, x1, y1] = normalizeBounds(
|
|
109
124
|
start[0],
|
|
@@ -116,6 +131,7 @@ export function brush(
|
|
|
116
131
|
if (reverse) updateReverseMask(fx, fy, fx1, fy1);
|
|
117
132
|
else updateNormalMask(fx, fy, fx1, fy1);
|
|
118
133
|
brushed(fx, fy, fx1, fy1);
|
|
134
|
+
return [fx, fy, fx1, fy1];
|
|
119
135
|
};
|
|
120
136
|
|
|
121
137
|
const updateNormalMask = (x, y, x1, y1) => {
|
|
@@ -156,7 +172,7 @@ export function brush(
|
|
|
156
172
|
// If target is mask, about to update position.
|
|
157
173
|
const dragstart = (event) => {
|
|
158
174
|
const { target } = event;
|
|
159
|
-
const [offsetX, offsetY] =
|
|
175
|
+
const [offsetX, offsetY] = brushMousePosition(root, event);
|
|
160
176
|
if (target === mask) {
|
|
161
177
|
moveStart = [offsetX, offsetY];
|
|
162
178
|
return;
|
|
@@ -168,7 +184,7 @@ export function brush(
|
|
|
168
184
|
// If target is plot area, resize mask.
|
|
169
185
|
// If target is mask, move mask.
|
|
170
186
|
const drag = (event) => {
|
|
171
|
-
const mouse =
|
|
187
|
+
const mouse = brushMousePosition(root, event);
|
|
172
188
|
if (!start) return;
|
|
173
189
|
if (moveStart) return moveMask(mouse);
|
|
174
190
|
updateMask(start, mouse);
|
|
@@ -185,9 +201,10 @@ export function brush(
|
|
|
185
201
|
end = [x + width, y + height];
|
|
186
202
|
return;
|
|
187
203
|
}
|
|
188
|
-
end =
|
|
189
|
-
updateMask(start, end);
|
|
204
|
+
end = brushMousePosition(root, event);
|
|
205
|
+
const [fx, fy, fx1, fy1] = updateMask(start, end);
|
|
190
206
|
resizing = false;
|
|
207
|
+
brushcreated(fx, fy, fx1, fy1);
|
|
191
208
|
};
|
|
192
209
|
|
|
193
210
|
// Hide mask.
|
|
@@ -203,36 +220,69 @@ export function brush(
|
|
|
203
220
|
else setCursor(root, 'crosshair');
|
|
204
221
|
};
|
|
205
222
|
|
|
223
|
+
const pointerleave = () => {
|
|
224
|
+
setCursor(root, 'default');
|
|
225
|
+
};
|
|
226
|
+
|
|
206
227
|
root.addEventListener('dragstart', dragstart);
|
|
207
228
|
root.addEventListener('drag', drag);
|
|
208
229
|
root.addEventListener('dragend', dragend);
|
|
209
230
|
root.addEventListener('click', click);
|
|
210
231
|
root.addEventListener('pointermove', pointermove);
|
|
232
|
+
root.addEventListener('pointerleave', pointerleave);
|
|
211
233
|
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
+
},
|
|
220
248
|
};
|
|
221
249
|
}
|
|
222
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
|
+
*/
|
|
223
265
|
export function brushHighlight(
|
|
224
266
|
root,
|
|
225
267
|
{
|
|
226
268
|
elements: elementof,
|
|
269
|
+
siblings: siblingsof = (root) => [],
|
|
227
270
|
datum,
|
|
228
271
|
brushRegion,
|
|
229
272
|
extent: optionalExtent,
|
|
230
273
|
reverse,
|
|
231
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
|
+
},
|
|
232
280
|
...rest
|
|
233
281
|
},
|
|
234
282
|
) {
|
|
235
283
|
const elements = elementof(root);
|
|
284
|
+
const siblings = siblingsof(root);
|
|
285
|
+
const siblingElements = siblings.flatMap(elementof);
|
|
236
286
|
const valueof = createValueof(elements, datum);
|
|
237
287
|
const brushStyle = subObject(rest, 'mask');
|
|
238
288
|
const { setState, removeState } = useState(rest, valueof);
|
|
@@ -242,24 +292,25 @@ export function brushHighlight(
|
|
|
242
292
|
height: rootHeight,
|
|
243
293
|
x: ordinalX,
|
|
244
294
|
y: ordinalY,
|
|
245
|
-
} = root
|
|
295
|
+
} = bboxOf(root);
|
|
246
296
|
const extent = optionalExtent
|
|
247
297
|
? optionalExtent
|
|
248
298
|
: [0, 0, rootWidth, rootHeight];
|
|
249
299
|
|
|
250
|
-
const
|
|
251
|
-
for (const element of elements
|
|
252
|
-
for (const cloned of clonedElement.values()) cloned.remove();
|
|
253
|
-
clonedElement.clear();
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const brushend = () => {
|
|
257
|
-
for (const element of elements) {
|
|
300
|
+
const brushended = () => {
|
|
301
|
+
for (const element of [...elements, ...siblingElements]) {
|
|
258
302
|
removeState(element, 'highlighted', 'unhighlighted');
|
|
259
303
|
}
|
|
260
304
|
};
|
|
261
305
|
|
|
262
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.
|
|
263
314
|
for (const element of elements) {
|
|
264
315
|
const { min, max } = element.getLocalBounds();
|
|
265
316
|
const [ex, ey] = min;
|
|
@@ -268,8 +319,21 @@ export function brushHighlight(
|
|
|
268
319
|
setState(element, 'unhighlighted');
|
|
269
320
|
} else {
|
|
270
321
|
setState(element, 'highlighted');
|
|
322
|
+
keys.add(key(element));
|
|
271
323
|
}
|
|
272
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();
|
|
273
337
|
};
|
|
274
338
|
|
|
275
339
|
const seriesBrushed = (x, y, x1, y1) => {
|
|
@@ -299,12 +363,12 @@ export function brushHighlight(
|
|
|
299
363
|
extent,
|
|
300
364
|
brushRegion,
|
|
301
365
|
reverse,
|
|
302
|
-
|
|
366
|
+
brushended: series ? seriesBrushend : brushended,
|
|
303
367
|
brushed: series ? seriesBrushed : brushed,
|
|
304
368
|
});
|
|
305
369
|
}
|
|
306
370
|
|
|
307
|
-
export function BrushHighlight({ facet, ...rest }) {
|
|
371
|
+
export function BrushHighlight({ facet, brushKey, ...rest }) {
|
|
308
372
|
return (target, viewInstances) => {
|
|
309
373
|
const { container, view } = target;
|
|
310
374
|
const plotArea = selectPlotArea(container);
|
|
@@ -334,13 +398,22 @@ export function BrushHighlight({ facet, ...rest }) {
|
|
|
334
398
|
...rest,
|
|
335
399
|
});
|
|
336
400
|
}
|
|
337
|
-
|
|
401
|
+
|
|
402
|
+
const brush = brushHighlight(plotArea, {
|
|
338
403
|
elements: selectG2Elements,
|
|
404
|
+
key: (element) => element.__data__.key,
|
|
405
|
+
siblings: () => selectSiblingContainers(target, viewInstances, brushKey),
|
|
339
406
|
datum: createDatumof(view),
|
|
340
407
|
brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
|
|
341
408
|
extent: undefined,
|
|
342
409
|
...defaultOptions,
|
|
343
410
|
...rest,
|
|
344
411
|
});
|
|
412
|
+
|
|
413
|
+
// Bind brush to the view it belongs to.
|
|
414
|
+
//@ts-ignore
|
|
415
|
+
plotArea.brush = brush;
|
|
416
|
+
|
|
417
|
+
return () => brush.destroy();
|
|
345
418
|
};
|
|
346
419
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BrushHighlight } from './brushHighlight';
|
|
2
2
|
|
|
3
|
+
export function brushXRegion(x, y, x1, y1, extent) {
|
|
4
|
+
const [, minY, , maxY] = extent;
|
|
5
|
+
return [x, minY, x1, maxY];
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export function BrushXHighlight(options) {
|
|
4
9
|
return BrushHighlight({
|
|
5
10
|
...options,
|
|
6
|
-
brushRegion:
|
|
7
|
-
const [, minY, , maxY] = extent;
|
|
8
|
-
return [x, minY, x1, maxY];
|
|
9
|
-
},
|
|
11
|
+
brushRegion: brushXRegion,
|
|
10
12
|
});
|
|
11
13
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BrushHighlight } from './brushHighlight';
|
|
2
2
|
|
|
3
|
+
export function brushYRegion(x, y, x1, y1, extent) {
|
|
4
|
+
const [minX, , maxX] = extent;
|
|
5
|
+
return [minX, y, maxX, y1];
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export function BrushYHighlight(options) {
|
|
4
9
|
return BrushHighlight({
|
|
5
10
|
...options,
|
|
6
|
-
brushRegion:
|
|
7
|
-
const [minX, , maxX] = extent;
|
|
8
|
-
return [minX, y, maxX, y1];
|
|
9
|
-
},
|
|
11
|
+
brushRegion: brushYRegion,
|
|
10
12
|
});
|
|
11
13
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { deepMix, throttle } from '@antv/util';
|
|
2
|
+
import { invert, domainOf } from '../../utils/scale';
|
|
3
|
+
|
|
4
|
+
export const SLIDER_CLASS_NAME = 'slider';
|
|
5
|
+
|
|
6
|
+
function filterDataByDomain(options, scaleOptions) {
|
|
7
|
+
const { marks } = options;
|
|
8
|
+
const newMarks = marks.map((mark) =>
|
|
9
|
+
deepMix(
|
|
10
|
+
{
|
|
11
|
+
// Hide label to keep smooth transition.
|
|
12
|
+
axis: {
|
|
13
|
+
x: { labelTransforms: [{ type: 'hide' }] },
|
|
14
|
+
y: { labelTransforms: [{ type: 'hide' }] },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
mark,
|
|
18
|
+
{
|
|
19
|
+
scale: scaleOptions,
|
|
20
|
+
// Don't rerender sliders.
|
|
21
|
+
slider: {
|
|
22
|
+
...(mark.slider.x && { x: { preserve: true } }),
|
|
23
|
+
...(mark.slider.y && { y: { preserve: true } }),
|
|
24
|
+
},
|
|
25
|
+
animate: false,
|
|
26
|
+
},
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Rerender and update view.
|
|
31
|
+
return {
|
|
32
|
+
...options,
|
|
33
|
+
marks: newMarks,
|
|
34
|
+
clip: true, // Clip shapes out of plot area.
|
|
35
|
+
animate: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function abstractValue(values, scale) {
|
|
40
|
+
const [x, x1] = values;
|
|
41
|
+
const d0 = invert(scale, x, true);
|
|
42
|
+
const d1 = invert(scale, x1, false);
|
|
43
|
+
return domainOf(scale, [d0, d1]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @todo Support click to reset after fix click and dragend conflict.
|
|
48
|
+
*/
|
|
49
|
+
export function SliderFilter({
|
|
50
|
+
wait = 50,
|
|
51
|
+
leading = true,
|
|
52
|
+
trailing = false,
|
|
53
|
+
}: any) {
|
|
54
|
+
return (context) => {
|
|
55
|
+
const { container, view, options, update } = context;
|
|
56
|
+
const sliders = container.getElementsByClassName(SLIDER_CLASS_NAME);
|
|
57
|
+
if (!sliders.length) return;
|
|
58
|
+
|
|
59
|
+
let filtering = false;
|
|
60
|
+
const { scale } = view;
|
|
61
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
62
|
+
|
|
63
|
+
const sliderHandler = new Map();
|
|
64
|
+
|
|
65
|
+
// Store current domain of x and y scale.
|
|
66
|
+
const channelDomain = {
|
|
67
|
+
x: scaleX.getOptions().domain,
|
|
68
|
+
y: scaleY.getOptions().domain,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
for (const slider of sliders) {
|
|
72
|
+
const { orient } = slider.attributes;
|
|
73
|
+
|
|
74
|
+
const onValueChange = throttle(
|
|
75
|
+
async (event) => {
|
|
76
|
+
const { value: values } = event.detail;
|
|
77
|
+
if (filtering) return;
|
|
78
|
+
filtering = true;
|
|
79
|
+
|
|
80
|
+
// Update domain of the current channel.
|
|
81
|
+
const channel0 = orient === 'vertical' ? 'y' : 'x';
|
|
82
|
+
const scale0 = scale[channel0];
|
|
83
|
+
const domain0 = abstractValue(values, scale0);
|
|
84
|
+
channelDomain[channel0] = domain0;
|
|
85
|
+
|
|
86
|
+
// Get domain of the other channel.
|
|
87
|
+
const channel1 = orient === 'vertical' ? 'x' : 'y';
|
|
88
|
+
const domain1 = channelDomain[channel1];
|
|
89
|
+
|
|
90
|
+
// Filter data.
|
|
91
|
+
const newOptions = filterDataByDomain(options, {
|
|
92
|
+
[channel0]: { domain: domain0 },
|
|
93
|
+
[channel1]: { domain: domain1 },
|
|
94
|
+
});
|
|
95
|
+
await update(newOptions);
|
|
96
|
+
filtering = false;
|
|
97
|
+
},
|
|
98
|
+
wait,
|
|
99
|
+
{ leading, trailing },
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
slider.addEventListener('valuechange', onValueChange);
|
|
103
|
+
sliderHandler.set(slider, onValueChange);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return () => {
|
|
107
|
+
for (const [slider, handler] of sliderHandler) {
|
|
108
|
+
slider.removeEventListener('valuechange', handler);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -72,8 +72,12 @@ function hideTooltip(root) {
|
|
|
72
72
|
if (tooltipElement) tooltipElement.hide();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function
|
|
76
|
-
|
|
75
|
+
function destroyTooltip(root) {
|
|
76
|
+
const { tooltipElement } = root;
|
|
77
|
+
if (tooltipElement) {
|
|
78
|
+
tooltipElement.destroy();
|
|
79
|
+
root.tooltipElement = undefined;
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
function filterDefined(obj) {
|
|
@@ -135,13 +139,20 @@ function normalizeTooltip(d) {
|
|
|
135
139
|
return isStrictObject(d) ? d : { value: d === undefined ? d : `${d}` };
|
|
136
140
|
}
|
|
137
141
|
|
|
142
|
+
function uniqueTitles(titles) {
|
|
143
|
+
const valueTitle = new Map(
|
|
144
|
+
titles.map((d) => [d instanceof Date ? +d : d, d]),
|
|
145
|
+
);
|
|
146
|
+
return Array.from(valueTitle.values());
|
|
147
|
+
}
|
|
148
|
+
|
|
138
149
|
function groupItems(
|
|
139
150
|
elements,
|
|
140
151
|
item,
|
|
141
152
|
scale,
|
|
142
153
|
data = elements.map((d) => d['__data__']),
|
|
143
154
|
) {
|
|
144
|
-
const T =
|
|
155
|
+
const T = uniqueTitles(data.map((d) => d.title)).filter(defined);
|
|
145
156
|
const items = data.flatMap((datum, i) => {
|
|
146
157
|
const element = elements[i];
|
|
147
158
|
const { title, ...rest } = datum;
|
|
@@ -162,7 +173,7 @@ function groupItems(
|
|
|
162
173
|
name,
|
|
163
174
|
color,
|
|
164
175
|
value,
|
|
165
|
-
...filterDefined(item({ channel: key, value
|
|
176
|
+
...filterDefined(item({ channel: key, value })),
|
|
166
177
|
};
|
|
167
178
|
})
|
|
168
179
|
.filter(({ value }) => value !== undefined);
|
|
@@ -381,6 +392,8 @@ export function seriesTooltip(
|
|
|
381
392
|
root.removeEventListener('pointerover', update);
|
|
382
393
|
root.removeEventListener('pointerout', update);
|
|
383
394
|
root.removeEventListener('pointerleave', hide);
|
|
395
|
+
destroyTooltip(root);
|
|
396
|
+
if (crosshairs) hideRuleY(root);
|
|
384
397
|
};
|
|
385
398
|
}
|
|
386
399
|
|
|
@@ -434,6 +447,7 @@ export function tooltip(
|
|
|
434
447
|
root.removeEventListener('pointerover', pointerover);
|
|
435
448
|
root.removeEventListener('pointermove', pointerover);
|
|
436
449
|
root.removeEventListener('pointerout', pointerout);
|
|
450
|
+
destroyTooltip(root);
|
|
437
451
|
};
|
|
438
452
|
}
|
|
439
453
|
|