@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/runtime/component.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://github.com/antvis/G2/discussions/4557
|
|
3
|
+
*/
|
|
1
4
|
import { Coordinate } from '@antv/coord';
|
|
5
|
+
import { group } from 'd3-array';
|
|
6
|
+
import { isEqual } from '@antv/util';
|
|
7
|
+
import { defined } from '../utils/helper';
|
|
8
|
+
import {
|
|
9
|
+
getPolarOptions,
|
|
10
|
+
getRadialOptions,
|
|
11
|
+
type PolarOptions,
|
|
12
|
+
type RadialOptions,
|
|
13
|
+
} from '../coordinate';
|
|
14
|
+
import { combine } from '../utils/array';
|
|
2
15
|
import {
|
|
16
|
+
coordOf,
|
|
3
17
|
isHelix,
|
|
4
18
|
isParallel,
|
|
5
19
|
isPolar,
|
|
20
|
+
isRadar,
|
|
6
21
|
isRadial,
|
|
7
22
|
isReflect,
|
|
8
23
|
isReflectY,
|
|
@@ -10,9 +25,16 @@ import {
|
|
|
10
25
|
isTranspose,
|
|
11
26
|
} from './coordinate';
|
|
12
27
|
import { useLibrary } from './library';
|
|
13
|
-
import { useRelationScale } from './scale';
|
|
14
|
-
import {
|
|
15
|
-
|
|
28
|
+
import { isValidScale, useRelationScale } from './scale';
|
|
29
|
+
import {
|
|
30
|
+
G2Theme,
|
|
31
|
+
GuideComponentOrientation as GCO,
|
|
32
|
+
GuideComponentPosition as GCP,
|
|
33
|
+
} from './types/common';
|
|
34
|
+
import {
|
|
35
|
+
GuideComponent,
|
|
36
|
+
GuideComponentComponent as GCC,
|
|
37
|
+
} from './types/component';
|
|
16
38
|
import {
|
|
17
39
|
G2CoordinateOptions,
|
|
18
40
|
G2GuideComponentOptions,
|
|
@@ -20,6 +42,11 @@ import {
|
|
|
20
42
|
G2ScaleOptions,
|
|
21
43
|
G2View,
|
|
22
44
|
} from './types/options';
|
|
45
|
+
import {
|
|
46
|
+
ContinuousScale,
|
|
47
|
+
DiscreteScale,
|
|
48
|
+
DistributionScale,
|
|
49
|
+
} from './types/scale';
|
|
23
50
|
|
|
24
51
|
export function inferComponent(
|
|
25
52
|
scales: G2ScaleOptions[],
|
|
@@ -34,7 +61,7 @@ export function inferComponent(
|
|
|
34
61
|
} = partialOptions;
|
|
35
62
|
const [, createGuideComponent] = useLibrary<
|
|
36
63
|
G2GuideComponentOptions,
|
|
37
|
-
|
|
64
|
+
GCC,
|
|
38
65
|
GuideComponent
|
|
39
66
|
>('component', library);
|
|
40
67
|
|
|
@@ -42,52 +69,62 @@ export function inferComponent(
|
|
|
42
69
|
if (guide === null) return false;
|
|
43
70
|
return true;
|
|
44
71
|
});
|
|
45
|
-
const sliders =
|
|
72
|
+
const sliders = inferScrollableComponents(partialOptions, scales, library);
|
|
46
73
|
const components = [...partialComponents, ...sliders];
|
|
47
74
|
if (title) {
|
|
48
75
|
const { props } = createGuideComponent('title');
|
|
49
|
-
const { defaultPosition, defaultOrder, defaultSize } =
|
|
76
|
+
const { defaultPosition, defaultOrientation, defaultOrder, defaultSize } =
|
|
77
|
+
props;
|
|
50
78
|
const titleOptions = typeof title === 'string' ? { title } : title;
|
|
51
79
|
components.push({
|
|
52
80
|
type: 'title',
|
|
53
81
|
position: defaultPosition,
|
|
82
|
+
orientation: defaultOrientation,
|
|
54
83
|
order: defaultOrder,
|
|
55
84
|
size: defaultSize,
|
|
56
85
|
...titleOptions,
|
|
57
86
|
});
|
|
58
87
|
}
|
|
59
88
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
const inferedComponents = inferComponentsType(displayedScales, coordinates);
|
|
90
|
+
|
|
91
|
+
inferedComponents.forEach(([type, relativeScales]) => {
|
|
92
|
+
const { props } = createGuideComponent(type);
|
|
93
|
+
const { defaultPosition, defaultOrientation, defaultSize, defaultOrder } =
|
|
94
|
+
props;
|
|
95
|
+
// @todo to be comfirm if the scale can be merged.
|
|
96
|
+
const scale: G2ScaleOptions = Object.assign({}, ...relativeScales);
|
|
97
|
+
const { guide: guideOptions, field } = scale;
|
|
98
|
+
// A scale may have multiple guides.
|
|
99
|
+
const guides = Array.isArray(guideOptions) ? guideOptions : [guideOptions];
|
|
100
|
+
for (const partialGuide of guides) {
|
|
101
|
+
const [position, orientation] = inferComponentPositionAndOrientation(
|
|
102
|
+
type,
|
|
103
|
+
defaultPosition,
|
|
104
|
+
defaultOrientation,
|
|
105
|
+
partialGuide,
|
|
106
|
+
relativeScales,
|
|
107
|
+
displayedScales,
|
|
108
|
+
coordinates,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// Skip if position and orientation are not specified.
|
|
112
|
+
// @example the last axis of radar chart
|
|
113
|
+
if (!position && !orientation) continue;
|
|
114
|
+
|
|
115
|
+
const { size = defaultSize, order = defaultOrder } = partialGuide;
|
|
116
|
+
components.push({
|
|
117
|
+
title: field,
|
|
118
|
+
...partialGuide,
|
|
119
|
+
position,
|
|
120
|
+
orientation,
|
|
121
|
+
order,
|
|
122
|
+
size,
|
|
123
|
+
type,
|
|
124
|
+
scales: relativeScales,
|
|
125
|
+
});
|
|
89
126
|
}
|
|
90
|
-
}
|
|
127
|
+
});
|
|
91
128
|
|
|
92
129
|
return components;
|
|
93
130
|
}
|
|
@@ -100,130 +137,305 @@ export function renderComponent(
|
|
|
100
137
|
) {
|
|
101
138
|
const [useGuideComponent] = useLibrary<
|
|
102
139
|
G2GuideComponentOptions,
|
|
103
|
-
|
|
140
|
+
GCC,
|
|
104
141
|
GuideComponent
|
|
105
142
|
>('component', library);
|
|
106
|
-
const {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const { field, domain } = scaleDescriptor || {};
|
|
112
|
-
const value = { field, domain, bbox };
|
|
143
|
+
const { scales: scaleDescriptors = [], bbox, ...options } = component;
|
|
144
|
+
const scales = scaleDescriptors.map((descriptor) =>
|
|
145
|
+
useRelationScale(descriptor, library),
|
|
146
|
+
);
|
|
147
|
+
const value = { bbox, scales: scaleDescriptors, library };
|
|
113
148
|
const render = useGuideComponent(options);
|
|
114
|
-
return render(
|
|
149
|
+
return render(scales, value, coordinates, theme);
|
|
115
150
|
}
|
|
116
151
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function inferComponentType(
|
|
120
|
-
scale: G2ScaleOptions,
|
|
152
|
+
function inferLegendComponentType(
|
|
153
|
+
scales: G2ScaleOptions[],
|
|
121
154
|
coordinates: G2CoordinateOptions[],
|
|
122
155
|
) {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
156
|
+
const scalesByField = group(scales, (d) => d.field || d.name);
|
|
157
|
+
|
|
158
|
+
const createStrategy = <T>(arr: T[], main: T): T[][] => {
|
|
159
|
+
const result = combine(arr);
|
|
160
|
+
result.forEach((c) => c.unshift(main));
|
|
161
|
+
result.push([main]);
|
|
162
|
+
return result.sort((a, b) => b.length - a.length);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// [legend type, [[channels, scale types]]][]
|
|
166
|
+
const strategy: [string, [string, string][][]][] = [
|
|
167
|
+
[
|
|
168
|
+
'legendCategory',
|
|
169
|
+
createStrategy(
|
|
170
|
+
[
|
|
171
|
+
// @todo now haven't provide constant scale of color channel,
|
|
172
|
+
// so won't display the single shape scale.
|
|
173
|
+
['shape', 'discrete'],
|
|
174
|
+
['size', 'discrete'],
|
|
175
|
+
['opacity', 'discrete'],
|
|
176
|
+
],
|
|
177
|
+
['color', 'discrete'],
|
|
178
|
+
),
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
'legendContinuousSize',
|
|
182
|
+
[
|
|
183
|
+
[
|
|
184
|
+
['color', 'continuous'],
|
|
185
|
+
['opacity', 'continuous'],
|
|
186
|
+
['size', 'continuous'],
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
['color', 'continuous'],
|
|
190
|
+
['size', 'continuous'],
|
|
191
|
+
],
|
|
192
|
+
],
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
'legendContinuousBlockSize',
|
|
196
|
+
[
|
|
197
|
+
[
|
|
198
|
+
['color', 'distribution'],
|
|
199
|
+
['opacity', 'distribution'],
|
|
200
|
+
['size', 'distribution'],
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
['color', 'distribution'],
|
|
204
|
+
['size', 'distribution'],
|
|
205
|
+
],
|
|
206
|
+
],
|
|
207
|
+
],
|
|
208
|
+
[
|
|
209
|
+
'legendContinuousBlock',
|
|
210
|
+
createStrategy([['opacity', 'continuous']], ['color', 'distribution']),
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
'legendContinuous',
|
|
214
|
+
createStrategy([['opacity', 'continuous']], ['color', 'continuous']),
|
|
215
|
+
],
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
function getScaleType(scale: G2ScaleOptions): string {
|
|
219
|
+
const { type } = scale;
|
|
220
|
+
if (typeof type !== 'string') return null;
|
|
221
|
+
if (type in ContinuousScale) return 'continuous';
|
|
222
|
+
if (type in DiscreteScale) return 'discrete';
|
|
223
|
+
if (type in DistributionScale) return 'distribution';
|
|
141
224
|
return null;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const components = Array.from(scalesByField)
|
|
228
|
+
.map(([, scs]) => {
|
|
229
|
+
const combinations = combine(scs).sort((a, b) => b.length - a.length);
|
|
230
|
+
const options = combinations.map((combination) => ({
|
|
231
|
+
combination,
|
|
232
|
+
option: combination.map((scale) => [scale.name, getScaleType(scale)]),
|
|
233
|
+
}));
|
|
234
|
+
|
|
235
|
+
const sort = (arr: string[][]) =>
|
|
236
|
+
arr.sort((a, b) => a[0].localeCompare(b[0]));
|
|
237
|
+
for (const [componentType, accords] of strategy) {
|
|
238
|
+
for (const { option, combination } of options) {
|
|
239
|
+
if (accords.some((accord) => isEqual(sort(accord), sort(option)))) {
|
|
240
|
+
return [componentType, combination] as [string, G2ScaleOptions[]];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
})
|
|
246
|
+
.filter(defined);
|
|
247
|
+
return components;
|
|
146
248
|
}
|
|
147
249
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
250
|
+
function inferAxisComponentType(
|
|
251
|
+
scales: G2ScaleOptions[],
|
|
252
|
+
coordinates: G2CoordinateOptions[],
|
|
253
|
+
) {
|
|
254
|
+
return scales
|
|
255
|
+
.map((scale) => {
|
|
256
|
+
const { name } = scale;
|
|
257
|
+
// todo wait for gui provide helix axis
|
|
258
|
+
if (isHelix(coordinates) || isTheta(coordinates)) return null;
|
|
259
|
+
if (
|
|
260
|
+
isTranspose(coordinates) &&
|
|
261
|
+
(isPolar(coordinates) || isRadial(coordinates))
|
|
262
|
+
)
|
|
263
|
+
return null;
|
|
264
|
+
// infer axis
|
|
265
|
+
if (name.startsWith('x')) {
|
|
266
|
+
if (isPolar(coordinates)) return ['axisArc', [scale]];
|
|
267
|
+
if (isRadial(coordinates)) return ['axisLinear', [scale]];
|
|
268
|
+
return [isTranspose(coordinates) ? 'axisY' : 'axisX', [scale]];
|
|
269
|
+
}
|
|
270
|
+
if (name.startsWith('y')) {
|
|
271
|
+
if (isPolar(coordinates)) return ['axisLinear', [scale]];
|
|
272
|
+
if (isRadial(coordinates)) return ['axisArc', [scale]];
|
|
273
|
+
return [isTranspose(coordinates) ? 'axisX' : 'axisY', [scale]];
|
|
274
|
+
}
|
|
275
|
+
if (name.startsWith('position')) {
|
|
276
|
+
if (isRadar(coordinates)) return ['axisRadar', [scale]];
|
|
277
|
+
if (!isPolar(coordinates)) return ['axisY', [scale]];
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
})
|
|
281
|
+
.filter(defined) as [string | GCC, G2ScaleOptions[]][];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function inferComponentsType(
|
|
285
|
+
scales: G2ScaleOptions[],
|
|
154
286
|
coordinates: G2CoordinateOptions[],
|
|
155
|
-
):
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'centerVertical',
|
|
162
|
-
'center',
|
|
287
|
+
): [string | GCC, G2ScaleOptions[]][] {
|
|
288
|
+
const avaliableScales = scales.filter((scale) => isValidScale(scale));
|
|
289
|
+
|
|
290
|
+
return [
|
|
291
|
+
...inferLegendComponentType(avaliableScales, coordinates),
|
|
292
|
+
...inferAxisComponentType(avaliableScales, coordinates),
|
|
163
293
|
];
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function angleOf(coordinates: G2CoordinateOptions[]) {
|
|
297
|
+
const polar = coordOf(coordinates, 'polar');
|
|
298
|
+
if (polar.length) {
|
|
299
|
+
const lastPolar = polar[polar.length - 1] as PolarOptions;
|
|
300
|
+
const { startAngle, endAngle } = getPolarOptions(lastPolar);
|
|
301
|
+
return [startAngle, endAngle];
|
|
302
|
+
}
|
|
303
|
+
const radial = coordOf(coordinates, 'radial') as RadialOptions[];
|
|
304
|
+
if (radial.length) {
|
|
305
|
+
const lastRadial = radial[radial.length - 1];
|
|
306
|
+
const { startAngle, endAngle } = getRadialOptions(lastRadial);
|
|
307
|
+
return [startAngle, endAngle];
|
|
308
|
+
}
|
|
309
|
+
return [-Math.PI / 2, (Math.PI / 2) * 3];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* match index of position
|
|
314
|
+
*/
|
|
315
|
+
function matchPosition(name: string) {
|
|
316
|
+
const match = /position(\d*)/g.exec(name);
|
|
317
|
+
if (!match) return null;
|
|
318
|
+
return +match[1];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function inferAxisPositionAndOrientation(
|
|
322
|
+
type: string,
|
|
323
|
+
ordinalPosition: [GCP, GCO],
|
|
324
|
+
relativeScales: G2ScaleOptions[],
|
|
325
|
+
scales: G2ScaleOptions[],
|
|
326
|
+
coordinates: G2CoordinateOptions[],
|
|
327
|
+
): [GCP, GCO] {
|
|
328
|
+
// a axis only has one scale
|
|
329
|
+
const { name } = relativeScales[0];
|
|
330
|
+
// todo, in current resolution, the radar chart is implement by parallel + polar coordinate.
|
|
331
|
+
// implementation plan to be confirmed.
|
|
332
|
+
// in current implementation, it must to add the first position encode to it's last.
|
|
333
|
+
// so we won't render the last axis repeatly.
|
|
334
|
+
if (type === 'axisRadar') {
|
|
335
|
+
const positions = scales.filter((scale) =>
|
|
336
|
+
scale.name.startsWith('position'),
|
|
337
|
+
);
|
|
338
|
+
const index = matchPosition(name);
|
|
339
|
+
if (name === positions.slice(-1)[0].name || index === null)
|
|
340
|
+
return [null, null];
|
|
341
|
+
// infer radar axis orientation
|
|
342
|
+
const [startAngle, endAngle] = angleOf(coordinates);
|
|
343
|
+
const angle =
|
|
344
|
+
((endAngle - startAngle) / (positions.length - 1)) * index + startAngle;
|
|
345
|
+
return ['center', angle];
|
|
346
|
+
}
|
|
167
347
|
|
|
168
348
|
// There are multiple axes for parallel coordinate.
|
|
169
349
|
// Place the first one in the border area and put others in the center.
|
|
170
350
|
if (type === 'axisY' && isParallel(coordinates)) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
351
|
+
// name looks like `position${number}`
|
|
352
|
+
const index = matchPosition(name);
|
|
353
|
+
if (index === null) return ordinalPosition;
|
|
354
|
+
|
|
174
355
|
if (isTranspose(coordinates)) {
|
|
175
|
-
return index === 0 ? 'top' : '
|
|
176
|
-
} else {
|
|
177
|
-
return index === 0 ? ordinalPosition : 'centerVertical';
|
|
356
|
+
return index === 0 ? ['top', null] : ['center', 'horizontal'];
|
|
178
357
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return '
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
358
|
+
return index === 0 ? ordinalPosition : ['center', 'vertical'];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// in non-cartesian coordinate systems, infer the arc axis angle
|
|
362
|
+
if (type === 'axisLinear') {
|
|
363
|
+
const [startAngle] = angleOf(coordinates);
|
|
364
|
+
return ['center', startAngle];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (type === 'axisArc') {
|
|
368
|
+
if (ordinalPosition[0] === 'inner') return ['inner', null];
|
|
369
|
+
return ['outer', null];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (isPolar(coordinates)) return ['center', null];
|
|
373
|
+
if (isRadial(coordinates)) return ['center', null];
|
|
374
|
+
if (
|
|
193
375
|
(type === 'axisX' && isReflect(coordinates)) ||
|
|
194
376
|
(type === 'axisX' && isReflectY(coordinates))
|
|
195
377
|
) {
|
|
196
|
-
return 'top';
|
|
197
|
-
}
|
|
378
|
+
return ['top', null];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// if (type === 'axisX') return ['bottom', null];
|
|
382
|
+
return ordinalPosition;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// @todo Infer position by coordinates.
|
|
386
|
+
function inferComponentPositionAndOrientation(
|
|
387
|
+
type: string | GCC,
|
|
388
|
+
defaultPosition: GCP,
|
|
389
|
+
defaultOrientation: GCO,
|
|
390
|
+
guide: G2GuideComponentOptions,
|
|
391
|
+
relativeScales: G2ScaleOptions[],
|
|
392
|
+
scales: G2ScaleOptions[],
|
|
393
|
+
coordinates: G2CoordinateOptions[],
|
|
394
|
+
): [GCP, GCO] {
|
|
395
|
+
const [startAngle] = angleOf(coordinates);
|
|
396
|
+
const ordinalPositionAndOrientation: [GCP, GCO] = [
|
|
397
|
+
guide.position || defaultPosition,
|
|
398
|
+
startAngle ?? defaultOrientation,
|
|
399
|
+
];
|
|
400
|
+
|
|
401
|
+
if (typeof type === 'string' && type.startsWith('axis')) {
|
|
402
|
+
return inferAxisPositionAndOrientation(
|
|
403
|
+
type,
|
|
404
|
+
ordinalPositionAndOrientation,
|
|
405
|
+
relativeScales,
|
|
406
|
+
scales,
|
|
407
|
+
coordinates,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (
|
|
198
412
|
typeof type === 'string' &&
|
|
199
413
|
type.startsWith('legend') &&
|
|
200
414
|
isPolar(coordinates)
|
|
201
415
|
) {
|
|
202
|
-
if (guide.position === 'center') return '
|
|
416
|
+
if (guide.position === 'center') return ['center', 'vertical'];
|
|
203
417
|
}
|
|
204
|
-
|
|
418
|
+
// for general component, use default position
|
|
419
|
+
return ordinalPositionAndOrientation;
|
|
205
420
|
}
|
|
206
421
|
|
|
207
|
-
|
|
208
|
-
* Infer scroll component type.
|
|
209
|
-
*/
|
|
210
|
-
function inferSCType(name: string, type: string, coordinates = []) {
|
|
422
|
+
function inferSrollableType(name: string, type: string, coordinates = []) {
|
|
211
423
|
if (name === 'x') return isTranspose(coordinates) ? `${type}Y` : `${type}X`;
|
|
212
424
|
if (name === 'y') return isTranspose(coordinates) ? `${type}X` : `${type}Y`;
|
|
213
425
|
return null;
|
|
214
426
|
}
|
|
215
427
|
|
|
216
428
|
/**
|
|
217
|
-
* Infer
|
|
429
|
+
* Infer scrollable components, such as slider and scrollbar.
|
|
218
430
|
*/
|
|
219
|
-
function
|
|
431
|
+
function inferScrollableComponents(
|
|
220
432
|
partialOptions: G2View,
|
|
221
433
|
scales: G2ScaleOptions[],
|
|
222
|
-
library,
|
|
223
|
-
) {
|
|
434
|
+
library: G2Library,
|
|
435
|
+
): G2GuideComponentOptions[] {
|
|
224
436
|
const [, createGuideComponent] = useLibrary<
|
|
225
437
|
G2GuideComponentOptions,
|
|
226
|
-
|
|
438
|
+
GCC,
|
|
227
439
|
GuideComponent
|
|
228
440
|
>('component', library);
|
|
229
441
|
|
|
@@ -235,7 +447,7 @@ function inferScrollComponents(
|
|
|
235
447
|
scale: G2ScaleOptions,
|
|
236
448
|
options: Record<string, any>,
|
|
237
449
|
) {
|
|
238
|
-
const componentType =
|
|
450
|
+
const componentType = inferSrollableType(channelName, type, coordinates);
|
|
239
451
|
if (!options || !componentType) return;
|
|
240
452
|
|
|
241
453
|
const { props } = createGuideComponent(componentType);
|
|
@@ -246,10 +458,9 @@ function inferScrollComponents(
|
|
|
246
458
|
order: defaultOrder,
|
|
247
459
|
type: componentType,
|
|
248
460
|
...options,
|
|
249
|
-
scale,
|
|
461
|
+
scales: [scale],
|
|
250
462
|
};
|
|
251
463
|
}
|
|
252
|
-
|
|
253
464
|
return scales
|
|
254
465
|
.filter((d) => d.slider || d.scrollbar)
|
|
255
466
|
.flatMap((scale) => {
|
|
@@ -39,44 +39,57 @@ export function createCoordinate(
|
|
|
39
39
|
return coordinate;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export function coordOf(
|
|
43
|
+
coordinates: G2CoordinateOptions[],
|
|
44
|
+
type: string,
|
|
45
|
+
): G2CoordinateOptions[] {
|
|
46
|
+
return coordinates.filter((d) => d.type === type);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* todo Duplication is not considered
|
|
51
|
+
*/
|
|
52
|
+
|
|
42
53
|
export function isPolar(coordinates: G2CoordinateOptions[]) {
|
|
43
|
-
|
|
44
|
-
return polar !== undefined;
|
|
54
|
+
return coordOf(coordinates, 'polar').length > 0;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
export function isHelix(coordinates: G2CoordinateOptions[]) {
|
|
48
|
-
|
|
49
|
-
return polar !== undefined;
|
|
58
|
+
return coordOf(coordinates, 'helix').length > 0;
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
/**
|
|
62
|
+
* todo The number of transposes matters
|
|
63
|
+
*/
|
|
52
64
|
export function isTranspose(coordinates: G2CoordinateOptions[]) {
|
|
53
|
-
|
|
54
|
-
return transposes.length % 2 === 1;
|
|
65
|
+
return coordOf(coordinates, 'transpose').length % 2 === 1;
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
export function isParallel(coordinates: G2CoordinateOptions[]) {
|
|
58
|
-
|
|
59
|
-
return parallel !== undefined;
|
|
69
|
+
return coordOf(coordinates, 'parallel').length > 0;
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
export function isTheta(coordinates: G2CoordinateOptions[]) {
|
|
63
|
-
|
|
64
|
-
return reflect !== undefined;
|
|
73
|
+
return coordOf(coordinates, 'theta').length > 0;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
export function isReflect(coordinates: G2CoordinateOptions[]) {
|
|
68
|
-
|
|
69
|
-
return reflect !== undefined;
|
|
77
|
+
return coordOf(coordinates, 'reflect').length > 0;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
export function isRadial(coordinates: G2CoordinateOptions[]) {
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
return coordOf(coordinates, 'radial').length > 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function isRadar(coordinates: G2CoordinateOptions[]) {
|
|
85
|
+
return isParallel(coordinates) && isPolar(coordinates);
|
|
75
86
|
}
|
|
76
87
|
|
|
88
|
+
/**
|
|
89
|
+
* todo The axis corresponding to the Y reversal is not reversed
|
|
90
|
+
*/
|
|
77
91
|
export function isReflectY(coordinates: G2CoordinateOptions[]) {
|
|
78
|
-
|
|
79
|
-
return reflect !== undefined;
|
|
92
|
+
return coordOf(coordinates, 'reflectY').length > 0;
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
function inferCoordinate(
|