@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
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
|
@@ -103,6 +103,20 @@ export function useRelation(
|
|
|
103
103
|
return [conditionalize, deconditionalize];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
export function useRelationScale(
|
|
107
|
+
options: Record<string, any>,
|
|
108
|
+
library: G2Library,
|
|
109
|
+
) {
|
|
110
|
+
const [useScale] = useLibrary<G2ScaleOptions, ScaleComponent, Scale>(
|
|
111
|
+
'scale',
|
|
112
|
+
library,
|
|
113
|
+
);
|
|
114
|
+
const { relations } = options;
|
|
115
|
+
const [conditionalize] = useRelation(relations);
|
|
116
|
+
const scale = useScale(options);
|
|
117
|
+
return conditionalize(scale);
|
|
118
|
+
}
|
|
119
|
+
|
|
106
120
|
export function syncFacetsScales(states: Map<G2Mark, G2MarkState>[]): void {
|
|
107
121
|
const scales = states
|
|
108
122
|
.flatMap((d) => Array.from(d.values()))
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Canvas, IAnimation as GAnimation } from '@antv/g';
|
|
2
2
|
import type { DisplayObject } from '@antv/g';
|
|
3
|
-
import
|
|
3
|
+
import EventEmitter from '@antv/event-emitter';
|
|
4
|
+
import {
|
|
5
|
+
G2Title,
|
|
6
|
+
G2ViewDescriptor,
|
|
7
|
+
GuideComponentPosition,
|
|
8
|
+
Layout,
|
|
9
|
+
Primitive,
|
|
10
|
+
} from './common';
|
|
4
11
|
import {
|
|
5
12
|
G2BaseComponent,
|
|
6
13
|
StatisticComponent,
|
|
@@ -46,9 +53,10 @@ export type G2Library = Record<
|
|
|
46
53
|
export type G2Context = {
|
|
47
54
|
library?: G2Library;
|
|
48
55
|
canvas?: Canvas;
|
|
56
|
+
emitter?: EventEmitter;
|
|
49
57
|
group?: DisplayObject;
|
|
50
58
|
animations?: GAnimation[];
|
|
51
|
-
|
|
59
|
+
views?: G2ViewDescriptor[];
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
export type G2View = {
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { curveStepAfter } from 'd3-shape';
|
|
2
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
3
|
+
import { Curve } from './curve';
|
|
4
|
+
|
|
5
|
+
export type HVOptions = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
export const HV: SC<HVOptions> = (options) => {
|
|
8
|
+
return (P, value, coordinate, theme) => {
|
|
9
|
+
return Curve({ curve: curveStepAfter, ...options })(
|
|
10
|
+
P,
|
|
11
|
+
value,
|
|
12
|
+
coordinate,
|
|
13
|
+
theme,
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
HV.props = {
|
|
19
|
+
...Curve.props,
|
|
20
|
+
};
|
|
@@ -2,14 +2,14 @@ import { curveStep } from 'd3-shape';
|
|
|
2
2
|
import { ShapeComponent as SC } from '../../runtime';
|
|
3
3
|
import { Curve } from './curve';
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type HVHOptions = Record<string, any>;
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const HVH: SC<HVHOptions> = (options) => {
|
|
8
8
|
return (P, value, coordinate, theme) => {
|
|
9
9
|
return Curve({ curve: curveStep, ...options })(P, value, coordinate, theme);
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
HVH.props = {
|
|
14
14
|
...Curve.props,
|
|
15
15
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { curveStepBefore } from 'd3-shape';
|
|
2
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
3
|
+
import { Curve } from './curve';
|
|
4
|
+
|
|
5
|
+
export type VHOptions = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
export const VH: SC<VHOptions> = (options) => {
|
|
8
|
+
return (P, value, coordinate, theme) => {
|
|
9
|
+
return Curve({ curve: curveStepBefore, ...options })(
|
|
10
|
+
P,
|
|
11
|
+
value,
|
|
12
|
+
coordinate,
|
|
13
|
+
theme,
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
VH.props = {
|
|
19
|
+
...Curve.props,
|
|
20
|
+
};
|
package/src/shape/index.ts
CHANGED
|
@@ -31,7 +31,9 @@ export { Text } from './text/text';
|
|
|
31
31
|
export { Badge } from './text/badge';
|
|
32
32
|
export { Area } from './area/area';
|
|
33
33
|
export { Smooth as SmoothArea } from './area/smooth';
|
|
34
|
-
export {
|
|
34
|
+
export { HVH as HVHArea } from './area/hvh';
|
|
35
|
+
export { VH as VHArea } from './area/vh';
|
|
36
|
+
export { HV as HVArea } from './area/hv';
|
|
35
37
|
export { Link } from './link/link';
|
|
36
38
|
export { Smooth as SmoothEdge } from './link/smooth';
|
|
37
39
|
export { VHV as VHVEdge } from './link/vhv';
|
|
@@ -83,7 +85,10 @@ export type { TextOptions } from './text/text';
|
|
|
83
85
|
export type { BadgeOptions } from './text/badge';
|
|
84
86
|
export type { AreaOptions } from './area/area';
|
|
85
87
|
export type { SmoothOptions as SmoothAreaOptions } from './area/smooth';
|
|
86
|
-
export type {
|
|
88
|
+
export type { HVHOptions as HVHAreaOptions } from './area/hvh';
|
|
89
|
+
export type { VHOptions as VHAreaOptions } from './area/vh';
|
|
90
|
+
export type { HVOptions as HVAreaOptions } from './area/hv';
|
|
91
|
+
|
|
87
92
|
export type { LinkOptions } from './link/link';
|
|
88
93
|
export type { ImageOptions } from './image/image';
|
|
89
94
|
export type { PolygonOptions } from './polygon/polygon';
|
|
@@ -17,6 +17,72 @@ export type ColorOptions = {
|
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
// Render rect in different coordinate.
|
|
21
|
+
export function rect(
|
|
22
|
+
points,
|
|
23
|
+
value,
|
|
24
|
+
coordinate,
|
|
25
|
+
style: Record<string, any> = {},
|
|
26
|
+
) {
|
|
27
|
+
const {
|
|
28
|
+
inset = 0,
|
|
29
|
+
radius = 0,
|
|
30
|
+
insetLeft = inset,
|
|
31
|
+
insetTop = inset,
|
|
32
|
+
insetRight = inset,
|
|
33
|
+
insetBottom = inset,
|
|
34
|
+
radiusBottomLeft = radius,
|
|
35
|
+
radiusBottomRight = radius,
|
|
36
|
+
radiusTopLeft = radius,
|
|
37
|
+
radiusTopRight = radius,
|
|
38
|
+
...rest
|
|
39
|
+
} = style;
|
|
40
|
+
if (!isPolar(coordinate) && !isHelix(coordinate)) {
|
|
41
|
+
const tpShape = !!isTranspose(coordinate);
|
|
42
|
+
|
|
43
|
+
const [p0, , p2] = tpShape ? reorder(points) : points;
|
|
44
|
+
const [x, y] = p0;
|
|
45
|
+
const [width, height] = sub(p2, p0);
|
|
46
|
+
// Deal with width or height is negative.
|
|
47
|
+
const absX = width > 0 ? x : x + width;
|
|
48
|
+
const absY = height > 0 ? y : y + height;
|
|
49
|
+
const absWidth = Math.abs(width);
|
|
50
|
+
const absHeight = Math.abs(height);
|
|
51
|
+
const finalX = absX + insetLeft;
|
|
52
|
+
const finalY = absY + insetTop;
|
|
53
|
+
const finalWidth = absWidth - (insetLeft + insetRight);
|
|
54
|
+
const finalHeight = absHeight - (insetTop + insetBottom);
|
|
55
|
+
|
|
56
|
+
return select(new Rect({}))
|
|
57
|
+
.style('x', finalX)
|
|
58
|
+
.style('y', finalY)
|
|
59
|
+
.style('width', finalWidth)
|
|
60
|
+
.style('height', finalHeight)
|
|
61
|
+
.style('radius', [
|
|
62
|
+
radiusTopLeft,
|
|
63
|
+
radiusTopRight,
|
|
64
|
+
radiusBottomRight,
|
|
65
|
+
radiusBottomLeft,
|
|
66
|
+
])
|
|
67
|
+
.call(applyStyle, rest)
|
|
68
|
+
.node();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Render path in polar coordinate.
|
|
72
|
+
const { y, y1 } = value;
|
|
73
|
+
const center = coordinate.getCenter() as Vector2;
|
|
74
|
+
const arcObject = getArcObject(coordinate, points, [y, y1]);
|
|
75
|
+
const path = arc()
|
|
76
|
+
.cornerRadius(radius as number)
|
|
77
|
+
.padAngle((inset * Math.PI) / 180);
|
|
78
|
+
|
|
79
|
+
return select(new Path({}))
|
|
80
|
+
.style('path', path(arcObject))
|
|
81
|
+
.style('transform', `translate(${center[0]}, ${center[1]})`)
|
|
82
|
+
.call(applyStyle, rest)
|
|
83
|
+
.node();
|
|
84
|
+
}
|
|
85
|
+
|
|
20
86
|
/**
|
|
21
87
|
* Render rect in different coordinate.
|
|
22
88
|
* Calc arc path based on control points directly rather startAngle, endAngle, innerRadius,
|
|
@@ -36,7 +102,6 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
36
102
|
return (points, value, coordinate, theme) => {
|
|
37
103
|
const { mark, shape, defaultShape } = value;
|
|
38
104
|
const {
|
|
39
|
-
// [colorAttribute]: defaultColor,
|
|
40
105
|
defaultColor,
|
|
41
106
|
radius: defaultRadius = 0,
|
|
42
107
|
...defaults
|
|
@@ -55,70 +120,37 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
55
120
|
innerRadiusTopRight = innerRadius,
|
|
56
121
|
innerRadiusBottomRight = innerRadius,
|
|
57
122
|
innerRadiusBottomLeft = innerRadius,
|
|
123
|
+
lineWidth = colorAttribute === 'stroke' || stroke ? defaultLineWidth : 0,
|
|
58
124
|
inset = 0,
|
|
59
125
|
insetLeft = inset,
|
|
60
126
|
insetRight = inset,
|
|
61
127
|
insetBottom = inset,
|
|
62
128
|
insetTop = inset,
|
|
63
|
-
lineWidth = colorAttribute === 'stroke' || stroke ? defaultLineWidth : 0,
|
|
64
129
|
...rest
|
|
65
130
|
} = style;
|
|
66
131
|
const { color = defaultColor, opacity } = value;
|
|
67
132
|
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const finalWidth = absWidth - (insetLeft + insetRight);
|
|
83
|
-
const finalHeight = absHeight - (insetTop + insetBottom);
|
|
84
|
-
|
|
85
|
-
return select(new Rect({}))
|
|
86
|
-
.call(applyStyle, defaults)
|
|
87
|
-
.style('lineWidth', lineWidth)
|
|
88
|
-
.style('x', finalX)
|
|
89
|
-
.style('y', finalY)
|
|
90
|
-
.style('width', finalWidth)
|
|
91
|
-
.style('height', finalHeight)
|
|
92
|
-
.style('stroke', stroke === undefined ? color : stroke)
|
|
93
|
-
.style(toOpacityKey(options), opacity)
|
|
94
|
-
.style(colorAttribute, color)
|
|
95
|
-
.style('radius', [
|
|
96
|
-
first ? radiusTopLeft : innerRadiusTopLeft,
|
|
97
|
-
first ? radiusTopRight : innerRadiusTopRight,
|
|
98
|
-
last ? radiusBottomRight : innerRadiusBottomRight,
|
|
99
|
-
last ? radiusBottomLeft : innerRadiusBottomLeft,
|
|
100
|
-
])
|
|
101
|
-
.call(applyStyle, rest)
|
|
102
|
-
.node();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Render path in polar coordinate.
|
|
106
|
-
const { y, y1 } = value;
|
|
107
|
-
const center = coordinate.getCenter() as Vector2;
|
|
108
|
-
const arcObject = getArcObject(coordinate, points, [y, y1]);
|
|
109
|
-
const path = arc()
|
|
110
|
-
.cornerRadius(radius as number)
|
|
111
|
-
.padAngle((inset * Math.PI) / 180);
|
|
133
|
+
// Extended style, which is not supported by native g shape,
|
|
134
|
+
// should apply at first.
|
|
135
|
+
const extendedStyle = {
|
|
136
|
+
radius,
|
|
137
|
+
radiusTopLeft: first ? radiusTopLeft : innerRadiusTopLeft,
|
|
138
|
+
radiusTopRight: first ? radiusTopRight : innerRadiusTopRight,
|
|
139
|
+
radiusBottomRight: last ? radiusBottomRight : innerRadiusBottomRight,
|
|
140
|
+
radiusBottomLeft: last ? radiusBottomLeft : innerRadiusBottomLeft,
|
|
141
|
+
inset,
|
|
142
|
+
insetLeft,
|
|
143
|
+
insetRight,
|
|
144
|
+
insetBottom,
|
|
145
|
+
insetTop,
|
|
146
|
+
};
|
|
112
147
|
|
|
113
|
-
return select(
|
|
114
|
-
.call(applyStyle, defaults)
|
|
115
|
-
.style('path', path(arcObject))
|
|
116
|
-
.style('transform', `translate(${center[0]}, ${center[1]})`)
|
|
117
|
-
.style('stroke', color || stroke)
|
|
118
|
-
.style('lineWidth', lineWidth)
|
|
119
|
-
.style(colorAttribute, color)
|
|
148
|
+
return select(rect(points, value, coordinate, extendedStyle))
|
|
149
|
+
.call(applyStyle, { ...defaults, ...rest })
|
|
120
150
|
.style(toOpacityKey(options), opacity)
|
|
121
|
-
.
|
|
151
|
+
.style(colorAttribute, color)
|
|
152
|
+
.style('lineWidth', lineWidth)
|
|
153
|
+
.style('stroke', stroke === undefined ? color : stroke)
|
|
122
154
|
.node();
|
|
123
155
|
};
|
|
124
156
|
};
|
package/src/spec/composition.ts
CHANGED
package/src/spec/geometry.ts
CHANGED
package/src/spec/interaction.ts
CHANGED
|
@@ -12,16 +12,18 @@ export type Interaction =
|
|
|
12
12
|
| ElementSelectInteraction
|
|
13
13
|
| TooltipInteraction
|
|
14
14
|
| FisheyeInteraction
|
|
15
|
-
|
|
|
15
|
+
| ChartIndexInteraction
|
|
16
16
|
| CustomInteraction
|
|
17
17
|
| LegendFilterInteraction
|
|
18
|
+
| LegendHighlightInteraction
|
|
18
19
|
| BrushHighlightInteraction
|
|
19
20
|
| BrushXHighlightInteraction
|
|
20
21
|
| BrushYHighlightInteraction
|
|
21
22
|
| BrushAxisHighlightInteraction
|
|
22
23
|
| BrushFilter
|
|
23
24
|
| BrushYFilter
|
|
24
|
-
| BrushXFilter
|
|
25
|
+
| BrushXFilter
|
|
26
|
+
| SliderFilter;
|
|
25
27
|
// | ElementListHighlightInteraction
|
|
26
28
|
// | LegendActiveInteraction
|
|
27
29
|
// | LegendHighlightInteraction
|
|
@@ -44,12 +46,14 @@ export type InteractionTypes =
|
|
|
44
46
|
| 'fisheye'
|
|
45
47
|
| 'tooltip'
|
|
46
48
|
| 'legendFilter'
|
|
49
|
+
| 'legendHighlight'
|
|
47
50
|
| 'brushXHighlight'
|
|
48
51
|
| 'brushYHighlight'
|
|
49
52
|
| 'brushHighlight'
|
|
50
53
|
| 'brushFilter'
|
|
51
54
|
| 'brushXFilter'
|
|
52
55
|
| 'brushYFilter'
|
|
56
|
+
| 'sliderFilter'
|
|
53
57
|
| InteractionComponent;
|
|
54
58
|
// | 'elementListHighlight'
|
|
55
59
|
// | 'legendActive'
|
|
@@ -123,33 +127,54 @@ export type ElementHighlightInteraction = {
|
|
|
123
127
|
type?: 'elementHighlight';
|
|
124
128
|
// @todo: Style supported by G.
|
|
125
129
|
link?: boolean;
|
|
126
|
-
|
|
130
|
+
background?: boolean;
|
|
131
|
+
offset?: number;
|
|
132
|
+
} & Record<
|
|
133
|
+
`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
|
|
134
|
+
any
|
|
135
|
+
>;
|
|
127
136
|
|
|
128
137
|
export type ElementSelectInteraction = {
|
|
129
138
|
type?: 'elementSelect';
|
|
130
139
|
single?: boolean;
|
|
131
|
-
|
|
140
|
+
background?: true;
|
|
141
|
+
offset?: number;
|
|
142
|
+
} & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
|
|
132
143
|
|
|
133
144
|
export type ElementSelectByColorInteraction = {
|
|
134
145
|
type?: 'elementSelectByColor';
|
|
135
146
|
single?: boolean;
|
|
147
|
+
offset?: number;
|
|
136
148
|
} & Record<`${'selected' | 'link' | 'unselected'}${any}`, any>;
|
|
137
149
|
|
|
138
150
|
export type ElementSelectByXInteraction = {
|
|
139
151
|
type?: 'elementSelectByX';
|
|
140
152
|
single?: boolean;
|
|
141
|
-
|
|
153
|
+
background?: true;
|
|
154
|
+
offset?: number;
|
|
155
|
+
} & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
|
|
142
156
|
|
|
143
157
|
export type ElementHighlightByXInteraction = {
|
|
144
158
|
type?: 'elementHighlightByX';
|
|
145
159
|
x?: string;
|
|
146
160
|
link?: boolean;
|
|
147
|
-
|
|
161
|
+
background?: boolean;
|
|
162
|
+
offset?: number;
|
|
163
|
+
} & Record<
|
|
164
|
+
`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
|
|
165
|
+
any
|
|
166
|
+
>;
|
|
148
167
|
|
|
149
168
|
export type ElementHighlightByColorInteraction = {
|
|
150
169
|
type?: 'elementHighlightByColor';
|
|
151
170
|
color?: string;
|
|
152
|
-
|
|
171
|
+
background?: boolean;
|
|
172
|
+
link?: boolean;
|
|
173
|
+
offset?: number;
|
|
174
|
+
} & Record<
|
|
175
|
+
`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
|
|
176
|
+
any
|
|
177
|
+
>;
|
|
153
178
|
|
|
154
179
|
export type LegendFilterInteraction = {
|
|
155
180
|
type?: 'legendFilter';
|
|
@@ -157,13 +182,25 @@ export type LegendFilterInteraction = {
|
|
|
157
182
|
[key: string]: any; // @todo
|
|
158
183
|
} & Record<`${'marker' | 'label'}Unselected${any}`, any>;
|
|
159
184
|
|
|
160
|
-
export type
|
|
185
|
+
export type LegendHighlightInteraction = {
|
|
186
|
+
type?: 'legendHighlight';
|
|
187
|
+
[key: string]: any; // @todo
|
|
188
|
+
} & Record<`${'marker' | 'label'}Unhighlighted${any}`, any>;
|
|
189
|
+
|
|
190
|
+
export type ChartIndexInteraction = {
|
|
161
191
|
type?: 'chartIndex';
|
|
162
192
|
wait?: number;
|
|
163
193
|
leading?: boolean;
|
|
164
194
|
trailing?: boolean;
|
|
165
195
|
} & Record<`${'rule' | 'label'}${any}`, any>;
|
|
166
196
|
|
|
197
|
+
export type SliderFilter = {
|
|
198
|
+
type?: 'sliderFilter';
|
|
199
|
+
wait?: number;
|
|
200
|
+
leading?: boolean;
|
|
201
|
+
trailing?: boolean;
|
|
202
|
+
};
|
|
203
|
+
|
|
167
204
|
export type ElementListHighlightInteraction = {
|
|
168
205
|
type?: 'elementListHighlight';
|
|
169
206
|
};
|
|
@@ -172,10 +209,6 @@ export type LegendActiveInteraction = {
|
|
|
172
209
|
type?: 'legendActive';
|
|
173
210
|
};
|
|
174
211
|
|
|
175
|
-
export type LegendHighlightInteraction = {
|
|
176
|
-
type?: 'legendHighlight';
|
|
177
|
-
};
|
|
178
|
-
|
|
179
212
|
export type TooltipInteraction = Omit<TooltipAction, 'type'> & {
|
|
180
213
|
type?: 'tooltip';
|
|
181
214
|
shared?: boolean;
|
package/src/spec/transform.ts
CHANGED
|
@@ -140,7 +140,9 @@ export type Selector =
|
|
|
140
140
|
export type SelectTransform = {
|
|
141
141
|
type?: 'select';
|
|
142
142
|
groupBy?: string | string[];
|
|
143
|
-
|
|
143
|
+
channel?: ChannelTypes;
|
|
144
|
+
selector?: Selector;
|
|
145
|
+
};
|
|
144
146
|
|
|
145
147
|
export type SelectXTransform = {
|
|
146
148
|
type?: 'selectX';
|
|
@@ -252,11 +254,36 @@ export type BinTransform = {
|
|
|
252
254
|
thresholdsY?: number;
|
|
253
255
|
} & { [key in ChannelTypes]?: Reducer };
|
|
254
256
|
|
|
257
|
+
export type SampleFunction = (
|
|
258
|
+
I: number[],
|
|
259
|
+
X: number[],
|
|
260
|
+
Y: number[],
|
|
261
|
+
thresholds: number,
|
|
262
|
+
) => number[];
|
|
263
|
+
|
|
255
264
|
export type SampleTransform = {
|
|
256
265
|
type?: 'sample';
|
|
257
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Sample strategy. Default is 'median'.
|
|
268
|
+
*/
|
|
269
|
+
strategy?:
|
|
270
|
+
| 'lttb'
|
|
271
|
+
| 'median'
|
|
272
|
+
| 'max'
|
|
273
|
+
| 'min'
|
|
274
|
+
| 'first'
|
|
275
|
+
| 'last'
|
|
276
|
+
| SampleFunction;
|
|
277
|
+
/**
|
|
278
|
+
* The thresholds of sample, when data size great then thresholds, sample will take effect.
|
|
279
|
+
* Default is 2000.
|
|
280
|
+
*/
|
|
258
281
|
thresholds?: number;
|
|
259
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Group data by fields, for series data.
|
|
284
|
+
*/
|
|
285
|
+
groupBy?: string | string[];
|
|
286
|
+
};
|
|
260
287
|
|
|
261
288
|
export type FilterTransform = {
|
|
262
289
|
type?: 'filter';
|
package/src/stdlib/index.ts
CHANGED
|
@@ -114,7 +114,9 @@ import {
|
|
|
114
114
|
Connector as ConnectorShape,
|
|
115
115
|
Area,
|
|
116
116
|
SmoothArea,
|
|
117
|
-
|
|
117
|
+
HVHArea,
|
|
118
|
+
VHArea,
|
|
119
|
+
HVArea,
|
|
118
120
|
SmoothEdge,
|
|
119
121
|
VHVEdge,
|
|
120
122
|
Arc,
|
|
@@ -159,10 +161,6 @@ import {
|
|
|
159
161
|
GrowInY,
|
|
160
162
|
} from '../animation';
|
|
161
163
|
import {
|
|
162
|
-
// ElementHighlight,
|
|
163
|
-
// ElementSelected,
|
|
164
|
-
// Tooltip,
|
|
165
|
-
// Fisheye as FisheyeInteraction,
|
|
166
164
|
ElementHighlight,
|
|
167
165
|
ElementHighlightByX,
|
|
168
166
|
ElementHighlightByColor,
|
|
@@ -173,6 +171,7 @@ import {
|
|
|
173
171
|
Fisheye as ChartFisheye,
|
|
174
172
|
Tooltip,
|
|
175
173
|
LegendFilter,
|
|
174
|
+
LegendHighlight,
|
|
176
175
|
BrushHighlight,
|
|
177
176
|
BrushXHighlight,
|
|
178
177
|
BrushYHighlight,
|
|
@@ -180,6 +179,7 @@ import {
|
|
|
180
179
|
BrushFilter,
|
|
181
180
|
BrushXFilter,
|
|
182
181
|
BrushYFilter,
|
|
182
|
+
SliderFilter,
|
|
183
183
|
// ElementHighlightByX,
|
|
184
184
|
// ElementHighlightByColor,
|
|
185
185
|
// ElementListHighlight,
|
|
@@ -446,7 +446,9 @@ export function createLibrary(): G2Library {
|
|
|
446
446
|
'shape.text.text': Text,
|
|
447
447
|
'shape.area.area': Area,
|
|
448
448
|
'shape.area.smooth': SmoothArea,
|
|
449
|
-
'shape.area.
|
|
449
|
+
'shape.area.hvh': HVHArea,
|
|
450
|
+
'shape.area.vh': VHArea,
|
|
451
|
+
'shape.area.hv': HVArea,
|
|
450
452
|
'shape.link.smooth': SmoothEdge,
|
|
451
453
|
'shape.link.vhv': VHVEdge,
|
|
452
454
|
'shape.link.arc': Arc,
|
|
@@ -502,6 +504,7 @@ export function createLibrary(): G2Library {
|
|
|
502
504
|
'interaction.chartIndex': ChartIndex,
|
|
503
505
|
'interaction.tooltip': Tooltip,
|
|
504
506
|
'interaction.legendFilter': LegendFilter,
|
|
507
|
+
'interaction.legendHighlight': LegendHighlight,
|
|
505
508
|
'interaction.brushHighlight': BrushHighlight,
|
|
506
509
|
'interaction.brushXHighlight': BrushXHighlight,
|
|
507
510
|
'interaction.brushYHighlight': BrushYHighlight,
|
|
@@ -509,6 +512,7 @@ export function createLibrary(): G2Library {
|
|
|
509
512
|
'interaction.brushFilter': BrushFilter,
|
|
510
513
|
'interaction.brushXFilter': BrushXFilter,
|
|
511
514
|
'interaction.brushYFilter': BrushYFilter,
|
|
515
|
+
'interaction.sliderFilter': SliderFilter,
|
|
512
516
|
// 'interaction.elementSelected': ElementSelected,
|
|
513
517
|
// 'interaction.elementHighlight': ElementHighlight,
|
|
514
518
|
// 'interaction.elementHighlightByX': ElementHighlightByX,
|