@antv/g2 5.0.0-beta.6 → 5.0.0-beta.8
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 +3 -3
- package/esm/api/chart.d.ts +8 -4
- package/esm/api/chart.js +33 -17
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +21 -0
- package/esm/api/composition/base.js +59 -0
- package/esm/api/composition/base.js.map +1 -0
- package/esm/api/composition/facetCircle.d.ts +2 -3
- package/esm/api/composition/facetCircle.js +2 -2
- package/esm/api/composition/facetCircle.js.map +1 -1
- package/esm/api/composition/facetRect.d.ts +2 -3
- package/esm/api/composition/facetRect.js +2 -2
- package/esm/api/composition/facetRect.js.map +1 -1
- package/esm/api/composition/geoPath.d.ts +2 -3
- package/esm/api/composition/geoPath.js +2 -2
- package/esm/api/composition/geoPath.js.map +1 -1
- package/esm/api/composition/geoView.d.ts +2 -3
- package/esm/api/composition/geoView.js +2 -2
- package/esm/api/composition/geoView.js.map +1 -1
- package/esm/api/composition/index.d.ts +2 -1
- package/esm/api/composition/index.js +2 -1
- package/esm/api/composition/index.js.map +1 -1
- package/esm/api/composition/repeatMatrix.d.ts +2 -3
- package/esm/api/composition/repeatMatrix.js +2 -2
- package/esm/api/composition/repeatMatrix.js.map +1 -1
- package/esm/api/composition/spaceFlex.d.ts +2 -3
- package/esm/api/composition/spaceFlex.js +2 -2
- package/esm/api/composition/spaceFlex.js.map +1 -1
- package/esm/api/composition/spaceLayer.d.ts +2 -3
- package/esm/api/composition/spaceLayer.js +2 -2
- package/esm/api/composition/spaceLayer.js.map +1 -1
- package/esm/api/composition/timingKeyframe.d.ts +2 -3
- package/esm/api/composition/timingKeyframe.js +2 -2
- package/esm/api/composition/timingKeyframe.js.map +1 -1
- package/esm/api/composition/view.d.ts +3 -3
- package/esm/api/composition/view.js +4 -4
- package/esm/api/composition/view.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 +29 -29
- package/esm/api/mark/mark.js +27 -27
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/node.d.ts +2 -1
- package/esm/api/node.js +8 -9
- package/esm/api/node.js.map +1 -1
- package/esm/api/props.js +0 -20
- package/esm/api/props.js.map +1 -1
- package/esm/component/axis.js +4 -0
- package/esm/component/axis.js.map +1 -1
- package/esm/component/legendContinuous.d.ts +1 -0
- package/esm/component/legendContinuous.js +14 -16
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/slider.js +3 -13
- package/esm/component/slider.js.map +1 -1
- package/esm/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
- package/esm/geo/{d3-projection.js → d3Projection.js} +1 -1
- package/esm/geo/d3Projection.js.map +1 -0
- package/esm/geo/geoView.js +1 -1
- package/esm/geo/geoView.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/brushFilter.d.ts +3 -1
- package/esm/interaction/native/brushFilter.js +7 -32
- package/esm/interaction/native/brushFilter.js.map +1 -1
- package/esm/interaction/native/brushXFilter.js +1 -1
- package/esm/interaction/native/brushXFilter.js.map +1 -1
- package/esm/interaction/native/brushYFilter.js +1 -1
- package/esm/interaction/native/brushYFilter.js.map +1 -1
- package/esm/interaction/native/elementHighlight.d.ts +7 -2
- package/esm/interaction/native/elementHighlight.js +72 -18
- 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 -20
- 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 +4 -0
- package/esm/interaction/native/legendFilter.js +7 -4
- package/esm/interaction/native/legendFilter.js.map +1 -1
- package/esm/interaction/native/legendHighlight.d.ts +4 -0
- package/esm/interaction/native/legendHighlight.js +94 -0
- package/esm/interaction/native/legendHighlight.js.map +1 -0
- package/esm/interaction/native/sliderFilter.d.ts +5 -0
- package/esm/interaction/native/sliderFilter.js +87 -0
- package/esm/interaction/native/sliderFilter.js.map +1 -0
- package/esm/interaction/native/tooltip.js +11 -0
- package/esm/interaction/native/tooltip.js.map +1 -1
- 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.map +1 -1
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/runtime/component.d.ts +1 -1
- package/esm/runtime/component.js +5 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/plot.d.ts +1 -1
- package/esm/runtime/plot.js +68 -29
- 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 +7 -0
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/types/options.d.ts +4 -2
- 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/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/spec/composition.d.ts +0 -3
- package/esm/spec/geometry.d.ts +1 -0
- package/esm/spec/interaction.d.ts +30 -11
- package/esm/spec/transform.d.ts +15 -5
- package/esm/stdlib/index.js +3 -8
- package/esm/stdlib/index.js.map +1 -1
- package/esm/transform/sample.js +42 -26
- package/esm/transform/sample.js.map +1 -1
- package/esm/transform/select.js +1 -13
- package/esm/transform/select.js.map +1 -1
- package/esm/transform/selectX.js +1 -1
- package/esm/transform/selectX.js.map +1 -1
- package/esm/transform/selectY.js +1 -1
- package/esm/transform/selectY.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/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 +3 -0
- package/esm/utils/scale.js +30 -0
- package/esm/utils/scale.js.map +1 -0
- package/esm/utils/vector.d.ts +1 -1
- package/esm/utils/vector.js +1 -1
- package/lib/api/chart.d.ts +8 -4
- package/lib/api/chart.js +34 -15
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +21 -0
- package/lib/api/composition/base.js +62 -0
- package/lib/api/composition/base.js.map +1 -0
- package/lib/api/composition/facetCircle.d.ts +2 -3
- package/lib/api/composition/facetCircle.js +2 -2
- package/lib/api/composition/facetCircle.js.map +1 -1
- package/lib/api/composition/facetRect.d.ts +2 -3
- package/lib/api/composition/facetRect.js +2 -2
- package/lib/api/composition/facetRect.js.map +1 -1
- package/lib/api/composition/geoPath.d.ts +2 -3
- package/lib/api/composition/geoPath.js +2 -2
- package/lib/api/composition/geoPath.js.map +1 -1
- package/lib/api/composition/geoView.d.ts +2 -3
- package/lib/api/composition/geoView.js +2 -2
- package/lib/api/composition/geoView.js.map +1 -1
- package/lib/api/composition/index.d.ts +2 -1
- package/lib/api/composition/index.js +3 -1
- package/lib/api/composition/index.js.map +1 -1
- package/lib/api/composition/repeatMatrix.d.ts +2 -3
- package/lib/api/composition/repeatMatrix.js +2 -2
- package/lib/api/composition/repeatMatrix.js.map +1 -1
- package/lib/api/composition/spaceFlex.d.ts +2 -3
- package/lib/api/composition/spaceFlex.js +2 -2
- package/lib/api/composition/spaceFlex.js.map +1 -1
- package/lib/api/composition/spaceLayer.d.ts +2 -3
- package/lib/api/composition/spaceLayer.js +2 -2
- package/lib/api/composition/spaceLayer.js.map +1 -1
- package/lib/api/composition/timingKeyframe.d.ts +2 -3
- package/lib/api/composition/timingKeyframe.js +2 -2
- package/lib/api/composition/timingKeyframe.js.map +1 -1
- package/lib/api/composition/view.d.ts +3 -3
- package/lib/api/composition/view.js +4 -4
- package/lib/api/composition/view.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 +29 -29
- package/lib/api/mark/mark.js +27 -27
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/node.d.ts +2 -1
- package/lib/api/node.js +8 -9
- package/lib/api/node.js.map +1 -1
- package/lib/api/props.js +0 -20
- package/lib/api/props.js.map +1 -1
- package/lib/component/axis.js +4 -0
- package/lib/component/axis.js.map +1 -1
- package/lib/component/legendContinuous.d.ts +1 -0
- package/lib/component/legendContinuous.js +14 -16
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/slider.js +3 -13
- package/lib/component/slider.js.map +1 -1
- package/lib/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
- package/lib/geo/{d3-projection.js → d3Projection.js} +1 -1
- package/lib/geo/d3Projection.js.map +1 -0
- package/lib/geo/geoView.js +1 -1
- package/lib/geo/geoView.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/brushFilter.d.ts +3 -1
- package/lib/interaction/native/brushFilter.js +10 -35
- package/lib/interaction/native/brushFilter.js.map +1 -1
- package/lib/interaction/native/brushXFilter.js +1 -1
- package/lib/interaction/native/brushXFilter.js.map +1 -1
- package/lib/interaction/native/brushYFilter.js +1 -1
- package/lib/interaction/native/brushYFilter.js.map +1 -1
- package/lib/interaction/native/elementHighlight.d.ts +7 -2
- package/lib/interaction/native/elementHighlight.js +71 -17
- 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 -19
- 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 +4 -0
- package/lib/interaction/native/legendFilter.js +10 -3
- package/lib/interaction/native/legendFilter.js.map +1 -1
- package/lib/interaction/native/legendHighlight.d.ts +4 -0
- package/lib/interaction/native/legendHighlight.js +98 -0
- package/lib/interaction/native/legendHighlight.js.map +1 -0
- package/lib/interaction/native/sliderFilter.d.ts +5 -0
- package/lib/interaction/native/sliderFilter.js +91 -0
- package/lib/interaction/native/sliderFilter.js.map +1 -0
- package/lib/interaction/native/tooltip.js +11 -0
- package/lib/interaction/native/tooltip.js.map +1 -1
- 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.map +1 -1
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/runtime/component.d.ts +1 -1
- package/lib/runtime/component.js +4 -2
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/plot.d.ts +1 -1
- package/lib/runtime/plot.js +65 -26
- 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 +9 -1
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/types/options.d.ts +4 -2
- 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/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/spec/composition.d.ts +0 -3
- package/lib/spec/geometry.d.ts +1 -0
- package/lib/spec/interaction.d.ts +30 -11
- package/lib/spec/transform.d.ts +15 -5
- package/lib/stdlib/index.js +1 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/transform/sample.js +42 -26
- package/lib/transform/sample.js.map +1 -1
- package/lib/transform/select.js +1 -13
- package/lib/transform/select.js.map +1 -1
- package/lib/transform/selectX.js +1 -1
- package/lib/transform/selectX.js.map +1 -1
- package/lib/transform/selectY.js +1 -1
- package/lib/transform/selectY.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/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 +3 -0
- package/lib/utils/scale.js +36 -0
- package/lib/utils/scale.js.map +1 -0
- package/lib/utils/vector.d.ts +1 -1
- package/lib/utils/vector.js +1 -1
- package/package.json +4 -3
- package/src/.DS_Store +0 -0
- package/src/api/chart.ts +39 -18
- package/src/api/composition/base.ts +56 -0
- package/src/api/composition/facetCircle.ts +2 -3
- package/src/api/composition/facetRect.ts +2 -3
- package/src/api/composition/geoPath.ts +2 -3
- package/src/api/composition/geoView.ts +2 -3
- package/src/api/composition/index.ts +2 -0
- package/src/api/composition/repeatMatrix.ts +2 -3
- package/src/api/composition/spaceFlex.ts +2 -3
- package/src/api/composition/spaceLayer.ts +2 -3
- package/src/api/composition/timingKeyframe.ts +2 -3
- package/src/api/composition/view.ts +6 -4
- package/src/api/mark/base.ts +58 -0
- package/src/api/mark/mark.ts +29 -28
- package/src/api/node.ts +9 -11
- package/src/api/props.ts +0 -23
- package/src/component/axis.ts +7 -0
- package/src/component/legendContinuous.ts +15 -5
- package/src/component/slider.ts +3 -12
- package/src/data/.DS_Store +0 -0
- package/src/geo/{d3-projection.ts → d3Projection.ts} +0 -0
- package/src/geo/geoView.ts +1 -1
- package/src/interaction/index.ts +2 -0
- package/src/interaction/native/brushFilter.ts +18 -38
- package/src/interaction/native/brushXFilter.ts +1 -0
- package/src/interaction/native/brushYFilter.ts +1 -0
- package/src/interaction/native/elementHighlight.ts +78 -11
- package/src/interaction/native/elementHighlightByColor.ts +9 -4
- package/src/interaction/native/elementHighlightByX.ts +9 -5
- package/src/interaction/native/elementSelect.ts +58 -14
- package/src/interaction/native/elementSelectByColor.ts +4 -1
- package/src/interaction/native/elementSelectByX.ts +4 -1
- package/src/interaction/native/legendFilter.ts +8 -4
- package/src/interaction/native/legendHighlight.ts +87 -0
- package/src/interaction/native/sliderFilter.ts +112 -0
- package/src/interaction/native/tooltip.ts +11 -0
- package/src/interaction/native/utils.ts +183 -26
- package/src/label-transform/overlapDodgeY.ts +1 -1
- package/src/mark/area.ts +1 -1
- package/src/runtime/component.ts +18 -25
- package/src/runtime/plot.ts +123 -75
- package/src/runtime/render.ts +26 -13
- package/src/runtime/scale.ts +14 -0
- package/src/runtime/types/options.ts +10 -2
- package/src/shape/.DS_Store +0 -0
- 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/index.ts +7 -2
- package/src/shape/interval/color.ts +86 -54
- package/src/spec/composition.ts +0 -1
- package/src/spec/geometry.ts +1 -0
- package/src/spec/interaction.ts +45 -12
- package/src/spec/transform.ts +30 -3
- package/src/stdlib/index.ts +10 -6
- package/src/transform/sample.ts +54 -18
- package/src/transform/select.ts +1 -2
- package/src/transform/selectX.ts +1 -1
- package/src/transform/selectY.ts +1 -1
- package/src/transform/utils/lttb.ts +73 -0
- package/src/utils/event.ts +0 -26
- package/src/utils/scale.ts +31 -0
- package/src/utils/vector.ts +1 -1
- package/esm/geo/d3-projection.js.map +0 -1
- package/esm/shape/area/step.d.ts +0 -3
- package/esm/shape/area/step.js.map +0 -1
- package/lib/geo/d3-projection.js.map +0 -1
- package/lib/shape/area/step.d.ts +0 -3
- package/lib/shape/area/step.js.map +0 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { DisplayObject, Path } from '@antv/g';
|
|
2
2
|
import { path as d3Path } from 'd3-path';
|
|
3
|
+
import { sort } from 'd3-array';
|
|
4
|
+
import { Vector2 } from '@antv/coord';
|
|
3
5
|
import { subObject } from '../../utils/helper';
|
|
4
|
-
import { select } from '../../utils/selection';
|
|
6
|
+
import { G2Element, select } from '../../utils/selection';
|
|
5
7
|
import { mapObject } from '../../utils/array';
|
|
6
8
|
import {
|
|
7
9
|
G2ViewDescriptor,
|
|
8
10
|
ELEMENT_CLASS_NAME,
|
|
9
11
|
PLOT_CLASS_NAME,
|
|
10
12
|
} from '../../runtime';
|
|
13
|
+
import { isOrdinalScale } from '../../utils/scale';
|
|
14
|
+
import { rect } from '../../shape/interval/color';
|
|
15
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
16
|
+
import { reorder } from '../../shape/utils';
|
|
17
|
+
import { angle, angleBetween, sub } from '../../utils/vector';
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* Given root of chart returns elements to be manipulated
|
|
@@ -180,56 +187,206 @@ export function createValueof(elements, datum) {
|
|
|
180
187
|
};
|
|
181
188
|
}
|
|
182
189
|
|
|
183
|
-
export function renderLink(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
export function renderLink({
|
|
191
|
+
link = false,
|
|
192
|
+
valueof = (d, element) => d,
|
|
193
|
+
coordinate,
|
|
194
|
+
...style
|
|
195
|
+
}) {
|
|
187
196
|
const LINK_CLASS_NAME = 'element-link';
|
|
188
|
-
|
|
197
|
+
|
|
198
|
+
if (!link) return [() => {}, () => {}];
|
|
199
|
+
|
|
200
|
+
const pointsOf = (element) => element.__data__.points;
|
|
201
|
+
|
|
202
|
+
const pathPointsOf = (P0, P1) => {
|
|
203
|
+
const [, p1, p2] = P0;
|
|
204
|
+
const [p0, , , p3] = P1;
|
|
205
|
+
const P: Vector2[] = [p1, p0, p3, p2];
|
|
206
|
+
return P;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const append = (elements) => {
|
|
189
210
|
if (elements.length <= 1) return;
|
|
190
|
-
const elementBBoxs = elements.map((d) => [d, d.getBBox()]);
|
|
191
211
|
|
|
192
|
-
// Sort elements
|
|
193
|
-
|
|
194
|
-
const { x: x0
|
|
195
|
-
const { x: x1
|
|
196
|
-
|
|
212
|
+
// Sort elements by normalized x to avoid cross.
|
|
213
|
+
const sortedElements = sort<G2Element>(elements, (e0, e1) => {
|
|
214
|
+
const { x: x0 } = e0.__data__;
|
|
215
|
+
const { x: x1 } = e1.__data__;
|
|
216
|
+
const dx = x0 - x1;
|
|
217
|
+
return dx;
|
|
197
218
|
});
|
|
198
219
|
|
|
199
|
-
for (let i = 1; i <
|
|
220
|
+
for (let i = 1; i < sortedElements.length; i++) {
|
|
200
221
|
const p = d3Path();
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
p.
|
|
205
|
-
p.lineTo(
|
|
206
|
-
p.lineTo(
|
|
222
|
+
const e0 = sortedElements[i - 1];
|
|
223
|
+
const e1 = sortedElements[i];
|
|
224
|
+
const [p0, p1, p2, p3] = pathPointsOf(pointsOf(e0), pointsOf(e1));
|
|
225
|
+
p.moveTo(...p0);
|
|
226
|
+
p.lineTo(...p1);
|
|
227
|
+
p.lineTo(...p2);
|
|
228
|
+
p.lineTo(...p3);
|
|
207
229
|
p.closePath();
|
|
208
230
|
const { fill = e0.getAttribute('fill'), ...rest } = mapObject(
|
|
209
231
|
style,
|
|
210
232
|
(d) => valueof(d, e0),
|
|
211
233
|
);
|
|
212
|
-
const
|
|
213
|
-
className:
|
|
234
|
+
const link = new Path({
|
|
235
|
+
className: LINK_CLASS_NAME,
|
|
214
236
|
style: {
|
|
215
237
|
d: p.toString(),
|
|
216
238
|
fill,
|
|
239
|
+
zIndex: -2,
|
|
217
240
|
...rest,
|
|
218
241
|
},
|
|
219
242
|
});
|
|
220
|
-
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
e0.link?.remove();
|
|
245
|
+
e0.parentNode.appendChild(link);
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
e0.link = link;
|
|
221
248
|
}
|
|
222
249
|
};
|
|
223
250
|
|
|
224
|
-
const remove = (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
for (const link of links) link.remove();
|
|
251
|
+
const remove = (element) => {
|
|
252
|
+
element.link?.remove();
|
|
253
|
+
element.link = null;
|
|
228
254
|
};
|
|
229
255
|
|
|
230
256
|
return [append, remove] as const;
|
|
231
257
|
}
|
|
232
258
|
|
|
259
|
+
// Apply translate to mock slice out.
|
|
260
|
+
export function offsetTransform(element, offset, coordinate) {
|
|
261
|
+
const append = (t) => {
|
|
262
|
+
const { transform } = element.style;
|
|
263
|
+
return transform ? `${transform} ${t}` : t;
|
|
264
|
+
};
|
|
265
|
+
if (isPolar(coordinate)) {
|
|
266
|
+
const { points } = element.__data__;
|
|
267
|
+
const [p0, p1] = isTranspose(coordinate) ? reorder(points) : points;
|
|
268
|
+
const center = coordinate.getCenter();
|
|
269
|
+
const v0 = sub(p0, center);
|
|
270
|
+
const v1 = sub(p1, center);
|
|
271
|
+
const a0 = angle(v0);
|
|
272
|
+
const da = angleBetween(v0, v1);
|
|
273
|
+
const amid = a0 + da / 2;
|
|
274
|
+
const dx = offset * Math.cos(amid);
|
|
275
|
+
const dy = offset * Math.sin(amid);
|
|
276
|
+
return append(`translate(${dx}, ${dy})`);
|
|
277
|
+
}
|
|
278
|
+
if (isTranspose(coordinate)) return append(`translate(${offset}, 0)`);
|
|
279
|
+
return append(`translate(0, ${-offset})`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function renderBackground({
|
|
283
|
+
background,
|
|
284
|
+
scale,
|
|
285
|
+
coordinate,
|
|
286
|
+
valueof,
|
|
287
|
+
padding = 0.001,
|
|
288
|
+
...rest
|
|
289
|
+
}) {
|
|
290
|
+
const BACKGROUND_CLASS_NAME = 'element-background';
|
|
291
|
+
|
|
292
|
+
// Don't have background.
|
|
293
|
+
if (!background) return [() => {}, () => {}];
|
|
294
|
+
|
|
295
|
+
const extentOf = (scale, x) => {
|
|
296
|
+
const ax = scale.invert(x);
|
|
297
|
+
const mid = x + scale.getBandWidth(ax) / 2;
|
|
298
|
+
const half = scale.getStep(ax) / 2;
|
|
299
|
+
const offset = half * padding;
|
|
300
|
+
return [mid - half + offset, mid + half - offset];
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const sizeXOf = (element) => {
|
|
304
|
+
const { x: scaleX } = scale;
|
|
305
|
+
if (!isOrdinalScale(scaleX)) return [0, 1];
|
|
306
|
+
const { __data__: data } = element;
|
|
307
|
+
const { x } = data;
|
|
308
|
+
const [e1, e2] = extentOf(scaleX, x);
|
|
309
|
+
return [e1, e2];
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const sizeYOf = (element) => {
|
|
313
|
+
const { y: scaleY } = scale;
|
|
314
|
+
if (!isOrdinalScale(scaleY)) return [0, 1];
|
|
315
|
+
const { __data__: data } = element;
|
|
316
|
+
const { y } = data;
|
|
317
|
+
const [e1, e2] = extentOf(scaleY, y);
|
|
318
|
+
return [e1, e2];
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const bandShapeOf = (element, style) => {
|
|
322
|
+
const [x1, x2] = sizeXOf(element);
|
|
323
|
+
const [y1, y2] = sizeYOf(element);
|
|
324
|
+
const points = [
|
|
325
|
+
[x1, y1],
|
|
326
|
+
[x2, y1],
|
|
327
|
+
[x2, y2],
|
|
328
|
+
[x1, y2],
|
|
329
|
+
].map((d) => coordinate.map(d));
|
|
330
|
+
const { __data__: data } = element;
|
|
331
|
+
const { y: dy, y1: dy1 } = data;
|
|
332
|
+
return rect(points, { y: dy, y1: dy1 }, coordinate, style);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// Shape without ordinal style.
|
|
336
|
+
// Clone and scale it.
|
|
337
|
+
const cloneShapeOf = (element, style) => {
|
|
338
|
+
const {
|
|
339
|
+
transform = 'scale(1.2, 1.2)',
|
|
340
|
+
transformOrigin = 'center center',
|
|
341
|
+
stroke = '',
|
|
342
|
+
...rest
|
|
343
|
+
} = style;
|
|
344
|
+
const finalStyle = { transform, transformOrigin, stroke, ...rest };
|
|
345
|
+
const shape = element.cloneNode(true);
|
|
346
|
+
for (const [key, value] of Object.entries(finalStyle)) {
|
|
347
|
+
shape.style[key] = value;
|
|
348
|
+
}
|
|
349
|
+
return shape;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const isOrdinalShape = () => {
|
|
353
|
+
const { x, y } = scale;
|
|
354
|
+
return [x, y].some(isOrdinalScale);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const append = (element) => {
|
|
358
|
+
if (element.background) element.background.remove();
|
|
359
|
+
const {
|
|
360
|
+
fill = '#CCD6EC',
|
|
361
|
+
fillOpacity = 0.3,
|
|
362
|
+
zIndex = -2,
|
|
363
|
+
...style
|
|
364
|
+
} = mapObject(rest, (d) => valueof(d, element));
|
|
365
|
+
const finalStyle = {
|
|
366
|
+
...style,
|
|
367
|
+
fill,
|
|
368
|
+
fillOpacity,
|
|
369
|
+
zIndex,
|
|
370
|
+
};
|
|
371
|
+
const shapeOf = isOrdinalShape() ? bandShapeOf : cloneShapeOf;
|
|
372
|
+
const shape = shapeOf(element, finalStyle);
|
|
373
|
+
shape.className = BACKGROUND_CLASS_NAME;
|
|
374
|
+
element.parentNode.appendChild(shape);
|
|
375
|
+
element.background = shape;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const remove = (element) => {
|
|
379
|
+
element.background?.remove();
|
|
380
|
+
element.background = null;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const is = (element) => {
|
|
384
|
+
return element.className === BACKGROUND_CLASS_NAME;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
return [append, remove, is] as const;
|
|
388
|
+
}
|
|
389
|
+
|
|
233
390
|
export function setCursor(root, cursor) {
|
|
234
391
|
// @ts-ignore
|
|
235
392
|
const canvas = root.getRootNode().defaultView;
|
|
@@ -2,6 +2,7 @@ import { DisplayObject } from '@antv/g';
|
|
|
2
2
|
import { ascending } from 'd3-array';
|
|
3
3
|
import { OverlapDodgeYTransform } from '../spec';
|
|
4
4
|
import { LabelTransformComponent as LLC } from '../runtime';
|
|
5
|
+
import { defined } from '../utils/helper';
|
|
5
6
|
|
|
6
7
|
export type OverlapDodgeYOptions = Omit<OverlapDodgeYTransform, 'type'>;
|
|
7
8
|
|
|
@@ -22,7 +23,6 @@ function getBoundsWithoutConnector(shape: DisplayObject) {
|
|
|
22
23
|
connectorShape && node.removeChild(connectorShape);
|
|
23
24
|
const { min, max } = node.getRenderBounds();
|
|
24
25
|
node.destroy();
|
|
25
|
-
|
|
26
26
|
return { min, max };
|
|
27
27
|
}
|
|
28
28
|
|
package/src/mark/area.ts
CHANGED
package/src/runtime/component.ts
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { deepMix } from '@antv/util';
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
G2CoordinateOptions,
|
|
6
|
-
G2Library,
|
|
7
|
-
G2GuideComponentOptions,
|
|
8
|
-
G2View,
|
|
9
|
-
G2TitleOptions,
|
|
10
|
-
} from './types/options';
|
|
11
|
-
import {
|
|
12
|
-
GuideComponentComponent,
|
|
13
|
-
GuideComponent,
|
|
14
|
-
ScaleComponent,
|
|
15
|
-
Scale,
|
|
16
|
-
} from './types/component';
|
|
17
|
-
import { G2Theme, GuideComponentPosition } from './types/common';
|
|
18
|
-
import {
|
|
19
|
-
isPolar,
|
|
20
|
-
isTranspose,
|
|
3
|
+
isHelix,
|
|
21
4
|
isParallel,
|
|
5
|
+
isPolar,
|
|
6
|
+
isRadial,
|
|
22
7
|
isReflect,
|
|
23
8
|
isReflectY,
|
|
24
9
|
isTheta,
|
|
25
|
-
|
|
26
|
-
isRadial,
|
|
10
|
+
isTranspose,
|
|
27
11
|
} from './coordinate';
|
|
28
12
|
import { useLibrary } from './library';
|
|
13
|
+
import { useRelationScale } from './scale';
|
|
14
|
+
import { G2Theme, GuideComponentPosition } from './types/common';
|
|
15
|
+
import { GuideComponent, GuideComponentComponent } from './types/component';
|
|
16
|
+
import {
|
|
17
|
+
G2CoordinateOptions,
|
|
18
|
+
G2GuideComponentOptions,
|
|
19
|
+
G2Library,
|
|
20
|
+
G2ScaleOptions,
|
|
21
|
+
G2View,
|
|
22
|
+
} from './types/options';
|
|
29
23
|
|
|
30
24
|
export function inferComponent(
|
|
31
25
|
scales: G2ScaleOptions[],
|
|
@@ -104,17 +98,16 @@ export function renderComponent(
|
|
|
104
98
|
theme: G2Theme,
|
|
105
99
|
library: G2Library,
|
|
106
100
|
) {
|
|
107
|
-
const [useScale] = useLibrary<G2ScaleOptions, ScaleComponent, Scale>(
|
|
108
|
-
'scale',
|
|
109
|
-
library,
|
|
110
|
-
);
|
|
111
101
|
const [useGuideComponent] = useLibrary<
|
|
112
102
|
G2GuideComponentOptions,
|
|
113
103
|
GuideComponentComponent,
|
|
114
104
|
GuideComponent
|
|
115
105
|
>('component', library);
|
|
116
106
|
const { scale: scaleDescriptor, bbox, ...options } = component;
|
|
117
|
-
const scale = scaleDescriptor
|
|
107
|
+
const scale = scaleDescriptor
|
|
108
|
+
? useRelationScale(scaleDescriptor, library)
|
|
109
|
+
: null;
|
|
110
|
+
|
|
118
111
|
const { field, domain } = scaleDescriptor || {};
|
|
119
112
|
const value = { field, domain, bbox };
|
|
120
113
|
const render = useGuideComponent(options);
|
package/src/runtime/plot.ts
CHANGED
|
@@ -1,76 +1,81 @@
|
|
|
1
|
+
import { Vector2 } from '@antv/coord';
|
|
1
2
|
import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
|
|
2
3
|
import { deepMix, upperFirst } from '@antv/util';
|
|
3
|
-
import { format } from 'd3-format';
|
|
4
|
-
import { Vector2 } from '@antv/coord';
|
|
5
4
|
import { group } from 'd3-array';
|
|
5
|
+
import { format } from 'd3-format';
|
|
6
6
|
import { mapObject } from '../utils/array';
|
|
7
|
+
import { CHART_LIFE_CIRCLE } from '../utils/event';
|
|
7
8
|
import {
|
|
8
|
-
copyAttributes,
|
|
9
|
-
error,
|
|
10
|
-
defined,
|
|
11
|
-
useMemo,
|
|
12
9
|
appendTransform,
|
|
13
10
|
compose,
|
|
11
|
+
copyAttributes,
|
|
12
|
+
defined,
|
|
13
|
+
error,
|
|
14
14
|
maybeSubObject,
|
|
15
15
|
subObject,
|
|
16
|
+
useMemo,
|
|
16
17
|
} from '../utils/helper';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
18
|
+
import { G2Element, select, Selection } from '../utils/selection';
|
|
19
|
+
import { inferComponent, renderComponent } from './component';
|
|
19
20
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} from './types/options';
|
|
21
|
+
AREA_CLASS_NAME,
|
|
22
|
+
COMPONENT_CLASS_NAME,
|
|
23
|
+
ELEMENT_CLASS_NAME,
|
|
24
|
+
LABEL_CLASS_NAME,
|
|
25
|
+
LABEL_LAYER_CLASS_NAME,
|
|
26
|
+
MAIN_LAYER_CLASS_NAME,
|
|
27
|
+
PLOT_CLASS_NAME,
|
|
28
|
+
VIEW_CLASS_NAME,
|
|
29
|
+
} from './constant';
|
|
30
|
+
import { createCoordinate } from './coordinate';
|
|
31
|
+
import { computeLayout, placeComponents } from './layout';
|
|
32
|
+
import { useLibrary } from './library';
|
|
33
|
+
import { initializeMark } from './mark';
|
|
34
34
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
AnimationComponent,
|
|
42
|
-
Animation,
|
|
43
|
-
CompositionComponent,
|
|
44
|
-
Composition,
|
|
45
|
-
InteractionComponent,
|
|
46
|
-
Interaction,
|
|
47
|
-
LabelTransformComponent,
|
|
48
|
-
LabelTransform,
|
|
49
|
-
} from './types/component';
|
|
50
|
-
import { MarkComponent, Mark, CompositeMark, SingleMark } from './types/mark';
|
|
35
|
+
applyScale,
|
|
36
|
+
inferScale,
|
|
37
|
+
syncFacetsScales,
|
|
38
|
+
useRelationScale,
|
|
39
|
+
} from './scale';
|
|
40
|
+
import { applyDataTransform } from './transform';
|
|
51
41
|
import {
|
|
52
|
-
G2ViewDescriptor,
|
|
53
42
|
G2MarkState,
|
|
43
|
+
G2ViewDescriptor,
|
|
54
44
|
G2ViewInstance,
|
|
55
45
|
Primitive,
|
|
56
46
|
} from './types/common';
|
|
57
|
-
import { useLibrary } from './library';
|
|
58
|
-
import { initializeMark } from './mark';
|
|
59
|
-
import { inferComponent, renderComponent } from './component';
|
|
60
|
-
import { computeLayout, placeComponents } from './layout';
|
|
61
|
-
import { createCoordinate } from './coordinate';
|
|
62
|
-
import { applyScale, syncFacetsScales, useRelation, inferScale } from './scale';
|
|
63
|
-
import { applyDataTransform } from './transform';
|
|
64
47
|
import {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
48
|
+
Animation,
|
|
49
|
+
AnimationComponent,
|
|
50
|
+
Composition,
|
|
51
|
+
CompositionComponent,
|
|
52
|
+
Interaction,
|
|
53
|
+
InteractionComponent,
|
|
54
|
+
LabelTransform,
|
|
55
|
+
LabelTransformComponent,
|
|
56
|
+
Scale,
|
|
57
|
+
ScaleComponent,
|
|
58
|
+
Shape,
|
|
59
|
+
ShapeComponent,
|
|
60
|
+
Theme,
|
|
61
|
+
ThemeComponent,
|
|
62
|
+
} from './types/component';
|
|
63
|
+
import { CompositeMark, Mark, MarkComponent, SingleMark } from './types/mark';
|
|
64
|
+
import {
|
|
65
|
+
G2AnimationOptions,
|
|
66
|
+
G2CompositionOptions,
|
|
67
|
+
G2Context,
|
|
68
|
+
G2InteractionOptions,
|
|
69
|
+
G2LabelTransformOptions,
|
|
70
|
+
G2Library,
|
|
71
|
+
G2Mark,
|
|
72
|
+
G2MarkOptions,
|
|
73
|
+
G2ScaleOptions,
|
|
74
|
+
G2ShapeOptions,
|
|
75
|
+
G2ThemeOptions,
|
|
76
|
+
G2View,
|
|
77
|
+
G2ViewTree,
|
|
78
|
+
} from './types/options';
|
|
74
79
|
|
|
75
80
|
export async function plot<T extends G2ViewTree>(
|
|
76
81
|
options: T,
|
|
@@ -160,11 +165,11 @@ export async function plot<T extends G2ViewTree>(
|
|
|
160
165
|
}
|
|
161
166
|
}
|
|
162
167
|
|
|
163
|
-
|
|
164
|
-
emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_PAINT);
|
|
168
|
+
context.emitter.emit(CHART_LIFE_CIRCLE.BEFORE_PAINT);
|
|
165
169
|
|
|
166
170
|
// Plot chart.
|
|
167
|
-
const
|
|
171
|
+
const enterContainer = new Map<G2ViewDescriptor, DisplayObject>();
|
|
172
|
+
const updateContainer = new Map<G2ViewDescriptor, DisplayObject>();
|
|
168
173
|
const transitions: GAnimation[] = [];
|
|
169
174
|
selection
|
|
170
175
|
.selectAll(className(VIEW_CLASS_NAME))
|
|
@@ -178,29 +183,68 @@ export async function plot<T extends G2ViewTree>(
|
|
|
178
183
|
.call(applyTranslate)
|
|
179
184
|
.each(function (view) {
|
|
180
185
|
plotView(view, select(this), transitions, library);
|
|
181
|
-
|
|
186
|
+
enterContainer.set(view, this);
|
|
182
187
|
}),
|
|
183
188
|
(update) =>
|
|
184
189
|
update.call(applyTranslate).each(function (view) {
|
|
185
190
|
plotView(view, select(this), transitions, library);
|
|
191
|
+
updateContainer.set(view, this);
|
|
186
192
|
}),
|
|
187
|
-
(exit) =>
|
|
193
|
+
(exit) =>
|
|
194
|
+
exit
|
|
195
|
+
.each(function () {
|
|
196
|
+
// Remove existed interactions.
|
|
197
|
+
const interactions = this['nameInteraction'].values();
|
|
198
|
+
for (const interaction of interactions) {
|
|
199
|
+
interaction.destroy();
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
.remove(),
|
|
188
203
|
);
|
|
189
204
|
|
|
190
|
-
// Apply
|
|
191
|
-
const
|
|
192
|
-
|
|
205
|
+
// Apply interactions.
|
|
206
|
+
const viewInstanceof = (
|
|
207
|
+
viewContainer: Map<G2ViewDescriptor, DisplayObject>,
|
|
208
|
+
) => {
|
|
209
|
+
return Array.from(viewContainer.entries()).map(([view, container]) => ({
|
|
193
210
|
view,
|
|
194
211
|
container,
|
|
195
212
|
options: viewNode.get(view),
|
|
196
213
|
update: createUpdateView(select(container), library, context),
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Interactions for enter views.
|
|
218
|
+
const enterViewInstances = viewInstanceof(enterContainer);
|
|
219
|
+
for (const target of enterViewInstances) {
|
|
200
220
|
const { options } = target;
|
|
221
|
+
|
|
222
|
+
// A Map index interaction by interaction name.
|
|
223
|
+
const nameInteraction = new Map();
|
|
224
|
+
target.container['nameInteraction'] = nameInteraction;
|
|
225
|
+
|
|
226
|
+
// Apply interactions.
|
|
201
227
|
for (const option of inferInteraction(options)) {
|
|
202
228
|
const interaction = useInteraction(option);
|
|
203
|
-
interaction(target,
|
|
229
|
+
const destroy = interaction(target, enterViewInstances);
|
|
230
|
+
nameInteraction.set(option.type, { destroy });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Interactions for update views.
|
|
235
|
+
const updateViewInstances = viewInstanceof(updateContainer);
|
|
236
|
+
for (const target of updateViewInstances) {
|
|
237
|
+
const { options, container } = target;
|
|
238
|
+
const nameInteraction = container['nameInteraction'];
|
|
239
|
+
for (const option of inferInteraction(options)) {
|
|
240
|
+
// Remove interaction for existed views.
|
|
241
|
+
const prevInteraction = nameInteraction.get(option.type);
|
|
242
|
+
if (prevInteraction) prevInteraction.destroy();
|
|
243
|
+
|
|
244
|
+
// Apply new interaction.
|
|
245
|
+
const interaction = useInteraction(option);
|
|
246
|
+
const destroy = interaction(target, updateViewInstances);
|
|
247
|
+
nameInteraction.set(options.type, { destroy });
|
|
204
248
|
}
|
|
205
249
|
}
|
|
206
250
|
|
|
@@ -221,9 +265,10 @@ export async function plot<T extends G2ViewTree>(
|
|
|
221
265
|
keyframes.push(keyframe);
|
|
222
266
|
}
|
|
223
267
|
|
|
268
|
+
context.views = views;
|
|
224
269
|
context.animations = transitions;
|
|
225
270
|
|
|
226
|
-
|
|
271
|
+
context.emitter.emit(CHART_LIFE_CIRCLE.AFTER_PAINT);
|
|
227
272
|
|
|
228
273
|
// Note!!!
|
|
229
274
|
// The returned promise will never resolved if one of nodeGenerator
|
|
@@ -424,13 +469,9 @@ function initializeState(
|
|
|
424
469
|
const scale = Object.fromEntries(
|
|
425
470
|
channels.map(({ name, scale }) => [name, scale]),
|
|
426
471
|
);
|
|
427
|
-
|
|
428
472
|
// Transform abstract value to visual value by scales.
|
|
429
473
|
const markScaleInstance = mapObject(scale, (options) => {
|
|
430
|
-
|
|
431
|
-
const [conditionalize] = useRelation(relations);
|
|
432
|
-
const scale = useScale(options);
|
|
433
|
-
return conditionalize(scale);
|
|
474
|
+
return useRelationScale(options, library);
|
|
434
475
|
});
|
|
435
476
|
Object.assign(scaleInstance, markScaleInstance);
|
|
436
477
|
const value = applyScale(channels, markScaleInstance);
|
|
@@ -564,6 +605,8 @@ async function plotView(
|
|
|
564
605
|
),
|
|
565
606
|
(update) =>
|
|
566
607
|
update.each(function (options) {
|
|
608
|
+
const { preserve = false } = options;
|
|
609
|
+
if (preserve) return;
|
|
567
610
|
const newComponent = renderComponent(
|
|
568
611
|
options,
|
|
569
612
|
coordinate,
|
|
@@ -1219,8 +1262,13 @@ function updateLayers(selection: Selection, marks: G2Mark[]) {
|
|
|
1219
1262
|
.attr('className', MAIN_LAYER_CLASS_NAME)
|
|
1220
1263
|
.attr('id', (d) => d.key)
|
|
1221
1264
|
.style('facet', facet)
|
|
1222
|
-
.style('fill', 'transparent')
|
|
1223
|
-
|
|
1265
|
+
.style('fill', 'transparent')
|
|
1266
|
+
.style('zIndex', (d) => d.zIndex ?? 0),
|
|
1267
|
+
(update) =>
|
|
1268
|
+
update
|
|
1269
|
+
.style('facet', facet)
|
|
1270
|
+
.style('fill', 'transparent')
|
|
1271
|
+
.style('zIndex', (d) => d.zIndex ?? 0),
|
|
1224
1272
|
(exit) => exit.remove(),
|
|
1225
1273
|
);
|
|
1226
1274
|
|