@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
package/src/component/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { LegendContinuous } from './legendContinuous';
|
|
|
5
5
|
export { TitleComponent } from './title';
|
|
6
6
|
export { SliderX } from './sliderX';
|
|
7
7
|
export { SliderY } from './sliderY';
|
|
8
|
+
export { ScrollbarX } from './scrollbarX';
|
|
9
|
+
export { ScrollbarY } from './scrollbarY';
|
|
8
10
|
|
|
9
11
|
export type { AxisXOptions } from './axisX';
|
|
10
12
|
export type { AxisYOptions } from './axisY';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Scrollbar as ScrollbarComponent } from '@antv/gui';
|
|
2
|
+
import { GuideComponentComponent as GCC } from '../runtime';
|
|
3
|
+
|
|
4
|
+
export type ScrollbarOptions = {
|
|
5
|
+
orient: 'horizontal' | 'vertical';
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Scrollbar component.
|
|
11
|
+
*/
|
|
12
|
+
export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
|
|
13
|
+
const { orient, labelFormatter, ...rest } = options;
|
|
14
|
+
|
|
15
|
+
return (scale, value, coordinate, theme) => {
|
|
16
|
+
const { bbox } = value;
|
|
17
|
+
const { x, y, width, height } = bbox;
|
|
18
|
+
const { scrollbar: scrollbarTheme = {} } = theme;
|
|
19
|
+
|
|
20
|
+
return new ScrollbarComponent({
|
|
21
|
+
className: 'scrollbar',
|
|
22
|
+
style: Object.assign({}, scrollbarTheme, {
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
trackLength: orient === 'horizontal' ? width : height,
|
|
26
|
+
...rest,
|
|
27
|
+
orient,
|
|
28
|
+
value: 0,
|
|
29
|
+
// @todo Get actual length of content.
|
|
30
|
+
contentLength: 1500,
|
|
31
|
+
viewportLength: orient === 'horizontal' ? width : height,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Scrollbar.props = {
|
|
38
|
+
defaultPosition: 'bottom',
|
|
39
|
+
defaultSize: 24,
|
|
40
|
+
defaultOrder: 1,
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
+
import { Scrollbar, ScrollbarOptions } from './scrollbar';
|
|
3
|
+
|
|
4
|
+
export type ScrollbarXOptions = ScrollbarOptions;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ScrollbarX component.
|
|
8
|
+
*/
|
|
9
|
+
export const ScrollbarX: GCC<ScrollbarXOptions> = (options) => {
|
|
10
|
+
return Scrollbar({ ...options, orient: 'horizontal' });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
ScrollbarX.props = {
|
|
14
|
+
...Scrollbar.props,
|
|
15
|
+
defaultPosition: 'bottom',
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
+
import { Scrollbar, ScrollbarOptions } from './scrollbar';
|
|
3
|
+
|
|
4
|
+
export type ScrollbarYOptions = ScrollbarOptions;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ScrollbarY component.
|
|
8
|
+
*/
|
|
9
|
+
export const ScrollbarY: GCC<ScrollbarYOptions> = (options) => {
|
|
10
|
+
return Scrollbar({ ...options, orient: 'vertical' });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
ScrollbarY.props = {
|
|
14
|
+
...Scrollbar.props,
|
|
15
|
+
defaultPosition: 'left',
|
|
16
|
+
};
|
package/src/component/slider.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Slider as SliderComponent } from '@antv/gui';
|
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
3
|
import { least } from 'd3-array';
|
|
4
4
|
import { GuideComponentComponent as GCC, Scale } from '../runtime';
|
|
5
|
+
import { invert } from '../utils/scale';
|
|
5
6
|
|
|
6
7
|
export type SliderOptions = {
|
|
7
8
|
orient: 'horizontal' | 'vertical';
|
|
@@ -34,7 +35,8 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
34
35
|
orient,
|
|
35
36
|
formatter: (v) => {
|
|
36
37
|
const f = formatter || defaultFormatter;
|
|
37
|
-
|
|
38
|
+
// @todo Pass index to distinguish the left and the right value.
|
|
39
|
+
const tick = invert(scale, v, true);
|
|
38
40
|
return f(tick);
|
|
39
41
|
},
|
|
40
42
|
...rest,
|
|
@@ -43,17 +45,6 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
/**
|
|
47
|
-
* Translate [0,1] value to origin value.
|
|
48
|
-
*/
|
|
49
|
-
function invertTick(scale: Scale, v: number) {
|
|
50
|
-
if (!scale.getBandWidth) return scale.invert(v);
|
|
51
|
-
// @ts-ignore @todo should support in scale
|
|
52
|
-
const range = scale.adjustedRange as number[];
|
|
53
|
-
const abs = (v) => Math.abs(v);
|
|
54
|
-
return scale.invert(least(range, (a, b) => abs(a - v) - abs(b - v)));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
48
|
Slider.props = {
|
|
58
49
|
defaultPosition: 'bottom',
|
|
59
50
|
defaultSize: 24,
|
package/src/component/title.ts
CHANGED
|
@@ -1,42 +1,85 @@
|
|
|
1
|
-
import { TextStyleProps } from '@antv/g';
|
|
2
1
|
import { deepMix } from '@antv/util';
|
|
3
2
|
import { applyStyle } from '../shape/utils';
|
|
3
|
+
import { subObject } from '../utils/helper';
|
|
4
4
|
import { GuideComponentComponent as GCC, G2TitleOptions } from '../runtime';
|
|
5
5
|
import { createComponent, maybeAppend } from './utils';
|
|
6
6
|
|
|
7
7
|
export type TitleComponentOptions = G2TitleOptions;
|
|
8
8
|
|
|
9
|
-
type TitleStyleProps = {
|
|
10
|
-
x
|
|
11
|
-
y
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
subtitle?: string | null;
|
|
15
|
-
subtitleStyle?: Omit<TextStyleProps, 'x' | 'y' | 'text'> & {
|
|
16
|
-
spacing?: number;
|
|
17
|
-
};
|
|
9
|
+
type TitleStyleProps = G2TitleOptions & {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
18
14
|
};
|
|
19
15
|
|
|
16
|
+
function inferStyleByAlign(
|
|
17
|
+
x: number,
|
|
18
|
+
y: number,
|
|
19
|
+
width: number,
|
|
20
|
+
align: TitleStyleProps['align'],
|
|
21
|
+
) {
|
|
22
|
+
switch (align) {
|
|
23
|
+
case 'center':
|
|
24
|
+
return {
|
|
25
|
+
x: x + width / 2,
|
|
26
|
+
y,
|
|
27
|
+
textAlign: 'middle',
|
|
28
|
+
};
|
|
29
|
+
case 'right':
|
|
30
|
+
return {
|
|
31
|
+
x: x + width,
|
|
32
|
+
y,
|
|
33
|
+
textAlign: 'right',
|
|
34
|
+
};
|
|
35
|
+
default:
|
|
36
|
+
return {
|
|
37
|
+
x,
|
|
38
|
+
y,
|
|
39
|
+
textAlign: 'left',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
20
44
|
const Title = createComponent<TitleStyleProps>({
|
|
21
45
|
render(attributes, container) {
|
|
22
|
-
const {
|
|
23
|
-
|
|
46
|
+
const {
|
|
47
|
+
x,
|
|
48
|
+
y,
|
|
49
|
+
width,
|
|
50
|
+
title,
|
|
51
|
+
subtitle,
|
|
52
|
+
spacing = 2,
|
|
53
|
+
align = 'left',
|
|
54
|
+
...rest
|
|
55
|
+
} = attributes;
|
|
56
|
+
|
|
57
|
+
const titleStyle = subObject(rest, 'title');
|
|
58
|
+
const subtitleStyle = subObject(rest, 'subtitle');
|
|
59
|
+
|
|
60
|
+
const mainTitle = maybeAppend(container, '.title', 'text')
|
|
24
61
|
.attr('className', 'title')
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
.call(applyStyle, {
|
|
63
|
+
...inferStyleByAlign(0, y, width, align),
|
|
64
|
+
fontSize: 14,
|
|
65
|
+
textBaseline: 'top',
|
|
66
|
+
text: title,
|
|
67
|
+
...titleStyle,
|
|
68
|
+
})
|
|
29
69
|
.node();
|
|
30
70
|
|
|
31
|
-
const bounds =
|
|
71
|
+
const bounds = mainTitle.getLocalBounds();
|
|
32
72
|
maybeAppend(container, '.sub-title', 'text')
|
|
33
73
|
.attr('className', 'sub-title')
|
|
34
|
-
.style('y', bounds.max[1] + (subtitleStyle?.spacing || 0))
|
|
35
|
-
.style('fontSize', 12)
|
|
36
|
-
.style('textBaseline', 'top')
|
|
37
74
|
.call((selection) => {
|
|
38
75
|
if (!subtitle) return selection.node().remove();
|
|
39
|
-
selection.node().attr({
|
|
76
|
+
selection.node().attr({
|
|
77
|
+
...inferStyleByAlign(0, bounds.max[1] + spacing, width, align),
|
|
78
|
+
fontSize: 12,
|
|
79
|
+
textBaseline: 'top',
|
|
80
|
+
text: subtitle,
|
|
81
|
+
...subtitleStyle,
|
|
82
|
+
});
|
|
40
83
|
});
|
|
41
84
|
},
|
|
42
85
|
});
|
|
@@ -45,24 +88,20 @@ const Title = createComponent<TitleStyleProps>({
|
|
|
45
88
|
* Title Component.
|
|
46
89
|
*/
|
|
47
90
|
export const TitleComponent: GCC<TitleComponentOptions> = (options) => {
|
|
48
|
-
const { text, style, subtitle, subtitleStyle } = options;
|
|
49
|
-
|
|
50
91
|
return (scale, value, coordinate, theme) => {
|
|
51
|
-
const { x, y } = value.bbox;
|
|
92
|
+
const { x, y, width, height } = value.bbox;
|
|
52
93
|
return new Title({
|
|
53
94
|
style: deepMix(
|
|
54
95
|
{},
|
|
55
96
|
{
|
|
56
97
|
style: theme.title,
|
|
57
|
-
subtitleStyle: theme.subtitle,
|
|
58
98
|
},
|
|
59
99
|
{
|
|
60
100
|
x,
|
|
61
101
|
y,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
subtitleStyle,
|
|
102
|
+
width,
|
|
103
|
+
height,
|
|
104
|
+
...options,
|
|
66
105
|
},
|
|
67
106
|
),
|
|
68
107
|
});
|
|
@@ -72,5 +111,5 @@ export const TitleComponent: GCC<TitleComponentOptions> = (options) => {
|
|
|
72
111
|
TitleComponent.props = {
|
|
73
112
|
defaultPosition: 'top',
|
|
74
113
|
defaultOrder: 2,
|
|
75
|
-
defaultSize:
|
|
114
|
+
defaultSize: 36,
|
|
76
115
|
};
|
package/src/data/fold.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DataComponent as DC } from '../runtime';
|
|
|
2
2
|
import { FoldTransform } from '../spec';
|
|
3
3
|
|
|
4
4
|
export function isEmpty(obj: any) {
|
|
5
|
-
return Object.keys(obj).length === 0;
|
|
5
|
+
return !obj || Object.keys(obj).length === 0;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export type FoldOptions = Omit<FoldTransform, 'type'>;
|
|
@@ -13,16 +13,12 @@ export type FoldOptions = Omit<FoldTransform, 'type'>;
|
|
|
13
13
|
* and `value` (contains the original data value.)
|
|
14
14
|
*/
|
|
15
15
|
export const Fold: DC<FoldOptions> = (options) => {
|
|
16
|
-
const { fields,
|
|
16
|
+
const { fields, key = 'key', value = 'value' } = options;
|
|
17
17
|
return (data) => {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
r.push({ ...d, [k]: fields[i], [v]: d[fields[i]] });
|
|
23
|
-
}
|
|
24
|
-
return r;
|
|
25
|
-
}, []);
|
|
18
|
+
if (isEmpty(fields)) return data;
|
|
19
|
+
return data.flatMap((d) =>
|
|
20
|
+
fields.map((f) => ({ ...d, [key]: f, [value]: d[f] })),
|
|
21
|
+
);
|
|
26
22
|
};
|
|
27
23
|
};
|
|
28
24
|
|
package/src/data/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ export { Filter } from './filter';
|
|
|
4
4
|
export { Sort } from './sort';
|
|
5
5
|
export { Pick } from './pick';
|
|
6
6
|
export { Rename } from './rename';
|
|
7
|
-
export { Subset } from './subset';
|
|
8
7
|
export { SortBy } from './sortBy';
|
|
9
8
|
export { Inline } from './inline';
|
|
10
9
|
export { Custom } from './custom';
|
|
@@ -15,6 +14,7 @@ export { Sankey } from './sankey';
|
|
|
15
14
|
export { Arc } from './arc';
|
|
16
15
|
export { WordCloud } from './wordCloud';
|
|
17
16
|
export { Join } from './join';
|
|
17
|
+
export { Slice } from './slice';
|
|
18
18
|
|
|
19
19
|
export type { FetchOptions } from './fetch';
|
|
20
20
|
export type { FoldOptions } from './fold';
|
|
@@ -22,7 +22,6 @@ export type { FilterDataOptions } from './filter';
|
|
|
22
22
|
export type { SortOptions } from './sort';
|
|
23
23
|
export type { PickOptions } from './pick';
|
|
24
24
|
export type { RenameOptions } from './rename';
|
|
25
|
-
export type { SubsetOptions } from './subset';
|
|
26
25
|
export type { SortByOptions } from './sortBy';
|
|
27
26
|
export type { InlineOptions } from './inline';
|
|
28
27
|
export type { CustomOptions } from './custom';
|
|
@@ -33,3 +32,4 @@ export type { SankeyOptions } from './sankey';
|
|
|
33
32
|
export type { ArcOptions } from './arc';
|
|
34
33
|
export type { WordCloudOptions } from './wordCloud';
|
|
35
34
|
export type { JoinOptions } from './join';
|
|
35
|
+
export type { SliceOptions } from './slice';
|
package/src/data/pick.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { DataComponent as DC } from '../runtime';
|
|
2
2
|
import { PickTransform } from '../spec';
|
|
3
|
-
import { Subset } from './subset';
|
|
4
3
|
|
|
5
4
|
export type PickOptions = Omit<PickTransform, 'type'>;
|
|
6
5
|
|
|
6
|
+
function pick(v: any, fields: string[] = []) {
|
|
7
|
+
return fields.reduce((datum, field) => {
|
|
8
|
+
// Pick the data deeply.
|
|
9
|
+
if (field in v) {
|
|
10
|
+
datum[field] = v[field];
|
|
11
|
+
}
|
|
12
|
+
return datum;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* Immutable data pick by specified fields.
|
|
9
18
|
*/
|
|
10
19
|
export const Pick: DC<PickOptions> = (options) => {
|
|
11
20
|
const { fields } = options;
|
|
12
|
-
return
|
|
21
|
+
return (data) => data.map((d) => pick(d, fields));
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
Pick.props = {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataComponent as DC } from '../runtime';
|
|
2
|
+
import { SliceTransform } from '../spec';
|
|
3
|
+
|
|
4
|
+
export type SliceOptions = Omit<SliceTransform, 'type'>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Slice data between `start` ~ `end`.
|
|
8
|
+
* Same with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
|
|
9
|
+
*/
|
|
10
|
+
export const Slice: DC<SliceOptions> = (options) => {
|
|
11
|
+
const { start, end } = options;
|
|
12
|
+
return (data) => data.slice(start, end);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Slice.props = {};
|
|
File without changes
|
package/src/geo/geoView.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { geoPath, geoGraticule10 } from 'd3-geo';
|
|
|
4
4
|
import { CompositionComponent as CC } from '../runtime';
|
|
5
5
|
import { GeoViewComposition } from '../spec';
|
|
6
6
|
|
|
7
|
-
import * as d3Projection from './
|
|
7
|
+
import * as d3Projection from './d3Projection';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Get projection factory from d3-projection.
|
package/src/interaction/index.ts
CHANGED
|
@@ -13,6 +13,11 @@ export { LegendFilter } from './native/legendFilter';
|
|
|
13
13
|
export { BrushHighlight } from './native/brushHighlight';
|
|
14
14
|
export { BrushXHighlight } from './native/brushXHighlight';
|
|
15
15
|
export { BrushYHighlight } from './native/brushYHighlight';
|
|
16
|
+
export { BrushAxisHighlight } from './native/brushAxisHighlight';
|
|
17
|
+
export { BrushFilter } from './native/brushFilter';
|
|
18
|
+
export { BrushXFilter } from './native/brushXFilter';
|
|
19
|
+
export { BrushYFilter } from './native/brushYFilter';
|
|
20
|
+
export { SliderFilter } from './native/sliderFilter';
|
|
16
21
|
|
|
17
22
|
export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
|
|
18
23
|
|
|
@@ -31,19 +36,19 @@ export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
|
|
|
31
36
|
// export { ActiveRegion } from './builtin/activeRegion';
|
|
32
37
|
// export { EllipsisText } from './builtin/ellipsisText';
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
export type {
|
|
40
|
+
InteractionContext,
|
|
41
|
+
ActionComponent,
|
|
42
|
+
InteractionDescriptor,
|
|
43
|
+
InteractionStep,
|
|
44
|
+
InteractorOptions,
|
|
45
|
+
ActionOptions,
|
|
46
|
+
Action,
|
|
47
|
+
InteractorAction,
|
|
48
|
+
Interactor,
|
|
49
|
+
G2Event,
|
|
50
|
+
InteractionNamespaces,
|
|
51
|
+
InteractorComponent,
|
|
52
|
+
InteractionOptions,
|
|
53
|
+
InteractionValue,
|
|
54
|
+
} from './types';
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Rect } from '@antv/g';
|
|
2
|
+
import { subObject } from '../../utils/helper';
|
|
3
|
+
import { brush } from './brushHighlight';
|
|
4
|
+
import { brushXRegion } from './brushXHighlight';
|
|
5
|
+
import { brushYRegion } from './brushYHighlight';
|
|
6
|
+
import {
|
|
7
|
+
selectG2Elements,
|
|
8
|
+
createDatumof,
|
|
9
|
+
createValueof,
|
|
10
|
+
useState,
|
|
11
|
+
selectPlotArea,
|
|
12
|
+
} from './utils';
|
|
13
|
+
|
|
14
|
+
export const AXIS_CLASS_NAME = 'axis';
|
|
15
|
+
|
|
16
|
+
export const AXIS_LINE_CLASS_NAME = 'axis-line';
|
|
17
|
+
|
|
18
|
+
export const AXIS_MAIN_CLASS_NAME = 'axis-main-group';
|
|
19
|
+
|
|
20
|
+
export const AXIS_HOT_AREA_CLASS_NAME = 'axis-hot-area';
|
|
21
|
+
|
|
22
|
+
function axesOf(container) {
|
|
23
|
+
return container.getElementsByClassName(AXIS_CLASS_NAME);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function lineOf(axis) {
|
|
27
|
+
return axis.getElementsByClassName(AXIS_LINE_CLASS_NAME)[0];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function mainGroupOf(axis) {
|
|
31
|
+
return axis.getElementsByClassName(AXIS_MAIN_CLASS_NAME)[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Use the bounds of main group of axis as the bounds of axis,
|
|
35
|
+
// get rid of grid and title.
|
|
36
|
+
function boundsOfAxis(axis) {
|
|
37
|
+
return mainGroupOf(axis).getLocalBounds();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Brush for vertical axis.
|
|
41
|
+
function verticalBrush(axis, { cross, offsetX, offsetY, ...style }) {
|
|
42
|
+
const bounds = boundsOfAxis(axis);
|
|
43
|
+
const axisLine = lineOf(axis);
|
|
44
|
+
const [lineX] = axisLine.getLocalBounds().min;
|
|
45
|
+
const [minX, minY] = bounds.min;
|
|
46
|
+
const [maxX, maxY] = bounds.max;
|
|
47
|
+
const size = (maxX - minX) * 2;
|
|
48
|
+
return {
|
|
49
|
+
brushRegion: brushYRegion,
|
|
50
|
+
hotZone: new Rect({
|
|
51
|
+
className: AXIS_HOT_AREA_CLASS_NAME,
|
|
52
|
+
style: {
|
|
53
|
+
// If it is not cross, draw brush in both side of axisLine,
|
|
54
|
+
// otherwise the draw brush within bounds area.
|
|
55
|
+
x: cross ? minX : lineX - size / 2,
|
|
56
|
+
width: cross ? size / 2 : size,
|
|
57
|
+
y: minY,
|
|
58
|
+
height: maxY - minY,
|
|
59
|
+
...style,
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
extent: cross
|
|
63
|
+
? // If it is cross, the x range is ignored.
|
|
64
|
+
(x, y, x1, y1) => [-Infinity, y, Infinity, y1]
|
|
65
|
+
: (x, y, x1, y1) => [
|
|
66
|
+
Math.floor(minX - offsetX),
|
|
67
|
+
y,
|
|
68
|
+
Math.ceil(maxX - offsetX),
|
|
69
|
+
y1,
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Brush for horizontal axis.
|
|
75
|
+
function horizontalBrush(axis, { offsetY, offsetX, cross = false, ...style }) {
|
|
76
|
+
const bounds = boundsOfAxis(axis);
|
|
77
|
+
const axisLine = lineOf(axis);
|
|
78
|
+
const [, lineY] = axisLine.getLocalBounds().min;
|
|
79
|
+
const [minX, minY] = bounds.min;
|
|
80
|
+
const [maxX, maxY] = bounds.max;
|
|
81
|
+
const size = maxY - minY;
|
|
82
|
+
return {
|
|
83
|
+
brushRegion: brushXRegion,
|
|
84
|
+
hotZone: new Rect({
|
|
85
|
+
className: AXIS_HOT_AREA_CLASS_NAME,
|
|
86
|
+
style: {
|
|
87
|
+
x: minX,
|
|
88
|
+
width: maxX - minX,
|
|
89
|
+
// If it is not cross, draw brush in both side of axisLine,
|
|
90
|
+
// otherwise the draw brush within bounds area.
|
|
91
|
+
y: cross ? minY : lineY - size,
|
|
92
|
+
height: cross ? size : size * 2,
|
|
93
|
+
...style,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
extent: cross
|
|
97
|
+
? // If it is cross, the y range is ignored.
|
|
98
|
+
(x, y, x1, y1) => [x, -Infinity, x1, Infinity]
|
|
99
|
+
: (x, y, x1, y1) => [
|
|
100
|
+
x,
|
|
101
|
+
Math.floor(minY - offsetY),
|
|
102
|
+
x1,
|
|
103
|
+
Math.ceil(maxY - offsetY),
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function brushAxisHighlight(
|
|
109
|
+
root,
|
|
110
|
+
{
|
|
111
|
+
axes: axesOf, // given root, return axes
|
|
112
|
+
elements: elementsOf, // given root, return elements
|
|
113
|
+
points: pointsOf, // given shape, return control points
|
|
114
|
+
horizontal: isHorizontal, // given axis, return direction
|
|
115
|
+
datum, // given shape, return datum
|
|
116
|
+
offsetY, // offsetY for shape area
|
|
117
|
+
offsetX, // offsetX for shape area
|
|
118
|
+
reverse = false,
|
|
119
|
+
...rest // style
|
|
120
|
+
},
|
|
121
|
+
) {
|
|
122
|
+
const elements = elementsOf(root);
|
|
123
|
+
const axes = axesOf(root);
|
|
124
|
+
const valueof = createValueof(elements, datum);
|
|
125
|
+
const { setState } = useState(rest, valueof);
|
|
126
|
+
const axisExtent = new Map();
|
|
127
|
+
const brushStyle = subObject(rest, 'mask');
|
|
128
|
+
|
|
129
|
+
// Only some of shape's points in all mask, it is selected.
|
|
130
|
+
const brushed = (points) =>
|
|
131
|
+
Array.from(axisExtent.values()).every(([x, y, x1, y1]) =>
|
|
132
|
+
points.some(([x0, y0]) => {
|
|
133
|
+
return x0 >= x && x0 <= x1 && y0 >= y && y0 <= y1;
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Update element when brush changed.
|
|
138
|
+
const updateElement = () => {
|
|
139
|
+
for (const element of elements) {
|
|
140
|
+
const points = pointsOf(element);
|
|
141
|
+
if (brushed(points)) setState(element, 'highlighted');
|
|
142
|
+
else setState(element, 'unhighlighted');
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Distinguish between parallel coordinates and normal charts.
|
|
147
|
+
const cross = axes.some(isHorizontal) && axes.some((d) => !isHorizontal(d));
|
|
148
|
+
for (const axis of axes) {
|
|
149
|
+
const createBrush = isHorizontal(axis) ? horizontalBrush : verticalBrush;
|
|
150
|
+
const { hotZone, brushRegion, extent } = createBrush(axis, {
|
|
151
|
+
offsetY,
|
|
152
|
+
offsetX,
|
|
153
|
+
cross,
|
|
154
|
+
zIndex: 999, // Pin mask to top.
|
|
155
|
+
fill: 'transparent', // Make it interactive.
|
|
156
|
+
});
|
|
157
|
+
axis.parentNode.appendChild(hotZone);
|
|
158
|
+
brush(hotZone, {
|
|
159
|
+
...brushStyle,
|
|
160
|
+
reverse,
|
|
161
|
+
brushRegion,
|
|
162
|
+
brushended() {
|
|
163
|
+
axisExtent.delete(axis);
|
|
164
|
+
updateElement();
|
|
165
|
+
},
|
|
166
|
+
brushed(x, y, x1, y1) {
|
|
167
|
+
axisExtent.set(axis, extent(x, y, x1, y1));
|
|
168
|
+
updateElement();
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @todo Support mask size.
|
|
176
|
+
*/
|
|
177
|
+
export function BrushAxisHighlight(options) {
|
|
178
|
+
return (target) => {
|
|
179
|
+
const { container, view } = target;
|
|
180
|
+
const plotArea = selectPlotArea(container);
|
|
181
|
+
const { x: x0, y: y0 } = plotArea.getBBox();
|
|
182
|
+
return brushAxisHighlight(container, {
|
|
183
|
+
elements: selectG2Elements,
|
|
184
|
+
axes: axesOf,
|
|
185
|
+
offsetY: y0,
|
|
186
|
+
offsetX: x0,
|
|
187
|
+
points: (element) => element.__data__.points,
|
|
188
|
+
horizontal: (axis) => axis.attributes.horizontal,
|
|
189
|
+
datum: createDatumof(view),
|
|
190
|
+
unhighlightedOpacity: 0.5,
|
|
191
|
+
...options,
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
}
|