@antv/g2 5.0.0-beta.4 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2-lite.min.js +5 -2
- package/dist/g2.min.js +5 -2
- package/esm/api/chart.d.ts +4 -0
- package/esm/api/chart.js +26 -4
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/mark.js +1 -2
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -2
- package/esm/component/axis.js +23 -9
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +2 -0
- package/esm/component/index.js +2 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/scrollbar.d.ts +9 -0
- package/esm/component/scrollbar.js +36 -0
- package/esm/component/scrollbar.js.map +1 -0
- package/esm/component/scrollbarX.d.ts +7 -0
- package/esm/component/scrollbarX.js +9 -0
- package/esm/component/scrollbarX.js.map +1 -0
- package/esm/component/scrollbarY.d.ts +7 -0
- package/esm/component/scrollbarY.js +9 -0
- package/esm/component/scrollbarY.js.map +1 -0
- package/esm/component/slider.js +2 -4
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js +46 -22
- package/esm/component/title.js.map +1 -1
- package/esm/composition/mark.js +2 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/data/fold.js +4 -10
- package/esm/data/fold.js.map +1 -1
- package/esm/data/index.d.ts +2 -2
- package/esm/data/index.js +1 -1
- package/esm/data/index.js.map +1 -1
- package/esm/data/pick.js +10 -2
- package/esm/data/pick.js.map +1 -1
- package/esm/data/slice.d.ts +8 -0
- package/esm/data/slice.js +10 -0
- package/esm/data/slice.js.map +1 -0
- package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
- package/esm/interaction/index.d.ts +8 -0
- package/esm/interaction/index.js +7 -30
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/esm/interaction/native/brushAxisHighlight.js +159 -0
- package/esm/interaction/native/brushAxisHighlight.js.map +1 -0
- package/esm/interaction/native/brushFilter.d.ts +12 -0
- package/esm/interaction/native/brushFilter.js +147 -0
- package/esm/interaction/native/brushFilter.js.map +1 -0
- package/esm/interaction/native/brushHighlight.d.ts +40 -0
- package/esm/interaction/native/brushHighlight.js +341 -0
- package/esm/interaction/native/brushHighlight.js.map +1 -0
- package/esm/interaction/native/brushXFilter.d.ts +1 -0
- package/esm/interaction/native/brushXFilter.js +6 -0
- package/esm/interaction/native/brushXFilter.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +6 -0
- package/esm/interaction/native/brushXHighlight.js +9 -0
- package/esm/interaction/native/brushXHighlight.js.map +1 -0
- package/esm/interaction/native/brushYFilter.d.ts +1 -0
- package/esm/interaction/native/brushYFilter.js +6 -0
- package/esm/interaction/native/brushYFilter.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +6 -0
- package/esm/interaction/native/brushYHighlight.js +9 -0
- package/esm/interaction/native/brushYHighlight.js.map +1 -0
- package/esm/interaction/native/legendFilter.js +3 -12
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/tooltip.js +101 -32
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +8 -0
- package/esm/interaction/native/utils.js +31 -0
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/contrastReverse.d.ts +9 -0
- package/esm/label-transform/contrastReverse.js +48 -0
- package/esm/label-transform/contrastReverse.js.map +1 -0
- package/esm/label-transform/index.d.ts +8 -8
- package/esm/label-transform/index.js +4 -4
- package/esm/label-transform/index.js.map +1 -1
- package/esm/label-transform/overflowHide.d.ts +7 -0
- package/esm/label-transform/overflowHide.js +18 -0
- package/esm/label-transform/overflowHide.js.map +1 -0
- package/esm/label-transform/overlapDodgeY.d.ts +7 -0
- package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
- package/esm/label-transform/overlapDodgeY.js.map +1 -0
- package/esm/label-transform/overlapHide.d.ts +7 -0
- package/esm/label-transform/overlapHide.js +24 -0
- package/esm/label-transform/overlapHide.js.map +1 -0
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/boxplot.js +5 -18
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/runtime/component.js +33 -38
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +7 -7
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +28 -6
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +0 -1
- package/esm/runtime/render.js +4 -34
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js +17 -5
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +16 -6
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +27 -9
- package/esm/runtime/types/options.d.ts +3 -5
- package/esm/runtime/types/theme.d.ts +2 -5
- package/esm/shape/area/curve.js +15 -8
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/box/box.js +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/connector/connector.js +2 -2
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/image/image.js +2 -2
- package/esm/shape/image/image.js.map +1 -1
- package/esm/shape/interval/color.js +3 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/label/label.js +3 -3
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/area.d.ts +13 -0
- package/esm/shape/label/position/area.js +28 -0
- package/esm/shape/label/position/area.js.map +1 -0
- package/esm/shape/label/position/bottom.d.ts +1 -0
- package/esm/shape/label/position/bottom.js +2 -0
- package/esm/shape/label/position/bottom.js.map +1 -0
- package/esm/shape/label/position/bottomLeft.d.ts +1 -0
- package/esm/shape/label/position/bottomLeft.js +2 -0
- package/esm/shape/label/position/bottomLeft.js.map +1 -0
- package/esm/shape/label/position/bottomRight.d.ts +1 -0
- package/esm/shape/label/position/bottomRight.js +2 -0
- package/esm/shape/label/position/bottomRight.js.map +1 -0
- package/esm/shape/label/position/default.d.ts +18 -0
- package/esm/shape/label/position/default.js +107 -0
- package/esm/shape/label/position/default.js.map +1 -0
- package/esm/shape/label/position/index.d.ts +13 -0
- package/esm/shape/label/position/index.js +14 -0
- package/esm/shape/label/position/index.js.map +1 -0
- package/esm/shape/label/position/inside.d.ts +1 -0
- package/esm/shape/label/position/inside.js +2 -0
- package/esm/shape/label/position/inside.js.map +1 -0
- package/esm/shape/label/position/left.d.ts +1 -0
- package/esm/shape/label/position/left.js +2 -0
- package/esm/shape/label/position/left.js.map +1 -0
- package/esm/shape/label/position/outside.d.ts +18 -0
- package/esm/shape/label/position/outside.js +67 -0
- package/esm/shape/label/position/outside.js.map +1 -0
- package/esm/shape/label/position/right.d.ts +1 -0
- package/esm/shape/label/position/right.js +2 -0
- package/esm/shape/label/position/right.js.map +1 -0
- package/esm/shape/label/position/spider.d.ts +7 -0
- package/esm/shape/label/position/spider.js +34 -0
- package/esm/shape/label/position/spider.js.map +1 -0
- package/esm/shape/label/position/surround.d.ts +7 -0
- package/esm/shape/label/position/surround.js +35 -0
- package/esm/shape/label/position/surround.js.map +1 -0
- package/esm/shape/label/position/top.d.ts +1 -0
- package/esm/shape/label/position/top.js +2 -0
- package/esm/shape/label/position/top.js.map +1 -0
- package/esm/shape/label/position/topLeft.d.ts +1 -0
- package/esm/shape/label/position/topLeft.js +2 -0
- package/esm/shape/label/position/topLeft.js.map +1 -0
- package/esm/shape/label/position/topRight.d.ts +1 -0
- package/esm/shape/label/position/topRight.js +2 -0
- package/esm/shape/label/position/topRight.js.map +1 -0
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/lineXY/line.js +2 -2
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/link/arc.js +2 -2
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/link.js +2 -2
- package/esm/shape/link/link.js.map +1 -1
- package/esm/shape/link/smooth.js +2 -2
- package/esm/shape/link/smooth.js.map +1 -1
- package/esm/shape/link/vhv.js +2 -2
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/point/color.js +1 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/polygon/polygon.js +3 -3
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js +3 -3
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +3 -3
- package/esm/shape/text/badge.js.map +1 -1
- package/esm/shape/text/text.js +1 -1
- package/esm/shape/text/text.js.map +1 -1
- package/esm/shape/utils.d.ts +4 -0
- package/esm/shape/utils.js +6 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js +3 -3
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/composition.d.ts +2 -0
- package/esm/spec/data.d.ts +24 -9
- package/esm/spec/geometry.d.ts +2 -1
- package/esm/spec/interaction.d.ts +41 -6
- package/esm/spec/labelTransform.d.ts +24 -11
- package/esm/spec/theme.d.ts +5 -2
- package/esm/stdlib/index.js +8 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.d.ts +3 -0
- package/esm/theme/academy.js +398 -0
- package/esm/theme/academy.js.map +1 -0
- package/esm/theme/dark.js +14 -20
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/index.js.map +1 -1
- package/esm/theme/light.js +29 -22
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/maybeTooltip.js +3 -1
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/utils/bounds.d.ts +26 -0
- package/esm/utils/bounds.js +41 -0
- package/esm/utils/bounds.js.map +1 -0
- package/esm/utils/color.d.ts +6 -0
- package/esm/utils/color.js +7 -0
- package/esm/utils/color.js.map +1 -0
- package/esm/utils/coordinate.d.ts +1 -0
- package/esm/utils/coordinate.js +12 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +3 -0
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/chart.d.ts +4 -0
- package/lib/api/chart.js +26 -4
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/mark.js +1 -2
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -2
- package/lib/component/axis.js +23 -9
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +2 -0
- package/lib/component/index.js +5 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/scrollbar.d.ts +9 -0
- package/lib/component/scrollbar.js +40 -0
- package/lib/component/scrollbar.js.map +1 -0
- package/lib/component/scrollbarX.d.ts +7 -0
- package/lib/component/scrollbarX.js +13 -0
- package/lib/component/scrollbarX.js.map +1 -0
- package/lib/component/scrollbarY.d.ts +7 -0
- package/lib/component/scrollbarY.js +13 -0
- package/lib/component/scrollbarY.js.map +1 -0
- package/lib/component/slider.js +2 -4
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js +46 -22
- package/lib/component/title.js.map +1 -1
- package/lib/composition/mark.js +2 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/data/fold.js +4 -10
- package/lib/data/fold.js.map +1 -1
- package/lib/data/index.d.ts +2 -2
- package/lib/data/index.js +3 -3
- package/lib/data/index.js.map +1 -1
- package/lib/data/pick.js +10 -2
- package/lib/data/pick.js.map +1 -1
- package/lib/data/slice.d.ts +8 -0
- package/lib/data/slice.js +14 -0
- package/lib/data/slice.js.map +1 -0
- package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
- package/lib/interaction/index.d.ts +8 -0
- package/lib/interaction/index.js +15 -31
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/lib/interaction/native/brushAxisHighlight.js +164 -0
- package/lib/interaction/native/brushAxisHighlight.js.map +1 -0
- package/lib/interaction/native/brushFilter.d.ts +12 -0
- package/lib/interaction/native/brushFilter.js +152 -0
- package/lib/interaction/native/brushFilter.js.map +1 -0
- package/lib/interaction/native/brushHighlight.d.ts +40 -0
- package/lib/interaction/native/brushHighlight.js +347 -0
- package/lib/interaction/native/brushHighlight.js.map +1 -0
- package/lib/interaction/native/brushXFilter.d.ts +1 -0
- package/lib/interaction/native/brushXFilter.js +10 -0
- package/lib/interaction/native/brushXFilter.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +6 -0
- package/lib/interaction/native/brushXHighlight.js +14 -0
- package/lib/interaction/native/brushXHighlight.js.map +1 -0
- package/lib/interaction/native/brushYFilter.d.ts +1 -0
- package/lib/interaction/native/brushYFilter.js +10 -0
- package/lib/interaction/native/brushYFilter.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +6 -0
- package/lib/interaction/native/brushYHighlight.js +14 -0
- package/lib/interaction/native/brushYHighlight.js.map +1 -0
- package/lib/interaction/native/legendFilter.js +4 -13
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/tooltip.js +98 -29
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +8 -0
- package/lib/interaction/native/utils.js +37 -1
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/contrastReverse.d.ts +9 -0
- package/lib/label-transform/contrastReverse.js +52 -0
- package/lib/label-transform/contrastReverse.js.map +1 -0
- package/lib/label-transform/index.d.ts +8 -8
- package/lib/label-transform/index.js +9 -9
- package/lib/label-transform/index.js.map +1 -1
- package/lib/label-transform/overflowHide.d.ts +7 -0
- package/lib/label-transform/overflowHide.js +22 -0
- package/lib/label-transform/overflowHide.js.map +1 -0
- package/lib/label-transform/overlapDodgeY.d.ts +7 -0
- package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
- package/lib/label-transform/overlapDodgeY.js.map +1 -0
- package/lib/label-transform/overlapHide.d.ts +7 -0
- package/lib/label-transform/overlapHide.js +28 -0
- package/lib/label-transform/overlapHide.js.map +1 -0
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/boxplot.js +5 -18
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/runtime/component.js +33 -38
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +7 -7
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +28 -6
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +0 -1
- package/lib/runtime/render.js +4 -35
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +16 -4
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +16 -6
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +27 -9
- package/lib/runtime/types/options.d.ts +3 -5
- package/lib/runtime/types/theme.d.ts +2 -5
- package/lib/shape/area/curve.js +14 -7
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/box/box.js +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/connector/connector.js +2 -2
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/image/image.js +2 -2
- package/lib/shape/image/image.js.map +1 -1
- package/lib/shape/interval/color.js +3 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/label/label.js +3 -3
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.d.ts +13 -0
- package/lib/shape/label/position/area.js +32 -0
- package/lib/shape/label/position/area.js.map +1 -0
- package/lib/shape/label/position/bottom.d.ts +1 -0
- package/lib/shape/label/position/bottom.js +6 -0
- package/lib/shape/label/position/bottom.js.map +1 -0
- package/lib/shape/label/position/bottomLeft.d.ts +1 -0
- package/lib/shape/label/position/bottomLeft.js +6 -0
- package/lib/shape/label/position/bottomLeft.js.map +1 -0
- package/lib/shape/label/position/bottomRight.d.ts +1 -0
- package/lib/shape/label/position/bottomRight.js +6 -0
- package/lib/shape/label/position/bottomRight.js.map +1 -0
- package/lib/shape/label/position/default.d.ts +18 -0
- package/lib/shape/label/{position.js → position/default.js} +24 -81
- package/lib/shape/label/position/default.js.map +1 -0
- package/lib/shape/label/position/index.d.ts +13 -0
- package/lib/shape/label/position/index.js +30 -0
- package/lib/shape/label/position/index.js.map +1 -0
- package/lib/shape/label/position/inside.d.ts +1 -0
- package/lib/shape/label/position/inside.js +6 -0
- package/lib/shape/label/position/inside.js.map +1 -0
- package/lib/shape/label/position/left.d.ts +1 -0
- package/lib/shape/label/position/left.js +6 -0
- package/lib/shape/label/position/left.js.map +1 -0
- package/lib/shape/label/position/outside.d.ts +18 -0
- package/lib/shape/label/position/outside.js +75 -0
- package/lib/shape/label/position/outside.js.map +1 -0
- package/lib/shape/label/position/right.d.ts +1 -0
- package/lib/shape/label/position/right.js +6 -0
- package/lib/shape/label/position/right.js.map +1 -0
- package/lib/shape/label/position/spider.d.ts +7 -0
- package/lib/shape/label/position/spider.js +38 -0
- package/lib/shape/label/position/spider.js.map +1 -0
- package/lib/shape/label/position/surround.d.ts +7 -0
- package/lib/shape/label/position/surround.js +39 -0
- package/lib/shape/label/position/surround.js.map +1 -0
- package/lib/shape/label/position/top.d.ts +1 -0
- package/lib/shape/label/position/top.js +6 -0
- package/lib/shape/label/position/top.js.map +1 -0
- package/lib/shape/label/position/topLeft.d.ts +1 -0
- package/lib/shape/label/position/topLeft.js +6 -0
- package/lib/shape/label/position/topLeft.js.map +1 -0
- package/lib/shape/label/position/topRight.d.ts +1 -0
- package/lib/shape/label/position/topRight.js +6 -0
- package/lib/shape/label/position/topRight.js.map +1 -0
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/lineXY/line.js +2 -2
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/link/arc.js +2 -2
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/link.js +2 -2
- package/lib/shape/link/link.js.map +1 -1
- package/lib/shape/link/smooth.js +2 -2
- package/lib/shape/link/smooth.js.map +1 -1
- package/lib/shape/link/vhv.js +2 -2
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/point/color.js +1 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/polygon/polygon.js +3 -3
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js +3 -3
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +3 -3
- package/lib/shape/text/badge.js.map +1 -1
- package/lib/shape/text/text.js +1 -1
- package/lib/shape/text/text.js.map +1 -1
- package/lib/shape/utils.d.ts +4 -0
- package/lib/shape/utils.js +6 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js +3 -3
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/composition.d.ts +2 -0
- package/lib/spec/data.d.ts +24 -9
- package/lib/spec/geometry.d.ts +2 -1
- package/lib/spec/interaction.d.ts +41 -6
- package/lib/spec/labelTransform.d.ts +24 -11
- package/lib/spec/theme.d.ts +5 -2
- package/lib/stdlib/index.js +3 -4
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.d.ts +3 -0
- package/lib/theme/academy.js +402 -0
- package/lib/theme/academy.js.map +1 -0
- package/lib/theme/dark.js +14 -20
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +3 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/light.js +29 -22
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/maybeTooltip.js +3 -1
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/utils/bounds.d.ts +26 -0
- package/lib/utils/bounds.js +48 -0
- package/lib/utils/bounds.js.map +1 -0
- package/lib/utils/color.d.ts +6 -0
- package/lib/utils/color.js +11 -0
- package/lib/utils/color.js.map +1 -0
- package/lib/utils/coordinate.d.ts +1 -0
- package/lib/utils/coordinate.js +14 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +5 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +2 -2
- package/src/api/chart.ts +29 -8
- package/src/api/mark/mark.ts +1 -2
- package/src/api/mark/types.ts +1 -2
- package/src/component/axis.ts +38 -16
- package/src/component/index.ts +2 -0
- package/src/component/scrollbar.ts +41 -0
- package/src/component/scrollbarX.ts +16 -0
- package/src/component/scrollbarY.ts +16 -0
- package/src/component/slider.ts +1 -3
- package/src/component/title.ts +69 -30
- package/src/composition/mark.ts +2 -0
- package/src/data/fold.ts +6 -10
- package/src/data/index.ts +2 -2
- package/src/data/pick.ts +11 -2
- package/src/data/slice.ts +15 -0
- package/src/interaction/index.ts +23 -16
- package/src/interaction/native/brushAxisHighlight.ts +194 -0
- package/src/interaction/native/brushFilter.ts +163 -0
- package/src/interaction/native/brushHighlight.ts +419 -0
- package/src/interaction/native/brushXFilter.ts +9 -0
- package/src/interaction/native/brushXHighlight.ts +13 -0
- package/src/interaction/native/brushYFilter.ts +9 -0
- package/src/interaction/native/brushYHighlight.ts +13 -0
- package/src/interaction/native/legendFilter.ts +3 -14
- package/src/interaction/native/tooltip.ts +128 -38
- package/src/interaction/native/utils.ts +40 -0
- package/src/label-transform/contrastReverse.ts +56 -0
- package/src/label-transform/index.ts +8 -8
- package/src/label-transform/overflowHide.ts +23 -0
- package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
- package/src/label-transform/overlapHide.ts +32 -0
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +3 -1
- package/src/runtime/component.ts +46 -47
- package/src/runtime/layout.ts +6 -6
- package/src/runtime/plot.ts +40 -6
- package/src/runtime/render.ts +6 -58
- package/src/runtime/scale.ts +15 -7
- package/src/runtime/transform.ts +19 -6
- package/src/runtime/types/common.ts +27 -10
- package/src/runtime/types/options.ts +3 -5
- package/src/runtime/types/theme.ts +2 -5
- package/src/shape/area/curve.ts +15 -8
- package/src/shape/box/box.ts +6 -6
- package/src/shape/connector/connector.ts +2 -3
- package/src/shape/image/image.ts +2 -2
- package/src/shape/interval/color.ts +2 -1
- package/src/shape/label/label.ts +4 -3
- package/src/shape/label/position/area.ts +39 -0
- package/src/shape/label/position/bottom.ts +1 -0
- package/src/shape/label/position/bottomLeft.ts +1 -0
- package/src/shape/label/position/bottomRight.ts +1 -0
- package/src/shape/label/{position.ts → position/default.ts} +26 -110
- package/src/shape/label/position/index.ts +13 -0
- package/src/shape/label/position/inside.ts +1 -0
- package/src/shape/label/position/left.ts +1 -0
- package/src/shape/label/position/outside.ts +121 -0
- package/src/shape/label/position/right.ts +1 -0
- package/src/shape/label/position/spider.ts +39 -0
- package/src/shape/label/position/surround.ts +40 -0
- package/src/shape/label/position/top.ts +1 -0
- package/src/shape/label/position/topLeft.ts +1 -0
- package/src/shape/label/position/topRight.ts +1 -0
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/lineXY/line.ts +2 -2
- package/src/shape/link/arc.ts +2 -2
- package/src/shape/link/link.ts +2 -2
- package/src/shape/link/smooth.ts +2 -2
- package/src/shape/link/vhv.ts +2 -2
- package/src/shape/point/color.ts +6 -5
- package/src/shape/polygon/polygon.ts +3 -3
- package/src/shape/polygon/ribbon.ts +3 -3
- package/src/shape/text/advance.ts +4 -1
- package/src/shape/text/badge.ts +8 -3
- package/src/shape/text/text.ts +1 -1
- package/src/shape/utils.ts +6 -5
- package/src/shape/vector/vector.ts +3 -3
- package/src/spec/action.ts +0 -1
- package/src/spec/composition.ts +2 -0
- package/src/spec/data.ts +25 -10
- package/src/spec/geometry.ts +3 -1
- package/src/spec/interaction.ts +59 -5
- package/src/spec/labelTransform.ts +29 -11
- package/src/spec/theme.ts +6 -2
- package/src/stdlib/index.ts +33 -9
- package/src/theme/academy.ts +404 -0
- package/src/theme/dark.ts +14 -20
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +29 -22
- package/src/transform/maybeTooltip.ts +3 -1
- package/src/utils/bounds.ts +52 -0
- package/src/utils/color.ts +12 -0
- package/src/utils/coordinate.ts +12 -0
- package/src/utils/helper.ts +4 -0
- package/esm/data/subset.d.ts +0 -7
- package/esm/data/subset.js +0 -26
- package/esm/data/subset.js.map +0 -1
- package/esm/label-transform/dodgeY.d.ts +0 -7
- package/esm/label-transform/dodgeY.js.map +0 -1
- package/esm/label-transform/hideOverlap.d.ts +0 -4
- package/esm/label-transform/hideOverlap.js +0 -48
- package/esm/label-transform/hideOverlap.js.map +0 -1
- package/esm/label-transform/spider.d.ts +0 -7
- package/esm/label-transform/spider.js +0 -30
- package/esm/label-transform/spider.js.map +0 -1
- package/esm/label-transform/surround.d.ts +0 -7
- package/esm/label-transform/surround.js +0 -30
- package/esm/label-transform/surround.js.map +0 -1
- package/esm/shape/label/position.d.ts +0 -25
- package/esm/shape/label/position.js +0 -169
- package/esm/shape/label/position.js.map +0 -1
- package/lib/data/subset.d.ts +0 -7
- package/lib/data/subset.js +0 -30
- package/lib/data/subset.js.map +0 -1
- package/lib/label-transform/dodgeY.d.ts +0 -7
- package/lib/label-transform/dodgeY.js.map +0 -1
- package/lib/label-transform/hideOverlap.d.ts +0 -4
- package/lib/label-transform/hideOverlap.js +0 -52
- package/lib/label-transform/hideOverlap.js.map +0 -1
- package/lib/label-transform/spider.d.ts +0 -7
- package/lib/label-transform/spider.js +0 -34
- package/lib/label-transform/spider.js.map +0 -1
- package/lib/label-transform/surround.d.ts +0 -7
- package/lib/label-transform/surround.js +0 -34
- package/lib/label-transform/surround.js.map +0 -1
- package/lib/shape/label/position.d.ts +0 -25
- package/lib/shape/label/position.js.map +0 -1
- package/src/data/subset.ts +0 -35
- package/src/label-transform/hideOverlap.ts +0 -62
- package/src/label-transform/spider.ts +0 -37
- package/src/label-transform/surround.ts +0 -37
|
@@ -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);
|
package/src/shape/label/label.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { applyStyle } from '../../shape/utils';
|
|
|
5
5
|
import { isTranspose, isCircular } from '../../utils/coordinate';
|
|
6
6
|
import { camelCase } from '../../utils/string';
|
|
7
7
|
import { Advance } from '../text/advance';
|
|
8
|
-
import { LabelPosition } from './position';
|
|
8
|
+
import { LabelPosition } from './position/default';
|
|
9
9
|
import * as PositionProcessor from './position';
|
|
10
10
|
|
|
11
11
|
export type LabelOptions = Record<string, any>;
|
|
@@ -22,6 +22,7 @@ function getDefaultStyle(
|
|
|
22
22
|
value: Record<string, any>,
|
|
23
23
|
coordinate: Coordinate,
|
|
24
24
|
theme: G2Theme,
|
|
25
|
+
options: LabelOptions,
|
|
25
26
|
): Record<string, any> {
|
|
26
27
|
// For non-series mark, calc position for label based on
|
|
27
28
|
// position and the bounds of shape.
|
|
@@ -35,7 +36,7 @@ function getDefaultStyle(
|
|
|
35
36
|
}
|
|
36
37
|
return {
|
|
37
38
|
...t,
|
|
38
|
-
...processor(p, points, v, coordinate),
|
|
39
|
+
...processor(p, points, v, coordinate, options),
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -50,7 +51,7 @@ export const Label: SC<LabelOptions> = (options) => {
|
|
|
50
51
|
rotate = 0,
|
|
51
52
|
transform = '',
|
|
52
53
|
...defaultStyle
|
|
53
|
-
} = getDefaultStyle(points, value, coordinate, theme);
|
|
54
|
+
} = getDefaultStyle(points, value, coordinate, theme, options);
|
|
54
55
|
|
|
55
56
|
return select(new Advance())
|
|
56
57
|
.call(applyStyle, defaultStyle)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { maxIndex } from 'd3-array';
|
|
2
|
+
import { Coordinate } from '@antv/coord';
|
|
3
|
+
import { Vector2 } from '../../../runtime';
|
|
4
|
+
import { sub, angle } from '../../../utils/vector';
|
|
5
|
+
import { LabelPosition } from './default';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Only for Area label.
|
|
9
|
+
*/
|
|
10
|
+
export function area(
|
|
11
|
+
position: LabelPosition,
|
|
12
|
+
points: Vector2[],
|
|
13
|
+
value: Record<string, any>,
|
|
14
|
+
coordinate: Coordinate,
|
|
15
|
+
) {
|
|
16
|
+
const l = points.length / 2;
|
|
17
|
+
const Y1 = points.slice(0, l);
|
|
18
|
+
const Y0 = points.slice(l);
|
|
19
|
+
// Get the maximal space for label.
|
|
20
|
+
let idx = maxIndex(Y1, (p, i) => Math.abs(p[1] - Y0[i][1]));
|
|
21
|
+
// Do not show label at first and last.
|
|
22
|
+
idx = Math.max(Math.min(idx, l - 2), 1);
|
|
23
|
+
|
|
24
|
+
const mid = (i: number): Vector2 => [Y1[i][0], (Y1[i][1] + Y0[i][1]) / 2];
|
|
25
|
+
const point = mid(idx);
|
|
26
|
+
const prev = mid(idx - 1);
|
|
27
|
+
const next = mid(idx + 1);
|
|
28
|
+
|
|
29
|
+
// todo: G rotate only support deg.
|
|
30
|
+
const rotate = (angle(sub(next, prev)) / Math.PI) * 180;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
x: point[0],
|
|
34
|
+
y: point[1],
|
|
35
|
+
transform: `rotate(${rotate}deg)`,
|
|
36
|
+
textAlign: 'center',
|
|
37
|
+
textBaseline: 'middle',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as bottom } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as bottomLeft } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as bottomRight } from './default';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { maxIndex } from 'd3-array';
|
|
2
1
|
import { Coordinate } from '@antv/coord';
|
|
3
|
-
import { Vector2 } from '
|
|
4
|
-
import { getArcObject } from '
|
|
5
|
-
import { isCircular, isRadial } from '
|
|
6
|
-
import { maybePercentage } from '
|
|
7
|
-
import {
|
|
2
|
+
import { Vector2 } from '../../../runtime';
|
|
3
|
+
import { getArcObject } from '../../../shape/utils';
|
|
4
|
+
import { isCircular, isRadial } from '../../../utils/coordinate';
|
|
5
|
+
import { maybePercentage } from '../../../utils/helper';
|
|
6
|
+
import { mid } from '../../../utils/vector';
|
|
8
7
|
|
|
9
8
|
export type LabelPosition =
|
|
10
9
|
| 'top'
|
|
@@ -17,9 +16,11 @@ export type LabelPosition =
|
|
|
17
16
|
| 'bottom-right'
|
|
18
17
|
| 'inside'
|
|
19
18
|
| 'outside'
|
|
20
|
-
| 'area'
|
|
19
|
+
| 'area'
|
|
20
|
+
| 'spider'
|
|
21
|
+
| 'surround';
|
|
21
22
|
|
|
22
|
-
function inferNonCircularStyle(
|
|
23
|
+
export function inferNonCircularStyle(
|
|
23
24
|
position: LabelPosition,
|
|
24
25
|
points: Vector2[],
|
|
25
26
|
value: Record<string, any>,
|
|
@@ -66,7 +67,7 @@ function inferNonCircularStyle(
|
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
function inferRadialStyle(
|
|
70
|
+
export function inferRadialStyle(
|
|
70
71
|
position: LabelPosition,
|
|
71
72
|
points: Vector2[],
|
|
72
73
|
value: Record<string, any>,
|
|
@@ -84,7 +85,7 @@ function inferRadialStyle(
|
|
|
84
85
|
const [p0, p1] = points;
|
|
85
86
|
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
86
87
|
const [x, y] =
|
|
87
|
-
position === 'inside' ?
|
|
88
|
+
position === 'inside' ? pointOfArc(center, angle, radius) : mid(p0, p1);
|
|
88
89
|
return { x, y };
|
|
89
90
|
})();
|
|
90
91
|
|
|
@@ -96,25 +97,21 @@ function inferRadialStyle(
|
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
function
|
|
100
|
+
export function pointOfArc(center: Vector2, angle, radius): Vector2 {
|
|
100
101
|
return [
|
|
101
102
|
center[0] + Math.sin(angle) * radius,
|
|
102
103
|
center[1] - Math.cos(angle) * radius,
|
|
103
104
|
];
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
function inferRotation(
|
|
107
|
-
angle: number,
|
|
108
|
-
autoRotate: boolean,
|
|
109
|
-
rotateToAlignArc: boolean,
|
|
110
|
-
) {
|
|
107
|
+
export function inferRotation(angle, autoRotate, rotateToAlignArc) {
|
|
111
108
|
if (!autoRotate) return 0;
|
|
112
109
|
|
|
113
110
|
const append = rotateToAlignArc ? 0 : Math.sin(angle) < 0 ? 90 : -90;
|
|
114
111
|
return (angle / Math.PI) * 180 + append;
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
function
|
|
114
|
+
function inferInnerCircularStyle(
|
|
118
115
|
position: LabelPosition,
|
|
119
116
|
points: Vector2[],
|
|
120
117
|
value: Record<string, any>,
|
|
@@ -125,9 +122,6 @@ function inferCircularStyle(
|
|
|
125
122
|
y1,
|
|
126
123
|
autoRotate,
|
|
127
124
|
rotateToAlignArc,
|
|
128
|
-
connector = true,
|
|
129
|
-
connectorLength2 = 0,
|
|
130
|
-
connectorDistance = 0,
|
|
131
125
|
radius: radiusRatio = 0.5,
|
|
132
126
|
offset = 0,
|
|
133
127
|
} = value;
|
|
@@ -136,55 +130,22 @@ function inferCircularStyle(
|
|
|
136
130
|
const center = coordinate.getCenter();
|
|
137
131
|
|
|
138
132
|
const angle = (startAngle + endAngle) / 2;
|
|
133
|
+
const rotate = inferRotation(angle, autoRotate, rotateToAlignArc);
|
|
139
134
|
|
|
140
|
-
const textStyle =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
textAlign: sign ? 'start' : 'end',
|
|
146
|
-
textBaseline: 'middle',
|
|
147
|
-
rotate,
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
const [r0, r1] = (() => {
|
|
151
|
-
const ratio = position === 'inside' ? radiusRatio : 1;
|
|
152
|
-
const { innerRadius, outerRadius } = arcObject;
|
|
153
|
-
const r0 = innerRadius + (outerRadius - innerRadius) * ratio;
|
|
154
|
-
const r1 = r0 + offset;
|
|
155
|
-
return [r0, r1];
|
|
156
|
-
})();
|
|
157
|
-
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
158
|
-
|
|
159
|
-
const [p0, p1, ...connectorPoints] = ((
|
|
160
|
-
radius: number,
|
|
161
|
-
finalRadius: number,
|
|
162
|
-
) => {
|
|
163
|
-
const [x0, y0] = arcPoint(center, angle, radius);
|
|
164
|
-
const [x, y] = arcPoint(center, angle, finalRadius);
|
|
165
|
-
const length2 = connector ? sign * connectorLength2 : 0;
|
|
166
|
-
const p0 = [x0, y0];
|
|
167
|
-
const p1 = [x + length2, y];
|
|
168
|
-
return [p0, p1, [-length2, 0]] as Vector2[];
|
|
169
|
-
})(r0, r1);
|
|
170
|
-
|
|
171
|
-
const connectorStyle = {
|
|
172
|
-
connector,
|
|
173
|
-
connectorPoints,
|
|
174
|
-
dx: connector ? +connectorDistance * sign : 0,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
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);
|
|
178
140
|
|
|
179
141
|
return {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
...textStyle
|
|
183
|
-
...connectorStyle,
|
|
142
|
+
x: x0,
|
|
143
|
+
y: y0,
|
|
144
|
+
...textStyle,
|
|
184
145
|
};
|
|
185
146
|
}
|
|
186
147
|
|
|
187
|
-
function inferIdentityStyle(position, points, value, coordinate) {
|
|
148
|
+
export function inferIdentityStyle(position, points, value, coordinate) {
|
|
188
149
|
const { bounds } = value;
|
|
189
150
|
const [p] = bounds;
|
|
190
151
|
return {
|
|
@@ -193,7 +154,7 @@ function inferIdentityStyle(position, points, value, coordinate) {
|
|
|
193
154
|
};
|
|
194
155
|
}
|
|
195
156
|
|
|
196
|
-
function getDefaultStyle(
|
|
157
|
+
export function getDefaultStyle(
|
|
197
158
|
position: LabelPosition,
|
|
198
159
|
points: Vector2[],
|
|
199
160
|
value: Record<string, any>,
|
|
@@ -211,53 +172,8 @@ function getDefaultStyle(
|
|
|
211
172
|
const inferDefaultStyle = isRadial(coordinate)
|
|
212
173
|
? inferRadialStyle
|
|
213
174
|
: isCircular(coordinate)
|
|
214
|
-
?
|
|
175
|
+
? inferInnerCircularStyle
|
|
215
176
|
: inferNonCircularStyle;
|
|
216
177
|
|
|
217
178
|
return inferDefaultStyle(position, points, value, coordinate);
|
|
218
179
|
}
|
|
219
|
-
|
|
220
|
-
export const top = getDefaultStyle;
|
|
221
|
-
export const bottom = getDefaultStyle;
|
|
222
|
-
export const right = getDefaultStyle;
|
|
223
|
-
export const left = getDefaultStyle;
|
|
224
|
-
export const topLeft = getDefaultStyle;
|
|
225
|
-
export const topRight = getDefaultStyle;
|
|
226
|
-
export const bottomLeft = getDefaultStyle;
|
|
227
|
-
export const bottomRight = getDefaultStyle;
|
|
228
|
-
export const inside = getDefaultStyle;
|
|
229
|
-
export const outside = getDefaultStyle;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Only for Area label.
|
|
233
|
-
*/
|
|
234
|
-
export function area(
|
|
235
|
-
position: LabelPosition,
|
|
236
|
-
points: Vector2[],
|
|
237
|
-
value: Record<string, any>,
|
|
238
|
-
coordinate: Coordinate,
|
|
239
|
-
) {
|
|
240
|
-
const l = points.length / 2;
|
|
241
|
-
const Y1 = points.slice(0, l);
|
|
242
|
-
const Y0 = points.slice(l);
|
|
243
|
-
// Get the maximal space for label.
|
|
244
|
-
let idx = maxIndex(Y1, (p, i) => Math.abs(p[1] - Y0[i][1]));
|
|
245
|
-
// Do not show label at first and last.
|
|
246
|
-
idx = Math.max(Math.min(idx, l - 2), 1);
|
|
247
|
-
|
|
248
|
-
const mid = (i: number): Vector2 => [Y1[i][0], (Y1[i][1] + Y0[i][1]) / 2];
|
|
249
|
-
const point = mid(idx);
|
|
250
|
-
const prev = mid(idx - 1);
|
|
251
|
-
const next = mid(idx + 1);
|
|
252
|
-
|
|
253
|
-
// todo: G rotate only support deg.
|
|
254
|
-
const rotate = (angle(sub(next, prev)) / Math.PI) * 180;
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
x: point[0],
|
|
258
|
-
y: point[1],
|
|
259
|
-
transform: `rotate(${rotate}deg)`,
|
|
260
|
-
textAlign: 'center',
|
|
261
|
-
textBaseline: 'middle',
|
|
262
|
-
};
|
|
263
|
-
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { area } from './area';
|
|
2
|
+
export { bottom } from './bottom';
|
|
3
|
+
export { bottomLeft } from './bottomLeft';
|
|
4
|
+
export { bottomRight } from './bottomRight';
|
|
5
|
+
export { inside } from './inside';
|
|
6
|
+
export { left } from './left';
|
|
7
|
+
export { outside } from './outside';
|
|
8
|
+
export { right } from './right';
|
|
9
|
+
export { spider } from './spider';
|
|
10
|
+
export { surround } from './surround';
|
|
11
|
+
export { top } from './top';
|
|
12
|
+
export { topLeft } from './topLeft';
|
|
13
|
+
export { topRight } from './topRight';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as inside } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as left } from './default';
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as right } from './default';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { Vector2 } from '../../../runtime';
|
|
3
|
+
import { isCircular } from '../../../utils/coordinate';
|
|
4
|
+
import { LabelPosition } from './default';
|
|
5
|
+
import { inferOutsideCircularStyle, radiusOf, angleOf } from './outside';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
|
|
9
|
+
*/
|
|
10
|
+
export function spider(
|
|
11
|
+
position: LabelPosition,
|
|
12
|
+
points: Vector2[],
|
|
13
|
+
value: Record<string, any>,
|
|
14
|
+
coordinate: Coordinate,
|
|
15
|
+
) {
|
|
16
|
+
if (!isCircular(coordinate)) return {};
|
|
17
|
+
const { connectorLength, connectorLength2, connectorDistance } = value;
|
|
18
|
+
|
|
19
|
+
const { ...style }: any = inferOutsideCircularStyle(
|
|
20
|
+
'outside',
|
|
21
|
+
points,
|
|
22
|
+
value,
|
|
23
|
+
coordinate,
|
|
24
|
+
);
|
|
25
|
+
const center = coordinate.getCenter();
|
|
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;
|
|
30
|
+
|
|
31
|
+
const newX = center[0] + (radius1 + +connectorDistance) * sign;
|
|
32
|
+
|
|
33
|
+
const { x: originX } = style;
|
|
34
|
+
const dx = newX - originX;
|
|
35
|
+
style.x += dx;
|
|
36
|
+
style.connectorPoints[0][0] -= dx;
|
|
37
|
+
|
|
38
|
+
return style;
|
|
39
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { Vector2 } from '../../../runtime';
|
|
3
|
+
import { getRadius, isCircular } from '../../../utils/coordinate';
|
|
4
|
+
import { angleWithQuadrant } from '../../../utils/vector';
|
|
5
|
+
import { LabelPosition, pointOfArc } from './default';
|
|
6
|
+
import { inferOutsideCircularStyle } from './outside';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Surround label transform is used to make labels surround circular.
|
|
10
|
+
*/
|
|
11
|
+
export function surround(
|
|
12
|
+
position: LabelPosition,
|
|
13
|
+
points: Vector2[],
|
|
14
|
+
value: Record<string, any>,
|
|
15
|
+
coordinate: Coordinate,
|
|
16
|
+
) {
|
|
17
|
+
if (!isCircular(coordinate)) return {};
|
|
18
|
+
const { connectorLength, connectorLength2, connectorDistance } = value;
|
|
19
|
+
|
|
20
|
+
const { ...style }: any = inferOutsideCircularStyle(
|
|
21
|
+
'outside',
|
|
22
|
+
points,
|
|
23
|
+
value,
|
|
24
|
+
coordinate,
|
|
25
|
+
);
|
|
26
|
+
const { x0, y0 } = style;
|
|
27
|
+
|
|
28
|
+
const center = coordinate.getCenter();
|
|
29
|
+
const radius = getRadius(coordinate);
|
|
30
|
+
const radius1 = radius + connectorLength;
|
|
31
|
+
const angle = angleWithQuadrant([x0 - center[0], y0 - center[1]]);
|
|
32
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
33
|
+
|
|
34
|
+
const [newX, newY] = pointOfArc(center, angle, radius1);
|
|
35
|
+
|
|
36
|
+
style.x = newX + (connectorLength2 + connectorDistance) * sign;
|
|
37
|
+
style.y = newY;
|
|
38
|
+
|
|
39
|
+
return style;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as top } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as topLeft } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as topRight } from './default';
|
package/src/shape/line/curve.ts
CHANGED
|
@@ -87,7 +87,7 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
87
87
|
// Compute styles.
|
|
88
88
|
const { mark, shape, defaultShape } = value;
|
|
89
89
|
const {
|
|
90
|
-
|
|
90
|
+
defaultColor,
|
|
91
91
|
lineWidth: defaultSize,
|
|
92
92
|
...defaults
|
|
93
93
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|
package/src/shape/lineXY/line.ts
CHANGED
|
@@ -35,13 +35,13 @@ export const Line: SC<LineOptions> = (options) => {
|
|
|
35
35
|
const { ...style } = options;
|
|
36
36
|
return (points, value, coordinate, theme) => {
|
|
37
37
|
const { mark, shape, defaultShape } = value;
|
|
38
|
-
const {
|
|
38
|
+
const { defaultColor, lineWidth, ...shapeTheme } = getShapeTheme(
|
|
39
39
|
theme,
|
|
40
40
|
mark,
|
|
41
41
|
shape,
|
|
42
42
|
defaultShape,
|
|
43
43
|
);
|
|
44
|
-
const { color =
|
|
44
|
+
const { color = defaultColor, size = lineWidth } = value;
|
|
45
45
|
|
|
46
46
|
const path = getPath(points, coordinate);
|
|
47
47
|
const transform = getTransform(coordinate, value.transform);
|
package/src/shape/link/arc.ts
CHANGED
|
@@ -17,13 +17,13 @@ export const Arc: SC<ArcOptions> = (options) => {
|
|
|
17
17
|
const { ...style } = options;
|
|
18
18
|
return (points, value, coordinate, theme) => {
|
|
19
19
|
const { mark, shape, defaultShape } = value;
|
|
20
|
-
const {
|
|
20
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
21
21
|
theme,
|
|
22
22
|
mark,
|
|
23
23
|
shape,
|
|
24
24
|
defaultShape,
|
|
25
25
|
);
|
|
26
|
-
const { color =
|
|
26
|
+
const { color = defaultColor, transform } = value;
|
|
27
27
|
const [from, to] = points;
|
|
28
28
|
|
|
29
29
|
const path = d3path();
|
package/src/shape/link/link.ts
CHANGED
|
@@ -13,13 +13,13 @@ export const Link: SC<LinkOptions> = (options) => {
|
|
|
13
13
|
const { arrowSize, ...style } = options;
|
|
14
14
|
return (points, value, coordinate, theme) => {
|
|
15
15
|
const { mark, shape, defaultShape } = value;
|
|
16
|
-
const {
|
|
16
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
17
17
|
theme,
|
|
18
18
|
mark,
|
|
19
19
|
shape,
|
|
20
20
|
defaultShape,
|
|
21
21
|
);
|
|
22
|
-
const { color =
|
|
22
|
+
const { color = defaultColor, transform } = value;
|
|
23
23
|
const [from, to] = points;
|
|
24
24
|
|
|
25
25
|
// Draw line
|
package/src/shape/link/smooth.ts
CHANGED
|
@@ -13,13 +13,13 @@ export const Smooth: SC<SmoothOptions> = (options) => {
|
|
|
13
13
|
const { ...style } = options;
|
|
14
14
|
return (points, value, coordinate, theme) => {
|
|
15
15
|
const { mark, shape, defaultShape } = value;
|
|
16
|
-
const {
|
|
16
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
17
17
|
theme,
|
|
18
18
|
mark,
|
|
19
19
|
shape,
|
|
20
20
|
defaultShape,
|
|
21
21
|
);
|
|
22
|
-
const { color =
|
|
22
|
+
const { color = defaultColor, transform } = value;
|
|
23
23
|
const [from, to] = points;
|
|
24
24
|
|
|
25
25
|
const path = d3path();
|
package/src/shape/link/vhv.ts
CHANGED
|
@@ -66,13 +66,13 @@ export const VHV: SC<VHVOptions> = (options) => {
|
|
|
66
66
|
const { cornerRatio = 1 / 3, ...style } = options;
|
|
67
67
|
return (points, value, coordinate, theme) => {
|
|
68
68
|
const { mark, shape, defaultShape } = value;
|
|
69
|
-
const {
|
|
69
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
70
70
|
theme,
|
|
71
71
|
mark,
|
|
72
72
|
shape,
|
|
73
73
|
defaultShape,
|
|
74
74
|
);
|
|
75
|
-
const { color =
|
|
75
|
+
const { color = defaultColor, transform } = value;
|
|
76
76
|
const [from, to] = points;
|
|
77
77
|
|
|
78
78
|
const path = getVHVPath(from, to, coordinate, cornerRatio);
|