@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/api/mark/mark.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IntervalGeometry,
|
|
3
|
+
RectGeometry,
|
|
3
4
|
AreaGeometry,
|
|
4
5
|
PointGeometry,
|
|
5
6
|
CellGeometry,
|
|
@@ -26,15 +27,15 @@ import {
|
|
|
26
27
|
WordCloudMark,
|
|
27
28
|
} from '../../spec';
|
|
28
29
|
import { NodePropertyDescriptor, defineProps } from '../props';
|
|
29
|
-
import { Node } from '../node';
|
|
30
30
|
import { Concrete } from '../types';
|
|
31
|
+
import { MarkBase } from './base';
|
|
31
32
|
import { API } from './types';
|
|
32
33
|
|
|
33
34
|
export interface Interval extends API<Concrete<IntervalGeometry>, Interval> {
|
|
34
35
|
type: 'interval';
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export interface Rect extends API<Concrete<
|
|
38
|
+
export interface Rect extends API<Concrete<RectGeometry>, Rect> {
|
|
38
39
|
type: 'rect';
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -148,182 +149,182 @@ export const props: NodePropertyDescriptor[] = [
|
|
|
148
149
|
];
|
|
149
150
|
|
|
150
151
|
@defineProps(props)
|
|
151
|
-
export class Interval extends
|
|
152
|
+
export class Interval extends MarkBase<IntervalGeometry> {
|
|
152
153
|
constructor() {
|
|
153
154
|
super({}, 'interval');
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
@defineProps(props)
|
|
158
|
-
export class Rect extends
|
|
159
|
+
export class Rect extends MarkBase<RectGeometry> {
|
|
159
160
|
constructor() {
|
|
160
161
|
super({}, 'rect');
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
@defineProps(props)
|
|
165
|
-
export class Point extends
|
|
166
|
+
export class Point extends MarkBase<PointGeometry> {
|
|
166
167
|
constructor() {
|
|
167
168
|
super({}, 'point');
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
@defineProps(props)
|
|
172
|
-
export class Area extends
|
|
173
|
+
export class Area extends MarkBase<AreaGeometry> {
|
|
173
174
|
constructor() {
|
|
174
175
|
super({}, 'area');
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
@defineProps(props)
|
|
179
|
-
export class Line extends
|
|
180
|
+
export class Line extends MarkBase<LineGeometry> {
|
|
180
181
|
constructor() {
|
|
181
182
|
super({}, 'line');
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
@defineProps(props)
|
|
186
|
-
export class Cell extends
|
|
187
|
+
export class Cell extends MarkBase<CellGeometry> {
|
|
187
188
|
constructor() {
|
|
188
189
|
super({}, 'cell');
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
@defineProps(props)
|
|
193
|
-
export class Vector extends
|
|
194
|
+
export class Vector extends MarkBase<VectorGeometry> {
|
|
194
195
|
constructor() {
|
|
195
196
|
super({}, 'vector');
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
@defineProps(props)
|
|
200
|
-
export class Link extends
|
|
201
|
+
export class Link extends MarkBase<LinkGeometry> {
|
|
201
202
|
constructor() {
|
|
202
203
|
super({}, 'link');
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
@defineProps(props)
|
|
207
|
-
export class Polygon extends
|
|
208
|
+
export class Polygon extends MarkBase<PolygonGeometry> {
|
|
208
209
|
constructor() {
|
|
209
210
|
super({}, 'polygon');
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
@defineProps(props)
|
|
214
|
-
export class Image extends
|
|
215
|
+
export class Image extends MarkBase<ImageGeometry> {
|
|
215
216
|
constructor() {
|
|
216
217
|
super({}, 'image');
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
@defineProps(props)
|
|
221
|
-
export class Text extends
|
|
222
|
+
export class Text extends MarkBase<TextGeometry> {
|
|
222
223
|
constructor() {
|
|
223
224
|
super({}, 'text');
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
@defineProps(props)
|
|
228
|
-
export class Box extends
|
|
229
|
+
export class Box extends MarkBase<BoxGeometry> {
|
|
229
230
|
constructor() {
|
|
230
231
|
super({}, 'box');
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
@defineProps(props)
|
|
235
|
-
export class LineX extends
|
|
236
|
+
export class LineX extends MarkBase<LineXMark> {
|
|
236
237
|
constructor() {
|
|
237
238
|
super({}, 'lineX');
|
|
238
239
|
}
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
@defineProps(props)
|
|
242
|
-
export class LineY extends
|
|
243
|
+
export class LineY extends MarkBase<LineYMark> {
|
|
243
244
|
constructor() {
|
|
244
245
|
super({}, 'lineY');
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
@defineProps(props)
|
|
249
|
-
export class Range extends
|
|
250
|
+
export class Range extends MarkBase<RangeMark> {
|
|
250
251
|
constructor() {
|
|
251
252
|
super({}, 'range');
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
@defineProps(props)
|
|
256
|
-
export class RangeX extends
|
|
257
|
+
export class RangeX extends MarkBase<RangeXMark> {
|
|
257
258
|
constructor() {
|
|
258
259
|
super({}, 'rangeX');
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
@defineProps(props)
|
|
263
|
-
export class RangeY extends
|
|
264
|
+
export class RangeY extends MarkBase<RangeYMark> {
|
|
264
265
|
constructor() {
|
|
265
266
|
super({}, 'rangeY');
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
@defineProps(props)
|
|
270
|
-
export class Connector extends
|
|
271
|
+
export class Connector extends MarkBase<ConnectorMark> {
|
|
271
272
|
constructor() {
|
|
272
273
|
super({}, 'connector');
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
@defineProps(props)
|
|
277
|
-
export class Shape extends
|
|
278
|
+
export class Shape extends MarkBase<ShapeMark> {
|
|
278
279
|
constructor() {
|
|
279
280
|
super({}, 'shape');
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
284
|
-
export class Sankey extends
|
|
285
|
+
export class Sankey extends MarkBase<SankeyMark> {
|
|
285
286
|
constructor() {
|
|
286
287
|
super({}, 'sankey');
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
291
|
-
export class Treemap extends
|
|
292
|
+
export class Treemap extends MarkBase<ConnectorMark> {
|
|
292
293
|
constructor() {
|
|
293
294
|
super({}, 'treemap');
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
@defineProps(props)
|
|
298
|
-
export class Boxplot extends
|
|
299
|
+
export class Boxplot extends MarkBase<Boxplot> {
|
|
299
300
|
constructor() {
|
|
300
301
|
super({}, 'boxplot');
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
305
|
-
export class Pack extends
|
|
306
|
+
export class Pack extends MarkBase<Pack> {
|
|
306
307
|
constructor() {
|
|
307
308
|
super({}, 'pack');
|
|
308
309
|
}
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
312
|
-
export class ForceGraph extends
|
|
313
|
+
export class ForceGraph extends MarkBase<ForceGraph> {
|
|
313
314
|
constructor() {
|
|
314
315
|
super({}, 'forceGraph');
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
|
|
318
319
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
319
|
-
export class Tree extends
|
|
320
|
+
export class Tree extends MarkBase<Tree> {
|
|
320
321
|
constructor() {
|
|
321
322
|
super({}, 'tree');
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
@defineProps([...props, { name: 'layout', type: 'object' }])
|
|
326
|
-
export class WordCloud extends
|
|
327
|
+
export class WordCloud extends MarkBase<WordCloud> {
|
|
327
328
|
constructor() {
|
|
328
329
|
super({}, 'wordCloud');
|
|
329
330
|
}
|
package/src/api/node.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { emitEvent, CHART_LIFE_CIRCLE } from '../utils/event';
|
|
2
1
|
import { Chart } from './chart';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -116,16 +115,6 @@ export class Node<
|
|
|
116
115
|
return nodes;
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
changeData(data: any) {
|
|
120
|
-
// Find the root chart and render.
|
|
121
|
-
let root: Node = this;
|
|
122
|
-
while (root && root.parentNode) {
|
|
123
|
-
root = root.parentNode;
|
|
124
|
-
}
|
|
125
|
-
this.attr('data', data);
|
|
126
|
-
(root as Chart).render();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
118
|
/**
|
|
130
119
|
* Apply specified callback to the node value.
|
|
131
120
|
*/
|
|
@@ -136,4 +125,13 @@ export class Node<
|
|
|
136
125
|
callback(this.map(), ...params);
|
|
137
126
|
return this;
|
|
138
127
|
}
|
|
128
|
+
|
|
129
|
+
root(): Chart {
|
|
130
|
+
// Find the root chart and render.
|
|
131
|
+
let root: Node = this;
|
|
132
|
+
while (root && root.parentNode) {
|
|
133
|
+
root = root.parentNode;
|
|
134
|
+
}
|
|
135
|
+
return root as Chart;
|
|
136
|
+
}
|
|
139
137
|
}
|
package/src/api/props.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { isObject, deepMix, get, isString, isArray } from '@antv/util';
|
|
2
|
-
|
|
3
|
-
type EventListener = (...args: any[]) => void;
|
|
4
|
-
|
|
5
1
|
export type NodePropertyDescriptor = {
|
|
6
2
|
type: 'object' | 'value' | 'array' | 'node' | 'container' | 'event';
|
|
7
3
|
name: string;
|
|
@@ -51,24 +47,6 @@ function defineContainerProp(Node, { name, ctor }: NodePropertyDescriptor) {
|
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
function defineEventProp(Node, { name, key = name }: NodePropertyDescriptor) {
|
|
55
|
-
Node.prototype[name] = function (
|
|
56
|
-
eventName: string,
|
|
57
|
-
listener: EventListener | EventListener[],
|
|
58
|
-
) {
|
|
59
|
-
const events = this.attr(key) || {};
|
|
60
|
-
if (arguments.length === 0) return events;
|
|
61
|
-
if (arguments.length === 1) return events[eventName];
|
|
62
|
-
const listeners = events[eventName];
|
|
63
|
-
if (listeners) {
|
|
64
|
-
isArray(listener) ? listeners.concat(listener) : listeners.push(listener);
|
|
65
|
-
} else {
|
|
66
|
-
events[eventName] = isArray(listener) ? listener : [listener];
|
|
67
|
-
}
|
|
68
|
-
return this.attr(key, events);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
50
|
/**
|
|
73
51
|
* A decorator to define different type of attribute setter or
|
|
74
52
|
* getter for current node.
|
|
@@ -82,7 +60,6 @@ export function defineProps(descriptors: NodePropertyDescriptor[]) {
|
|
|
82
60
|
else if (type === 'object') defineObjectProp(Node, descriptor);
|
|
83
61
|
else if (type === 'node') defineNodeProp(Node, descriptor);
|
|
84
62
|
else if (type === 'container') defineContainerProp(Node, descriptor);
|
|
85
|
-
else if (type === 'event') defineEventProp(Node, descriptor);
|
|
86
63
|
}
|
|
87
64
|
return Node;
|
|
88
65
|
};
|
package/src/component/axis.ts
CHANGED
|
@@ -273,10 +273,17 @@ function inferOverrideStyle(
|
|
|
273
273
|
startPos: [x, y],
|
|
274
274
|
};
|
|
275
275
|
} else if (position === 'arcY') {
|
|
276
|
+
const [startAngle, endAngle] = angleOf(coordinate);
|
|
276
277
|
return {
|
|
277
278
|
startPos: [x, y],
|
|
278
279
|
endPos: [x + width, y + height],
|
|
279
280
|
gridCenter: [bbox.x, cy + bbox.y],
|
|
281
|
+
gridControlAngles: new Array(3)
|
|
282
|
+
.fill(0)
|
|
283
|
+
.map(
|
|
284
|
+
(d, i, arr) =>
|
|
285
|
+
90 + startAngle + ((endAngle - startAngle) / (arr.length - 1)) * i,
|
|
286
|
+
),
|
|
280
287
|
};
|
|
281
288
|
}
|
|
282
289
|
|
|
@@ -8,8 +8,21 @@ import { titleContent } from './utils';
|
|
|
8
8
|
export type LegendContinuousOptions = {
|
|
9
9
|
position?: GuideComponentPosition;
|
|
10
10
|
title?: string | string[];
|
|
11
|
+
[key: string]: any;
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
function inferContinuousLayout(options: LegendContinuousOptions) {
|
|
15
|
+
const { position = 'top', size, length = 200 } = options;
|
|
16
|
+
const layouts = {
|
|
17
|
+
left: ['vertical', size, length],
|
|
18
|
+
right: ['vertical', size, length],
|
|
19
|
+
top: ['horizontal', length, size],
|
|
20
|
+
bottom: ['horizontal', length, size],
|
|
21
|
+
};
|
|
22
|
+
const [orient, width, height] = layouts[position];
|
|
23
|
+
return { orient, width, height };
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* Guide Component for continuous color scale.
|
|
15
28
|
* @todo Custom style.
|
|
@@ -30,17 +43,14 @@ export const LegendContinuous: GCC<LegendContinuousOptions> = (options) => {
|
|
|
30
43
|
{
|
|
31
44
|
x,
|
|
32
45
|
y,
|
|
33
|
-
width: 400,
|
|
34
|
-
height: 300,
|
|
35
46
|
data: [{ value: min }, { value: max }],
|
|
36
47
|
titleText: titleContent(title),
|
|
37
48
|
titleFontSize: 12,
|
|
38
|
-
ribbonLen: 120,
|
|
39
|
-
ribbonSize: 12,
|
|
40
49
|
ribbonColor: domain.map((d) => scale.map(d)),
|
|
41
50
|
showHandle: false,
|
|
42
51
|
showIndicator: false,
|
|
43
52
|
labelAlign: 'value',
|
|
53
|
+
...inferContinuousLayout(options),
|
|
44
54
|
},
|
|
45
55
|
rest,
|
|
46
56
|
),
|
|
@@ -51,5 +61,5 @@ export const LegendContinuous: GCC<LegendContinuousOptions> = (options) => {
|
|
|
51
61
|
LegendContinuous.props = {
|
|
52
62
|
defaultPosition: 'top',
|
|
53
63
|
defaultOrder: 1,
|
|
54
|
-
defaultSize:
|
|
64
|
+
defaultSize: 50,
|
|
55
65
|
};
|
package/src/component/slider.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Slider as SliderComponent } from '@antv/gui';
|
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
3
|
import { least } from 'd3-array';
|
|
4
4
|
import { GuideComponentComponent as GCC, Scale } from '../runtime';
|
|
5
|
+
import { invert } from '../utils/scale';
|
|
5
6
|
|
|
6
7
|
export type SliderOptions = {
|
|
7
8
|
orient: 'horizontal' | 'vertical';
|
|
@@ -34,7 +35,8 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
34
35
|
orient,
|
|
35
36
|
formatter: (v) => {
|
|
36
37
|
const f = formatter || defaultFormatter;
|
|
37
|
-
|
|
38
|
+
// @todo Pass index to distinguish the left and the right value.
|
|
39
|
+
const tick = invert(scale, v, true);
|
|
38
40
|
return f(tick);
|
|
39
41
|
},
|
|
40
42
|
...rest,
|
|
@@ -43,17 +45,6 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
/**
|
|
47
|
-
* Translate [0,1] value to origin value.
|
|
48
|
-
*/
|
|
49
|
-
function invertTick(scale: Scale, v: number) {
|
|
50
|
-
if (!scale.getBandWidth) return scale.invert(v);
|
|
51
|
-
// @ts-ignore @todo should support in scale
|
|
52
|
-
const range = scale.adjustedRange as number[];
|
|
53
|
-
const abs = (v) => Math.abs(v);
|
|
54
|
-
return scale.invert(least(range, (a, b) => abs(a - v) - abs(b - v)));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
48
|
Slider.props = {
|
|
58
49
|
defaultPosition: 'bottom',
|
|
59
50
|
defaultSize: 24,
|
|
Binary file
|
|
File without changes
|
package/src/geo/geoView.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { geoPath, geoGraticule10 } from 'd3-geo';
|
|
|
4
4
|
import { CompositionComponent as CC } from '../runtime';
|
|
5
5
|
import { GeoViewComposition } from '../spec';
|
|
6
6
|
|
|
7
|
-
import * as d3Projection from './
|
|
7
|
+
import * as d3Projection from './d3Projection';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Get projection factory from d3-projection.
|
package/src/interaction/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { ChartIndex } from './native/chartIndex';
|
|
|
10
10
|
export { Fisheye } from './native/fisheye';
|
|
11
11
|
export { Tooltip } from './native/tooltip';
|
|
12
12
|
export { LegendFilter } from './native/legendFilter';
|
|
13
|
+
export { LegendHighlight } from './native/legendHighlight';
|
|
13
14
|
export { BrushHighlight } from './native/brushHighlight';
|
|
14
15
|
export { BrushXHighlight } from './native/brushXHighlight';
|
|
15
16
|
export { BrushYHighlight } from './native/brushYHighlight';
|
|
@@ -17,6 +18,7 @@ export { BrushAxisHighlight } from './native/brushAxisHighlight';
|
|
|
17
18
|
export { BrushFilter } from './native/brushFilter';
|
|
18
19
|
export { BrushXFilter } from './native/brushXFilter';
|
|
19
20
|
export { BrushYFilter } from './native/brushYFilter';
|
|
21
|
+
export { SliderFilter } from './native/sliderFilter';
|
|
20
22
|
|
|
21
23
|
export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
|
|
22
24
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
|
-
import { bisectLeft, sort } from 'd3-array';
|
|
3
2
|
import { subObject } from '../../utils/helper';
|
|
4
|
-
import {
|
|
3
|
+
import { invert, domainOf } from '../../utils/scale';
|
|
5
4
|
import { brush as createBrush } from './brushHighlight';
|
|
5
|
+
import { selectPlotArea } from './utils';
|
|
6
6
|
|
|
7
7
|
// Mock dblclick events.
|
|
8
8
|
function dblclick(interval = 300) {
|
|
@@ -64,37 +64,7 @@ export function brushFilter(
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function
|
|
68
|
-
return scale.getBandWidth;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function constrain(x, lo, hi) {
|
|
72
|
-
return Math.min(hi, Math.max(lo, x));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function invert(scale, x, start) {
|
|
76
|
-
if (!isOrdinalScale(scale)) return scale.invert(x);
|
|
77
|
-
const { adjustedRange } = scale;
|
|
78
|
-
const { domain } = scale.getOptions();
|
|
79
|
-
const offset = start ? -1 : 0;
|
|
80
|
-
const step = scale.getStep();
|
|
81
|
-
const range = start ? adjustedRange : adjustedRange.map((d) => d + step);
|
|
82
|
-
// R[i0 - 1] < x <= R[i0]
|
|
83
|
-
const i0 = bisectLeft(range, x);
|
|
84
|
-
const i1 = constrain(i0 + offset, 0, domain.length - 1);
|
|
85
|
-
return domain[i1];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function domainOf(scale, values) {
|
|
89
|
-
if (!isOrdinalScale(scale)) return sort(values);
|
|
90
|
-
const { domain } = scale.getOptions();
|
|
91
|
-
const [v1, v2] = values;
|
|
92
|
-
const start = domain.indexOf(v1);
|
|
93
|
-
const end = domain.indexOf(v2);
|
|
94
|
-
return domain.slice(start, end + 1);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function BrushFilter({ ...rest }) {
|
|
67
|
+
export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
98
68
|
return (target, viewInstances) => {
|
|
99
69
|
const { container, view, options: viewOptions, update } = target;
|
|
100
70
|
const plotArea = selectPlotArea(container);
|
|
@@ -130,12 +100,22 @@ export function BrushFilter({ ...rest }) {
|
|
|
130
100
|
// Update the domain of x and y scale to filter data.
|
|
131
101
|
const { marks } = viewOptions;
|
|
132
102
|
const newMarks = marks.map((mark) =>
|
|
133
|
-
deepMix(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
103
|
+
deepMix(
|
|
104
|
+
{
|
|
105
|
+
// Hide label to keep smooth transition.
|
|
106
|
+
axis: {
|
|
107
|
+
...(hideX && { x: { labelTransforms: [{ type: 'hide' }] } }),
|
|
108
|
+
...(hideY && { y: { labelTransforms: [{ type: 'hide' }] } }),
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
mark,
|
|
112
|
+
{
|
|
113
|
+
scale: {
|
|
114
|
+
x: { domain: domainOf(scaleX, [p0[0], p1[0]]) },
|
|
115
|
+
y: { domain: domainOf(scaleY, [p0[1], p1[1]]) },
|
|
116
|
+
},
|
|
137
117
|
},
|
|
138
|
-
|
|
118
|
+
),
|
|
139
119
|
);
|
|
140
120
|
|
|
141
121
|
// Rerender and update view.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { group } from 'd3-array';
|
|
3
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
3
4
|
import { subObject } from '../../utils/helper';
|
|
4
5
|
import {
|
|
5
6
|
createValueof,
|
|
@@ -8,6 +9,9 @@ import {
|
|
|
8
9
|
useState,
|
|
9
10
|
renderLink,
|
|
10
11
|
applyDefaultsHighlightedStyle,
|
|
12
|
+
renderBackground,
|
|
13
|
+
selectPlotArea,
|
|
14
|
+
offsetTransform,
|
|
11
15
|
} from './utils';
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -20,6 +24,11 @@ export function elementHighlight(
|
|
|
20
24
|
datum, // given each element returns the datum of it
|
|
21
25
|
groupKey = (d) => d, // group elements by specified key
|
|
22
26
|
link = false, // draw link or not
|
|
27
|
+
background = false, // draw background or not
|
|
28
|
+
delay = 60, // delay to unhighlighted element
|
|
29
|
+
scale,
|
|
30
|
+
coordinate,
|
|
31
|
+
offset = 0,
|
|
23
32
|
...rest
|
|
24
33
|
}: Record<string, any>,
|
|
25
34
|
) {
|
|
@@ -27,49 +36,107 @@ export function elementHighlight(
|
|
|
27
36
|
const elementSet = new Set(elements);
|
|
28
37
|
const keyGroup = group(elements, groupKey);
|
|
29
38
|
const valueof = createValueof(elements, datum);
|
|
30
|
-
const [appendLink, removeLink] = renderLink(
|
|
39
|
+
const [appendLink, removeLink] = renderLink({
|
|
31
40
|
elements,
|
|
32
41
|
valueof,
|
|
42
|
+
link,
|
|
43
|
+
coordinate,
|
|
33
44
|
...subObject(rest, 'link'),
|
|
34
45
|
});
|
|
35
|
-
const
|
|
46
|
+
const [appendBackground, removeBackground, isBackground] = renderBackground({
|
|
47
|
+
scale,
|
|
48
|
+
coordinate,
|
|
49
|
+
background,
|
|
50
|
+
valueof,
|
|
51
|
+
...subObject(rest, 'background'),
|
|
52
|
+
});
|
|
53
|
+
const elementStyle = {
|
|
54
|
+
...(offset !== 0 && {
|
|
55
|
+
// Apply translate to mock slice out.
|
|
56
|
+
highlightedTransform: (_, i) => {
|
|
57
|
+
return offsetTransform(elements[i], offset, coordinate);
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
...rest,
|
|
61
|
+
};
|
|
62
|
+
const { setState, removeState, hasState } = useState(elementStyle, valueof);
|
|
36
63
|
|
|
64
|
+
let out; // Timer for delaying unhighlighted.
|
|
37
65
|
const pointerover = (event) => {
|
|
38
66
|
const { target: element } = event;
|
|
39
67
|
if (!elementSet.has(element)) return;
|
|
68
|
+
if (out) clearTimeout(out);
|
|
40
69
|
const k = groupKey(element);
|
|
41
70
|
const group = keyGroup.get(k);
|
|
42
71
|
const groupSet = new Set(group);
|
|
43
72
|
for (const e of elements) {
|
|
44
|
-
if (groupSet.has(e))
|
|
45
|
-
|
|
73
|
+
if (groupSet.has(e)) {
|
|
74
|
+
if (!hasState(e, 'highlighted')) setState(e, 'highlighted');
|
|
75
|
+
} else {
|
|
76
|
+
setState(e, 'unhighlighted');
|
|
77
|
+
removeLink(e);
|
|
78
|
+
}
|
|
79
|
+
if (e !== element) removeBackground(e);
|
|
80
|
+
}
|
|
81
|
+
appendBackground(element);
|
|
82
|
+
appendLink(group);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const delayUnhighlighted = () => {
|
|
86
|
+
if (out) clearTimeout(out);
|
|
87
|
+
out = setTimeout(() => {
|
|
88
|
+
unhighlighted();
|
|
89
|
+
out = null;
|
|
90
|
+
}, delay);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const unhighlighted = () => {
|
|
94
|
+
for (const e of elements) {
|
|
95
|
+
removeState(e, 'unhighlighted', 'highlighted');
|
|
96
|
+
removeBackground(e);
|
|
97
|
+
removeLink(e);
|
|
46
98
|
}
|
|
47
|
-
if (link) appendLink(group);
|
|
48
99
|
};
|
|
49
100
|
|
|
50
101
|
const pointerout = (event) => {
|
|
51
102
|
const { target: element } = event;
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
if (
|
|
103
|
+
if (background && !isBackground(element)) return;
|
|
104
|
+
if (!background && !elementSet.has(element)) return;
|
|
105
|
+
if (delay > 0) delayUnhighlighted();
|
|
106
|
+
else unhighlighted();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const pointerleave = () => {
|
|
110
|
+
unhighlighted();
|
|
55
111
|
};
|
|
56
112
|
|
|
57
113
|
root.addEventListener('pointerover', pointerover);
|
|
58
114
|
root.addEventListener('pointerout', pointerout);
|
|
115
|
+
root.addEventListener('pointerleave', pointerleave);
|
|
59
116
|
|
|
60
117
|
return () => {
|
|
61
118
|
root.removeEventListener('pointerover', pointerover);
|
|
62
119
|
root.removeEventListener('pointerout', pointerout);
|
|
120
|
+
root.removeEventListener('pointerleave', pointerleave);
|
|
121
|
+
for (const e of elements) {
|
|
122
|
+
removeBackground(e);
|
|
123
|
+
removeLink(e);
|
|
124
|
+
}
|
|
63
125
|
};
|
|
64
126
|
}
|
|
65
127
|
|
|
66
|
-
export function ElementHighlight(
|
|
128
|
+
export function ElementHighlight({ delay, ...rest }) {
|
|
67
129
|
return (context) => {
|
|
68
130
|
const { container, view } = context;
|
|
69
|
-
|
|
70
|
-
|
|
131
|
+
const { scale, coordinate } = view;
|
|
132
|
+
const plotArea = selectPlotArea(container);
|
|
133
|
+
return elementHighlight(plotArea, {
|
|
134
|
+
...applyDefaultsHighlightedStyle(rest),
|
|
71
135
|
elements: selectG2Elements,
|
|
72
136
|
datum: createDatumof(view),
|
|
137
|
+
scale,
|
|
138
|
+
coordinate,
|
|
139
|
+
delay,
|
|
73
140
|
});
|
|
74
141
|
};
|
|
75
142
|
}
|