@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/layout.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import {
|
|
2
|
+
import { ascending, group } from 'd3-array';
|
|
3
|
+
import { isParallel, isPolar, isRadar, radiusOf } from '../utils/coordinate';
|
|
3
4
|
import { capitalizeFirst } from '../utils/helper';
|
|
5
|
+
import { divide } from '../utils/array';
|
|
4
6
|
import {
|
|
5
|
-
GuideComponentPosition,
|
|
6
|
-
|
|
7
|
+
GuideComponentPosition as GCP,
|
|
8
|
+
GuideComponentOrientation as GCO,
|
|
7
9
|
Layout,
|
|
10
|
+
Section,
|
|
8
11
|
SectionArea,
|
|
9
12
|
} from './types/common';
|
|
10
|
-
import {
|
|
13
|
+
import { G2GuideComponentOptions, G2View } from './types/options';
|
|
11
14
|
|
|
12
15
|
export function computeLayout(
|
|
13
16
|
components: G2GuideComponentOptions[],
|
|
@@ -31,6 +34,7 @@ export function computeLayout(
|
|
|
31
34
|
marginTop = margin,
|
|
32
35
|
marginRight = margin,
|
|
33
36
|
} = options;
|
|
37
|
+
|
|
34
38
|
return {
|
|
35
39
|
...padding,
|
|
36
40
|
width,
|
|
@@ -57,11 +61,15 @@ function computePadding(
|
|
|
57
61
|
components: G2GuideComponentOptions[],
|
|
58
62
|
options: G2View,
|
|
59
63
|
) {
|
|
60
|
-
const positions:
|
|
64
|
+
const positions: GCP[] = [
|
|
61
65
|
'left',
|
|
62
66
|
'right',
|
|
63
67
|
'top',
|
|
64
68
|
'bottom',
|
|
69
|
+
'top-left',
|
|
70
|
+
'top-right',
|
|
71
|
+
'bottom-left',
|
|
72
|
+
'bottom-right',
|
|
65
73
|
];
|
|
66
74
|
const positionComponents = group(components, (d) => d.position);
|
|
67
75
|
const {
|
|
@@ -119,40 +127,179 @@ export function placeComponents(
|
|
|
119
127
|
const pb = paddingBottom + marginBottom;
|
|
120
128
|
|
|
121
129
|
const section: Section = {
|
|
122
|
-
top: [pl, 0, innerWidth, pt,
|
|
123
|
-
right: [width - pr, pt, pr, innerHeight,
|
|
124
|
-
bottom: [pl, height - pb, innerWidth, pb,
|
|
125
|
-
left: [0, pt, pl, innerHeight,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
top: [pl, 0, innerWidth, pt, 'vertical', true, ascending],
|
|
131
|
+
right: [width - pr, pt, pr, innerHeight, 'horizontal', false, ascending],
|
|
132
|
+
bottom: [pl, height - pb, innerWidth, pb, 'vertical', false, ascending],
|
|
133
|
+
left: [0, pt, pl, innerHeight, 'horizontal', true, ascending],
|
|
134
|
+
'top-left': [pl, 0, innerWidth, pt, 'vertical', true, ascending],
|
|
135
|
+
'top-right': [pl, 0, innerWidth, pt, 'vertical', true, ascending],
|
|
136
|
+
'bottom-left': [
|
|
137
|
+
pl,
|
|
138
|
+
height - pb,
|
|
139
|
+
innerWidth,
|
|
140
|
+
pb,
|
|
141
|
+
'vertical',
|
|
142
|
+
false,
|
|
143
|
+
ascending,
|
|
144
|
+
],
|
|
145
|
+
'bottom-right': [
|
|
146
|
+
pl,
|
|
147
|
+
height - pb,
|
|
148
|
+
innerWidth,
|
|
149
|
+
pb,
|
|
150
|
+
'vertical',
|
|
151
|
+
false,
|
|
152
|
+
ascending,
|
|
153
|
+
],
|
|
154
|
+
center: [pl, pt, innerWidth, innerHeight, 'center', null, null],
|
|
155
|
+
inner: [pl, pt, innerWidth, innerHeight, 'center', null, null],
|
|
156
|
+
outer: [pl, pt, innerWidth, innerHeight, 'center', null, null],
|
|
133
157
|
};
|
|
158
|
+
for (const [position, components] of positionComponents.entries()) {
|
|
159
|
+
const area = section[position];
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @description non-entity components: axis in the center, inner, outer, component in the center
|
|
163
|
+
* @description entity components: other components
|
|
164
|
+
* @description no volumn components take up no extra space
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
const [nonEntityComponents, entityComponents] = divide(
|
|
168
|
+
components,
|
|
169
|
+
(component) => {
|
|
170
|
+
if (typeof component.type !== 'string') return false;
|
|
171
|
+
if (position === 'center') return true;
|
|
172
|
+
if (
|
|
173
|
+
component.type.startsWith('axis') &&
|
|
174
|
+
['inner', 'outer'].includes(position)
|
|
175
|
+
) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
180
|
+
);
|
|
134
181
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} else if (key === 'centerHorizontal') {
|
|
140
|
-
placeCenterHorizontal(components, coordinate, area);
|
|
141
|
-
} else if (key === 'arc') {
|
|
142
|
-
placeArc(components, coordinate, area);
|
|
143
|
-
} else if (key === 'arcY') {
|
|
144
|
-
placeArcY(components, coordinate, area);
|
|
145
|
-
} else if (key === 'arcInner') {
|
|
146
|
-
placeArcInner(components, coordinate, area);
|
|
147
|
-
} else if (key === 'arcCenter') {
|
|
148
|
-
placeArcCenter(components, coordinate, area);
|
|
149
|
-
} else {
|
|
182
|
+
if (nonEntityComponents.length) {
|
|
183
|
+
placeNonEntityComponents(nonEntityComponents, coordinate, area, position);
|
|
184
|
+
}
|
|
185
|
+
if (entityComponents.length) {
|
|
150
186
|
placePaddingArea(components, coordinate, area);
|
|
151
187
|
}
|
|
152
188
|
}
|
|
153
189
|
}
|
|
154
190
|
|
|
155
|
-
function
|
|
191
|
+
function placeNonEntityComponents(
|
|
192
|
+
components: G2GuideComponentOptions[],
|
|
193
|
+
coordinate: Coordinate,
|
|
194
|
+
area: SectionArea,
|
|
195
|
+
position: GCP,
|
|
196
|
+
) {
|
|
197
|
+
const [axisComponents, nonAxisComponents] = divide(
|
|
198
|
+
components,
|
|
199
|
+
(component) => {
|
|
200
|
+
if (
|
|
201
|
+
typeof component.type === 'string' &&
|
|
202
|
+
component.type.startsWith('axis')
|
|
203
|
+
) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
},
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
placeNonEntityAxis(axisComponents, coordinate, area, position);
|
|
211
|
+
// in current stage, only legend component which located in the center can be placed
|
|
212
|
+
placeCenter(nonAxisComponents, coordinate, area);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function placeNonEntityAxis(
|
|
216
|
+
components: G2GuideComponentOptions[],
|
|
217
|
+
coordinate: Coordinate,
|
|
218
|
+
area: SectionArea,
|
|
219
|
+
position: GCP,
|
|
220
|
+
) {
|
|
221
|
+
if (position === 'center') {
|
|
222
|
+
if (isRadar(coordinate)) {
|
|
223
|
+
placeAxisRadar(components, coordinate, area, position);
|
|
224
|
+
} else if (isPolar(coordinate)) {
|
|
225
|
+
placeArcLinear(components, coordinate, area);
|
|
226
|
+
} else if (isParallel(coordinate)) {
|
|
227
|
+
placeAxisParallel(
|
|
228
|
+
components,
|
|
229
|
+
coordinate,
|
|
230
|
+
area,
|
|
231
|
+
components[0].orientation, // assume that all components have the same orientation
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
} else if (position === 'inner') {
|
|
235
|
+
placeAxisArcInner(components, coordinate, area);
|
|
236
|
+
} else if (position === 'outer') {
|
|
237
|
+
placeAxisArcOuter(components, coordinate, area);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function placeAxisArcInner(
|
|
242
|
+
components: G2GuideComponentOptions[],
|
|
243
|
+
coordinate: Coordinate,
|
|
244
|
+
area: SectionArea,
|
|
245
|
+
) {
|
|
246
|
+
const [x, y, , height] = area;
|
|
247
|
+
const [cx, cy] = coordinate.getCenter();
|
|
248
|
+
const [innerRadius] = radiusOf(coordinate);
|
|
249
|
+
const r = height / 2;
|
|
250
|
+
const size = innerRadius * r;
|
|
251
|
+
const x0 = cx - size;
|
|
252
|
+
const y0 = cy - size;
|
|
253
|
+
for (let i = 0; i < components.length; i++) {
|
|
254
|
+
const component = components[i];
|
|
255
|
+
component.bbox = {
|
|
256
|
+
x: x + x0,
|
|
257
|
+
y: y + y0,
|
|
258
|
+
width: size * 2,
|
|
259
|
+
height: size * 2,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function placeAxisArcOuter(
|
|
265
|
+
components: G2GuideComponentOptions[],
|
|
266
|
+
coordinate: Coordinate,
|
|
267
|
+
area: SectionArea,
|
|
268
|
+
) {
|
|
269
|
+
const [x, y, width, height] = area;
|
|
270
|
+
for (const component of components) {
|
|
271
|
+
component.bbox = { x, y, width, height };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @example arcX, arcY, axisLinear with angle
|
|
277
|
+
*/
|
|
278
|
+
function placeArcLinear(
|
|
279
|
+
components: G2GuideComponentOptions[],
|
|
280
|
+
coordinate: Coordinate,
|
|
281
|
+
area: SectionArea,
|
|
282
|
+
) {
|
|
283
|
+
const [x, y, width, height] = area;
|
|
284
|
+
for (const component of components) {
|
|
285
|
+
component.bbox = { x: x, y, width, height };
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function placeAxisParallel(
|
|
290
|
+
components: G2GuideComponentOptions[],
|
|
291
|
+
coordinate: Coordinate,
|
|
292
|
+
area: SectionArea,
|
|
293
|
+
orientation: GCO,
|
|
294
|
+
) {
|
|
295
|
+
if (orientation === 'horizontal') {
|
|
296
|
+
placeAxisParallelHorizontal(components, coordinate, area);
|
|
297
|
+
} else if (orientation === 'vertical') {
|
|
298
|
+
placeAxisParallelVertical(components, coordinate, area);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function placeAxisParallelVertical(
|
|
156
303
|
components: G2GuideComponentOptions[],
|
|
157
304
|
coordinate: Coordinate,
|
|
158
305
|
area: SectionArea,
|
|
@@ -177,7 +324,7 @@ function placeCenterVertical(
|
|
|
177
324
|
}
|
|
178
325
|
}
|
|
179
326
|
|
|
180
|
-
function
|
|
327
|
+
function placeAxisParallelHorizontal(
|
|
181
328
|
components: G2GuideComponentOptions[],
|
|
182
329
|
coordinate: Coordinate,
|
|
183
330
|
area: SectionArea,
|
|
@@ -200,13 +347,31 @@ function placeCenterHorizontal(
|
|
|
200
347
|
const height = Y[i + 1] - y;
|
|
201
348
|
component.bbox = { x, y, width, height };
|
|
202
349
|
}
|
|
350
|
+
|
|
351
|
+
// override style
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function placeAxisRadar(
|
|
355
|
+
components: G2GuideComponentOptions[],
|
|
356
|
+
coordinate: Coordinate,
|
|
357
|
+
area: SectionArea,
|
|
358
|
+
position: GCP,
|
|
359
|
+
) {
|
|
360
|
+
const [x, y, width, height] = area;
|
|
361
|
+
for (const component of components) {
|
|
362
|
+
component.bbox = { x, y, width, height };
|
|
363
|
+
component.radar = {
|
|
364
|
+
index: components.indexOf(component),
|
|
365
|
+
count: components.length,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
203
368
|
}
|
|
204
369
|
|
|
205
370
|
function placePaddingArea(
|
|
206
371
|
components: G2GuideComponentOptions[],
|
|
207
372
|
coordinate: Coordinate,
|
|
208
373
|
area: SectionArea,
|
|
209
|
-
)
|
|
374
|
+
) {
|
|
210
375
|
const [x, y, width, height, direction, reverse, comparator] = area;
|
|
211
376
|
const [
|
|
212
377
|
mainStartKey,
|
|
@@ -218,13 +383,13 @@ function placePaddingArea(
|
|
|
218
383
|
crossSizeKey,
|
|
219
384
|
crossSizeValue,
|
|
220
385
|
] =
|
|
221
|
-
direction ===
|
|
386
|
+
direction === 'vertical'
|
|
222
387
|
? ['y', y, 'x', x, 'height', height, 'width', width]
|
|
223
388
|
: ['x', x, 'y', y, 'width', width, 'height', height];
|
|
224
389
|
|
|
225
390
|
// Sort components by order.
|
|
226
391
|
// The smaller the order, the closer to center.
|
|
227
|
-
components.sort((a, b) => comparator(a.order, b.order));
|
|
392
|
+
components.sort((a, b) => comparator?.(a.order, b.order));
|
|
228
393
|
|
|
229
394
|
const startValue = reverse ? mainStartValue + mainSizeValue : mainStartValue;
|
|
230
395
|
for (let i = 0, start = startValue; i < components.length; i++) {
|
|
@@ -240,40 +405,15 @@ function placePaddingArea(
|
|
|
240
405
|
}
|
|
241
406
|
}
|
|
242
407
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
) {
|
|
248
|
-
const [x, y, width, height] = area;
|
|
249
|
-
for (let i = 0; i < components.length; i++) {
|
|
250
|
-
const component = components[i];
|
|
251
|
-
component.bbox = { x, y, width, height };
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function placeArcY(
|
|
256
|
-
components: G2GuideComponentOptions[],
|
|
257
|
-
coordinate: Coordinate,
|
|
258
|
-
area: SectionArea,
|
|
259
|
-
) {
|
|
260
|
-
const [x, y, , height] = area;
|
|
261
|
-
const [cx, cy] = coordinate.getCenter();
|
|
262
|
-
const [innerRadius, outerRadius] = radiusOf(coordinate);
|
|
263
|
-
const r = height / 2;
|
|
264
|
-
const y0 = cy - outerRadius * r;
|
|
265
|
-
const h = (outerRadius - innerRadius) * r;
|
|
266
|
-
for (let i = 0; i < components.length; i++) {
|
|
267
|
-
const component = components[i];
|
|
268
|
-
component.bbox = { x: cx + x, y: y0 + y, width: 0, height: h };
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function placeArcCenter(
|
|
408
|
+
/**
|
|
409
|
+
* @example legend in the center of radial or polar system
|
|
410
|
+
*/
|
|
411
|
+
function placeCenter(
|
|
273
412
|
components: G2GuideComponentOptions[],
|
|
274
413
|
coordinate: Coordinate,
|
|
275
414
|
area: SectionArea,
|
|
276
415
|
) {
|
|
416
|
+
if (components.length === 0) return;
|
|
277
417
|
const [x, y, width, height] = area;
|
|
278
418
|
const [innerRadius] = radiusOf(coordinate);
|
|
279
419
|
const r = ((height / 2) * innerRadius) / Math.sqrt(2);
|
|
@@ -284,34 +424,3 @@ function placeArcCenter(
|
|
|
284
424
|
component.bbox = { x: cx - r, y: cy - r, width: r * 2, height: r * 2 };
|
|
285
425
|
}
|
|
286
426
|
}
|
|
287
|
-
|
|
288
|
-
function placeArcInner(
|
|
289
|
-
components: G2GuideComponentOptions[],
|
|
290
|
-
coordinate: Coordinate,
|
|
291
|
-
area: SectionArea,
|
|
292
|
-
) {
|
|
293
|
-
const [x, y, , height] = area;
|
|
294
|
-
const [cx, cy] = coordinate.getCenter();
|
|
295
|
-
const [innerRadius] = radiusOf(coordinate);
|
|
296
|
-
const r = height / 2;
|
|
297
|
-
const size = innerRadius * r;
|
|
298
|
-
const x0 = cx - size;
|
|
299
|
-
const y0 = cy - size;
|
|
300
|
-
for (let i = 0; i < components.length; i++) {
|
|
301
|
-
const component = components[i];
|
|
302
|
-
component.bbox = {
|
|
303
|
-
x: x + x0,
|
|
304
|
-
y: y + y0,
|
|
305
|
-
width: size * 2,
|
|
306
|
-
height: size * 2,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function radiusOf(coordinate: Coordinate): [number, number] {
|
|
312
|
-
const { transformations } = coordinate.getOptions();
|
|
313
|
-
const [, , , innerRadius, outerRadius] = transformations.find(
|
|
314
|
-
(d) => d[0] === 'polar',
|
|
315
|
-
);
|
|
316
|
-
return [innerRadius as number, outerRadius as number];
|
|
317
|
-
}
|
package/src/runtime/plot.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { deepMix, upperFirst } from '@antv/util';
|
|
|
4
4
|
import { group } from 'd3-array';
|
|
5
5
|
import { format } from 'd3-format';
|
|
6
6
|
import { mapObject } from '../utils/array';
|
|
7
|
-
import { CHART_LIFE_CIRCLE
|
|
7
|
+
import { CHART_LIFE_CIRCLE } from '../utils/event';
|
|
8
8
|
import {
|
|
9
9
|
appendTransform,
|
|
10
10
|
compose,
|
|
@@ -165,8 +165,7 @@ export async function plot<T extends G2ViewTree>(
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_PAINT);
|
|
168
|
+
context.emitter.emit(CHART_LIFE_CIRCLE.BEFORE_PAINT);
|
|
170
169
|
|
|
171
170
|
// Plot chart.
|
|
172
171
|
const enterContainer = new Map<G2ViewDescriptor, DisplayObject>();
|
|
@@ -266,9 +265,10 @@ export async function plot<T extends G2ViewTree>(
|
|
|
266
265
|
keyframes.push(keyframe);
|
|
267
266
|
}
|
|
268
267
|
|
|
268
|
+
context.views = views;
|
|
269
269
|
context.animations = transitions;
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
context.emitter.emit(CHART_LIFE_CIRCLE.AFTER_PAINT);
|
|
272
272
|
|
|
273
273
|
// Note!!!
|
|
274
274
|
// The returned promise will never resolved if one of nodeGenerator
|
|
@@ -632,6 +632,7 @@ async function plotView(
|
|
|
632
632
|
enter
|
|
633
633
|
// Make this layer interactive, such as click and mousemove events.
|
|
634
634
|
.append('rect')
|
|
635
|
+
// todo zIndex
|
|
635
636
|
.style('fill', 'transparent')
|
|
636
637
|
.attr('className', PLOT_CLASS_NAME)
|
|
637
638
|
.call(updateBBox)
|
package/src/runtime/render.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { Canvas as GCanvas, DisplayObject, Group } from '@antv/g';
|
|
|
2
2
|
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
3
|
import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
4
4
|
import { deepMix } from '@antv/util';
|
|
5
|
+
import EventEmitter from '@antv/event-emitter';
|
|
5
6
|
import { createLibrary } from '../stdlib';
|
|
6
7
|
import { select } from '../utils/selection';
|
|
7
|
-
import {
|
|
8
|
+
import { CHART_LIFE_CIRCLE } from '../utils/event';
|
|
8
9
|
import { G2Context, G2ViewTree } from './types/options';
|
|
9
10
|
import { plot } from './plot';
|
|
10
11
|
|
|
@@ -65,12 +66,17 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
65
66
|
// Initialize the context if it is not provided.
|
|
66
67
|
const { width = 640, height = 480, on } = options;
|
|
67
68
|
const keyed = inferKeys(options);
|
|
68
|
-
const {
|
|
69
|
+
const {
|
|
70
|
+
canvas = Canvas(width, height),
|
|
71
|
+
library = createLibrary(),
|
|
72
|
+
emitter = new EventEmitter(),
|
|
73
|
+
} = context;
|
|
69
74
|
context.canvas = canvas;
|
|
70
75
|
context.library = library;
|
|
76
|
+
context.emitter = emitter;
|
|
71
77
|
canvas.resize(width, height);
|
|
72
78
|
|
|
73
|
-
|
|
79
|
+
emitter.emit(CHART_LIFE_CIRCLE.BEFORE_RENDER);
|
|
74
80
|
|
|
75
81
|
// Plot the chart and mutate context.
|
|
76
82
|
// Make sure that plot chart after container is ready for every time.
|
|
@@ -79,8 +85,10 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
79
85
|
.then(() =>
|
|
80
86
|
plot<T>({ ...keyed, width, height }, selection, library, context),
|
|
81
87
|
)
|
|
82
|
-
.then(
|
|
83
|
-
|
|
88
|
+
.then(() => {
|
|
89
|
+
emitter.emit(CHART_LIFE_CIRCLE.AFTER_RENDER);
|
|
90
|
+
callback?.();
|
|
91
|
+
});
|
|
84
92
|
|
|
85
93
|
// Return the container HTML element wraps the canvas or svg element.
|
|
86
94
|
return normalizeContainer(canvas.getConfig().container);
|
|
@@ -94,7 +102,11 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
|
|
|
94
102
|
// Initialize the context if it is not provided.
|
|
95
103
|
const { width = 640, height = 480, on } = options;
|
|
96
104
|
const keyed = inferKeys(options);
|
|
97
|
-
const {
|
|
105
|
+
const {
|
|
106
|
+
library = createLibrary(),
|
|
107
|
+
group = new Group(),
|
|
108
|
+
emitter = new EventEmitter(),
|
|
109
|
+
} = context;
|
|
98
110
|
|
|
99
111
|
if (!group?.parentElement) {
|
|
100
112
|
throw new Error(
|
|
@@ -105,13 +117,15 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
|
|
|
105
117
|
const selection = select(group);
|
|
106
118
|
context.group = group;
|
|
107
119
|
context.library = library;
|
|
120
|
+
context.emitter = emitter;
|
|
108
121
|
|
|
109
|
-
|
|
122
|
+
emitter.emit(CHART_LIFE_CIRCLE.BEFORE_RENDER);
|
|
110
123
|
// Plot the chart and mutate context.
|
|
111
124
|
// Make sure that plot chart after container is ready for every time.
|
|
112
|
-
plot<T>({ ...keyed, width, height }, selection, library, context)
|
|
113
|
-
.
|
|
114
|
-
|
|
125
|
+
plot<T>({ ...keyed, width, height }, selection, library, context).then(() => {
|
|
126
|
+
emitter.emit(CHART_LIFE_CIRCLE.AFTER_RENDER);
|
|
127
|
+
callback?.();
|
|
128
|
+
});
|
|
115
129
|
|
|
116
130
|
// Return the Group wraps the canvas or svg element.
|
|
117
131
|
return group;
|
|
@@ -121,12 +135,11 @@ export function destroy<T extends G2ViewTree = G2ViewTree>(
|
|
|
121
135
|
options: T,
|
|
122
136
|
context: G2Context = {},
|
|
123
137
|
) {
|
|
124
|
-
const {
|
|
125
|
-
const { canvas } = context;
|
|
138
|
+
const { canvas, emitter } = context;
|
|
126
139
|
if (canvas) {
|
|
127
140
|
canvas.destroy();
|
|
128
141
|
}
|
|
129
|
-
|
|
142
|
+
emitter.off();
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
function normalizeContainer(container: HTMLElement | string): HTMLElement {
|
package/src/runtime/scale.ts
CHANGED
|
@@ -234,6 +234,7 @@ function inferScaleRange(
|
|
|
234
234
|
case 'linear':
|
|
235
235
|
case 'time':
|
|
236
236
|
case 'log':
|
|
237
|
+
case 'pow':
|
|
237
238
|
case 'sqrt': {
|
|
238
239
|
const colors = categoricalColors(values, options, domain, theme, library);
|
|
239
240
|
const [r0, r1] = inferRangeQ(name, colors);
|
|
@@ -498,3 +499,43 @@ export function isPosition(name: string): boolean {
|
|
|
498
499
|
name === 'exitDuration'
|
|
499
500
|
);
|
|
500
501
|
}
|
|
502
|
+
|
|
503
|
+
export function isValidScale(scale: G2ScaleOptions) {
|
|
504
|
+
if (!scale || !scale.type) return false;
|
|
505
|
+
if (typeof scale.type === 'function') return true;
|
|
506
|
+
const { type, domain, range, interpolator } = scale;
|
|
507
|
+
const isValidDomain = domain && domain.length > 0;
|
|
508
|
+
const isValidRange = range && range.length > 0;
|
|
509
|
+
|
|
510
|
+
if (
|
|
511
|
+
[
|
|
512
|
+
'linear',
|
|
513
|
+
'sqrt',
|
|
514
|
+
'log',
|
|
515
|
+
'time',
|
|
516
|
+
'pow',
|
|
517
|
+
'threshold',
|
|
518
|
+
'quantize',
|
|
519
|
+
'quantile',
|
|
520
|
+
'ordinal',
|
|
521
|
+
'band',
|
|
522
|
+
'point',
|
|
523
|
+
].includes(type) &&
|
|
524
|
+
isValidDomain &&
|
|
525
|
+
isValidRange
|
|
526
|
+
) {
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (
|
|
531
|
+
['sequential'].includes(type) &&
|
|
532
|
+
isValidDomain &&
|
|
533
|
+
(isValidRange || interpolator)
|
|
534
|
+
) {
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (['constant', 'identity'].includes(type) && isValidRange) return true;
|
|
539
|
+
|
|
540
|
+
return false;
|
|
541
|
+
}
|
package/src/runtime/transform.ts
CHANGED
|
@@ -174,6 +174,9 @@ export function addGuideToScale(
|
|
|
174
174
|
),
|
|
175
175
|
color: { guide: normalize(legend, 'color') },
|
|
176
176
|
size: { guide: normalize(legend, 'size') },
|
|
177
|
+
shape: { guide: normalize(legend, 'shape') },
|
|
178
|
+
// fixme: opacity is conflict with DisplayObject.opacity
|
|
179
|
+
// opacity: { guide: normalize(legend, 'opacity') },
|
|
177
180
|
},
|
|
178
181
|
});
|
|
179
182
|
return [I, mark];
|
|
@@ -127,18 +127,24 @@ export type BBox = {
|
|
|
127
127
|
height?: number;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
export type
|
|
130
|
+
export type GuidePrimitivePosition =
|
|
131
131
|
| 'top'
|
|
132
|
-
| 'left'
|
|
133
132
|
| 'bottom'
|
|
133
|
+
| 'left'
|
|
134
134
|
| 'right'
|
|
135
|
-
| 'centerVertical'
|
|
136
|
-
| 'centerHorizontal'
|
|
137
135
|
| 'center'
|
|
138
|
-
| '
|
|
139
|
-
| '
|
|
140
|
-
|
|
141
|
-
| '
|
|
136
|
+
| 'inner'
|
|
137
|
+
| 'outer';
|
|
138
|
+
export type GuideCompositePosition =
|
|
139
|
+
| 'top-left'
|
|
140
|
+
| 'top-right'
|
|
141
|
+
| 'bottom-left'
|
|
142
|
+
| 'bottom-right';
|
|
143
|
+
export type GuideComponentPosition =
|
|
144
|
+
| GuidePrimitivePosition
|
|
145
|
+
| GuideCompositePosition;
|
|
146
|
+
|
|
147
|
+
export type GuideComponentOrientation = 'horizontal' | 'vertical' | number;
|
|
142
148
|
|
|
143
149
|
export type Layout = {
|
|
144
150
|
paddingLeft?: number;
|
|
@@ -162,13 +168,20 @@ export type Layout = {
|
|
|
162
168
|
y?: number;
|
|
163
169
|
};
|
|
164
170
|
|
|
165
|
-
|
|
171
|
+
export type Direction = 'horizontal' | 'vertical' | 'center';
|
|
172
|
+
|
|
173
|
+
export type FlexLayout = {
|
|
174
|
+
flexDirection?: 'row' | 'column';
|
|
175
|
+
justifyContent?: 'flex-start' | 'flex-end' | 'center';
|
|
176
|
+
alignItems?: 'flex-start' | 'flex-end' | 'center';
|
|
177
|
+
};
|
|
178
|
+
|
|
166
179
|
export type SectionArea = [
|
|
167
180
|
x: number,
|
|
168
181
|
y: number,
|
|
169
182
|
width: number,
|
|
170
183
|
height: number,
|
|
171
|
-
direction:
|
|
184
|
+
direction: Direction,
|
|
172
185
|
reverse: boolean,
|
|
173
186
|
comparator: (a: Primitive, b: Primitive) => number,
|
|
174
187
|
];
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import { Coordinate, Transformation } from '@antv/coord';
|
|
1
2
|
import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
|
|
2
|
-
import { Transformation, Coordinate } from '@antv/coord';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
G2View,
|
|
5
|
+
G2GuideComponentOptions,
|
|
6
|
+
G2CoordinateOptions,
|
|
7
|
+
G2ScaleOptions,
|
|
8
|
+
G2ViewTree,
|
|
9
|
+
} from './options';
|
|
10
|
+
import {
|
|
5
11
|
G2Theme,
|
|
6
|
-
|
|
12
|
+
G2ViewInstance,
|
|
7
13
|
GuideComponentPosition,
|
|
14
|
+
GuideComponentOrientation,
|
|
15
|
+
IndexedValue,
|
|
8
16
|
Layout,
|
|
9
|
-
|
|
17
|
+
Vector2,
|
|
10
18
|
} from './common';
|
|
11
|
-
import { G2ViewTree } from './options';
|
|
12
|
-
import { EncodeComponent, Encode } from './encode';
|
|
13
|
-
import { MarkComponent, Mark } from './mark';
|
|
14
|
-
import { TransformComponent, Transform } from './transform';
|
|
15
19
|
import { DataComponent } from './data';
|
|
20
|
+
import { Encode, EncodeComponent } from './encode';
|
|
21
|
+
import { Mark, MarkComponent } from './mark';
|
|
22
|
+
import { Transform, TransformComponent } from './transform';
|
|
16
23
|
|
|
17
24
|
export type G2ComponentNamespaces =
|
|
18
25
|
| 'coordinate'
|
|
@@ -156,15 +163,17 @@ export type ThemeComponent<O = Record<string, unknown>> = G2BaseComponent<
|
|
|
156
163
|
>;
|
|
157
164
|
|
|
158
165
|
export type GuideComponent = (
|
|
159
|
-
|
|
166
|
+
scales: Scale[],
|
|
160
167
|
style: Record<string, any>,
|
|
161
168
|
coordinate: Coordinate,
|
|
162
169
|
theme: G2Theme,
|
|
163
170
|
) => DisplayObject;
|
|
164
171
|
export type GuideComponentProps = {
|
|
165
|
-
defaultPosition
|
|
172
|
+
defaultPosition?: GuideComponentPosition;
|
|
173
|
+
defaultOrientation?: GuideComponentOrientation;
|
|
166
174
|
defaultSize: number;
|
|
167
175
|
defaultOrder: number;
|
|
176
|
+
[key: string]: any;
|
|
168
177
|
};
|
|
169
178
|
export type GuideComponentComponent<O = Record<string, unknown>> =
|
|
170
179
|
G2BaseComponent<GuideComponent, O, GuideComponentProps>;
|