@antv/g2 5.0.0-beta.7 → 5.0.0-beta.9
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 +3 -3
- package/dist/g2.min.js +4 -4
- package/esm/animation/morphing.js +22 -2
- package/esm/animation/morphing.js.map +1 -1
- package/esm/api/chart.d.ts +8 -3
- package/esm/api/chart.js +35 -16
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +18 -1
- package/esm/api/composition/base.js +44 -1
- package/esm/api/composition/base.js.map +1 -1
- package/esm/api/mark/base.d.ts +22 -0
- package/esm/api/mark/base.js +54 -0
- package/esm/api/mark/base.js.map +1 -0
- package/esm/api/mark/mark.d.ts +1 -7
- package/esm/api/mark/mark.js +1 -13
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/props.js +0 -20
- package/esm/api/props.js.map +1 -1
- package/esm/component/axis.d.ts +5 -7
- package/esm/component/axis.js +126 -94
- package/esm/component/axis.js.map +1 -1
- package/esm/component/axisArc.d.ts +7 -0
- package/esm/component/axisArc.js +9 -0
- package/esm/component/axisArc.js.map +1 -0
- package/esm/component/axisRadar.d.ts +9 -0
- package/esm/component/axisRadar.js +46 -0
- package/esm/component/axisRadar.js.map +1 -0
- package/esm/component/axisX.d.ts +2 -1
- package/esm/component/axisX.js +5 -4
- package/esm/component/axisX.js.map +1 -1
- package/esm/component/axisY.d.ts +1 -1
- package/esm/component/axisY.js +4 -4
- package/esm/component/axisY.js.map +1 -1
- package/esm/component/index.d.ts +8 -0
- package/esm/component/index.js +5 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/legendCategory.d.ts +5 -3
- package/esm/component/legendCategory.js +80 -36
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.d.ts +4 -2
- package/esm/component/legendContinuous.js +76 -24
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/legendContinuousBlock.d.ts +4 -0
- package/esm/component/legendContinuousBlock.js +6 -0
- package/esm/component/legendContinuousBlock.js.map +1 -0
- package/esm/component/legendContinuousBlockSize.d.ts +4 -0
- package/esm/component/legendContinuousBlockSize.js +6 -0
- package/esm/component/legendContinuousBlockSize.js.map +1 -0
- package/esm/component/legendContinuousSize.d.ts +4 -0
- package/esm/component/legendContinuousSize.js +10 -0
- package/esm/component/legendContinuousSize.js.map +1 -0
- package/esm/component/scrollbar.js +1 -1
- package/esm/component/scrollbar.js.map +1 -1
- package/esm/component/slider.js +1 -1
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js +1 -1
- package/esm/component/title.js.map +1 -1
- package/esm/component/utils.d.ts +12 -0
- package/esm/component/utils.js +35 -0
- package/esm/component/utils.js.map +1 -1
- package/esm/composition/facetCircle.js +1 -1
- package/esm/composition/facetCircle.js.map +1 -1
- package/esm/coordinate/index.d.ts +3 -3
- package/esm/coordinate/index.js +3 -3
- package/esm/coordinate/index.js.map +1 -1
- package/esm/coordinate/polar.d.ts +6 -0
- package/esm/coordinate/polar.js +18 -6
- package/esm/coordinate/polar.js.map +1 -1
- package/esm/coordinate/radial.d.ts +6 -0
- package/esm/coordinate/radial.js +17 -5
- package/esm/coordinate/radial.js.map +1 -1
- package/esm/coordinate/theta.d.ts +7 -0
- package/esm/coordinate/theta.js +16 -4
- package/esm/coordinate/theta.js.map +1 -1
- package/esm/interaction/builtin/elementHighlight.d.ts +2 -0
- package/esm/interaction/builtin/elementHighlightByColor.d.ts +2 -0
- package/esm/interaction/builtin/elementHighlightByX.d.ts +2 -0
- package/esm/interaction/index.d.ts +2 -0
- package/esm/interaction/index.js +2 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushAxisHighlight.js +6 -1
- package/esm/interaction/native/brushAxisHighlight.js.map +1 -1
- package/esm/interaction/native/brushFilter.js +1 -1
- package/esm/interaction/native/brushFilter.js.map +1 -1
- package/esm/interaction/native/elementHighlight.d.ts +7 -2
- package/esm/interaction/native/elementHighlight.js +72 -19
- package/esm/interaction/native/elementHighlight.js.map +1 -1
- package/esm/interaction/native/elementHighlightByColor.d.ts +4 -1
- package/esm/interaction/native/elementHighlightByColor.js +19 -3
- package/esm/interaction/native/elementHighlightByColor.js.map +1 -1
- package/esm/interaction/native/elementHighlightByX.d.ts +3 -3
- package/esm/interaction/native/elementHighlightByX.js +19 -3
- package/esm/interaction/native/elementHighlightByX.js.map +1 -1
- package/esm/interaction/native/elementSelect.d.ts +1 -1
- package/esm/interaction/native/elementSelect.js +42 -21
- package/esm/interaction/native/elementSelect.js.map +1 -1
- package/esm/interaction/native/elementSelectByColor.js +3 -2
- package/esm/interaction/native/elementSelectByColor.js.map +1 -1
- package/esm/interaction/native/elementSelectByX.js +3 -2
- package/esm/interaction/native/elementSelectByX.js.map +1 -1
- package/esm/interaction/native/legendFilter.d.ts +6 -0
- package/esm/interaction/native/legendFilter.js +26 -7
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/legendHighlight.d.ts +4 -0
- package/esm/interaction/native/legendHighlight.js +93 -0
- package/esm/interaction/native/legendHighlight.js.map +1 -0
- package/esm/interaction/native/poptip.d.ts +5 -0
- package/esm/interaction/native/poptip.js +91 -0
- package/esm/interaction/native/poptip.js.map +1 -0
- package/esm/interaction/native/utils.d.ts +13 -2
- package/esm/interaction/native/utils.js +151 -26
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/label-transform/overlapDodgeY.js +0 -8
- package/esm/label-transform/overlapDodgeY.js.map +1 -1
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/pack.js +0 -1
- package/esm/mark/pack.js.map +1 -1
- package/esm/mark/treemap.js +0 -1
- package/esm/mark/treemap.js.map +1 -1
- package/esm/runtime/component.d.ts +3 -0
- package/esm/runtime/component.js +246 -103
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/coordinate.d.ts +11 -0
- package/esm/runtime/coordinate.js +23 -16
- package/esm/runtime/coordinate.js.map +1 -1
- package/esm/runtime/layout.d.ts +1 -1
- package/esm/runtime/layout.js +145 -76
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +5 -4
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +18 -13
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.d.ts +2 -1
- package/esm/runtime/scale.js +35 -0
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +1 -1
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +11 -2
- package/esm/runtime/types/component.d.ts +9 -7
- package/esm/runtime/types/options.d.ts +8 -6
- package/esm/runtime/types/scale.d.ts +18 -0
- package/esm/runtime/types/scale.js +19 -0
- package/esm/runtime/types/scale.js.map +1 -0
- package/esm/runtime/types/theme.d.ts +2 -1
- package/esm/shape/area/hv.d.ts +3 -0
- package/esm/shape/area/hv.js +9 -0
- package/esm/shape/area/hv.js.map +1 -0
- package/esm/shape/area/hvh.d.ts +3 -0
- package/esm/shape/area/{step.js → hvh.js} +3 -3
- package/esm/shape/area/hvh.js.map +1 -0
- package/esm/shape/area/vh.d.ts +3 -0
- package/esm/shape/area/vh.js +9 -0
- package/esm/shape/area/vh.js.map +1 -0
- package/esm/shape/connector/connector.js +1 -1
- package/esm/shape/index.d.ts +6 -2
- package/esm/shape/index.js +3 -1
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/interval/color.d.ts +1 -0
- package/esm/shape/interval/color.js +65 -53
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/spec/composition.d.ts +0 -3
- package/esm/spec/geometry.d.ts +1 -1
- package/esm/spec/interaction.d.ts +33 -15
- package/esm/spec/transform.d.ts +13 -3
- package/esm/stdlib/index.js +4 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.js +10 -4
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/dark.js +10 -4
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/light.js +12 -4
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/sample.js +42 -26
- package/esm/transform/sample.js.map +1 -1
- package/esm/transform/utils/lttb.d.ts +5 -0
- package/esm/transform/utils/lttb.js +56 -0
- package/esm/transform/utils/lttb.js.map +1 -0
- package/esm/utils/angle.d.ts +2 -0
- package/esm/utils/angle.js +7 -0
- package/esm/utils/angle.js.map +1 -0
- package/esm/utils/array.d.ts +8 -0
- package/esm/utils/array.js +35 -0
- package/esm/utils/array.js.map +1 -1
- package/esm/utils/coordinate.d.ts +4 -0
- package/esm/utils/coordinate.js +19 -0
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/event.d.ts +0 -2
- package/esm/utils/event.js +0 -18
- package/esm/utils/event.js.map +1 -1
- package/esm/utils/scale.d.ts +1 -0
- package/esm/utils/scale.js +3 -3
- package/esm/utils/scale.js.map +1 -1
- package/esm/utils/vector.d.ts +1 -1
- package/esm/utils/vector.js +1 -1
- package/lib/animation/morphing.js +22 -2
- package/lib/animation/morphing.js.map +1 -1
- package/lib/api/chart.d.ts +8 -3
- package/lib/api/chart.js +37 -15
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +18 -1
- package/lib/api/composition/base.js +44 -1
- package/lib/api/composition/base.js.map +1 -1
- package/lib/api/mark/base.d.ts +22 -0
- package/lib/api/mark/base.js +58 -0
- package/lib/api/mark/base.js.map +1 -0
- package/lib/api/mark/mark.d.ts +1 -7
- package/lib/api/mark/mark.js +28 -41
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/props.js +0 -20
- package/lib/api/props.js.map +1 -1
- package/lib/component/axis.d.ts +5 -7
- package/lib/component/axis.js +127 -96
- package/lib/component/axis.js.map +1 -1
- package/lib/component/axisArc.d.ts +7 -0
- package/lib/component/axisArc.js +13 -0
- package/lib/component/axisArc.js.map +1 -0
- package/lib/component/axisRadar.d.ts +9 -0
- package/lib/component/axisRadar.js +50 -0
- package/lib/component/axisRadar.js.map +1 -0
- package/lib/component/axisX.d.ts +2 -1
- package/lib/component/axisX.js +6 -4
- package/lib/component/axisX.js.map +1 -1
- package/lib/component/axisY.d.ts +1 -1
- package/lib/component/axisY.js +3 -3
- package/lib/component/axisY.js.map +1 -1
- package/lib/component/index.d.ts +8 -0
- package/lib/component/index.js +12 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/legendCategory.d.ts +5 -3
- package/lib/component/legendCategory.js +79 -35
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.d.ts +4 -2
- package/lib/component/legendContinuous.js +75 -23
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/legendContinuousBlock.d.ts +4 -0
- package/lib/component/legendContinuousBlock.js +10 -0
- package/lib/component/legendContinuousBlock.js.map +1 -0
- package/lib/component/legendContinuousBlockSize.d.ts +4 -0
- package/lib/component/legendContinuousBlockSize.js +10 -0
- package/lib/component/legendContinuousBlockSize.js.map +1 -0
- package/lib/component/legendContinuousSize.d.ts +4 -0
- package/lib/component/legendContinuousSize.js +14 -0
- package/lib/component/legendContinuousSize.js.map +1 -0
- package/lib/component/scrollbar.js +1 -1
- package/lib/component/scrollbar.js.map +1 -1
- package/lib/component/slider.js +1 -1
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js +1 -1
- package/lib/component/title.js.map +1 -1
- package/lib/component/utils.d.ts +12 -0
- package/lib/component/utils.js +39 -1
- package/lib/component/utils.js.map +1 -1
- package/lib/composition/facetCircle.js +1 -1
- package/lib/composition/facetCircle.js.map +1 -1
- package/lib/coordinate/index.d.ts +3 -3
- package/lib/coordinate/index.js +4 -1
- package/lib/coordinate/index.js.map +1 -1
- package/lib/coordinate/polar.d.ts +6 -0
- package/lib/coordinate/polar.js +20 -7
- package/lib/coordinate/polar.js.map +1 -1
- package/lib/coordinate/radial.d.ts +6 -0
- package/lib/coordinate/radial.js +19 -6
- package/lib/coordinate/radial.js.map +1 -1
- package/lib/coordinate/theta.d.ts +7 -0
- package/lib/coordinate/theta.js +18 -5
- package/lib/coordinate/theta.js.map +1 -1
- package/lib/interaction/builtin/elementHighlight.d.ts +2 -0
- package/lib/interaction/builtin/elementHighlightByColor.d.ts +2 -0
- package/lib/interaction/builtin/elementHighlightByX.d.ts +2 -0
- package/lib/interaction/index.d.ts +2 -0
- package/lib/interaction/index.js +5 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushAxisHighlight.js +6 -1
- package/lib/interaction/native/brushAxisHighlight.js.map +1 -1
- package/lib/interaction/native/brushFilter.js +1 -1
- package/lib/interaction/native/brushFilter.js.map +1 -1
- package/lib/interaction/native/elementHighlight.d.ts +7 -2
- package/lib/interaction/native/elementHighlight.js +71 -18
- package/lib/interaction/native/elementHighlight.js.map +1 -1
- package/lib/interaction/native/elementHighlightByColor.d.ts +4 -1
- package/lib/interaction/native/elementHighlightByColor.js +18 -2
- package/lib/interaction/native/elementHighlightByColor.js.map +1 -1
- package/lib/interaction/native/elementHighlightByX.d.ts +3 -3
- package/lib/interaction/native/elementHighlightByX.js +18 -2
- package/lib/interaction/native/elementHighlightByX.js.map +1 -1
- package/lib/interaction/native/elementSelect.d.ts +1 -1
- package/lib/interaction/native/elementSelect.js +41 -20
- package/lib/interaction/native/elementSelect.js.map +1 -1
- package/lib/interaction/native/elementSelectByColor.js +2 -1
- package/lib/interaction/native/elementSelectByColor.js.map +1 -1
- package/lib/interaction/native/elementSelectByX.js +2 -1
- package/lib/interaction/native/elementSelectByX.js.map +1 -1
- package/lib/interaction/native/legendFilter.d.ts +6 -0
- package/lib/interaction/native/legendFilter.js +31 -6
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/legendHighlight.d.ts +4 -0
- package/lib/interaction/native/legendHighlight.js +97 -0
- package/lib/interaction/native/legendHighlight.js.map +1 -0
- package/lib/interaction/native/poptip.d.ts +5 -0
- package/lib/interaction/native/poptip.js +95 -0
- package/lib/interaction/native/poptip.js.map +1 -0
- package/lib/interaction/native/utils.d.ts +13 -2
- package/lib/interaction/native/utils.js +154 -27
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/label-transform/overlapDodgeY.js +0 -8
- package/lib/label-transform/overlapDodgeY.js.map +1 -1
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/pack.js +0 -1
- package/lib/mark/pack.js.map +1 -1
- package/lib/mark/treemap.js +0 -1
- package/lib/mark/treemap.js.map +1 -1
- package/lib/runtime/component.d.ts +3 -0
- package/lib/runtime/component.js +250 -107
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/coordinate.d.ts +11 -0
- package/lib/runtime/coordinate.js +26 -17
- package/lib/runtime/coordinate.js.map +1 -1
- package/lib/runtime/layout.d.ts +1 -1
- package/lib/runtime/layout.js +146 -77
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +4 -3
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +20 -12
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.d.ts +2 -1
- package/lib/runtime/scale.js +37 -1
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +1 -1
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +11 -2
- package/lib/runtime/types/component.d.ts +9 -7
- package/lib/runtime/types/options.d.ts +8 -6
- package/lib/runtime/types/scale.d.ts +18 -0
- package/lib/runtime/types/scale.js +22 -0
- package/lib/runtime/types/scale.js.map +1 -0
- package/lib/runtime/types/theme.d.ts +2 -1
- package/lib/shape/area/hv.d.ts +3 -0
- package/lib/shape/area/hv.js +13 -0
- package/lib/shape/area/hv.js.map +1 -0
- package/lib/shape/area/hvh.d.ts +3 -0
- package/lib/shape/area/{step.js → hvh.js} +5 -5
- package/lib/shape/area/hvh.js.map +1 -0
- package/lib/shape/area/vh.d.ts +3 -0
- package/lib/shape/area/vh.js +13 -0
- package/lib/shape/area/vh.js.map +1 -0
- package/lib/shape/connector/connector.js +1 -1
- package/lib/shape/index.d.ts +6 -2
- package/lib/shape/index.js +7 -3
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/interval/color.d.ts +1 -0
- package/lib/shape/interval/color.js +67 -54
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/spec/composition.d.ts +0 -3
- package/lib/spec/geometry.d.ts +1 -1
- package/lib/spec/interaction.d.ts +33 -15
- package/lib/spec/transform.d.ts +13 -3
- package/lib/stdlib/index.js +1 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.js +10 -4
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/dark.js +10 -4
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/light.js +12 -4
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/sample.js +42 -26
- package/lib/transform/sample.js.map +1 -1
- package/lib/transform/utils/lttb.d.ts +5 -0
- package/lib/transform/utils/lttb.js +60 -0
- package/lib/transform/utils/lttb.js.map +1 -0
- package/lib/utils/angle.d.ts +2 -0
- package/lib/utils/angle.js +12 -0
- package/lib/utils/angle.js.map +1 -0
- package/lib/utils/array.d.ts +8 -0
- package/lib/utils/array.js +38 -1
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/coordinate.d.ts +4 -0
- package/lib/utils/coordinate.js +24 -1
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/event.d.ts +0 -2
- package/lib/utils/event.js +1 -21
- package/lib/utils/event.js.map +1 -1
- package/lib/utils/scale.d.ts +1 -0
- package/lib/utils/scale.js +5 -4
- package/lib/utils/scale.js.map +1 -1
- package/lib/utils/vector.d.ts +1 -1
- package/lib/utils/vector.js +1 -1
- package/package.json +7 -7
- package/src/animation/morphing.ts +23 -2
- package/src/api/chart.ts +43 -20
- package/src/api/composition/base.ts +46 -1
- package/src/api/mark/base.ts +58 -0
- package/src/api/mark/mark.ts +1 -20
- package/src/api/props.ts +0 -23
- package/src/component/axis.ts +199 -118
- package/src/component/axisArc.ts +16 -0
- package/src/component/axisRadar.ts +73 -0
- package/src/component/axisX.ts +7 -4
- package/src/component/axisY.ts +4 -4
- package/src/component/index.ts +8 -0
- package/src/component/legendCategory.ts +156 -35
- package/src/component/legendContinuous.ts +133 -32
- package/src/component/legendContinuousBlock.ts +17 -0
- package/src/component/legendContinuousBlockSize.ts +22 -0
- package/src/component/legendContinuousSize.ts +27 -0
- package/src/component/scrollbar.ts +1 -1
- package/src/component/slider.ts +1 -1
- package/src/component/title.ts +1 -1
- package/src/component/utils.ts +46 -0
- package/src/composition/facetCircle.ts +1 -1
- package/src/coordinate/index.ts +3 -3
- package/src/coordinate/polar.ts +19 -11
- package/src/coordinate/radial.ts +19 -10
- package/src/coordinate/theta.ts +18 -9
- package/src/interaction/index.ts +2 -0
- package/src/interaction/native/brushAxisHighlight.ts +9 -1
- package/src/interaction/native/brushFilter.ts +1 -1
- package/src/interaction/native/elementHighlight.ts +78 -12
- package/src/interaction/native/elementHighlightByColor.ts +9 -4
- package/src/interaction/native/elementHighlightByX.ts +9 -5
- package/src/interaction/native/elementSelect.ts +58 -15
- package/src/interaction/native/elementSelectByColor.ts +4 -1
- package/src/interaction/native/elementSelectByX.ts +4 -1
- package/src/interaction/native/legendFilter.ts +29 -7
- package/src/interaction/native/legendHighlight.ts +86 -0
- package/src/interaction/native/poptip.ts +87 -0
- package/src/interaction/native/utils.ts +183 -26
- package/src/label-transform/overlapDodgeY.ts +0 -7
- package/src/mark/area.ts +1 -1
- package/src/mark/pack.ts +0 -1
- package/src/mark/treemap.ts +0 -1
- package/src/runtime/component.ts +335 -124
- package/src/runtime/coordinate.ts +29 -16
- package/src/runtime/layout.ts +206 -97
- package/src/runtime/plot.ts +5 -4
- package/src/runtime/render.ts +26 -13
- package/src/runtime/scale.ts +41 -0
- package/src/runtime/transform.ts +3 -0
- package/src/runtime/types/common.ts +23 -10
- package/src/runtime/types/component.ts +19 -10
- package/src/runtime/types/options.ts +24 -16
- package/src/runtime/types/scale.ts +20 -0
- package/src/runtime/types/theme.ts +2 -1
- package/src/shape/area/hv.ts +20 -0
- package/src/shape/area/{step.ts → hvh.ts} +3 -3
- package/src/shape/area/vh.ts +20 -0
- package/src/shape/connector/connector.ts +1 -1
- package/src/shape/index.ts +7 -2
- package/src/shape/interval/color.ts +86 -54
- package/src/shape/utils.ts +2 -0
- package/src/spec/composition.ts +0 -1
- package/src/spec/geometry.ts +3 -1
- package/src/spec/interaction.ts +51 -19
- package/src/spec/transform.ts +27 -2
- package/src/stdlib/index.ts +22 -6
- package/src/theme/academy.ts +10 -4
- package/src/theme/dark.ts +10 -4
- package/src/theme/light.ts +12 -4
- package/src/transform/sample.ts +54 -18
- package/src/transform/utils/lttb.ts +73 -0
- package/src/utils/angle.ts +7 -0
- package/src/utils/array.ts +39 -0
- package/src/utils/coordinate.ts +29 -0
- package/src/utils/event.ts +0 -26
- package/src/utils/scale.ts +4 -4
- package/src/utils/vector.ts +1 -1
- package/esm/shape/area/step.d.ts +0 -3
- package/esm/shape/area/step.js.map +0 -1
- package/lib/shape/area/step.d.ts +0 -3
- package/lib/shape/area/step.js.map +0 -1
package/src/component/axis.ts
CHANGED
|
@@ -2,30 +2,34 @@ import { Coordinate } from '@antv/coord';
|
|
|
2
2
|
import { Axis as AxisComponent } from '@antv/gui';
|
|
3
3
|
import { Linear as LinearScale } from '@antv/scale';
|
|
4
4
|
import { deepMix } from '@antv/util';
|
|
5
|
-
import { format } from 'd3-format';
|
|
6
5
|
import { extent } from 'd3-array';
|
|
6
|
+
import { format } from 'd3-format';
|
|
7
7
|
import {
|
|
8
|
+
BBox,
|
|
9
|
+
G2Theme,
|
|
10
|
+
GuideComponentComponent as GCC,
|
|
11
|
+
GuideComponentOrientation as GCO,
|
|
12
|
+
GuideComponentPosition as GCP,
|
|
13
|
+
Scale,
|
|
14
|
+
} from '../runtime';
|
|
15
|
+
import {
|
|
16
|
+
angleOf,
|
|
17
|
+
isFisheye,
|
|
8
18
|
isParallel,
|
|
9
19
|
isPolar,
|
|
10
|
-
isTranspose,
|
|
11
|
-
isTheta,
|
|
12
20
|
isRadial,
|
|
13
|
-
|
|
21
|
+
isTheta,
|
|
22
|
+
isTranspose,
|
|
23
|
+
isNonCartesian,
|
|
24
|
+
radiusOf,
|
|
14
25
|
} from '../utils/coordinate';
|
|
15
26
|
import { capitalizeFirst } from '../utils/helper';
|
|
16
|
-
import {
|
|
17
|
-
BBox,
|
|
18
|
-
GuideComponentComponent as GCC,
|
|
19
|
-
GuideComponentPosition,
|
|
20
|
-
Scale,
|
|
21
|
-
} from '../runtime';
|
|
22
27
|
import { titleContent } from './utils';
|
|
23
28
|
|
|
24
29
|
export type AxisOptions = {
|
|
25
|
-
position?:
|
|
30
|
+
position?: GCP;
|
|
26
31
|
zIndex?: number;
|
|
27
32
|
title?: string | string[];
|
|
28
|
-
d;
|
|
29
33
|
direction?: 'left' | 'center' | 'right';
|
|
30
34
|
labelFormatter?: (d: any, index: number, array: any) => string;
|
|
31
35
|
tickFilter?: (datum: any, index: number, array: any) => boolean;
|
|
@@ -36,25 +40,11 @@ export type AxisOptions = {
|
|
|
36
40
|
) => number[];
|
|
37
41
|
tickCount?: number;
|
|
38
42
|
grid: any;
|
|
43
|
+
// options won't be overridden
|
|
44
|
+
important: Record<string, any>;
|
|
39
45
|
[key: string]: any;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
|
-
function angleOf(coordinate: Coordinate): [number, number] {
|
|
43
|
-
const { transformations } = coordinate.getOptions();
|
|
44
|
-
const [, startAngle, endAngle] = transformations.find(
|
|
45
|
-
(d) => d[0] === 'polar',
|
|
46
|
-
);
|
|
47
|
-
return [(+startAngle * 180) / Math.PI, (+endAngle * 180) / Math.PI];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function radiusOf(coordinate: Coordinate): [number, number] {
|
|
51
|
-
const { transformations } = coordinate.getOptions();
|
|
52
|
-
const [, , , innerRadius, outerRadius] = transformations.find(
|
|
53
|
-
(d) => d[0] === 'polar',
|
|
54
|
-
);
|
|
55
|
-
return [+innerRadius, +outerRadius];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
48
|
function sizeOf(coordinate: Coordinate): [number, number] {
|
|
59
49
|
// @ts-ignore
|
|
60
50
|
const { innerWidth, innerHeight } = coordinate.getOptions();
|
|
@@ -102,6 +92,14 @@ function ticksOf(
|
|
|
102
92
|
return tickMethod(min, max, tickCount);
|
|
103
93
|
}
|
|
104
94
|
|
|
95
|
+
function isHorizontal(orientation: GCO) {
|
|
96
|
+
return orientation === 'horizontal' || orientation === 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isVertical(orientation: GCO) {
|
|
100
|
+
return orientation === 'vertical' || orientation === -Math.PI / 2;
|
|
101
|
+
}
|
|
102
|
+
|
|
105
103
|
function prettyNumber(n: number) {
|
|
106
104
|
if (typeof n !== 'number') return n;
|
|
107
105
|
return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(15));
|
|
@@ -139,7 +137,7 @@ function getTicks(
|
|
|
139
137
|
defaultTickFormatter: AxisOptions['labelFormatter'],
|
|
140
138
|
tickFilter: AxisOptions['tickFilter'],
|
|
141
139
|
tickMethod: AxisOptions['tickMethod'],
|
|
142
|
-
position:
|
|
140
|
+
position: GCP,
|
|
143
141
|
coordinate: Coordinate,
|
|
144
142
|
) {
|
|
145
143
|
if (tickCount !== undefined || tickMethod !== undefined) {
|
|
@@ -167,7 +165,7 @@ function getTicks(
|
|
|
167
165
|
});
|
|
168
166
|
// @todo GUI should consider the overlap problem for the first
|
|
169
167
|
// and label of arc axis.
|
|
170
|
-
return isRadial(coordinate) && position === '
|
|
168
|
+
return isRadial(coordinate) && position === 'center'
|
|
171
169
|
? reverseTicks(axisTicks)
|
|
172
170
|
: axisTicks;
|
|
173
171
|
}
|
|
@@ -183,9 +181,9 @@ function getTicks(
|
|
|
183
181
|
});
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
function
|
|
184
|
+
function inferGridLength(position: GCP, coordinate: Coordinate) {
|
|
187
185
|
const [width, height] = sizeOf(coordinate);
|
|
188
|
-
if (position
|
|
186
|
+
if (position.includes('bottom') || position.includes('top')) return height;
|
|
189
187
|
return width;
|
|
190
188
|
}
|
|
191
189
|
|
|
@@ -198,15 +196,24 @@ function labelTransforms(autoHide?: boolean, autoRotate?: boolean) {
|
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
function inferArcStyle(
|
|
201
|
-
position:
|
|
199
|
+
position: GCP,
|
|
200
|
+
bbox: BBox,
|
|
202
201
|
innerRadius: number,
|
|
203
202
|
outerRadius: number,
|
|
204
203
|
coordinate: Coordinate,
|
|
205
204
|
) {
|
|
205
|
+
const { x, y, width, height } = bbox;
|
|
206
|
+
const center: [number, number] = [x + width / 2, y + height / 2];
|
|
207
|
+
const radius = Math.min(width, height) / 2;
|
|
208
|
+
const [startAngle, endAngle] = angleOf(coordinate);
|
|
209
|
+
|
|
206
210
|
const [w, h] = sizeOf(coordinate);
|
|
207
211
|
const r = Math.min(w, h) / 2;
|
|
208
212
|
|
|
209
213
|
const common = {
|
|
214
|
+
center,
|
|
215
|
+
radius,
|
|
216
|
+
angleRange: [startAngle, endAngle],
|
|
210
217
|
titleFillOpacity: 0,
|
|
211
218
|
titlePosition: 'inner',
|
|
212
219
|
showLine: false,
|
|
@@ -214,7 +221,7 @@ function inferArcStyle(
|
|
|
214
221
|
gridLength: (outerRadius - innerRadius) * r,
|
|
215
222
|
};
|
|
216
223
|
|
|
217
|
-
if (position === '
|
|
224
|
+
if (position === 'inner') {
|
|
218
225
|
const [w, h] = sizeOf(coordinate);
|
|
219
226
|
const r = Math.min(w, h) / 2;
|
|
220
227
|
return {
|
|
@@ -227,6 +234,7 @@ function inferArcStyle(
|
|
|
227
234
|
};
|
|
228
235
|
}
|
|
229
236
|
|
|
237
|
+
// arc outer
|
|
230
238
|
return {
|
|
231
239
|
...common,
|
|
232
240
|
labelAlign: 'parallel',
|
|
@@ -243,67 +251,111 @@ function inferGrid(value: boolean, coordinate: Coordinate, scale: Scale) {
|
|
|
243
251
|
return value === undefined ? !!scale.getTicks : value;
|
|
244
252
|
}
|
|
245
253
|
|
|
246
|
-
function
|
|
247
|
-
position:
|
|
254
|
+
function inferAxisLinearOverrideStyle(
|
|
255
|
+
position: GCP,
|
|
256
|
+
orientation: GCO,
|
|
248
257
|
bbox: BBox,
|
|
249
258
|
coordinate: Coordinate,
|
|
250
259
|
): {
|
|
251
|
-
startPos
|
|
252
|
-
endPos
|
|
260
|
+
startPos?: [number, number];
|
|
261
|
+
endPos?: [number, number];
|
|
253
262
|
showLine?: boolean;
|
|
254
263
|
[k: string]: any;
|
|
255
264
|
} {
|
|
256
|
-
const [, cy] = coordinate.getCenter();
|
|
257
265
|
const { x, y, width, height } = bbox;
|
|
258
266
|
|
|
259
267
|
if (position === 'bottom') {
|
|
260
|
-
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
268
|
+
return { startPos: [x, y], endPos: [x + width, y] };
|
|
269
|
+
}
|
|
270
|
+
if (position === 'left') {
|
|
271
|
+
return { startPos: [x + width, y], endPos: [x + width, y + height] };
|
|
272
|
+
}
|
|
273
|
+
if (position === 'right') {
|
|
274
|
+
return { endPos: [x, y + height], startPos: [x, y] };
|
|
275
|
+
}
|
|
276
|
+
if (position === 'top') {
|
|
277
|
+
return { startPos: [x, y + height], endPos: [x + width, y + height] };
|
|
278
|
+
}
|
|
279
|
+
// linear axis, maybe in parallel, polar, radial or radar systems.
|
|
280
|
+
if (position === 'center') {
|
|
281
|
+
// axisY
|
|
282
|
+
if (orientation === 'vertical') {
|
|
283
|
+
return {
|
|
284
|
+
startPos: [x + width, y],
|
|
285
|
+
endPos: [x + width, y + height],
|
|
286
|
+
showLine: true,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
// axisX
|
|
290
|
+
else if (orientation === 'horizontal') {
|
|
291
|
+
return {
|
|
292
|
+
startPos: [x, y + height],
|
|
293
|
+
endPos: [x + width, y + height],
|
|
294
|
+
showLine: true,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// axis with rotate
|
|
298
|
+
else if (typeof orientation === 'number') {
|
|
299
|
+
const [cx, cy] = coordinate.getCenter();
|
|
300
|
+
const [innerRadius, outerRadius] = radiusOf(coordinate);
|
|
301
|
+
const [startAngle, endAngle] = angleOf(coordinate);
|
|
302
|
+
const r = height / 2;
|
|
303
|
+
|
|
304
|
+
const innerR = innerRadius * r;
|
|
305
|
+
const outerR = outerRadius * r;
|
|
306
|
+
|
|
307
|
+
const [actualCx, actualCy] = [cx + x, cy + y];
|
|
308
|
+
const [cos, sin] = [Math.cos(orientation), Math.sin(orientation)];
|
|
309
|
+
|
|
310
|
+
const startPos: [number, number] = [
|
|
311
|
+
actualCx + outerR * cos,
|
|
312
|
+
actualCy + outerR * sin,
|
|
313
|
+
];
|
|
314
|
+
const endPos: [number, number] = [
|
|
315
|
+
actualCx + innerR * cos,
|
|
316
|
+
actualCy + innerR * sin,
|
|
317
|
+
];
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
startPos,
|
|
321
|
+
endPos,
|
|
322
|
+
gridClosed: endAngle - startAngle === 360,
|
|
323
|
+
gridCenter: [cx + x, y + cy],
|
|
324
|
+
gridControlAngles: new Array(3)
|
|
325
|
+
.fill(0)
|
|
326
|
+
.map(
|
|
327
|
+
(d, i, arr) =>
|
|
328
|
+
90 +
|
|
329
|
+
startAngle +
|
|
330
|
+
((endAngle - startAngle) / (arr.length - 1)) * i,
|
|
331
|
+
),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
281
334
|
}
|
|
282
335
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
showLine: position === 'centerHorizontal' ? true : undefined,
|
|
287
|
-
};
|
|
336
|
+
// position is inner or outer for arc axis won't be here
|
|
337
|
+
|
|
338
|
+
return {};
|
|
288
339
|
}
|
|
289
340
|
|
|
290
|
-
const
|
|
341
|
+
const ArcAxisComponent: GCC<AxisOptions> = (options) => {
|
|
291
342
|
const {
|
|
292
343
|
order,
|
|
293
344
|
size,
|
|
294
345
|
position,
|
|
346
|
+
orientation,
|
|
295
347
|
labelFormatter = (d) => `${d}`,
|
|
296
348
|
tickFilter,
|
|
297
349
|
tickCount,
|
|
298
350
|
tickMethod,
|
|
299
351
|
title,
|
|
300
352
|
grid: showGrid = false,
|
|
353
|
+
important = {},
|
|
301
354
|
...rest
|
|
302
355
|
} = options;
|
|
303
|
-
return (scale, value, coordinate, theme) => {
|
|
304
|
-
const {
|
|
305
|
-
const {
|
|
306
|
-
const center: [number, number] = [x + width / 2, y + height / 2];
|
|
356
|
+
return ([scale], value, coordinate, theme) => {
|
|
357
|
+
const { bbox } = value;
|
|
358
|
+
const { domain } = scale.getOptions();
|
|
307
359
|
const ticks = getTicks(
|
|
308
360
|
scale,
|
|
309
361
|
domain,
|
|
@@ -315,39 +367,62 @@ const ArcAxis = (options) => {
|
|
|
315
367
|
coordinate,
|
|
316
368
|
);
|
|
317
369
|
|
|
318
|
-
const radius = Math.min(width, height) / 2;
|
|
319
|
-
const [startAngle, endAngle] = angleOf(coordinate);
|
|
320
370
|
const [innerRadius, outerRadius] = radiusOf(coordinate);
|
|
321
371
|
|
|
322
372
|
const defaultStyle = inferArcStyle(
|
|
323
373
|
position,
|
|
374
|
+
bbox,
|
|
324
375
|
innerRadius,
|
|
325
376
|
outerRadius,
|
|
326
377
|
coordinate,
|
|
327
378
|
);
|
|
379
|
+
|
|
328
380
|
const { axis: axisTheme } = theme;
|
|
329
381
|
return new AxisComponent({
|
|
330
382
|
style: deepMix({}, axisTheme, defaultStyle, {
|
|
331
383
|
type: 'arc',
|
|
332
|
-
center,
|
|
333
|
-
radius,
|
|
334
|
-
angleRange: [startAngle, endAngle],
|
|
335
384
|
data: ticks,
|
|
336
385
|
title: titleContent(title),
|
|
337
386
|
showGrid,
|
|
338
387
|
...rest,
|
|
388
|
+
...important,
|
|
339
389
|
}),
|
|
340
390
|
});
|
|
341
391
|
};
|
|
342
392
|
};
|
|
343
393
|
|
|
344
|
-
function
|
|
345
|
-
|
|
394
|
+
function inferThemeStyle(
|
|
395
|
+
scale: Scale,
|
|
396
|
+
coordinate: Coordinate,
|
|
397
|
+
theme: G2Theme,
|
|
398
|
+
direction,
|
|
399
|
+
position: GCP,
|
|
400
|
+
orientation: GCO,
|
|
401
|
+
) {
|
|
402
|
+
const baseStyle = theme.axis;
|
|
403
|
+
let furtherStyle = theme.axisLinear;
|
|
346
404
|
|
|
347
|
-
|
|
348
|
-
{}
|
|
349
|
-
|
|
350
|
-
|
|
405
|
+
if (['top', 'right', 'bottom', 'left'].includes(position)) {
|
|
406
|
+
furtherStyle = theme[`axis${capitalizeFirst(position)}`];
|
|
407
|
+
}
|
|
408
|
+
return Object.assign({}, baseStyle, furtherStyle);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function inferDefaultStyle(
|
|
412
|
+
scale: Scale,
|
|
413
|
+
coordinate: Coordinate,
|
|
414
|
+
theme: G2Theme,
|
|
415
|
+
direction,
|
|
416
|
+
position: GCP,
|
|
417
|
+
orientation: GCO,
|
|
418
|
+
) {
|
|
419
|
+
const themeStyle = inferThemeStyle(
|
|
420
|
+
scale,
|
|
421
|
+
coordinate,
|
|
422
|
+
theme,
|
|
423
|
+
direction,
|
|
424
|
+
position,
|
|
425
|
+
orientation,
|
|
351
426
|
);
|
|
352
427
|
|
|
353
428
|
if (position === 'bottom') {
|
|
@@ -357,48 +432,41 @@ function inferDefaultStyle(scale, theme, position, direction) {
|
|
|
357
432
|
titleTransformOrigin: 'center',
|
|
358
433
|
titleTransform: scale.getTicks ? 'translate(-100%, 0)' : undefined,
|
|
359
434
|
};
|
|
360
|
-
}
|
|
435
|
+
}
|
|
436
|
+
if (position === 'center') {
|
|
361
437
|
return {
|
|
362
438
|
...themeStyle,
|
|
363
439
|
labelDirection: direction === 'right' ? 'negative' : 'positive',
|
|
364
440
|
labelTransform: direction === 'center' ? 'translate(50%, 0)' : '',
|
|
365
441
|
tickDirection: direction === 'right' ? 'negative' : 'positive',
|
|
366
442
|
labelSpacing: direction === 'center' ? 0 : 4,
|
|
443
|
+
titleSpacing: isVertical(orientation) ? 10 : 0,
|
|
367
444
|
tick: direction === 'center' ? false : undefined,
|
|
368
445
|
};
|
|
369
446
|
}
|
|
370
|
-
|
|
371
447
|
return themeStyle;
|
|
372
448
|
}
|
|
373
449
|
|
|
374
|
-
|
|
375
|
-
switch (position) {
|
|
376
|
-
case 'top':
|
|
377
|
-
case 'bottom':
|
|
378
|
-
case 'centerHorizontal':
|
|
379
|
-
return true;
|
|
380
|
-
default:
|
|
381
|
-
return false;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
450
|
+
const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
386
451
|
const {
|
|
387
452
|
order,
|
|
388
453
|
size,
|
|
389
454
|
transform,
|
|
390
455
|
position,
|
|
456
|
+
orientation,
|
|
391
457
|
title,
|
|
392
458
|
labelFormatter = (d) => `${d}`,
|
|
393
459
|
direction = 'left',
|
|
394
460
|
tickCount,
|
|
395
461
|
tickFilter,
|
|
396
462
|
tickMethod,
|
|
463
|
+
important = {},
|
|
397
464
|
...userDefinitions
|
|
398
465
|
} = options;
|
|
399
466
|
|
|
400
|
-
return (scale, value, coordinate, theme) => {
|
|
401
|
-
const {
|
|
467
|
+
return ([scale], value, coordinate, theme) => {
|
|
468
|
+
const { bbox } = value;
|
|
469
|
+
const { domain } = scale.getOptions();
|
|
402
470
|
|
|
403
471
|
const ticks = getTicks(
|
|
404
472
|
scale,
|
|
@@ -411,7 +479,14 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
411
479
|
coordinate,
|
|
412
480
|
);
|
|
413
481
|
|
|
414
|
-
const defaultStyle = inferDefaultStyle(
|
|
482
|
+
const defaultStyle = inferDefaultStyle(
|
|
483
|
+
scale,
|
|
484
|
+
coordinate,
|
|
485
|
+
theme,
|
|
486
|
+
direction,
|
|
487
|
+
position,
|
|
488
|
+
orientation,
|
|
489
|
+
);
|
|
415
490
|
const {
|
|
416
491
|
labelAutoRotate = true,
|
|
417
492
|
labelAutoHide = false,
|
|
@@ -422,14 +497,14 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
422
497
|
} = Object.assign({}, defaultStyle, userDefinitions);
|
|
423
498
|
|
|
424
499
|
const showGrid = inferGrid(grid, coordinate, scale);
|
|
425
|
-
const gridLength =
|
|
500
|
+
const gridLength = inferGridLength(position, coordinate);
|
|
426
501
|
|
|
427
|
-
const { showLine = line, ...overrideStyle } =
|
|
502
|
+
const { showLine = line, ...overrideStyle } = inferAxisLinearOverrideStyle(
|
|
428
503
|
position,
|
|
504
|
+
orientation,
|
|
429
505
|
bbox,
|
|
430
506
|
coordinate,
|
|
431
507
|
);
|
|
432
|
-
|
|
433
508
|
const axisStyle = {
|
|
434
509
|
...defaultStyle,
|
|
435
510
|
type: 'linear' as const,
|
|
@@ -445,34 +520,40 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
|
|
|
445
520
|
showLine: true,
|
|
446
521
|
...(!showLine ? { lineOpacity: 0 } : null),
|
|
447
522
|
...overrideStyle,
|
|
523
|
+
...important,
|
|
448
524
|
};
|
|
449
525
|
|
|
450
526
|
return new AxisComponent({
|
|
451
527
|
className: 'axis',
|
|
452
|
-
style:
|
|
453
|
-
...axisStyle,
|
|
454
|
-
horizontal: isHorizontal(position),
|
|
455
|
-
},
|
|
528
|
+
style: axisStyle,
|
|
456
529
|
});
|
|
457
530
|
};
|
|
458
531
|
};
|
|
459
532
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return position === 'arc' || position === 'arcInner'
|
|
469
|
-
? ArcAxis(normalizedOptions)(scale, value, coordinate, theme)
|
|
470
|
-
: LinearAxis(normalizedOptions)(scale, value, coordinate, theme);
|
|
533
|
+
const axisFactor: (
|
|
534
|
+
axis: typeof ArcAxisComponent | typeof LinearAxisComponent,
|
|
535
|
+
) => GCC<AxisOptions> = (axis) => {
|
|
536
|
+
return (options) => {
|
|
537
|
+
const { labelFormatter: f = (d) => `${d}` } = options;
|
|
538
|
+
const labelFormatter = typeof f === 'string' ? format(f) : f;
|
|
539
|
+
const normalizedOptions = { ...options, labelFormatter };
|
|
540
|
+
return (...args) => axis(normalizedOptions)(...args);
|
|
471
541
|
};
|
|
472
542
|
};
|
|
473
543
|
|
|
474
|
-
|
|
475
|
-
|
|
544
|
+
export const LinearAxis = axisFactor(LinearAxisComponent);
|
|
545
|
+
|
|
546
|
+
export const ArcAxis = axisFactor(ArcAxisComponent);
|
|
547
|
+
|
|
548
|
+
LinearAxis.props = {
|
|
549
|
+
defaultPosition: 'center',
|
|
550
|
+
defaultSize: 45,
|
|
551
|
+
defaultOrder: 0,
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
ArcAxis.props = {
|
|
555
|
+
defaultPosition: 'outer',
|
|
556
|
+
defaultOrientation: 'vertical',
|
|
476
557
|
defaultSize: 45,
|
|
477
558
|
defaultOrder: 0,
|
|
478
559
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
+
import { ArcAxis, AxisOptions } from './axis';
|
|
3
|
+
|
|
4
|
+
export type AxisYOptions = AxisOptions;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ArcAxis component bind to x scale.
|
|
8
|
+
*/
|
|
9
|
+
export const AxisArc: GCC<AxisYOptions> = (options) => {
|
|
10
|
+
return ArcAxis(options);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
AxisArc.props = {
|
|
14
|
+
...ArcAxis.props,
|
|
15
|
+
defaultPosition: 'left',
|
|
16
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { G2Theme, GuideComponentComponent as GCC } from '../runtime';
|
|
3
|
+
import { angleOf } from '../utils/coordinate';
|
|
4
|
+
import { AxisOptions, LinearAxis } from './axis';
|
|
5
|
+
|
|
6
|
+
export type AxisRadarOptions = AxisOptions & {
|
|
7
|
+
radar: {
|
|
8
|
+
count: number;
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function inferTitleTransform(orientation: number) {
|
|
14
|
+
const internalOrientation = orientation % (Math.PI * 2);
|
|
15
|
+
|
|
16
|
+
if (internalOrientation === Math.PI / 2) {
|
|
17
|
+
return { titleTransform: 'translate(0, 50%)' };
|
|
18
|
+
}
|
|
19
|
+
if (internalOrientation > -Math.PI / 2 && internalOrientation < Math.PI / 2) {
|
|
20
|
+
return { titleTransform: 'translate(50%, 0)' };
|
|
21
|
+
}
|
|
22
|
+
if (
|
|
23
|
+
internalOrientation > Math.PI / 2 &&
|
|
24
|
+
internalOrientation < (Math.PI * 3) / 2
|
|
25
|
+
) {
|
|
26
|
+
return { titleTransform: 'translate(-50%, 0)' };
|
|
27
|
+
}
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function inferAxisStyle(
|
|
32
|
+
options: AxisRadarOptions,
|
|
33
|
+
theme: G2Theme,
|
|
34
|
+
coordinate: Coordinate,
|
|
35
|
+
value: Record<string, any>,
|
|
36
|
+
) {
|
|
37
|
+
const { radar } = options;
|
|
38
|
+
const {
|
|
39
|
+
scales: [{ name }],
|
|
40
|
+
} = value;
|
|
41
|
+
const [startAngle, endAngle] = angleOf(coordinate);
|
|
42
|
+
const { axisRadar: radarTheme = {} } = theme;
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...radarTheme,
|
|
46
|
+
showGrid: name === 'position',
|
|
47
|
+
gridConnect: 'line',
|
|
48
|
+
gridControlAngles: new Array(radar.count).fill(0).map((_, i) => {
|
|
49
|
+
const angle = (endAngle - startAngle) / radar.count;
|
|
50
|
+
// the zero angle of grid is 90 degree
|
|
51
|
+
return startAngle + angle * i + 90;
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const AxisRadar: GCC<AxisRadarOptions> = (options) => {
|
|
57
|
+
const { important = {}, ...restOptions } = options;
|
|
58
|
+
return (scales, value, coordinate, theme) => {
|
|
59
|
+
return LinearAxis({
|
|
60
|
+
...restOptions,
|
|
61
|
+
...inferTitleTransform(options.orientation),
|
|
62
|
+
important: {
|
|
63
|
+
...inferAxisStyle(options, theme, coordinate, value),
|
|
64
|
+
...important,
|
|
65
|
+
},
|
|
66
|
+
})(scales, value, coordinate, theme);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
AxisRadar.props = {
|
|
71
|
+
...LinearAxis.props,
|
|
72
|
+
defaultPosition: 'center',
|
|
73
|
+
};
|
package/src/component/axisX.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { Axis } from '@antv/gui';
|
|
1
2
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
-
import {
|
|
3
|
+
import { LinearAxis, AxisOptions } from './axis';
|
|
3
4
|
|
|
4
5
|
export type AxisXOptions = AxisOptions;
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* LinearAxis component bind to x scale.
|
|
8
9
|
*/
|
|
9
10
|
export const AxisX: GCC<AxisXOptions> = (options) => {
|
|
10
|
-
return
|
|
11
|
+
return LinearAxis(options);
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
AxisX.props = {
|
|
14
|
-
...
|
|
15
|
+
...LinearAxis.props,
|
|
15
16
|
defaultPosition: 'bottom',
|
|
16
17
|
};
|
|
18
|
+
|
|
19
|
+
export function axisXConfig() {}
|
package/src/component/axisY.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { AxisOptions, LinearAxis } from './axis';
|
|
3
3
|
|
|
4
4
|
export type AxisYOptions = AxisOptions;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* LinearAxis component bind to y scale.
|
|
8
8
|
*/
|
|
9
9
|
export const AxisY: GCC<AxisYOptions> = (options) => {
|
|
10
|
-
return
|
|
10
|
+
return LinearAxis(options);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
AxisY.props = {
|
|
14
|
-
...
|
|
14
|
+
...LinearAxis.props,
|
|
15
15
|
defaultPosition: 'left',
|
|
16
16
|
};
|
package/src/component/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export { LinearAxis as AxisLinear, ArcAxis as AxisArc } from './axis';
|
|
1
2
|
export { AxisX } from './axisX';
|
|
2
3
|
export { AxisY } from './axisY';
|
|
4
|
+
export { AxisRadar } from './axisRadar';
|
|
3
5
|
export { LegendCategory } from './legendCategory';
|
|
4
6
|
export { LegendContinuous } from './legendContinuous';
|
|
7
|
+
export { LegendContinuousBlock } from './legendContinuousBlock';
|
|
8
|
+
export { LegendContinuousBlockSize } from './legendContinuousBlockSize';
|
|
9
|
+
export { LegendContinuousSize } from './legendContinuousSize';
|
|
5
10
|
export { TitleComponent } from './title';
|
|
6
11
|
export { SliderX } from './sliderX';
|
|
7
12
|
export { SliderY } from './sliderY';
|
|
@@ -12,6 +17,9 @@ export type { AxisXOptions } from './axisX';
|
|
|
12
17
|
export type { AxisYOptions } from './axisY';
|
|
13
18
|
export type { LegendCategoryOptions } from './legendCategory';
|
|
14
19
|
export type { LegendContinuousOptions } from './legendContinuous';
|
|
20
|
+
export type { LegendContinuousBlockOptions } from './legendContinuousBlock';
|
|
21
|
+
export type { LegendContinuousBlockSizeOptions } from './legendContinuousBlockSize';
|
|
22
|
+
export type { LegendContinuousSizeOptions } from './legendContinuousSize';
|
|
15
23
|
export type { TitleComponentOptions } from './title';
|
|
16
24
|
export type { SliderXOptions } from './sliderX';
|
|
17
25
|
export type { SliderYOptions } from './sliderY';
|