@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/runtime/render.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Canvas as GCanvas, DisplayObject, Group } from '@antv/g';
|
|
2
2
|
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
3
|
import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
4
|
-
import {
|
|
4
|
+
import { deepMix } from '@antv/util';
|
|
5
5
|
import { createLibrary } from '../stdlib';
|
|
6
6
|
import { select } from '../utils/selection';
|
|
7
7
|
import { emitEvent, CHART_LIFE_CIRCLE, offEvent } from '../utils/event';
|
|
8
|
-
import { getChartSize } from '../utils/size';
|
|
9
8
|
import { G2Context, G2ViewTree } from './types/options';
|
|
10
9
|
import { plot } from './plot';
|
|
11
10
|
|
|
@@ -64,18 +63,11 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
64
63
|
callback?: () => void,
|
|
65
64
|
): HTMLElement {
|
|
66
65
|
// Initialize the context if it is not provided.
|
|
67
|
-
const { width = 640, height = 480,
|
|
66
|
+
const { width = 640, height = 480, on } = options;
|
|
68
67
|
const keyed = inferKeys(options);
|
|
69
68
|
const { canvas = Canvas(width, height), library = createLibrary() } = context;
|
|
70
69
|
context.canvas = canvas;
|
|
71
70
|
context.library = library;
|
|
72
|
-
|
|
73
|
-
if (autoFit && !context.bindAutoFit) {
|
|
74
|
-
// Bind the autoFit event once.
|
|
75
|
-
bindAutoFit(options, context);
|
|
76
|
-
context.bindAutoFit = true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
canvas.resize(width, height);
|
|
80
72
|
|
|
81
73
|
emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_RENDER);
|
|
@@ -104,8 +96,10 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
|
|
|
104
96
|
const keyed = inferKeys(options);
|
|
105
97
|
const { library = createLibrary(), group = new Group() } = context;
|
|
106
98
|
|
|
107
|
-
if (
|
|
108
|
-
throw new Error(
|
|
99
|
+
if (!group?.parentElement) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`renderToMountedElement can't render chart to unmounted group.`,
|
|
102
|
+
);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
const selection = select(group);
|
|
@@ -132,9 +126,6 @@ export function destroy<T extends G2ViewTree = G2ViewTree>(
|
|
|
132
126
|
if (canvas) {
|
|
133
127
|
canvas.destroy();
|
|
134
128
|
}
|
|
135
|
-
|
|
136
|
-
// Unbind chart events.
|
|
137
|
-
unbindAutoFit(options, context);
|
|
138
129
|
offEvent(on);
|
|
139
130
|
}
|
|
140
131
|
|
|
@@ -143,46 +134,3 @@ function normalizeContainer(container: HTMLElement | string): HTMLElement {
|
|
|
143
134
|
? document.getElementById(container)
|
|
144
135
|
: container;
|
|
145
136
|
}
|
|
146
|
-
|
|
147
|
-
const onResize = <T extends G2ViewTree = G2ViewTree>(
|
|
148
|
-
options: T,
|
|
149
|
-
context: G2Context = {},
|
|
150
|
-
) =>
|
|
151
|
-
debounce(() => {
|
|
152
|
-
// Update size.
|
|
153
|
-
const { width, height, autoFit } = options;
|
|
154
|
-
const { canvas } = context;
|
|
155
|
-
const container = canvas.getConfig().container as HTMLElement;
|
|
156
|
-
const { width: adjustedWidth, height: adjustedHeight } = getChartSize(
|
|
157
|
-
container,
|
|
158
|
-
autoFit,
|
|
159
|
-
width,
|
|
160
|
-
height,
|
|
161
|
-
);
|
|
162
|
-
const newOptions = {
|
|
163
|
-
...options,
|
|
164
|
-
width: adjustedWidth,
|
|
165
|
-
height: adjustedHeight,
|
|
166
|
-
};
|
|
167
|
-
if (newOptions.width && newOptions.height) render(newOptions, context);
|
|
168
|
-
}, 300);
|
|
169
|
-
|
|
170
|
-
export function bindAutoFit<T extends G2ViewTree = G2ViewTree>(
|
|
171
|
-
options: T,
|
|
172
|
-
context: G2Context = {},
|
|
173
|
-
) {
|
|
174
|
-
const { autoFit } = options;
|
|
175
|
-
if (autoFit) {
|
|
176
|
-
window.addEventListener('resize', onResize(options, context));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function unbindAutoFit<T extends G2ViewTree = G2ViewTree>(
|
|
181
|
-
options: T,
|
|
182
|
-
context: G2Context = {},
|
|
183
|
-
) {
|
|
184
|
-
const { autoFit } = options;
|
|
185
|
-
if (autoFit) {
|
|
186
|
-
window.removeEventListener('resize', onResize(options, context));
|
|
187
|
-
}
|
|
188
|
-
}
|
package/src/runtime/scale.ts
CHANGED
|
@@ -103,6 +103,20 @@ export function useRelation(
|
|
|
103
103
|
return [conditionalize, deconditionalize];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
export function useRelationScale(
|
|
107
|
+
options: Record<string, any>,
|
|
108
|
+
library: G2Library,
|
|
109
|
+
) {
|
|
110
|
+
const [useScale] = useLibrary<G2ScaleOptions, ScaleComponent, Scale>(
|
|
111
|
+
'scale',
|
|
112
|
+
library,
|
|
113
|
+
);
|
|
114
|
+
const { relations } = options;
|
|
115
|
+
const [conditionalize] = useRelation(relations);
|
|
116
|
+
const scale = useScale(options);
|
|
117
|
+
return conditionalize(scale);
|
|
118
|
+
}
|
|
119
|
+
|
|
106
120
|
export function syncFacetsScales(states: Map<G2Mark, G2MarkState>[]): void {
|
|
107
121
|
const scales = states
|
|
108
122
|
.flatMap((d) => Array.from(d.values()))
|
package/src/runtime/transform.ts
CHANGED
|
@@ -149,7 +149,7 @@ export function addGuideToScale(
|
|
|
149
149
|
mark: G2Mark,
|
|
150
150
|
context: TransformContext,
|
|
151
151
|
): [number[], G2Mark] {
|
|
152
|
-
const { axis = {}, legend = {} } = mark;
|
|
152
|
+
const { axis = {}, legend = {}, slider = {}, scrollbar = {} } = mark;
|
|
153
153
|
const normalize = (guide: boolean | Record<string, any>, channel: string) => {
|
|
154
154
|
if (typeof guide === 'boolean') return guide ? {} : null;
|
|
155
155
|
const eachGuide = guide[channel];
|
|
@@ -165,7 +165,11 @@ export function addGuideToScale(
|
|
|
165
165
|
...Object.fromEntries(
|
|
166
166
|
axisChannels.map((channel) => [
|
|
167
167
|
channel,
|
|
168
|
-
{
|
|
168
|
+
{
|
|
169
|
+
guide: normalize(axis, channel),
|
|
170
|
+
slider: normalize(slider, channel),
|
|
171
|
+
scrollbar: normalize(scrollbar, channel),
|
|
172
|
+
},
|
|
169
173
|
]),
|
|
170
174
|
),
|
|
171
175
|
color: { guide: normalize(legend, 'color') },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { DisplayObject, TextStyleProps } from '@antv/g';
|
|
3
3
|
import { G2GuideComponentOptions, G2Mark, G2ViewTree } from './options';
|
|
4
4
|
import { LabelTransform, Scale } from './component';
|
|
5
5
|
import { MarkProps } from './mark';
|
|
@@ -8,11 +8,28 @@ import { G2Theme } from './theme';
|
|
|
8
8
|
export type { G2Theme };
|
|
9
9
|
|
|
10
10
|
export type G2Title = {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Height of title, default is 36.
|
|
13
|
+
*/
|
|
14
|
+
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Text of title.
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Text of subtitle.
|
|
21
|
+
*/
|
|
12
22
|
subtitle?: string | null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Align method for title.
|
|
25
|
+
*/
|
|
26
|
+
align?: 'left' | 'center' | 'right';
|
|
27
|
+
/**
|
|
28
|
+
* The vertical spacing between title and subtitle, default is 2.
|
|
29
|
+
*/
|
|
30
|
+
spacing?: number;
|
|
31
|
+
} & WithPrefix<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'title'> & // G.Text style for title.
|
|
32
|
+
WithPrefix<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'subtitle'>; // G.Text style for subtitle.
|
|
16
33
|
|
|
17
34
|
export type G2ViewDescriptor = {
|
|
18
35
|
scale: Record<string, Scale>;
|
|
@@ -59,10 +76,9 @@ export type Primitive = number | string | boolean | Date;
|
|
|
59
76
|
|
|
60
77
|
export type TabularData = Record<string, Primitive>[];
|
|
61
78
|
|
|
62
|
-
export type WithPrefix<
|
|
63
|
-
string
|
|
64
|
-
|
|
65
|
-
: unknown;
|
|
79
|
+
export type WithPrefix<O extends Record<string, any>, P extends string> = {
|
|
80
|
+
[K in keyof O as `${P}${Capitalize<K & string>}`]?: O[K];
|
|
81
|
+
};
|
|
66
82
|
|
|
67
83
|
export type EncodeFunction = (
|
|
68
84
|
data: Record<string, MaybeArray<Primitive>>[],
|
|
@@ -116,8 +132,8 @@ export type GuideComponentPosition =
|
|
|
116
132
|
| 'left'
|
|
117
133
|
| 'bottom'
|
|
118
134
|
| 'right'
|
|
119
|
-
| 'centerHorizontal'
|
|
120
135
|
| 'centerVertical'
|
|
136
|
+
| 'centerHorizontal'
|
|
121
137
|
| 'center'
|
|
122
138
|
| 'arc'
|
|
123
139
|
| 'arcY'
|
|
@@ -102,6 +102,7 @@ export type G2Mark = {
|
|
|
102
102
|
axis?: boolean | Record<string, any>;
|
|
103
103
|
legend?: boolean | Record<string, any>;
|
|
104
104
|
slider?: Record<string, any>;
|
|
105
|
+
scrollbar?: Record<string, any>;
|
|
105
106
|
filter?: (i: number) => boolean;
|
|
106
107
|
children?: G2MarkChildrenCallback;
|
|
107
108
|
dataDomain?: number;
|
|
@@ -180,9 +181,5 @@ export type G2CompositionOptions = G2BaseComponentOptions<CompositionComponent>;
|
|
|
180
181
|
export type G2AdjustOptions = G2BaseComponentOptions<AdjustComponent>;
|
|
181
182
|
export type G2LabelTransformOptions =
|
|
182
183
|
G2BaseComponentOptions<LabelTransformComponent>;
|
|
183
|
-
export type G2TitleOptions = G2Title
|
|
184
|
-
position?: GuideComponentPosition;
|
|
185
|
-
size?: number;
|
|
186
|
-
zIndex?: number;
|
|
187
|
-
};
|
|
184
|
+
export type G2TitleOptions = G2Title;
|
|
188
185
|
export type G2DataOptions = G2BaseComponent<DataComponent>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextStyleProps, PathStyleProps } from '@antv/g';
|
|
2
|
-
import { WithPrefix } from './common';
|
|
2
|
+
import { G2Title, WithPrefix } from './common';
|
|
3
3
|
|
|
4
4
|
type TupleToUnion<T, U> = T extends [infer F, ...infer R]
|
|
5
5
|
? F extends string
|
|
@@ -81,10 +81,7 @@ type ComponentTheme = {
|
|
|
81
81
|
innerLabel?: LabelStyleProps;
|
|
82
82
|
slider?: any;
|
|
83
83
|
scrollbar?: any;
|
|
84
|
-
title?:
|
|
85
|
-
subtitle?: Omit<TextStyleProps, 'text'> & {
|
|
86
|
-
spacing?: number;
|
|
87
|
-
};
|
|
84
|
+
title?: Partial<G2Title>;
|
|
88
85
|
};
|
|
89
86
|
|
|
90
87
|
type AnimationTheme = {
|
package/src/shape/area/curve.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { area, areaRadial, CurveFactory } from 'd3-shape';
|
|
2
2
|
import { Path } from '@antv/g';
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
|
-
import { isPolar } from '../../utils/coordinate';
|
|
4
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
5
5
|
import { Vector2, ShapeComponent as SC } from '../../runtime';
|
|
6
6
|
import { angleWithQuadrant, sub, dist } from '../../utils/vector';
|
|
7
7
|
import {
|
|
@@ -86,7 +86,7 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
86
86
|
} = options;
|
|
87
87
|
return (P, value, coordinate, theme) => {
|
|
88
88
|
const { mark, shape, defaultShape } = value;
|
|
89
|
-
const {
|
|
89
|
+
const { defaultColor, ...defaults } = getShapeTheme(
|
|
90
90
|
theme,
|
|
91
91
|
mark,
|
|
92
92
|
shape,
|
|
@@ -128,12 +128,19 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
128
128
|
const areaPath = (points) => {
|
|
129
129
|
const Y1 = points.slice(0, points.length / 2);
|
|
130
130
|
const Y0 = points.slice(points.length / 2);
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
return isTranspose(coordinate)
|
|
132
|
+
? area()
|
|
133
|
+
.y((_, idx) => Y1[idx][1])
|
|
134
|
+
.x1((_, idx) => Y1[idx][0])
|
|
135
|
+
.x0((_, idx) => Y0[idx][0])
|
|
136
|
+
.defined((_, idx) => [...Y1[idx], ...Y0[idx]].every(defined))
|
|
137
|
+
.curve(curve)(Y1)
|
|
138
|
+
: area()
|
|
139
|
+
.x((_, idx) => Y1[idx][0])
|
|
140
|
+
.y1((_, idx) => Y1[idx][1])
|
|
141
|
+
.y0((_, idx) => Y0[idx][1])
|
|
142
|
+
.defined((_, idx) => [...Y1[idx], ...Y0[idx]].every(defined))
|
|
143
|
+
.curve(curve)(Y1);
|
|
137
144
|
};
|
|
138
145
|
|
|
139
146
|
// Draw one area of connected defined points.
|
package/src/shape/box/box.ts
CHANGED
|
@@ -77,12 +77,12 @@ export const Box: SC<BoxOptions> = (options) => {
|
|
|
77
77
|
const { ...style } = options;
|
|
78
78
|
return (points, value, coordinate, theme) => {
|
|
79
79
|
const { mark, shape, defaultShape, color, transform } = value;
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
80
|
+
const {
|
|
81
|
+
defaultColor,
|
|
82
|
+
fill = defaultColor,
|
|
83
|
+
stroke = defaultColor,
|
|
84
|
+
...shapeTheme
|
|
85
|
+
} = getShapeTheme(theme, mark, shape, defaultShape);
|
|
86
86
|
|
|
87
87
|
const path = getPath(points, coordinate);
|
|
88
88
|
|
|
@@ -102,8 +102,7 @@ export const Connector: SC<ConnectorOptions> = (options) => {
|
|
|
102
102
|
return (points, value, coordinate, theme) => {
|
|
103
103
|
const { mark, shape, defaultShape } = value;
|
|
104
104
|
const {
|
|
105
|
-
|
|
106
|
-
stroke = fill,
|
|
105
|
+
defaultColor,
|
|
107
106
|
connectLength1 = length1,
|
|
108
107
|
...shapeTheme
|
|
109
108
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|
|
@@ -114,7 +113,7 @@ export const Connector: SC<ConnectorOptions> = (options) => {
|
|
|
114
113
|
return select(new ConnectorPath())
|
|
115
114
|
.call(applyStyle, shapeTheme)
|
|
116
115
|
.style('points', P)
|
|
117
|
-
.style('stroke', color ||
|
|
116
|
+
.style('stroke', color || defaultColor)
|
|
118
117
|
.style('transform', transform)
|
|
119
118
|
.call(applyStyle, style)
|
|
120
119
|
.node();
|
package/src/shape/image/image.ts
CHANGED
|
@@ -9,13 +9,13 @@ export const Image: SC<ImageOptions> = (options) => {
|
|
|
9
9
|
const { ...style } = options;
|
|
10
10
|
return (points, value, coordinate, theme) => {
|
|
11
11
|
const { mark, shape, defaultShape } = value;
|
|
12
|
-
const {
|
|
12
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
13
13
|
theme,
|
|
14
14
|
mark,
|
|
15
15
|
shape,
|
|
16
16
|
defaultShape,
|
|
17
17
|
);
|
|
18
|
-
const { color =
|
|
18
|
+
const { color = defaultColor, src = '', size = 32, transform = '' } = value;
|
|
19
19
|
const { width = size, height = size } = style;
|
|
20
20
|
const [[x0, y0]] = points;
|
|
21
21
|
|
|
@@ -36,7 +36,8 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
36
36
|
return (points, value, coordinate, theme) => {
|
|
37
37
|
const { mark, shape, defaultShape } = value;
|
|
38
38
|
const {
|
|
39
|
-
[colorAttribute]: defaultColor,
|
|
39
|
+
// [colorAttribute]: defaultColor,
|
|
40
|
+
defaultColor,
|
|
40
41
|
radius: defaultRadius = 0,
|
|
41
42
|
...defaults
|
|
42
43
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|
|
@@ -85,7 +85,7 @@ export function inferRadialStyle(
|
|
|
85
85
|
const [p0, p1] = points;
|
|
86
86
|
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
87
87
|
const [x, y] =
|
|
88
|
-
position === 'inside' ?
|
|
88
|
+
position === 'inside' ? pointOfArc(center, angle, radius) : mid(p0, p1);
|
|
89
89
|
return { x, y };
|
|
90
90
|
})();
|
|
91
91
|
|
|
@@ -97,25 +97,21 @@ export function inferRadialStyle(
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function
|
|
100
|
+
export function pointOfArc(center: Vector2, angle, radius): Vector2 {
|
|
101
101
|
return [
|
|
102
102
|
center[0] + Math.sin(angle) * radius,
|
|
103
103
|
center[1] - Math.cos(angle) * radius,
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function inferRotation(
|
|
108
|
-
angle: number,
|
|
109
|
-
autoRotate: boolean,
|
|
110
|
-
rotateToAlignArc: boolean,
|
|
111
|
-
) {
|
|
107
|
+
export function inferRotation(angle, autoRotate, rotateToAlignArc) {
|
|
112
108
|
if (!autoRotate) return 0;
|
|
113
109
|
|
|
114
110
|
const append = rotateToAlignArc ? 0 : Math.sin(angle) < 0 ? 90 : -90;
|
|
115
111
|
return (angle / Math.PI) * 180 + append;
|
|
116
112
|
}
|
|
117
113
|
|
|
118
|
-
|
|
114
|
+
function inferInnerCircularStyle(
|
|
119
115
|
position: LabelPosition,
|
|
120
116
|
points: Vector2[],
|
|
121
117
|
value: Record<string, any>,
|
|
@@ -126,9 +122,6 @@ export function inferCircularStyle(
|
|
|
126
122
|
y1,
|
|
127
123
|
autoRotate,
|
|
128
124
|
rotateToAlignArc,
|
|
129
|
-
connector = true,
|
|
130
|
-
connectorLength2 = 0,
|
|
131
|
-
connectorDistance = 0,
|
|
132
125
|
radius: radiusRatio = 0.5,
|
|
133
126
|
offset = 0,
|
|
134
127
|
} = value;
|
|
@@ -137,55 +130,22 @@ export function inferCircularStyle(
|
|
|
137
130
|
const center = coordinate.getCenter();
|
|
138
131
|
|
|
139
132
|
const angle = (startAngle + endAngle) / 2;
|
|
133
|
+
const rotate = inferRotation(angle, autoRotate, rotateToAlignArc);
|
|
140
134
|
|
|
141
|
-
const textStyle =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
textAlign: sign ? 'start' : 'end',
|
|
147
|
-
textBaseline: 'middle',
|
|
148
|
-
rotate,
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
const [r0, r1] = (() => {
|
|
152
|
-
const ratio = position === 'inside' ? radiusRatio : 1;
|
|
153
|
-
const { innerRadius, outerRadius } = arcObject;
|
|
154
|
-
const r0 = innerRadius + (outerRadius - innerRadius) * ratio;
|
|
155
|
-
const r1 = r0 + offset;
|
|
156
|
-
return [r0, r1];
|
|
157
|
-
})();
|
|
158
|
-
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
159
|
-
|
|
160
|
-
const [p0, p1, ...connectorPoints] = ((
|
|
161
|
-
radius: number,
|
|
162
|
-
finalRadius: number,
|
|
163
|
-
) => {
|
|
164
|
-
const [x0, y0] = arcPoint(center, angle, radius);
|
|
165
|
-
const [x, y] = arcPoint(center, angle, finalRadius);
|
|
166
|
-
const length2 = connector ? sign * connectorLength2 : 0;
|
|
167
|
-
const p0 = [x0, y0];
|
|
168
|
-
const p1 = [x + length2, y];
|
|
169
|
-
return [p0, p1, [-length2, 0]] as Vector2[];
|
|
170
|
-
})(r0, r1);
|
|
171
|
-
|
|
172
|
-
const connectorStyle = {
|
|
173
|
-
connector,
|
|
174
|
-
connectorPoints,
|
|
175
|
-
dx: connector ? +connectorDistance * sign : 0,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const toPoint = (v: Vector2, x = 'x', y = 'y') => ({ [x]: v[0], [y]: v[1] });
|
|
135
|
+
const textStyle = { textAlign: 'center', textBaseline: 'middle', rotate };
|
|
136
|
+
const { innerRadius, outerRadius } = arcObject;
|
|
137
|
+
const r0 = innerRadius + (outerRadius - innerRadius) * radiusRatio;
|
|
138
|
+
const r1 = r0 + offset;
|
|
139
|
+
const [x0, y0] = pointOfArc(center, angle, r1);
|
|
179
140
|
|
|
180
141
|
return {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
...textStyle
|
|
184
|
-
...connectorStyle,
|
|
142
|
+
x: x0,
|
|
143
|
+
y: y0,
|
|
144
|
+
...textStyle,
|
|
185
145
|
};
|
|
186
146
|
}
|
|
187
147
|
|
|
188
|
-
function inferIdentityStyle(position, points, value, coordinate) {
|
|
148
|
+
export function inferIdentityStyle(position, points, value, coordinate) {
|
|
189
149
|
const { bounds } = value;
|
|
190
150
|
const [p] = bounds;
|
|
191
151
|
return {
|
|
@@ -212,7 +172,7 @@ export function getDefaultStyle(
|
|
|
212
172
|
const inferDefaultStyle = isRadial(coordinate)
|
|
213
173
|
? inferRadialStyle
|
|
214
174
|
: isCircular(coordinate)
|
|
215
|
-
?
|
|
175
|
+
? inferInnerCircularStyle
|
|
216
176
|
: inferNonCircularStyle;
|
|
217
177
|
|
|
218
178
|
return inferDefaultStyle(position, points, value, coordinate);
|
|
@@ -1 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { Vector2 } from '../../../runtime';
|
|
3
|
+
import { getArcObject } from '../../../shape/utils';
|
|
4
|
+
import { isCircular, isRadial } from '../../../utils/coordinate';
|
|
5
|
+
|
|
6
|
+
import type { LabelPosition } from './default';
|
|
7
|
+
import {
|
|
8
|
+
pointOfArc,
|
|
9
|
+
inferRotation,
|
|
10
|
+
inferIdentityStyle,
|
|
11
|
+
inferRadialStyle,
|
|
12
|
+
inferNonCircularStyle,
|
|
13
|
+
} from './default';
|
|
14
|
+
|
|
15
|
+
export function linePoints(center: Vector2, angle, radius, radius1, offsetX) {
|
|
16
|
+
const [x0, y0] = pointOfArc(center, angle, radius);
|
|
17
|
+
const [x1, y1] = pointOfArc(center, angle, radius1);
|
|
18
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
19
|
+
return [
|
|
20
|
+
[x0, y0],
|
|
21
|
+
[x1, y1],
|
|
22
|
+
[x1 + sign * offsetX, y1],
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function radiusOf(points, value, coordinate) {
|
|
27
|
+
const arcObject = getArcObject(coordinate, points, [value.y, value.y1]);
|
|
28
|
+
const { innerRadius, outerRadius } = arcObject;
|
|
29
|
+
return innerRadius + (outerRadius - innerRadius);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function angleOf(points, value, coordinate) {
|
|
33
|
+
const arcObject = getArcObject(coordinate, points, [value.y, value.y1]);
|
|
34
|
+
const { startAngle, endAngle } = arcObject;
|
|
35
|
+
|
|
36
|
+
return (startAngle + endAngle) / 2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function inferOutsideCircularStyle(
|
|
40
|
+
position: LabelPosition,
|
|
41
|
+
points: Vector2[],
|
|
42
|
+
value: Record<string, any>,
|
|
43
|
+
coordinate: Coordinate,
|
|
44
|
+
) {
|
|
45
|
+
const {
|
|
46
|
+
autoRotate,
|
|
47
|
+
rotateToAlignArc,
|
|
48
|
+
offset = 0,
|
|
49
|
+
connector = true,
|
|
50
|
+
connectorLength = offset,
|
|
51
|
+
connectorLength2 = 0,
|
|
52
|
+
connectorDistance = 0,
|
|
53
|
+
} = value;
|
|
54
|
+
const center = coordinate.getCenter();
|
|
55
|
+
|
|
56
|
+
const angle = angleOf(points, value, coordinate);
|
|
57
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
58
|
+
|
|
59
|
+
const rotate = inferRotation(angle, autoRotate, rotateToAlignArc);
|
|
60
|
+
const textStyle = {
|
|
61
|
+
textAlign: sign > 0 || isRadial(coordinate) ? 'start' : 'end',
|
|
62
|
+
textBaseline: 'middle',
|
|
63
|
+
rotate,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const radius = radiusOf(points, value, coordinate);
|
|
67
|
+
const radius1 = radius + (connector ? connectorLength : offset);
|
|
68
|
+
|
|
69
|
+
const [[x0, y0], [x1, y1], [x2, y2]] = linePoints(
|
|
70
|
+
center,
|
|
71
|
+
angle,
|
|
72
|
+
radius,
|
|
73
|
+
radius1,
|
|
74
|
+
connector ? connectorLength2 : 0,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const dx = connector ? +connectorDistance * sign : 0;
|
|
78
|
+
|
|
79
|
+
const x = x2 + dx;
|
|
80
|
+
const y = y2;
|
|
81
|
+
const connectorStyle = {
|
|
82
|
+
connector,
|
|
83
|
+
connectorPoints: [
|
|
84
|
+
[x1 - x, y1 - y],
|
|
85
|
+
[x2 - x, y2 - y],
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
x0,
|
|
91
|
+
y0,
|
|
92
|
+
x: x2 + dx,
|
|
93
|
+
y: y2,
|
|
94
|
+
...textStyle,
|
|
95
|
+
...connectorStyle,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function outside(
|
|
100
|
+
position: LabelPosition,
|
|
101
|
+
points: Vector2[],
|
|
102
|
+
value: Record<string, any>,
|
|
103
|
+
coordinate: Coordinate,
|
|
104
|
+
) {
|
|
105
|
+
const { bounds } = value;
|
|
106
|
+
// When bounds.length = 1
|
|
107
|
+
// For series mark, such as line and area.
|
|
108
|
+
// The bounds for text is defined with only one point.
|
|
109
|
+
// Use this point as the label position.
|
|
110
|
+
if (bounds.length === 1) {
|
|
111
|
+
return inferIdentityStyle(position, points, value, coordinate);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const inferDefaultStyle = isRadial(coordinate)
|
|
115
|
+
? inferRadialStyle
|
|
116
|
+
: isCircular(coordinate)
|
|
117
|
+
? inferOutsideCircularStyle
|
|
118
|
+
: inferNonCircularStyle;
|
|
119
|
+
|
|
120
|
+
return inferDefaultStyle(position, points, value, coordinate);
|
|
121
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { sub } from '../../../utils/vector';
|
|
3
2
|
import { Vector2 } from '../../../runtime';
|
|
4
3
|
import { isCircular } from '../../../utils/coordinate';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { LabelPosition } from './default';
|
|
5
|
+
import { inferOutsideCircularStyle, radiusOf, angleOf } from './outside';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
|
|
@@ -13,34 +12,28 @@ export function spider(
|
|
|
13
12
|
points: Vector2[],
|
|
14
13
|
value: Record<string, any>,
|
|
15
14
|
coordinate: Coordinate,
|
|
16
|
-
options,
|
|
17
15
|
) {
|
|
18
16
|
if (!isCircular(coordinate)) return {};
|
|
19
|
-
const {
|
|
17
|
+
const { connectorLength, connectorLength2, connectorDistance } = value;
|
|
20
18
|
|
|
21
|
-
const { ...style }: any =
|
|
19
|
+
const { ...style }: any = inferOutsideCircularStyle(
|
|
22
20
|
'outside',
|
|
23
21
|
points,
|
|
24
22
|
value,
|
|
25
23
|
coordinate,
|
|
26
24
|
);
|
|
27
|
-
const { x: coordX, width } = coordinate.getOptions();
|
|
28
25
|
const center = coordinate.getCenter();
|
|
29
|
-
|
|
30
|
-
const
|
|
26
|
+
const radius = radiusOf(points, value, coordinate);
|
|
27
|
+
const angle = angleOf(points, value, coordinate);
|
|
28
|
+
const radius1 = radius + connectorLength + connectorLength2;
|
|
29
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
31
30
|
|
|
32
|
-
const
|
|
33
|
-
const edgeX1 = coordX + width - margin;
|
|
31
|
+
const newX = center[0] + (radius1 + +connectorDistance) * sign;
|
|
34
32
|
|
|
35
|
-
const { x: originX
|
|
36
|
-
const dx =
|
|
33
|
+
const { x: originX } = style;
|
|
34
|
+
const dx = newX - originX;
|
|
37
35
|
style.x += dx;
|
|
38
|
-
|
|
39
|
-
const { x, y } = style;
|
|
40
|
-
const p0 = sub([x0, y0], center);
|
|
41
|
-
const p1 = sub([0, y], center);
|
|
42
|
-
const p1x = p0[1] ? (p0[0] * p1[1]) / p0[1] + center[0] : x;
|
|
43
|
-
style.connectorPoints = [[p1x - x, 0]];
|
|
36
|
+
style.connectorPoints[0][0] -= dx;
|
|
44
37
|
|
|
45
38
|
return style;
|
|
46
39
|
}
|