@antv/g2 5.0.0-beta.3 → 5.0.0-beta.5
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/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 +46 -24
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +4 -0
- package/esm/component/index.js +2 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/legendCategory.js +1 -0
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/slider.d.ts +9 -0
- package/esm/component/slider.js +57 -0
- package/esm/component/slider.js.map +1 -0
- package/esm/component/sliderX.d.ts +7 -0
- package/esm/component/sliderX.js +9 -0
- package/esm/component/sliderX.js.map +1 -0
- package/esm/component/sliderY.d.ts +7 -0
- package/esm/component/sliderY.js +9 -0
- package/esm/component/sliderY.js.map +1 -0
- package/esm/composition/facetRect.js +4 -4
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/composition/mark.js +3 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/composition/repeatMatrix.js +2 -2
- package/esm/composition/repeatMatrix.js.map +1 -1
- package/esm/data/filter.d.ts +3 -3
- package/esm/data/filter.js.map +1 -1
- package/esm/data/index.d.ts +3 -1
- package/esm/data/index.js +1 -0
- package/esm/data/index.js.map +1 -1
- package/esm/data/sort.d.ts +8 -0
- package/esm/data/sort.js +12 -0
- package/esm/data/sort.js.map +1 -0
- package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
- package/esm/interaction/builtin/tooltip.d.ts +6 -4
- package/esm/interaction/index.d.ts +5 -0
- package/esm/interaction/index.js +5 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushHighlight.d.ts +15 -0
- package/esm/interaction/native/brushHighlight.js +283 -0
- package/esm/interaction/native/brushHighlight.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +1 -0
- package/esm/interaction/native/brushXHighlight.js +8 -0
- package/esm/interaction/native/brushXHighlight.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +1 -0
- package/esm/interaction/native/brushYHighlight.js +8 -0
- package/esm/interaction/native/brushYHighlight.js.map +1 -0
- package/esm/interaction/native/legendFilter.d.ts +8 -0
- package/esm/interaction/native/legendFilter.js +180 -0
- package/esm/interaction/native/legendFilter.js.map +1 -0
- package/esm/interaction/native/tooltip.d.ts +2 -2
- package/esm/interaction/native/tooltip.js +134 -44
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +5 -1
- package/esm/interaction/native/utils.js +25 -2
- 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/line.js +1 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/runtime/component.js +29 -1
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/plot.js +38 -13
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.js +17 -5
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +10 -4
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +1 -0
- package/esm/runtime/types/mark.d.ts +1 -1
- package/esm/runtime/types/options.d.ts +2 -0
- package/esm/runtime/types/theme.d.ts +5 -0
- 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 +20 -0
- package/esm/shape/label/{position.js → position/default.js} +9 -45
- 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 +1 -0
- package/esm/shape/label/position/outside.js +2 -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 +40 -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 +37 -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/spec/composition.d.ts +2 -0
- package/esm/spec/data.d.ts +10 -3
- package/esm/spec/geometry.d.ts +2 -1
- package/esm/spec/interaction.d.ts +28 -5
- package/esm/spec/labelTransform.d.ts +24 -11
- package/esm/spec/theme.d.ts +5 -2
- package/esm/spec/transform.d.ts +7 -2
- package/esm/stdlib/index.js +9 -10
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.d.ts +3 -0
- package/esm/theme/academy.js +402 -0
- package/esm/theme/academy.js.map +1 -0
- package/esm/theme/dark.js +80 -29
- 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 +71 -19
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/filter.d.ts +7 -0
- package/esm/transform/filter.js +42 -0
- package/esm/transform/filter.js.map +1 -0
- package/esm/transform/index.d.ts +2 -0
- package/esm/transform/index.js +1 -0
- package/esm/transform/index.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/esm/utils/selection.d.ts +1 -0
- package/esm/utils/selection.js.map +1 -1
- package/esm/utils/size.js +1 -1
- package/esm/utils/size.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 +46 -24
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +4 -0
- package/lib/component/index.js +5 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/legendCategory.js +1 -0
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/slider.d.ts +9 -0
- package/lib/component/slider.js +61 -0
- package/lib/component/slider.js.map +1 -0
- package/lib/component/sliderX.d.ts +7 -0
- package/lib/component/sliderX.js +13 -0
- package/lib/component/sliderX.js.map +1 -0
- package/lib/component/sliderY.d.ts +7 -0
- package/lib/component/sliderY.js +13 -0
- package/lib/component/sliderY.js.map +1 -0
- package/lib/composition/facetRect.js +4 -4
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/composition/mark.js +3 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/composition/repeatMatrix.js +2 -2
- package/lib/composition/repeatMatrix.js.map +1 -1
- package/lib/data/filter.d.ts +3 -3
- package/lib/data/filter.js.map +1 -1
- package/lib/data/index.d.ts +3 -1
- package/lib/data/index.js +3 -1
- package/lib/data/index.js.map +1 -1
- package/lib/data/sort.d.ts +8 -0
- package/lib/data/sort.js +17 -0
- package/lib/data/sort.js.map +1 -0
- package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
- package/lib/interaction/builtin/tooltip.d.ts +6 -4
- package/lib/interaction/index.d.ts +5 -0
- package/lib/interaction/index.js +11 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushHighlight.d.ts +15 -0
- package/lib/interaction/native/brushHighlight.js +289 -0
- package/lib/interaction/native/brushHighlight.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +1 -0
- package/lib/interaction/native/brushXHighlight.js +12 -0
- package/lib/interaction/native/brushXHighlight.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +1 -0
- package/lib/interaction/native/brushYHighlight.js +12 -0
- package/lib/interaction/native/brushYHighlight.js.map +1 -0
- package/lib/interaction/native/legendFilter.d.ts +8 -0
- package/lib/interaction/native/legendFilter.js +184 -0
- package/lib/interaction/native/legendFilter.js.map +1 -0
- package/lib/interaction/native/tooltip.d.ts +2 -2
- package/lib/interaction/native/tooltip.js +131 -41
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +5 -1
- package/lib/interaction/native/utils.js +30 -3
- 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/line.js +1 -1
- package/lib/mark/line.js.map +1 -1
- package/lib/runtime/component.js +29 -1
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/plot.js +38 -13
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.js +16 -4
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +10 -4
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +1 -0
- package/lib/runtime/types/mark.d.ts +1 -1
- package/lib/runtime/types/options.d.ts +2 -0
- package/lib/runtime/types/theme.d.ts +5 -0
- 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 +20 -0
- package/lib/shape/label/{position.js → position/default.js} +10 -43
- 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 +1 -0
- package/lib/shape/label/position/outside.js +6 -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 +44 -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 +41 -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/spec/composition.d.ts +2 -0
- package/lib/spec/data.d.ts +10 -3
- package/lib/spec/geometry.d.ts +2 -1
- package/lib/spec/interaction.d.ts +28 -5
- package/lib/spec/labelTransform.d.ts +24 -11
- package/lib/spec/theme.d.ts +5 -2
- package/lib/spec/transform.d.ts +7 -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 +406 -0
- package/lib/theme/academy.js.map +1 -0
- package/lib/theme/dark.js +80 -29
- 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 +71 -19
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/filter.d.ts +7 -0
- package/lib/transform/filter.js +46 -0
- package/lib/transform/filter.js.map +1 -0
- package/lib/transform/index.d.ts +2 -0
- package/lib/transform/index.js +3 -1
- package/lib/transform/index.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/lib/utils/selection.d.ts +1 -0
- package/lib/utils/selection.js.map +1 -1
- package/lib/utils/size.js +1 -1
- package/lib/utils/size.js.map +1 -1
- package/package.json +4 -3
- package/src/api/mark/mark.ts +1 -2
- package/src/api/mark/types.ts +1 -2
- package/src/component/axis.ts +56 -96
- package/src/component/index.ts +4 -0
- package/src/component/legendCategory.ts +1 -0
- package/src/component/slider.ts +61 -0
- package/src/component/sliderX.ts +16 -0
- package/src/component/sliderY.ts +16 -0
- package/src/composition/facetRect.ts +4 -2
- package/src/composition/mark.ts +4 -0
- package/src/composition/repeatMatrix.ts +8 -1
- package/src/data/filter.ts +3 -3
- package/src/data/index.ts +3 -1
- package/src/data/sort.ts +18 -0
- package/src/interaction/index.ts +6 -0
- package/src/interaction/native/brushHighlight.ts +346 -0
- package/src/interaction/native/brushXHighlight.ts +11 -0
- package/src/interaction/native/brushYHighlight.ts +11 -0
- package/src/interaction/native/legendFilter.ts +195 -0
- package/src/interaction/native/tooltip.ts +173 -45
- package/src/interaction/native/utils.ts +33 -1
- 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/line.ts +1 -1
- package/src/runtime/component.ts +49 -2
- package/src/runtime/plot.ts +46 -11
- package/src/runtime/scale.ts +15 -7
- package/src/runtime/transform.ts +13 -4
- package/src/runtime/types/common.ts +1 -0
- package/src/runtime/types/mark.ts +1 -1
- package/src/runtime/types/options.ts +2 -0
- package/src/runtime/types/theme.ts +5 -0
- 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} +12 -56
- 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 +1 -0
- package/src/shape/label/position/right.ts +1 -0
- package/src/shape/label/position/spider.ts +46 -0
- package/src/shape/label/position/surround.ts +42 -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/spec/composition.ts +2 -0
- package/src/spec/data.ts +12 -2
- package/src/spec/geometry.ts +3 -1
- package/src/spec/interaction.ts +38 -4
- package/src/spec/labelTransform.ts +29 -11
- package/src/spec/theme.ts +6 -2
- package/src/spec/transform.ts +9 -1
- package/src/stdlib/index.ts +31 -9
- package/src/theme/academy.ts +408 -0
- package/src/theme/dark.ts +81 -29
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +71 -19
- package/src/transform/filter.ts +48 -0
- package/src/transform/index.ts +2 -0
- 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/src/utils/selection.ts +2 -0
- package/src/utils/size.ts +1 -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.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/label-transform/hideOverlap.ts +0 -62
- package/src/label-transform/spider.ts +0 -37
- package/src/label-transform/surround.ts +0 -37
package/src/runtime/component.ts
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
isRadial,
|
|
27
27
|
} from './coordinate';
|
|
28
28
|
import { useLibrary } from './library';
|
|
29
|
-
import { isPosition } from './scale';
|
|
30
29
|
|
|
31
30
|
export function inferComponent(
|
|
32
31
|
scales: G2ScaleOptions[],
|
|
@@ -49,7 +48,8 @@ export function inferComponent(
|
|
|
49
48
|
if (guide === null) return false;
|
|
50
49
|
return true;
|
|
51
50
|
});
|
|
52
|
-
const
|
|
51
|
+
const sliders = createSliders(partialOptions, scales, library);
|
|
52
|
+
const components = [...partialComponents, ...sliders];
|
|
53
53
|
if (title) {
|
|
54
54
|
const { props } = createGuideComponent('title');
|
|
55
55
|
const { defaultPosition, defaultOrder, defaultSize } = props;
|
|
@@ -223,3 +223,50 @@ function inferTitleComponentSize(options: G2TitleOptions) {
|
|
|
223
223
|
// Extra 4px spacing.
|
|
224
224
|
return (text ? titleSize + 4 : 0) + (subtitle ? subtitleSize + spacing : 0);
|
|
225
225
|
}
|
|
226
|
+
|
|
227
|
+
function inferSliderType(
|
|
228
|
+
name: string,
|
|
229
|
+
coordinates: G2CoordinateOptions[] = [],
|
|
230
|
+
) {
|
|
231
|
+
if (name === 'x') return isTranspose(coordinates) ? 'sliderY' : 'sliderX';
|
|
232
|
+
if (name === 'y') return isTranspose(coordinates) ? 'sliderX' : 'sliderY';
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function createSliders(
|
|
237
|
+
partialOptions: G2View,
|
|
238
|
+
scales: G2ScaleOptions[],
|
|
239
|
+
library,
|
|
240
|
+
) {
|
|
241
|
+
const [, createGuideComponent] = useLibrary<
|
|
242
|
+
G2GuideComponentOptions,
|
|
243
|
+
GuideComponentComponent,
|
|
244
|
+
GuideComponent
|
|
245
|
+
>('component', library);
|
|
246
|
+
|
|
247
|
+
const { marks, coordinates } = partialOptions;
|
|
248
|
+
const nameScale = new Map(scales.map((scale) => [scale.name, scale]));
|
|
249
|
+
|
|
250
|
+
return marks
|
|
251
|
+
.filter((d) => d.slider)
|
|
252
|
+
.flatMap((mark) => {
|
|
253
|
+
const { slider } = mark;
|
|
254
|
+
return Object.entries(slider).map(([channelName, options]) => {
|
|
255
|
+
const scale = nameScale.get(channelName);
|
|
256
|
+
const componentType = inferSliderType(channelName, coordinates);
|
|
257
|
+
if (!scale || !componentType) return;
|
|
258
|
+
|
|
259
|
+
const { props } = createGuideComponent(componentType);
|
|
260
|
+
const { defaultPosition, defaultSize, defaultOrder } = props;
|
|
261
|
+
return {
|
|
262
|
+
position: defaultPosition,
|
|
263
|
+
size: defaultSize,
|
|
264
|
+
order: defaultOrder,
|
|
265
|
+
type: componentType,
|
|
266
|
+
...options,
|
|
267
|
+
scale,
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
})
|
|
271
|
+
.filter((d) => !!d);
|
|
272
|
+
}
|
package/src/runtime/plot.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
|
|
1
|
+
import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
|
|
2
2
|
import { deepMix, upperFirst } from '@antv/util';
|
|
3
3
|
import { format } from 'd3-format';
|
|
4
4
|
import { Vector2 } from '@antv/coord';
|
|
@@ -383,7 +383,8 @@ function initializeState(
|
|
|
383
383
|
library,
|
|
384
384
|
);
|
|
385
385
|
|
|
386
|
-
const { key, frame = false, theme: partialTheme, style = {} } = options;
|
|
386
|
+
const { key, frame = false, theme: partialTheme, clip, style = {} } = options;
|
|
387
|
+
|
|
387
388
|
const theme = useTheme(inferTheme(partialTheme));
|
|
388
389
|
|
|
389
390
|
// Infer components and compute layout.
|
|
@@ -396,7 +397,7 @@ function initializeState(
|
|
|
396
397
|
const layout = computeLayout(components, options);
|
|
397
398
|
const coordinate = createCoordinate(layout, options, library);
|
|
398
399
|
const framedStyle = frame
|
|
399
|
-
? deepMix({
|
|
400
|
+
? deepMix({ mainLineWidth: 1, mainStroke: '#000' }, style)
|
|
400
401
|
: style;
|
|
401
402
|
|
|
402
403
|
// Place components and mutate their bbox.
|
|
@@ -473,6 +474,7 @@ function initializeState(
|
|
|
473
474
|
components,
|
|
474
475
|
markState,
|
|
475
476
|
key,
|
|
477
|
+
clip,
|
|
476
478
|
scale: scaleInstance,
|
|
477
479
|
style: framedStyle,
|
|
478
480
|
};
|
|
@@ -489,7 +491,8 @@ async function plotView(
|
|
|
489
491
|
transitions: GAnimation[],
|
|
490
492
|
library: G2Library,
|
|
491
493
|
): Promise<void> {
|
|
492
|
-
const { components, theme, layout, markState, coordinate, key, style } =
|
|
494
|
+
const { components, theme, layout, markState, coordinate, key, style, clip } =
|
|
495
|
+
view;
|
|
493
496
|
|
|
494
497
|
// Render background for the different areas.
|
|
495
498
|
const { x, y, width, height, ...rest } = layout;
|
|
@@ -589,7 +592,8 @@ async function plotView(
|
|
|
589
592
|
.style('fill', 'transparent')
|
|
590
593
|
.attr('className', PLOT_CLASS_NAME)
|
|
591
594
|
.call(updateBBox)
|
|
592
|
-
.call(updateLayers, Array.from(markState.keys()))
|
|
595
|
+
.call(updateLayers, Array.from(markState.keys()))
|
|
596
|
+
.call(applyClip, clip),
|
|
593
597
|
(update) =>
|
|
594
598
|
update
|
|
595
599
|
.call(updateLayers, Array.from(markState.keys()))
|
|
@@ -597,7 +601,8 @@ async function plotView(
|
|
|
597
601
|
return animationExtent
|
|
598
602
|
? animateBBox(selection, animationExtent)
|
|
599
603
|
: updateBBox(selection);
|
|
600
|
-
})
|
|
604
|
+
})
|
|
605
|
+
.call(applyClip, clip),
|
|
601
606
|
)
|
|
602
607
|
.transitions();
|
|
603
608
|
transitions.push(...T.flat());
|
|
@@ -643,12 +648,16 @@ async function plotView(
|
|
|
643
648
|
return animation;
|
|
644
649
|
});
|
|
645
650
|
}),
|
|
646
|
-
(exit) =>
|
|
647
|
-
exit
|
|
651
|
+
(exit) => {
|
|
652
|
+
return exit
|
|
653
|
+
.each(function () {
|
|
654
|
+
this.__removed__ = true;
|
|
655
|
+
})
|
|
648
656
|
.transition(function (data) {
|
|
649
657
|
return exitFunction(data, [this]);
|
|
650
658
|
})
|
|
651
|
-
.remove()
|
|
659
|
+
.remove();
|
|
660
|
+
},
|
|
652
661
|
(merge) =>
|
|
653
662
|
merge
|
|
654
663
|
// Append elements to be merged.
|
|
@@ -714,7 +723,9 @@ function plotLabel(
|
|
|
714
723
|
const elements = selection
|
|
715
724
|
.select(`#${key}`)
|
|
716
725
|
.selectAll(className(ELEMENT_CLASS_NAME))
|
|
717
|
-
.nodes()
|
|
726
|
+
.nodes()
|
|
727
|
+
// Only select the valid element.
|
|
728
|
+
.filter((n) => !n.__removed__);
|
|
718
729
|
return labelOptions.flatMap((labelOption, i) => {
|
|
719
730
|
const { transform = [], ...options } = labelOption;
|
|
720
731
|
return elements.flatMap((e) => {
|
|
@@ -773,7 +784,16 @@ function getLabels(
|
|
|
773
784
|
const { seriesIndex: SI, seriesKey, points, key, index } = element.__data__;
|
|
774
785
|
const bounds = getLocalBounds(element);
|
|
775
786
|
if (!SI) {
|
|
776
|
-
return [
|
|
787
|
+
return [
|
|
788
|
+
{
|
|
789
|
+
...label,
|
|
790
|
+
key: `${key}-${labelIndex}`,
|
|
791
|
+
bounds,
|
|
792
|
+
index,
|
|
793
|
+
points,
|
|
794
|
+
dependentElement: element,
|
|
795
|
+
},
|
|
796
|
+
];
|
|
777
797
|
}
|
|
778
798
|
const selector = normalizeLabelSelector(label);
|
|
779
799
|
const F = SI.map((index: number, i: number) => ({
|
|
@@ -782,6 +802,7 @@ function getLabels(
|
|
|
782
802
|
bounds: [points[i]],
|
|
783
803
|
index,
|
|
784
804
|
points,
|
|
805
|
+
dependentElement: element,
|
|
785
806
|
}));
|
|
786
807
|
return selector ? selector(F) : F;
|
|
787
808
|
}
|
|
@@ -1207,6 +1228,20 @@ function className(...names: string[]): string {
|
|
|
1207
1228
|
return names.map((d) => `.${d}`).join('');
|
|
1208
1229
|
}
|
|
1209
1230
|
|
|
1231
|
+
function applyClip(selection, clip?: boolean) {
|
|
1232
|
+
if (!selection.node()) return;
|
|
1233
|
+
selection.style('clipPath', (data) => {
|
|
1234
|
+
if (!clip) return;
|
|
1235
|
+
const {
|
|
1236
|
+
paddingTop: y,
|
|
1237
|
+
paddingLeft: x,
|
|
1238
|
+
innerWidth: width,
|
|
1239
|
+
innerHeight: height,
|
|
1240
|
+
} = data;
|
|
1241
|
+
return new Rect({ style: { x, y, width, height } });
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1210
1245
|
export function applyStyle(
|
|
1211
1246
|
selection: Selection,
|
|
1212
1247
|
style: Record<string, Primitive>,
|
package/src/runtime/scale.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { extent } from 'd3-array';
|
|
|
3
3
|
import * as d3ScaleChromatic from 'd3-scale-chromatic';
|
|
4
4
|
import { upperFirst } from '@antv/util';
|
|
5
5
|
import { firstOf, lastOf, unique } from '../utils/array';
|
|
6
|
-
import { defined, identity } from '../utils/helper';
|
|
6
|
+
import { defined, identity, isStrictObject } from '../utils/helper';
|
|
7
7
|
import { Primitive, G2Theme, G2MarkState, ChannelGroups } from './types/common';
|
|
8
8
|
import {
|
|
9
9
|
G2CoordinateOptions,
|
|
@@ -155,7 +155,7 @@ function inferScaleType(
|
|
|
155
155
|
): string | ScaleComponent {
|
|
156
156
|
const { type, domain, range } = options;
|
|
157
157
|
if (type !== undefined) return type;
|
|
158
|
-
|
|
158
|
+
if (isObject(values)) return 'identity';
|
|
159
159
|
if (typeof range === 'string') return 'linear';
|
|
160
160
|
if ((domain || range || []).length > 2) return asOrdinalType(name);
|
|
161
161
|
if (domain !== undefined) {
|
|
@@ -275,11 +275,15 @@ function categoricalColors(
|
|
|
275
275
|
);
|
|
276
276
|
const { defaultCategory10: c10, defaultCategory20: c20 } = theme;
|
|
277
277
|
const defaultPalette = unique(values.flat()).length <= c10.length ? c10 : c20;
|
|
278
|
-
const { palette, offset } = options;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
usePalette({ type: palette
|
|
282
|
-
|
|
278
|
+
const { palette = defaultPalette, offset } = options;
|
|
279
|
+
// Built-in palettes have higher priority.
|
|
280
|
+
try {
|
|
281
|
+
return usePalette({ type: palette });
|
|
282
|
+
} catch (e) {
|
|
283
|
+
const colors = interpolatedColors(palette, domain, offset);
|
|
284
|
+
if (colors) return colors;
|
|
285
|
+
throw new Error(`Unknown Component: ${palette} `);
|
|
286
|
+
}
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
function gradientColors(range: string): string[] {
|
|
@@ -446,6 +450,10 @@ function isTemporal(values: Primitive[][]): boolean {
|
|
|
446
450
|
return some(values, (d) => d instanceof Date);
|
|
447
451
|
}
|
|
448
452
|
|
|
453
|
+
function isObject(values: Primitive[][]): boolean {
|
|
454
|
+
return some(values, isStrictObject);
|
|
455
|
+
}
|
|
456
|
+
|
|
449
457
|
function some(values, callback) {
|
|
450
458
|
for (const V of values) {
|
|
451
459
|
if (V.some(callback)) return true;
|
package/src/runtime/transform.ts
CHANGED
|
@@ -193,19 +193,28 @@ export function maybeNonAnimate(
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
function isTypedChannel(channel): boolean {
|
|
196
|
-
if (
|
|
196
|
+
if (
|
|
197
|
+
typeof channel !== 'object' ||
|
|
198
|
+
channel instanceof Date ||
|
|
199
|
+
channel === null
|
|
200
|
+
) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
197
203
|
const { type } = channel;
|
|
198
204
|
return defined(type);
|
|
199
205
|
}
|
|
200
206
|
|
|
201
207
|
function inferChannelType(data: Record<string, Primitive>[], channel): string {
|
|
202
208
|
if (typeof channel === 'function') return 'transform';
|
|
203
|
-
if (typeof channel === 'string' && data
|
|
204
|
-
return 'field';
|
|
205
|
-
}
|
|
209
|
+
if (typeof channel === 'string' && isField(data, channel)) return 'field';
|
|
206
210
|
return 'constant';
|
|
207
211
|
}
|
|
208
212
|
|
|
213
|
+
function isField(data: Record<string, Primitive>[], value: string): boolean {
|
|
214
|
+
if (!Array.isArray(data)) return false;
|
|
215
|
+
return data.some((d) => d[value] !== undefined);
|
|
216
|
+
}
|
|
217
|
+
|
|
209
218
|
function normalizedDataSource(data) {
|
|
210
219
|
// Return null as a placeholder.
|
|
211
220
|
if (!data) return { type: 'inline', value: null };
|
|
@@ -82,6 +82,7 @@ export type G2View = {
|
|
|
82
82
|
labelTransform?: G2LabelTransformOptions[];
|
|
83
83
|
style?: Record<string, any>;
|
|
84
84
|
tooltip?: boolean;
|
|
85
|
+
clip?: boolean;
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
export type G2Mark = {
|
|
@@ -100,6 +101,7 @@ export type G2Mark = {
|
|
|
100
101
|
facet?: boolean;
|
|
101
102
|
axis?: boolean | Record<string, any>;
|
|
102
103
|
legend?: boolean | Record<string, any>;
|
|
104
|
+
slider?: Record<string, any>;
|
|
103
105
|
filter?: (i: number) => boolean;
|
|
104
106
|
children?: G2MarkChildrenCallback;
|
|
105
107
|
dataDomain?: number;
|
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>,
|
|
@@ -114,7 +115,7 @@ function inferRotation(
|
|
|
114
115
|
return (angle / Math.PI) * 180 + append;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
function inferCircularStyle(
|
|
118
|
+
export function inferCircularStyle(
|
|
118
119
|
position: LabelPosition,
|
|
119
120
|
points: Vector2[],
|
|
120
121
|
value: Record<string, any>,
|
|
@@ -193,7 +194,7 @@ function inferIdentityStyle(position, points, value, coordinate) {
|
|
|
193
194
|
};
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
function getDefaultStyle(
|
|
197
|
+
export function getDefaultStyle(
|
|
197
198
|
position: LabelPosition,
|
|
198
199
|
points: Vector2[],
|
|
199
200
|
value: Record<string, any>,
|
|
@@ -216,48 +217,3 @@ function getDefaultStyle(
|
|
|
216
217
|
|
|
217
218
|
return inferDefaultStyle(position, points, value, coordinate);
|
|
218
219
|
}
|
|
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 @@
|
|
|
1
|
+
export { getDefaultStyle as outside } from './default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultStyle as right } from './default';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { sub } from '../../../utils/vector';
|
|
3
|
+
import { Vector2 } from '../../../runtime';
|
|
4
|
+
import { isCircular } from '../../../utils/coordinate';
|
|
5
|
+
import { maybePercentage } from '../../../utils/helper';
|
|
6
|
+
import { inferCircularStyle, LabelPosition } from './default';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
|
|
10
|
+
*/
|
|
11
|
+
export function spider(
|
|
12
|
+
position: LabelPosition,
|
|
13
|
+
points: Vector2[],
|
|
14
|
+
value: Record<string, any>,
|
|
15
|
+
coordinate: Coordinate,
|
|
16
|
+
options,
|
|
17
|
+
) {
|
|
18
|
+
if (!isCircular(coordinate)) return {};
|
|
19
|
+
const { edgeDistance = 0 } = options;
|
|
20
|
+
|
|
21
|
+
const { ...style }: any = inferCircularStyle(
|
|
22
|
+
'outside',
|
|
23
|
+
points,
|
|
24
|
+
value,
|
|
25
|
+
coordinate,
|
|
26
|
+
);
|
|
27
|
+
const { x: coordX, width } = coordinate.getOptions();
|
|
28
|
+
const center = coordinate.getCenter();
|
|
29
|
+
// todo: How to configure spider.
|
|
30
|
+
const margin = maybePercentage(edgeDistance, width);
|
|
31
|
+
|
|
32
|
+
const edgeX = coordX + margin;
|
|
33
|
+
const edgeX1 = coordX + width - margin;
|
|
34
|
+
|
|
35
|
+
const { x: originX, x0, y0 } = style;
|
|
36
|
+
const dx = originX <= center[0] ? edgeX - originX : edgeX1 - originX;
|
|
37
|
+
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]];
|
|
44
|
+
|
|
45
|
+
return style;
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { PolarCoordinate } from 'spec';
|
|
3
|
+
import { Vector2 } from '../../../runtime';
|
|
4
|
+
import { getRadius, isCircular } from '../../../utils/coordinate';
|
|
5
|
+
import { angleWithQuadrant } from '../../../utils/vector';
|
|
6
|
+
import { inferCircularStyle, LabelPosition } from './default';
|
|
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
|
+
options,
|
|
17
|
+
) {
|
|
18
|
+
if (!isCircular(coordinate)) return {};
|
|
19
|
+
|
|
20
|
+
const { offset = 12 } = options;
|
|
21
|
+
const { ...style }: any = inferCircularStyle(
|
|
22
|
+
'outside',
|
|
23
|
+
points,
|
|
24
|
+
value,
|
|
25
|
+
coordinate,
|
|
26
|
+
);
|
|
27
|
+
const center = coordinate.getCenter();
|
|
28
|
+
const radius = getRadius(coordinate) + offset;
|
|
29
|
+
|
|
30
|
+
const { x0, y0, connector, connectorLength2 = 0 } = style;
|
|
31
|
+
const labelAngle = angleWithQuadrant([x0 - center[0], y0 - center[1]]);
|
|
32
|
+
const length2 = connector
|
|
33
|
+
? connectorLength2 * (Math.sin(labelAngle) < 0 ? -1 : 1)
|
|
34
|
+
: 0;
|
|
35
|
+
const newX = center[0] + Math.sin(labelAngle) * radius;
|
|
36
|
+
const newY = center[1] - Math.cos(labelAngle) * radius;
|
|
37
|
+
style.x = newX + length2;
|
|
38
|
+
style.y = newY;
|
|
39
|
+
style.connectorPoints = [[-length2, 0]];
|
|
40
|
+
|
|
41
|
+
return style;
|
|
42
|
+
}
|
|
@@ -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/spec/composition.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type Node =
|
|
|
24
24
|
|
|
25
25
|
export type MarkComposition = Geometry & {
|
|
26
26
|
title?: Title;
|
|
27
|
+
clip?: boolean;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export type ViewComposition = {
|
|
@@ -63,6 +64,7 @@ export type ViewComposition = {
|
|
|
63
64
|
on?: Record<string, EventType | EventType[]>;
|
|
64
65
|
// @todo
|
|
65
66
|
style?: Record<string, any>;
|
|
67
|
+
clip?: boolean;
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
export type SpaceLayerComposition = {
|