@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
|
@@ -3,21 +3,26 @@ import {
|
|
|
3
3
|
createDatumof,
|
|
4
4
|
selectG2Elements,
|
|
5
5
|
createColorKey,
|
|
6
|
+
selectPlotArea,
|
|
6
7
|
} from './utils';
|
|
7
8
|
import { elementHighlight } from './elementHighlight';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @todo Bind abstract data or data index.
|
|
11
12
|
*/
|
|
12
|
-
export function ElementHighlightByColor(
|
|
13
|
+
export function ElementHighlightByColor({ delay, ...rest }) {
|
|
13
14
|
return (context) => {
|
|
14
15
|
const { container, view } = context;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const { scale, coordinate } = view;
|
|
17
|
+
const plotArea = selectPlotArea(container);
|
|
18
|
+
return elementHighlight(plotArea, {
|
|
19
|
+
...applyDefaultsHighlightedStyle(rest),
|
|
18
20
|
elements: selectG2Elements,
|
|
19
21
|
datum: createDatumof(view),
|
|
20
22
|
groupKey: createColorKey(view),
|
|
23
|
+
scale,
|
|
24
|
+
coordinate,
|
|
25
|
+
delay,
|
|
21
26
|
});
|
|
22
27
|
};
|
|
23
28
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
createDatumof,
|
|
4
4
|
selectG2Elements,
|
|
5
5
|
createXKey,
|
|
6
|
+
selectPlotArea,
|
|
6
7
|
} from './utils';
|
|
7
8
|
import { elementHighlight } from './elementHighlight';
|
|
8
9
|
|
|
@@ -10,16 +11,19 @@ import { elementHighlight } from './elementHighlight';
|
|
|
10
11
|
*
|
|
11
12
|
* @todo Bind abstract data or data index.
|
|
12
13
|
*/
|
|
13
|
-
export function ElementHighlightByX(
|
|
14
|
-
options = { selectedLineWidth: 1, selectedColor: 'black' },
|
|
15
|
-
) {
|
|
14
|
+
export function ElementHighlightByX({ delay, ...rest }) {
|
|
16
15
|
return (context) => {
|
|
17
16
|
const { container, view } = context;
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const { scale, coordinate } = view;
|
|
18
|
+
const plotArea = selectPlotArea(container);
|
|
19
|
+
return elementHighlight(plotArea, {
|
|
20
|
+
...applyDefaultsHighlightedStyle(rest),
|
|
20
21
|
elements: selectG2Elements,
|
|
21
22
|
datum: createDatumof(view),
|
|
22
23
|
groupKey: createXKey(view),
|
|
24
|
+
scale,
|
|
25
|
+
coordinate,
|
|
26
|
+
delay,
|
|
23
27
|
});
|
|
24
28
|
};
|
|
25
29
|
}
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
useState,
|
|
9
9
|
renderLink,
|
|
10
10
|
applyDefaultsHighlightedStyle,
|
|
11
|
+
renderBackground,
|
|
12
|
+
selectPlotArea,
|
|
13
|
+
offsetTransform,
|
|
11
14
|
} from './utils';
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -21,6 +24,10 @@ export function elementSelect(
|
|
|
21
24
|
groupKey = (d) => d, // group elements by specified key
|
|
22
25
|
link = false, // draw link or not
|
|
23
26
|
single = false, // single select or not
|
|
27
|
+
coordinate,
|
|
28
|
+
background = false,
|
|
29
|
+
offset = 0,
|
|
30
|
+
scale,
|
|
24
31
|
...rest
|
|
25
32
|
}: Record<string, any>,
|
|
26
33
|
) {
|
|
@@ -28,15 +35,39 @@ export function elementSelect(
|
|
|
28
35
|
const elementSet = new Set(elements);
|
|
29
36
|
const keyGroup = group(elements, groupKey);
|
|
30
37
|
const valueof = createValueof(elements, datum);
|
|
31
|
-
const [appendLink, removeLink] = renderLink(
|
|
38
|
+
const [appendLink, removeLink] = renderLink({
|
|
39
|
+
link,
|
|
32
40
|
elements,
|
|
33
41
|
valueof,
|
|
42
|
+
coordinate,
|
|
34
43
|
...subObject(rest, 'link'),
|
|
35
44
|
});
|
|
36
|
-
|
|
45
|
+
|
|
46
|
+
const [appendBackground, removeBackground] = renderBackground({
|
|
47
|
+
background,
|
|
48
|
+
coordinate,
|
|
49
|
+
scale,
|
|
50
|
+
valueof,
|
|
51
|
+
...subObject(rest, 'background'),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const elementStyle = {
|
|
55
|
+
...(offset !== 0 && {
|
|
56
|
+
// Apply translate to mock slice out.
|
|
57
|
+
selectedTransform: (_, i) => {
|
|
58
|
+
return offsetTransform(elements[i], offset, coordinate);
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
...rest,
|
|
62
|
+
};
|
|
63
|
+
const { setState, removeState, hasState } = useState(elementStyle, valueof);
|
|
64
|
+
|
|
37
65
|
const clear = () => {
|
|
38
|
-
for (const e of elements)
|
|
39
|
-
|
|
66
|
+
for (const e of elements) {
|
|
67
|
+
removeState(e, 'selected', 'unselected');
|
|
68
|
+
removeLink(e);
|
|
69
|
+
removeBackground(e);
|
|
70
|
+
}
|
|
40
71
|
return;
|
|
41
72
|
};
|
|
42
73
|
|
|
@@ -49,13 +80,14 @@ export function elementSelect(
|
|
|
49
80
|
const groupSet = new Set(group);
|
|
50
81
|
for (const e of elements) {
|
|
51
82
|
if (groupSet.has(e)) setState(e, 'selected');
|
|
52
|
-
else
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
appendLink(group);
|
|
83
|
+
else {
|
|
84
|
+
setState(e, 'unselected');
|
|
85
|
+
removeLink(e);
|
|
86
|
+
}
|
|
87
|
+
if (e !== element) removeBackground(e);
|
|
58
88
|
}
|
|
89
|
+
appendLink(group);
|
|
90
|
+
appendBackground(element);
|
|
59
91
|
}
|
|
60
92
|
};
|
|
61
93
|
|
|
@@ -70,7 +102,8 @@ export function elementSelect(
|
|
|
70
102
|
else if (!hasState(e, 'selected')) setState(e, 'unselected');
|
|
71
103
|
}
|
|
72
104
|
// Append link for each group only once.
|
|
73
|
-
if (!hasSelectedGroup && link) appendLink(group
|
|
105
|
+
if (!hasSelectedGroup && link) appendLink(group);
|
|
106
|
+
appendBackground(element);
|
|
74
107
|
} else {
|
|
75
108
|
// If there is no selected elements after resetting this group,
|
|
76
109
|
// clear the states.
|
|
@@ -80,8 +113,11 @@ export function elementSelect(
|
|
|
80
113
|
if (!hasSelected) return clear();
|
|
81
114
|
// If there are still some selected elements after resetting this group,
|
|
82
115
|
// only remove the link.
|
|
83
|
-
for (const e of group)
|
|
84
|
-
|
|
116
|
+
for (const e of group) {
|
|
117
|
+
setState(e, 'unselected');
|
|
118
|
+
removeLink(e);
|
|
119
|
+
removeBackground(e);
|
|
120
|
+
}
|
|
85
121
|
}
|
|
86
122
|
};
|
|
87
123
|
|
|
@@ -98,16 +134,24 @@ export function elementSelect(
|
|
|
98
134
|
|
|
99
135
|
return () => {
|
|
100
136
|
root.removeEventListener('click', click);
|
|
137
|
+
for (const e of elements) {
|
|
138
|
+
removeLink(e);
|
|
139
|
+
}
|
|
101
140
|
};
|
|
102
141
|
}
|
|
103
142
|
|
|
104
143
|
export function ElementSelect(options) {
|
|
105
144
|
return (context) => {
|
|
106
145
|
const { container, view } = context;
|
|
107
|
-
|
|
146
|
+
const { coordinate, scale } = view;
|
|
147
|
+
const plotArea = selectPlotArea(container);
|
|
148
|
+
return elementSelect(plotArea, {
|
|
149
|
+
...options,
|
|
108
150
|
...applyDefaultsHighlightedStyle(options),
|
|
109
151
|
elements: selectG2Elements,
|
|
110
152
|
datum: createDatumof(view),
|
|
153
|
+
coordinate,
|
|
154
|
+
scale,
|
|
111
155
|
});
|
|
112
156
|
};
|
|
113
157
|
}
|
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
selectG2Elements,
|
|
4
4
|
applyDefaultsHighlightedStyle,
|
|
5
5
|
createColorKey,
|
|
6
|
+
selectPlotArea,
|
|
6
7
|
} from './utils';
|
|
7
8
|
import { elementSelect } from './elementSelect';
|
|
8
9
|
|
|
9
10
|
export function ElementSelectByColor(options) {
|
|
10
11
|
return (context) => {
|
|
11
12
|
const { container, view } = context;
|
|
12
|
-
|
|
13
|
+
const plot = selectPlotArea(container);
|
|
14
|
+
return elementSelect(plot, {
|
|
15
|
+
...options,
|
|
13
16
|
...applyDefaultsHighlightedStyle(options),
|
|
14
17
|
elements: selectG2Elements,
|
|
15
18
|
datum: createDatumof(view),
|
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
selectG2Elements,
|
|
4
4
|
applyDefaultsHighlightedStyle,
|
|
5
5
|
createXKey,
|
|
6
|
+
selectPlotArea,
|
|
6
7
|
} from './utils';
|
|
7
8
|
import { elementSelect } from './elementSelect';
|
|
8
9
|
|
|
9
10
|
export function ElementSelectByX(options) {
|
|
10
11
|
return (context) => {
|
|
11
12
|
const { container, view } = context;
|
|
12
|
-
|
|
13
|
+
const plot = selectPlotArea(container);
|
|
14
|
+
return elementSelect(plot, {
|
|
15
|
+
...options,
|
|
13
16
|
...applyDefaultsHighlightedStyle(options),
|
|
14
17
|
elements: selectG2Elements,
|
|
15
18
|
datum: createDatumof(view),
|
|
@@ -11,18 +11,22 @@ export const LEGEND_MAKER_CLASS_NAME = 'legend-category-item-marker';
|
|
|
11
11
|
|
|
12
12
|
export const LEGEND_LABEL_CLASS_NAME = 'legend-category-item-label';
|
|
13
13
|
|
|
14
|
-
function markerOf(item) {
|
|
14
|
+
export function markerOf(item) {
|
|
15
15
|
return item.getElementsByClassName(LEGEND_MAKER_CLASS_NAME)[0];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function labelOf(item) {
|
|
18
|
+
export function labelOf(item) {
|
|
19
19
|
return item.getElementsByClassName(LEGEND_LABEL_CLASS_NAME)[0];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
export function itemsOf(root) {
|
|
23
23
|
return root.getElementsByClassName(LEGEND_ITEMS_CLASS_NAME);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export function legendsOf(root) {
|
|
27
|
+
return root.getElementsByClassName(CATEGORY_LEGEND_CLASS_NAME);
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
function builtInAccessors(selectedLegend) {
|
|
27
31
|
// Get the value and scale type from legend.
|
|
28
32
|
const { data } = selectedLegend.attributes;
|
|
@@ -31,7 +35,7 @@ function builtInAccessors(selectedLegend) {
|
|
|
31
35
|
return [
|
|
32
36
|
channel,
|
|
33
37
|
{
|
|
34
|
-
legends:
|
|
38
|
+
legends: itemsOf,
|
|
35
39
|
marker: markerOf,
|
|
36
40
|
label: labelOf,
|
|
37
41
|
datum: (d) => {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { group } from 'd3-array';
|
|
2
|
+
import { subObject } from '../../utils/helper';
|
|
3
|
+
import { selectG2Elements, useState } from './utils';
|
|
4
|
+
import { markerOf, labelOf, itemsOf, legendsOf } from './legendFilter';
|
|
5
|
+
|
|
6
|
+
export function LegendHighlight({ channel, ...rest }) {
|
|
7
|
+
return (context) => {
|
|
8
|
+
const { container, view } = context;
|
|
9
|
+
const legends = legendsOf(container);
|
|
10
|
+
const elements = selectG2Elements(container);
|
|
11
|
+
const channelOf = (legend) => {
|
|
12
|
+
const { __data__ } = legend.parentNode;
|
|
13
|
+
return __data__.scale.name;
|
|
14
|
+
};
|
|
15
|
+
const scaleOf = (channel) => {
|
|
16
|
+
const {
|
|
17
|
+
scale: { [channel]: scale },
|
|
18
|
+
} = view;
|
|
19
|
+
return scale;
|
|
20
|
+
};
|
|
21
|
+
for (const legend of legends) {
|
|
22
|
+
const datumOf = (item) => {
|
|
23
|
+
const { data } = legend.attributes;
|
|
24
|
+
const { __data__: datum } = item;
|
|
25
|
+
const { index } = datum;
|
|
26
|
+
return data[index].label;
|
|
27
|
+
};
|
|
28
|
+
const channel = channelOf(legend);
|
|
29
|
+
const items = itemsOf(legend);
|
|
30
|
+
const scale = scaleOf(channel);
|
|
31
|
+
const elementGroup = group<any, any>(elements, (d) =>
|
|
32
|
+
scale.invert(d.__data__[channel]),
|
|
33
|
+
);
|
|
34
|
+
const { setState, removeState } = useState(rest);
|
|
35
|
+
const markerStyle = subObject(rest, 'marker');
|
|
36
|
+
const labelStyle = subObject(rest, 'label');
|
|
37
|
+
const { setState: setM, removeState: removeM } = useState(markerStyle);
|
|
38
|
+
const { setState: setL, removeState: removeL } = useState(labelStyle);
|
|
39
|
+
const updateLegendState = (highlight) => {
|
|
40
|
+
for (const item of items) {
|
|
41
|
+
const marker = markerOf(item);
|
|
42
|
+
const label = labelOf(item);
|
|
43
|
+
if (item === highlight || highlight === null) {
|
|
44
|
+
removeM(marker, 'unhighlighted');
|
|
45
|
+
removeL(label, 'unhighlighted');
|
|
46
|
+
} else {
|
|
47
|
+
setM(marker, 'unhighlighted');
|
|
48
|
+
setL(label, 'unhighlighted');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const itemPointerover = new Map();
|
|
54
|
+
|
|
55
|
+
// Add listener for the legend items.
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
const pointerover = () => {
|
|
58
|
+
const value = datumOf(item);
|
|
59
|
+
const elementSet = new Set(elementGroup.get(value));
|
|
60
|
+
for (const e of elements) {
|
|
61
|
+
if (elementSet.has(e)) setState(e, 'highlighted');
|
|
62
|
+
else setState(e, 'unhighlighted');
|
|
63
|
+
}
|
|
64
|
+
updateLegendState(item);
|
|
65
|
+
};
|
|
66
|
+
item.addEventListener('pointerover', pointerover);
|
|
67
|
+
itemPointerover.set(item, pointerover);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Add listener for the legend group.
|
|
71
|
+
const pointerleave = () => {
|
|
72
|
+
for (const e of elements) {
|
|
73
|
+
removeState(e, 'unhighlighted', 'highlighted');
|
|
74
|
+
}
|
|
75
|
+
updateLegendState(null);
|
|
76
|
+
};
|
|
77
|
+
legend.addEventListener('pointerleave', pointerleave);
|
|
78
|
+
|
|
79
|
+
return () => {
|
|
80
|
+
legend.removeEventListener(pointerleave);
|
|
81
|
+
for (const [item, pointerover] of itemPointerover) {
|
|
82
|
+
item.removeEventListener(pointerover);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { deepMix, throttle } from '@antv/util';
|
|
2
|
+
import { invert, domainOf } from '../../utils/scale';
|
|
3
|
+
|
|
4
|
+
export const SLIDER_CLASS_NAME = 'slider';
|
|
5
|
+
|
|
6
|
+
function filterDataByDomain(options, scaleOptions) {
|
|
7
|
+
const { marks } = options;
|
|
8
|
+
const newMarks = marks.map((mark) =>
|
|
9
|
+
deepMix(
|
|
10
|
+
{
|
|
11
|
+
// Hide label to keep smooth transition.
|
|
12
|
+
axis: {
|
|
13
|
+
x: { labelTransforms: [{ type: 'hide' }] },
|
|
14
|
+
y: { labelTransforms: [{ type: 'hide' }] },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
mark,
|
|
18
|
+
{
|
|
19
|
+
scale: scaleOptions,
|
|
20
|
+
// Don't rerender sliders.
|
|
21
|
+
slider: {
|
|
22
|
+
...(mark.slider.x && { x: { preserve: true } }),
|
|
23
|
+
...(mark.slider.y && { y: { preserve: true } }),
|
|
24
|
+
},
|
|
25
|
+
animate: false,
|
|
26
|
+
},
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Rerender and update view.
|
|
31
|
+
return {
|
|
32
|
+
...options,
|
|
33
|
+
marks: newMarks,
|
|
34
|
+
clip: true, // Clip shapes out of plot area.
|
|
35
|
+
animate: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function abstractValue(values, scale) {
|
|
40
|
+
const [x, x1] = values;
|
|
41
|
+
const d0 = invert(scale, x, true);
|
|
42
|
+
const d1 = invert(scale, x1, false);
|
|
43
|
+
return domainOf(scale, [d0, d1]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @todo Support click to reset after fix click and dragend conflict.
|
|
48
|
+
*/
|
|
49
|
+
export function SliderFilter({
|
|
50
|
+
wait = 50,
|
|
51
|
+
leading = true,
|
|
52
|
+
trailing = false,
|
|
53
|
+
}: any) {
|
|
54
|
+
return (context) => {
|
|
55
|
+
const { container, view, options, update } = context;
|
|
56
|
+
const sliders = container.getElementsByClassName(SLIDER_CLASS_NAME);
|
|
57
|
+
if (!sliders.length) return;
|
|
58
|
+
|
|
59
|
+
let filtering = false;
|
|
60
|
+
const { scale } = view;
|
|
61
|
+
const { x: scaleX, y: scaleY } = scale;
|
|
62
|
+
|
|
63
|
+
const sliderHandler = new Map();
|
|
64
|
+
|
|
65
|
+
// Store current domain of x and y scale.
|
|
66
|
+
const channelDomain = {
|
|
67
|
+
x: scaleX.getOptions().domain,
|
|
68
|
+
y: scaleY.getOptions().domain,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
for (const slider of sliders) {
|
|
72
|
+
const { orient } = slider.attributes;
|
|
73
|
+
|
|
74
|
+
const onValueChange = throttle(
|
|
75
|
+
async (event) => {
|
|
76
|
+
const { value: values } = event.detail;
|
|
77
|
+
if (filtering) return;
|
|
78
|
+
filtering = true;
|
|
79
|
+
|
|
80
|
+
// Update domain of the current channel.
|
|
81
|
+
const channel0 = orient === 'vertical' ? 'y' : 'x';
|
|
82
|
+
const scale0 = scale[channel0];
|
|
83
|
+
const domain0 = abstractValue(values, scale0);
|
|
84
|
+
channelDomain[channel0] = domain0;
|
|
85
|
+
|
|
86
|
+
// Get domain of the other channel.
|
|
87
|
+
const channel1 = orient === 'vertical' ? 'x' : 'y';
|
|
88
|
+
const domain1 = channelDomain[channel1];
|
|
89
|
+
|
|
90
|
+
// Filter data.
|
|
91
|
+
const newOptions = filterDataByDomain(options, {
|
|
92
|
+
[channel0]: { domain: domain0 },
|
|
93
|
+
[channel1]: { domain: domain1 },
|
|
94
|
+
});
|
|
95
|
+
await update(newOptions);
|
|
96
|
+
filtering = false;
|
|
97
|
+
},
|
|
98
|
+
wait,
|
|
99
|
+
{ leading, trailing },
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
slider.addEventListener('valuechange', onValueChange);
|
|
103
|
+
sliderHandler.set(slider, onValueChange);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return () => {
|
|
107
|
+
for (const [slider, handler] of sliderHandler) {
|
|
108
|
+
slider.removeEventListener('valuechange', handler);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -72,6 +72,14 @@ function hideTooltip(root) {
|
|
|
72
72
|
if (tooltipElement) tooltipElement.hide();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function destroyTooltip(root) {
|
|
76
|
+
const { tooltipElement } = root;
|
|
77
|
+
if (tooltipElement) {
|
|
78
|
+
tooltipElement.destroy();
|
|
79
|
+
root.tooltipElement = undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
75
83
|
function filterDefined(obj) {
|
|
76
84
|
return Object.fromEntries(
|
|
77
85
|
Object.entries(obj).filter(([, value]) => defined(value)),
|
|
@@ -384,6 +392,8 @@ export function seriesTooltip(
|
|
|
384
392
|
root.removeEventListener('pointerover', update);
|
|
385
393
|
root.removeEventListener('pointerout', update);
|
|
386
394
|
root.removeEventListener('pointerleave', hide);
|
|
395
|
+
destroyTooltip(root);
|
|
396
|
+
if (crosshairs) hideRuleY(root);
|
|
387
397
|
};
|
|
388
398
|
}
|
|
389
399
|
|
|
@@ -437,6 +447,7 @@ export function tooltip(
|
|
|
437
447
|
root.removeEventListener('pointerover', pointerover);
|
|
438
448
|
root.removeEventListener('pointermove', pointerover);
|
|
439
449
|
root.removeEventListener('pointerout', pointerout);
|
|
450
|
+
destroyTooltip(root);
|
|
440
451
|
};
|
|
441
452
|
}
|
|
442
453
|
|