@antv/g2 5.2.10 → 5.2.12
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/g2.lite.min.js +22 -22
- package/dist/g2.min.js +22 -22
- package/esm/animation/scaleInY.js +2 -20
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/waveIn.js +1 -1
- package/esm/animation/waveIn.js.map +1 -1
- package/esm/api/runtime.js +2 -1
- package/esm/api/runtime.js.map +1 -1
- package/esm/component/axis.js +2 -2
- package/esm/component/axis.js.map +1 -1
- package/esm/component/legendCategory.js +6 -2
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +1 -1
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/slider.js +1 -1
- package/esm/component/slider.js.map +1 -1
- package/esm/composition/d3Projection.d.ts +1 -1
- package/esm/composition/d3Projection.js +1 -1
- package/esm/composition/d3Projection.js.map +1 -1
- package/esm/composition/facetRect.js +1 -1
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/composition/geoView.js +1 -1
- package/esm/composition/geoView.js.map +1 -1
- package/esm/data/cluster.d.ts +1 -1
- package/esm/data/cluster.js +1 -1
- package/esm/data/cluster.js.map +1 -1
- package/esm/data/fetch.js +1 -1
- package/esm/data/fetch.js.map +1 -1
- package/esm/data/join.js +1 -1
- package/esm/data/join.js.map +1 -1
- package/esm/data/kde.js +1 -1
- package/esm/data/kde.js.map +1 -1
- package/esm/data/tree.js +1 -1
- package/esm/data/tree.js.map +1 -1
- package/esm/data/utils/arc/arc.d.ts +25 -2
- package/esm/data/utils/arc/arc.js +1 -1
- package/esm/data/utils/arc/arc.js.map +1 -1
- package/esm/data/utils/arc/types.d.ts +27 -2
- package/esm/data/utils/d3-sankey/align.js +1 -1
- package/esm/data/utils/d3-sankey/align.js.map +1 -1
- package/esm/data/utils/d3-sankey/sankey.js +1 -1
- package/esm/data/utils/d3-sankey/sankey.js.map +1 -1
- package/esm/data/wordCloud.js +1 -1
- package/esm/data/wordCloud.js.map +1 -1
- package/esm/exports.d.ts +2 -0
- package/esm/exports.js +2 -0
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/interaction/chartIndex.js +1 -1
- package/esm/interaction/chartIndex.js.map +1 -1
- package/esm/interaction/elementHighlight.js +1 -1
- package/esm/interaction/elementHighlight.js.map +1 -1
- package/esm/interaction/elementSelect.d.ts +1 -0
- package/esm/interaction/elementSelect.js +32 -3
- package/esm/interaction/elementSelect.js.map +1 -1
- package/esm/interaction/event.d.ts +0 -1
- package/esm/interaction/event.js +2 -13
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/legendHighlight.js +1 -1
- package/esm/interaction/legendHighlight.js.map +1 -1
- package/esm/interaction/tooltip.js +8 -35
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/treemapDrillDown.d.ts +2 -2
- package/esm/interaction/treemapDrillDown.js.map +1 -1
- package/esm/interaction/utils.js +2 -2
- package/esm/interaction/utils.js.map +1 -1
- package/esm/label-transform/contrastReverse.js +1 -1
- package/esm/label-transform/contrastReverse.js.map +1 -1
- package/esm/label-transform/overlapDodgeY.js +1 -1
- package/esm/label-transform/overlapDodgeY.js.map +1 -1
- package/esm/lib/core.d.ts +1 -0
- package/esm/lib/core.js +2 -1
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +1 -0
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/boxplot.js +1 -1
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/mark/forceGraph.js +1 -1
- package/esm/mark/forceGraph.js.map +1 -1
- package/esm/mark/line.js +1 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/pack.js +1 -1
- package/esm/mark/pack.js.map +1 -1
- package/esm/mark/utils.d.ts +1 -1
- package/esm/runtime/component.js +2 -2
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +1 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/mark.js +1 -1
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/plot.js +2 -2
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.js +2 -2
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.d.ts +1 -0
- package/esm/runtime/transform.js +3 -2
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/mark.d.ts +1 -1
- package/esm/shape/area/area.js +1 -1
- package/esm/shape/area/area.js.map +1 -1
- package/esm/shape/area/curve.d.ts +1 -1
- package/esm/shape/area/curve.js +1 -1
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/area/hv.js +1 -1
- package/esm/shape/area/hv.js.map +1 -1
- package/esm/shape/area/hvh.js +1 -1
- package/esm/shape/area/hvh.js.map +1 -1
- package/esm/shape/area/smooth.js +1 -1
- package/esm/shape/area/smooth.js.map +1 -1
- package/esm/shape/area/vh.js +1 -1
- package/esm/shape/area/vh.js.map +1 -1
- package/esm/shape/box/box.js +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/box/violin.js +1 -1
- package/esm/shape/box/violin.js.map +1 -1
- package/esm/shape/connector/connector.js +1 -1
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/density/density.js +1 -1
- package/esm/shape/density/density.js.map +1 -1
- package/esm/shape/heatmap/heatmap.js +2 -2
- package/esm/shape/heatmap/heatmap.js.map +1 -1
- package/esm/shape/interval/color.js +1 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/funnel.js +1 -1
- package/esm/shape/interval/funnel.js.map +1 -1
- package/esm/shape/label/position/area.js +1 -1
- package/esm/shape/label/position/area.js.map +1 -1
- package/esm/shape/label/position/utils.js +1 -1
- package/esm/shape/label/position/utils.js.map +1 -1
- package/esm/shape/line/curve.d.ts +1 -1
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/line/hv.js +1 -1
- package/esm/shape/line/hv.js.map +1 -1
- package/esm/shape/line/hvh.js +1 -1
- package/esm/shape/line/hvh.js.map +1 -1
- package/esm/shape/line/line.js +1 -1
- package/esm/shape/line/line.js.map +1 -1
- package/esm/shape/line/smooth.js +1 -1
- package/esm/shape/line/smooth.js.map +1 -1
- package/esm/shape/line/trail.js +1 -1
- package/esm/shape/line/trail.js.map +1 -1
- package/esm/shape/line/vh.js +1 -1
- package/esm/shape/line/vh.js.map +1 -1
- package/esm/shape/lineXY/line.js +1 -1
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/link/arc.js +1 -1
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/smooth.js +1 -1
- package/esm/shape/link/smooth.js.map +1 -1
- package/esm/shape/link/vhv.js +1 -1
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/polygon/polygon.js +1 -1
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js +1 -1
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/utils.d.ts +1 -1
- package/esm/shape/utils.js +1 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js +1 -1
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/interaction.d.ts +1 -0
- package/esm/transform/bin.js +1 -1
- package/esm/transform/bin.js.map +1 -1
- package/esm/transform/flexX.js +1 -1
- package/esm/transform/flexX.js.map +1 -1
- package/esm/transform/groupN.js +1 -1
- package/esm/transform/groupN.js.map +1 -1
- package/esm/transform/normalizeY.js +1 -1
- package/esm/transform/normalizeY.js.map +1 -1
- package/esm/transform/sample.js +1 -1
- package/esm/transform/sample.js.map +1 -1
- package/esm/transform/select.js +1 -1
- package/esm/transform/select.js.map +1 -1
- package/esm/transform/sort.d.ts +1 -1
- package/esm/transform/sort.js +20 -52
- package/esm/transform/sort.js.map +1 -1
- package/esm/transform/stackEnter.js +1 -1
- package/esm/transform/stackEnter.js.map +1 -1
- package/esm/transform/symmetryY.js +1 -1
- package/esm/transform/symmetryY.js.map +1 -1
- package/esm/transform/utils/order.d.ts +1 -1
- package/esm/transform/utils/order.js +1 -1
- package/esm/transform/utils/order.js.map +1 -1
- package/esm/utils/bounds.d.ts +4 -2
- package/esm/utils/bounds.js +11 -4
- package/esm/utils/bounds.js.map +1 -1
- package/esm/utils/helper.d.ts +24 -0
- package/esm/utils/helper.js +76 -0
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/scale.js +1 -1
- package/esm/utils/scale.js.map +1 -1
- package/esm/utils/selection.js +1 -1
- package/esm/utils/selection.js.map +1 -1
- package/esm/utils/treeDataTransform.d.ts +9 -2
- package/esm/utils/treeDataTransform.js +6 -2
- package/esm/utils/treeDataTransform.js.map +1 -1
- package/lib/animation/scaleInY.js +1 -19
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/waveIn.js +1 -1
- package/lib/animation/waveIn.js.map +1 -1
- package/lib/api/runtime.js +2 -1
- package/lib/api/runtime.js.map +1 -1
- package/lib/component/axis.js +2 -2
- package/lib/component/axis.js.map +1 -1
- package/lib/component/legendCategory.js +6 -2
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +1 -1
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/slider.js +1 -1
- package/lib/component/slider.js.map +1 -1
- package/lib/composition/d3Projection.d.ts +1 -1
- package/lib/composition/d3Projection.js +1 -1
- package/lib/composition/d3Projection.js.map +1 -1
- package/lib/composition/facetRect.js +1 -1
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/composition/geoView.js +1 -1
- package/lib/composition/geoView.js.map +1 -1
- package/lib/data/cluster.d.ts +1 -1
- package/lib/data/cluster.js +1 -1
- package/lib/data/cluster.js.map +1 -1
- package/lib/data/fetch.js +1 -1
- package/lib/data/fetch.js.map +1 -1
- package/lib/data/join.js +1 -1
- package/lib/data/join.js.map +1 -1
- package/lib/data/kde.js +1 -1
- package/lib/data/kde.js.map +1 -1
- package/lib/data/tree.js +1 -1
- package/lib/data/tree.js.map +1 -1
- package/lib/data/utils/arc/arc.d.ts +25 -2
- package/lib/data/utils/arc/arc.js +1 -1
- package/lib/data/utils/arc/arc.js.map +1 -1
- package/lib/data/utils/arc/types.d.ts +27 -2
- package/lib/data/utils/d3-sankey/align.js +1 -1
- package/lib/data/utils/d3-sankey/align.js.map +1 -1
- package/lib/data/utils/d3-sankey/sankey.js +1 -1
- package/lib/data/utils/d3-sankey/sankey.js.map +1 -1
- package/lib/data/wordCloud.js +1 -1
- package/lib/data/wordCloud.js.map +1 -1
- package/lib/exports.d.ts +2 -0
- package/lib/exports.js +7 -1
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/interaction/chartIndex.js +1 -1
- package/lib/interaction/chartIndex.js.map +1 -1
- package/lib/interaction/elementHighlight.js +1 -1
- package/lib/interaction/elementHighlight.js.map +1 -1
- package/lib/interaction/elementSelect.d.ts +1 -0
- package/lib/interaction/elementSelect.js +32 -3
- package/lib/interaction/elementSelect.js.map +1 -1
- package/lib/interaction/event.d.ts +0 -1
- package/lib/interaction/event.js +3 -15
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/legendHighlight.js +1 -1
- package/lib/interaction/legendHighlight.js.map +1 -1
- package/lib/interaction/tooltip.js +10 -37
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/treemapDrillDown.d.ts +2 -2
- package/lib/interaction/treemapDrillDown.js.map +1 -1
- package/lib/interaction/utils.js +2 -2
- package/lib/interaction/utils.js.map +1 -1
- package/lib/label-transform/contrastReverse.js +1 -1
- package/lib/label-transform/contrastReverse.js.map +1 -1
- package/lib/label-transform/overlapDodgeY.js +1 -1
- package/lib/label-transform/overlapDodgeY.js.map +1 -1
- package/lib/lib/core.d.ts +1 -0
- package/lib/lib/core.js +1 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +1 -0
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/boxplot.js +1 -1
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/mark/forceGraph.js +1 -1
- package/lib/mark/forceGraph.js.map +1 -1
- package/lib/mark/line.js +1 -1
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/pack.js +1 -1
- package/lib/mark/pack.js.map +1 -1
- package/lib/mark/utils.d.ts +1 -1
- package/lib/runtime/component.js +2 -2
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +1 -1
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/mark.js +1 -1
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/plot.js +2 -2
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.js +2 -2
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.d.ts +1 -0
- package/lib/runtime/transform.js +4 -3
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/mark.d.ts +1 -1
- package/lib/shape/area/area.js +1 -1
- package/lib/shape/area/area.js.map +1 -1
- package/lib/shape/area/curve.d.ts +1 -1
- package/lib/shape/area/curve.js +1 -1
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/area/hv.js +1 -1
- package/lib/shape/area/hv.js.map +1 -1
- package/lib/shape/area/hvh.js +1 -1
- package/lib/shape/area/hvh.js.map +1 -1
- package/lib/shape/area/smooth.js +1 -1
- package/lib/shape/area/smooth.js.map +1 -1
- package/lib/shape/area/vh.js +1 -1
- package/lib/shape/area/vh.js.map +1 -1
- package/lib/shape/box/box.js +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/box/violin.js +1 -1
- package/lib/shape/box/violin.js.map +1 -1
- package/lib/shape/connector/connector.js +1 -1
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/density/density.js +1 -1
- package/lib/shape/density/density.js.map +1 -1
- package/lib/shape/heatmap/heatmap.js +2 -2
- package/lib/shape/heatmap/heatmap.js.map +1 -1
- package/lib/shape/interval/color.js +1 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/funnel.js +1 -1
- package/lib/shape/interval/funnel.js.map +1 -1
- package/lib/shape/label/position/area.js +1 -1
- package/lib/shape/label/position/area.js.map +1 -1
- package/lib/shape/label/position/utils.js +1 -1
- package/lib/shape/label/position/utils.js.map +1 -1
- package/lib/shape/line/curve.d.ts +1 -1
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/line/hv.js +1 -1
- package/lib/shape/line/hv.js.map +1 -1
- package/lib/shape/line/hvh.js +1 -1
- package/lib/shape/line/hvh.js.map +1 -1
- package/lib/shape/line/line.js +1 -1
- package/lib/shape/line/line.js.map +1 -1
- package/lib/shape/line/smooth.js +1 -1
- package/lib/shape/line/smooth.js.map +1 -1
- package/lib/shape/line/trail.js +1 -1
- package/lib/shape/line/trail.js.map +1 -1
- package/lib/shape/line/vh.js +1 -1
- package/lib/shape/line/vh.js.map +1 -1
- package/lib/shape/lineXY/line.js +1 -1
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/link/arc.js +1 -1
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/smooth.js +1 -1
- package/lib/shape/link/smooth.js.map +1 -1
- package/lib/shape/link/vhv.js +1 -1
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/polygon/polygon.js +1 -1
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js +1 -1
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/utils.d.ts +1 -1
- package/lib/shape/utils.js +1 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js +1 -1
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/interaction.d.ts +1 -0
- package/lib/transform/bin.js +1 -1
- package/lib/transform/bin.js.map +1 -1
- package/lib/transform/flexX.js +1 -1
- package/lib/transform/flexX.js.map +1 -1
- package/lib/transform/groupN.js +1 -1
- package/lib/transform/groupN.js.map +1 -1
- package/lib/transform/normalizeY.js +1 -1
- package/lib/transform/normalizeY.js.map +1 -1
- package/lib/transform/sample.js +1 -1
- package/lib/transform/sample.js.map +1 -1
- package/lib/transform/select.js +1 -1
- package/lib/transform/select.js.map +1 -1
- package/lib/transform/sort.d.ts +1 -1
- package/lib/transform/sort.js +20 -52
- package/lib/transform/sort.js.map +1 -1
- package/lib/transform/stackEnter.js +1 -1
- package/lib/transform/stackEnter.js.map +1 -1
- package/lib/transform/symmetryY.js +1 -1
- package/lib/transform/symmetryY.js.map +1 -1
- package/lib/transform/utils/order.d.ts +1 -1
- package/lib/transform/utils/order.js +1 -1
- package/lib/transform/utils/order.js.map +1 -1
- package/lib/utils/bounds.d.ts +4 -2
- package/lib/utils/bounds.js +11 -4
- package/lib/utils/bounds.js.map +1 -1
- package/lib/utils/helper.d.ts +24 -0
- package/lib/utils/helper.js +81 -1
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/scale.js +1 -1
- package/lib/utils/scale.js.map +1 -1
- package/lib/utils/selection.js +1 -1
- package/lib/utils/selection.js.map +1 -1
- package/lib/utils/treeDataTransform.d.ts +9 -2
- package/lib/utils/treeDataTransform.js +6 -2
- package/lib/utils/treeDataTransform.js.map +1 -1
- package/package.json +7 -24
- package/src/animation/scaleInY.ts +2 -45
- package/src/animation/waveIn.ts +1 -1
- package/src/api/runtime.ts +3 -1
- package/src/component/axis.ts +2 -2
- package/src/component/legendCategory.ts +10 -2
- package/src/component/legendContinuous.ts +1 -1
- package/src/component/slider.ts +1 -1
- package/src/composition/d3Projection.ts +1 -1
- package/src/composition/facetRect.ts +1 -1
- package/src/composition/geoView.ts +1 -1
- package/src/data/cluster.ts +1 -1
- package/src/data/fetch.ts +1 -1
- package/src/data/join.ts +1 -1
- package/src/data/kde.ts +1 -1
- package/src/data/tree.ts +1 -1
- package/src/data/utils/arc/arc.ts +6 -6
- package/src/data/utils/arc/types.ts +28 -2
- package/src/data/utils/d3-sankey/align.ts +1 -1
- package/src/data/utils/d3-sankey/sankey.ts +1 -1
- package/src/data/wordCloud.ts +1 -1
- package/src/exports.ts +3 -0
- package/src/interaction/chartIndex.ts +1 -1
- package/src/interaction/elementHighlight.ts +1 -1
- package/src/interaction/elementSelect.ts +33 -3
- package/src/interaction/event.ts +2 -15
- package/src/interaction/legendHighlight.ts +4 -2
- package/src/interaction/tooltip.ts +10 -39
- package/src/interaction/treemapDrillDown.ts +2 -3
- package/src/interaction/utils.ts +2 -2
- package/src/label-transform/contrastReverse.ts +1 -1
- package/src/label-transform/overlapDodgeY.ts +1 -1
- package/src/lib/core.ts +2 -0
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +6 -1
- package/src/mark/forceGraph.ts +1 -1
- package/src/mark/line.ts +1 -1
- package/src/mark/pack.ts +5 -1
- package/src/mark/utils.ts +1 -1
- package/src/runtime/component.ts +2 -2
- package/src/runtime/layout.ts +15 -2
- package/src/runtime/mark.ts +1 -1
- package/src/runtime/plot.ts +2 -2
- package/src/runtime/scale.ts +2 -2
- package/src/runtime/transform.ts +6 -3
- package/src/runtime/types/mark.ts +1 -1
- package/src/shape/area/area.ts +1 -1
- package/src/shape/area/curve.ts +1 -1
- package/src/shape/area/hv.ts +1 -1
- package/src/shape/area/hvh.ts +1 -1
- package/src/shape/area/smooth.ts +1 -1
- package/src/shape/area/vh.ts +1 -1
- package/src/shape/box/box.ts +1 -1
- package/src/shape/box/violin.ts +1 -1
- package/src/shape/connector/connector.ts +1 -1
- package/src/shape/density/density.ts +1 -1
- package/src/shape/heatmap/heatmap.ts +2 -2
- package/src/shape/interval/color.ts +1 -1
- package/src/shape/interval/funnel.ts +1 -1
- package/src/shape/label/position/area.ts +1 -1
- package/src/shape/label/position/utils.ts +1 -1
- package/src/shape/line/curve.ts +6 -1
- package/src/shape/line/hv.ts +1 -1
- package/src/shape/line/hvh.ts +1 -1
- package/src/shape/line/line.ts +1 -1
- package/src/shape/line/smooth.ts +1 -1
- package/src/shape/line/trail.ts +1 -1
- package/src/shape/line/vh.ts +1 -1
- package/src/shape/lineXY/line.ts +1 -1
- package/src/shape/link/arc.ts +1 -1
- package/src/shape/link/smooth.ts +1 -1
- package/src/shape/link/vhv.ts +1 -1
- package/src/shape/polygon/polygon.ts +1 -1
- package/src/shape/polygon/ribbon.ts +1 -1
- package/src/shape/text/advance.ts +1 -1
- package/src/shape/utils.ts +2 -2
- package/src/shape/vector/vector.ts +1 -1
- package/src/spec/interaction.ts +1 -0
- package/src/transform/bin.ts +8 -3
- package/src/transform/flexX.ts +1 -1
- package/src/transform/groupN.ts +1 -1
- package/src/transform/normalizeY.ts +1 -1
- package/src/transform/sample.ts +1 -1
- package/src/transform/select.ts +1 -1
- package/src/transform/sort.ts +21 -43
- package/src/transform/stackEnter.ts +1 -1
- package/src/transform/symmetryY.ts +1 -1
- package/src/transform/utils/order.ts +1 -1
- package/src/utils/bounds.ts +22 -4
- package/src/utils/helper.ts +83 -0
- package/src/utils/scale.ts +1 -1
- package/src/utils/selection.ts +1 -1
- package/src/utils/treeDataTransform.ts +26 -13
package/src/runtime/scale.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Linear, createInterpolateValue } from '@antv/scale';
|
|
2
|
-
import { extent, max, rollups } from 'd3-array';
|
|
3
|
-
import * as d3ScaleChromatic from 'd3-scale-chromatic';
|
|
2
|
+
import { extent, max, rollups } from '@antv/vendor/d3-array';
|
|
3
|
+
import * as d3ScaleChromatic from '@antv/vendor/d3-scale-chromatic';
|
|
4
4
|
import { deepMix, omit, upperFirst } from '@antv/util';
|
|
5
5
|
import { firstOf, lastOf, unique } from '../utils/array';
|
|
6
6
|
import { defined, identity, isStrictObject } from '../utils/helper';
|
package/src/runtime/transform.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Primitive } from 'd3-array';
|
|
1
|
+
import { Primitive } from '@antv/vendor/d3-array';
|
|
2
2
|
import { deepMix, isNumber } from '@antv/util';
|
|
3
|
-
import { format } from 'd3-format';
|
|
3
|
+
import { format } from '@antv/vendor/d3-format';
|
|
4
4
|
import { indexOf, mapObject } from '../utils/array';
|
|
5
5
|
import {
|
|
6
6
|
composeAsync,
|
|
@@ -15,6 +15,8 @@ import { Data, DataComponent } from './types/data';
|
|
|
15
15
|
import { G2Mark, G2DataOptions, G2Context } from './types/options';
|
|
16
16
|
import { isPosition } from './scale';
|
|
17
17
|
|
|
18
|
+
export const CALLBACK_ITEM_SYMBOL = Symbol('CALLBACK_ITEM');
|
|
19
|
+
|
|
18
20
|
// @todo Add more defaults.
|
|
19
21
|
export function applyDefaults(
|
|
20
22
|
I: number[],
|
|
@@ -192,7 +194,8 @@ export function extractTooltip(
|
|
|
192
194
|
const values = [];
|
|
193
195
|
for (const i of I) {
|
|
194
196
|
const v = item(data[i], i, data, encode);
|
|
195
|
-
if (isStrictObject(v))
|
|
197
|
+
if (isStrictObject(v))
|
|
198
|
+
values[i] = { ...v, [CALLBACK_ITEM_SYMBOL]: true };
|
|
196
199
|
else values[i] = { value: v };
|
|
197
200
|
}
|
|
198
201
|
return values;
|
package/src/shape/area/area.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { curveLinearClosed, curveLinear } from 'd3-shape';
|
|
1
|
+
import { curveLinearClosed, curveLinear } from '@antv/vendor/d3-shape';
|
|
2
2
|
import { isPolar } from '../../utils/coordinate';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { Curve } from './curve';
|
package/src/shape/area/curve.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { area, areaRadial, CurveFactory } from 'd3-shape';
|
|
1
|
+
import { area, areaRadial, CurveFactory } from '@antv/vendor/d3-shape';
|
|
2
2
|
import { select } from '../../utils/selection';
|
|
3
3
|
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
4
4
|
import { Vector2, ShapeComponent as SC } from '../../runtime';
|
package/src/shape/area/hv.ts
CHANGED
package/src/shape/area/hvh.ts
CHANGED
package/src/shape/area/smooth.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
curveCatmullRomClosed,
|
|
3
3
|
curveMonotoneX,
|
|
4
4
|
curveMonotoneY,
|
|
5
|
-
} from 'd3-shape';
|
|
5
|
+
} from '@antv/vendor/d3-shape';
|
|
6
6
|
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
7
7
|
import { ShapeComponent as SC } from '../../runtime';
|
|
8
8
|
import { Curve } from './curve';
|
package/src/shape/area/vh.ts
CHANGED
package/src/shape/box/box.ts
CHANGED
package/src/shape/box/violin.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
|
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
3
|
import { PathStyleProps, Path } from '@antv/g';
|
|
4
4
|
import { Marker } from '@antv/component';
|
|
5
|
-
import { line as d3line } from 'd3-shape';
|
|
5
|
+
import { line as d3line } from '@antv/vendor/d3-shape';
|
|
6
6
|
import { ShapeComponent as SC, Vector2, WithPrefix } from '../../runtime';
|
|
7
7
|
import { isTranspose } from '../../utils/coordinate';
|
|
8
8
|
import { subObject } from '../../utils/helper';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { max as d3max, min as d3min } from 'd3-array';
|
|
1
|
+
import { max as d3max, min as d3min } from '@antv/vendor/d3-array';
|
|
2
2
|
import { applyStyle } from '../utils';
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
4
|
import { ShapeComponent as SC } from '../../runtime';
|
|
@@ -66,7 +66,7 @@ export const Heatmap: SC<HeatmapOptions> = (options, context) => {
|
|
|
66
66
|
.style('y', 0)
|
|
67
67
|
.style('width', width)
|
|
68
68
|
.style('height', height)
|
|
69
|
-
.style('src', ctx.canvas)
|
|
69
|
+
.style('src', ctx.canvas.toDataURL())
|
|
70
70
|
.style('transform', transform)
|
|
71
71
|
.call(applyStyle, style)
|
|
72
72
|
.node();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { line, curveLinearClosed } from 'd3-shape';
|
|
1
|
+
import { line, curveLinearClosed } from '@antv/vendor/d3-shape';
|
|
2
2
|
import { Coordinate } from '@antv/coord';
|
|
3
3
|
import { isTranspose } from '../../utils/coordinate';
|
|
4
4
|
import { ShapeComponent as SC, Vector2 } from '../../runtime';
|
package/src/shape/line/curve.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
line,
|
|
3
|
+
lineRadial,
|
|
4
|
+
CurveFactory,
|
|
5
|
+
CurveFactoryLineOnly,
|
|
6
|
+
} from '@antv/vendor/d3-shape';
|
|
2
7
|
import { Vector2 } from '@antv/coord';
|
|
3
8
|
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
4
9
|
import { select } from '../../utils/selection';
|
package/src/shape/line/hv.ts
CHANGED
package/src/shape/line/hvh.ts
CHANGED
package/src/shape/line/line.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { curveLinear, curveLinearClosed } from 'd3-shape';
|
|
1
|
+
import { curveLinear, curveLinearClosed } from '@antv/vendor/d3-shape';
|
|
2
2
|
import { isPolar } from '../../utils/coordinate';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { Curve } from './curve';
|
package/src/shape/line/smooth.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
curveMonotoneX,
|
|
3
3
|
curveMonotoneY,
|
|
4
4
|
curveCatmullRomClosed,
|
|
5
|
-
} from 'd3-shape';
|
|
5
|
+
} from '@antv/vendor/d3-shape';
|
|
6
6
|
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
7
7
|
import { ShapeComponent as SC } from '../../runtime';
|
|
8
8
|
import { Curve } from './curve';
|
package/src/shape/line/trail.ts
CHANGED
package/src/shape/line/vh.ts
CHANGED
package/src/shape/lineXY/line.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IDocument } from '@antv/g';
|
|
2
2
|
import { Coordinate } from '@antv/coord';
|
|
3
|
-
import { arc, line } from 'd3-shape';
|
|
3
|
+
import { arc, line } from '@antv/vendor/d3-shape';
|
|
4
4
|
import { isPolar } from '../../utils/coordinate';
|
|
5
5
|
import { select } from '../../utils/selection';
|
|
6
6
|
import { dist } from '../../utils/vector';
|
package/src/shape/link/arc.ts
CHANGED
package/src/shape/link/smooth.ts
CHANGED
package/src/shape/link/vhv.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { path as d3path } from 'd3-path';
|
|
2
|
+
import { path as d3path } from '@antv/vendor/d3-path';
|
|
3
3
|
import { isPolar } from '../../utils/coordinate';
|
|
4
4
|
import { applyStyle, appendPolygon, appendArc } from '../utils';
|
|
5
5
|
import { select } from '../../utils/selection';
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@antv/g';
|
|
10
10
|
import { isNumber } from '@antv/util';
|
|
11
11
|
import { Marker } from '@antv/component';
|
|
12
|
-
import { line } from 'd3-shape';
|
|
12
|
+
import { line } from '@antv/vendor/d3-shape';
|
|
13
13
|
import { WithPrefix } from '../../runtime';
|
|
14
14
|
import { createElement } from '../../utils/createElement';
|
|
15
15
|
import { applyStyle } from '../utils';
|
package/src/shape/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
2
|
import { Linear } from '@antv/scale';
|
|
3
3
|
import { isNumber, lowerFirst } from '@antv/util';
|
|
4
|
-
import { extent } from 'd3-array';
|
|
5
|
-
import { Path as D3Path } from 'd3-path';
|
|
4
|
+
import { extent } from '@antv/vendor/d3-array';
|
|
5
|
+
import { Path as D3Path } from '@antv/vendor/d3-path';
|
|
6
6
|
import { Primitive, Vector2, Vector3 } from '../runtime';
|
|
7
7
|
import { indexOf } from '../utils/array';
|
|
8
8
|
import { isPolar, isTranspose } from '../utils/coordinate';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { path as d3path } from 'd3-path';
|
|
1
|
+
import { path as d3path } from '@antv/vendor/d3-path';
|
|
2
2
|
import { applyStyle, arrowPoints, ArrowOptions } from '../utils';
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
4
|
import { ShapeComponent as SC } from '../../runtime';
|
package/src/spec/interaction.ts
CHANGED
|
@@ -107,6 +107,7 @@ export type ElementSelectInteraction = {
|
|
|
107
107
|
single?: boolean;
|
|
108
108
|
background?: boolean;
|
|
109
109
|
offset?: number;
|
|
110
|
+
multipleSelectHotkey?: string;
|
|
110
111
|
} & Record<`${'link' | 'background'}${any}`, any>;
|
|
111
112
|
|
|
112
113
|
export type ElementSelectByColorInteraction = {
|
package/src/transform/bin.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
bin as d3Bin,
|
|
3
|
+
group,
|
|
4
|
+
thresholdScott,
|
|
5
|
+
extent,
|
|
6
|
+
} from '@antv/vendor/d3-array';
|
|
2
7
|
import { defined, subObject } from '../utils/helper';
|
|
3
8
|
import { TransformComponent as TC } from '../runtime';
|
|
4
9
|
import { BinTransform } from '../spec';
|
|
@@ -34,7 +39,7 @@ export const Bin: TC<BinOptions> = (options = {}) => {
|
|
|
34
39
|
const channelIndexKey = {};
|
|
35
40
|
|
|
36
41
|
// Group indexes and update channelIndexKey.
|
|
37
|
-
const groupBy = (I, mark) => {
|
|
42
|
+
const groupBy = (I, mark): number[][] => {
|
|
38
43
|
const { encode } = mark;
|
|
39
44
|
const binValues = binChannels.map((channel) => {
|
|
40
45
|
const [V] = columnOf(encode, channel);
|
|
@@ -75,7 +80,7 @@ export const Bin: TC<BinOptions> = (options = {}) => {
|
|
|
75
80
|
|
|
76
81
|
// Group by indexes by channel keys.
|
|
77
82
|
const key = (i: number) => groupKeys.map((key) => key(i)).join('-');
|
|
78
|
-
return Array.from(group(DI, key).values());
|
|
83
|
+
return Array.from(group(DI, key).values()) as number[][];
|
|
79
84
|
};
|
|
80
85
|
|
|
81
86
|
return GroupN({
|
package/src/transform/flexX.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
|
-
import { rollups, sum, Primitive } from 'd3-array';
|
|
2
|
+
import { rollups, sum, Primitive } from '@antv/vendor/d3-array';
|
|
3
3
|
import { TransformComponent as TC } from '../runtime';
|
|
4
4
|
import { FlexXTransform } from '../spec';
|
|
5
5
|
import { columnOf } from './utils/helper';
|
package/src/transform/groupN.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
sum as d3Sum,
|
|
6
6
|
min as d3Min,
|
|
7
7
|
median as d3Median,
|
|
8
|
-
} from 'd3-array';
|
|
8
|
+
} from '@antv/vendor/d3-array';
|
|
9
9
|
import { TransformComponent as TC, Primitive, G2Mark } from '../runtime';
|
|
10
10
|
import { GroupTransform, Reducer } from '../spec';
|
|
11
11
|
import { indexOf } from '../utils/array';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
|
-
import { mean, deviation, median, sum, max, min } from 'd3-array';
|
|
2
|
+
import { mean, deviation, median, sum, max, min } from '@antv/vendor/d3-array';
|
|
3
3
|
import { isUnset } from '../utils/helper';
|
|
4
4
|
import { TransformComponent as TC } from '../runtime';
|
|
5
5
|
import { NormalizeYTransform } from '../spec';
|
package/src/transform/sample.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-ignore medianIndex exist in d3-array@3.2.0, but @types/d3-array Expired.
|
|
2
|
-
import { maxIndex, minIndex, medianIndex } from 'd3-array';
|
|
2
|
+
import { maxIndex, minIndex, medianIndex } from '@antv/vendor/d3-array';
|
|
3
3
|
import { TransformComponent as TC, Primitive } from '../runtime';
|
|
4
4
|
import { SampleTransform, SampleFunction } from '../spec';
|
|
5
5
|
import { createGroups } from './utils/order';
|
package/src/transform/select.ts
CHANGED
package/src/transform/sort.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
mean,
|
|
9
9
|
median,
|
|
10
10
|
sort,
|
|
11
|
-
} from 'd3-array';
|
|
11
|
+
} from '@antv/vendor/d3-array';
|
|
12
12
|
import { G2Mark, TransformComponent as TC } from '../runtime';
|
|
13
13
|
import { columnOf } from './utils/helper';
|
|
14
14
|
|
|
@@ -43,16 +43,6 @@ export type SortOptions = {
|
|
|
43
43
|
| ((I: number[], V: Primitive[]) => Primitive);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
function sortQuantitative(I, mark, options): [number[], G2Mark] {
|
|
47
|
-
const { reverse, channel } = options;
|
|
48
|
-
const { encode } = mark;
|
|
49
|
-
const [V] = columnOf(encode, channel);
|
|
50
|
-
const sortedI = sort(I, (i: number) => V[i]);
|
|
51
|
-
if (reverse) sortedI.reverse();
|
|
52
|
-
// const s = typeof slice === 'number' ? [0, slice] : slice;
|
|
53
|
-
return [sortedI, mark];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
46
|
// If domain is specified, only sort data in the domain.
|
|
57
47
|
function filterIndex(I, values, specifiedDomain): number[] {
|
|
58
48
|
if (!Array.isArray(specifiedDomain)) return I;
|
|
@@ -60,44 +50,32 @@ function filterIndex(I, values, specifiedDomain): number[] {
|
|
|
60
50
|
return I.filter((i) => domain.has(values[i]));
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
function sortOrdinal(I, mark, options): [number[], G2Mark] {
|
|
64
|
-
const { reverse, slice, channel, ...rest } = options;
|
|
65
|
-
const { encode, scale = {} } = mark;
|
|
66
|
-
const domain = scale[channel]?.domain;
|
|
67
|
-
const [T] = columnOf(encode, channel);
|
|
68
|
-
const normalizeReducer = createReducer(channel, rest, encode);
|
|
69
|
-
const SI = filterIndex(I, T, domain);
|
|
70
|
-
const sortedDomain = groupSort(SI, normalizeReducer, (i: number) => T[i]);
|
|
71
|
-
if (reverse) sortedDomain.reverse();
|
|
72
|
-
const s = typeof slice === 'number' ? [0, slice] : slice;
|
|
73
|
-
const slicedDomain = slice ? sortedDomain.slice(...s) : sortedDomain;
|
|
74
|
-
return [
|
|
75
|
-
I,
|
|
76
|
-
deepMix(mark, {
|
|
77
|
-
scale: {
|
|
78
|
-
[channel]: {
|
|
79
|
-
domain: slicedDomain,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
53
|
/**
|
|
87
54
|
* Sort marks groups by groups.
|
|
88
55
|
*/
|
|
89
56
|
export const Sort: TC<SortOptions> = (options = {}) => {
|
|
90
|
-
const { reverse = false, slice, channel, ordinal = true, ...rest } = options;
|
|
91
57
|
return (I, mark) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
58
|
+
const { reverse, slice, channel, by, ordinal = true, reducer } = options;
|
|
59
|
+
const { encode, scale = {} } = mark;
|
|
60
|
+
const domain = scale[channel].domain;
|
|
61
|
+
const [V] = columnOf(encode, by ?? channel);
|
|
62
|
+
const [T] = columnOf(encode, channel);
|
|
63
|
+
const normalizeReducer = createReducer(channel, { by, reducer }, encode);
|
|
64
|
+
const SI = filterIndex(I, T, domain);
|
|
65
|
+
const sortedDomain = groupSort(SI, normalizeReducer, (i: number) => T[i]);
|
|
66
|
+
|
|
67
|
+
// when ordinal is true, do not change the index of the data.
|
|
68
|
+
const sortedI = !ordinal ? sort(I, (i: number) => V[i]) : I;
|
|
69
|
+
if (reverse) {
|
|
70
|
+
!ordinal && sortedI.reverse();
|
|
71
|
+
sortedDomain.reverse();
|
|
99
72
|
}
|
|
100
|
-
|
|
73
|
+
const s = typeof slice === 'number' ? [0, slice] : slice;
|
|
74
|
+
const slicedDomain = slice ? sortedDomain.slice(...s) : sortedDomain;
|
|
75
|
+
return [
|
|
76
|
+
sortedI,
|
|
77
|
+
deepMix(mark, { scale: { [channel]: { domain: slicedDomain } } }),
|
|
78
|
+
];
|
|
101
79
|
};
|
|
102
80
|
};
|
|
103
81
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
|
-
import { extent } from 'd3-array';
|
|
2
|
+
import { extent } from '@antv/vendor/d3-array';
|
|
3
3
|
import { TransformComponent as TC } from '../runtime';
|
|
4
4
|
import { SymmetryYTransform } from '../spec';
|
|
5
5
|
import { columnOf, column } from './utils/helper';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { group, ascending, maxIndex, Primitive } from 'd3-array';
|
|
1
|
+
import { group, ascending, maxIndex, Primitive } from '@antv/vendor/d3-array';
|
|
2
2
|
import { defined } from '../../utils/helper';
|
|
3
3
|
import { TabularData, G2Mark } from '../../runtime';
|
|
4
4
|
import { indexOf } from '../../utils/array';
|
package/src/utils/bounds.ts
CHANGED
|
@@ -5,6 +5,9 @@ type Min = Vector2;
|
|
|
5
5
|
type Max = Vector2;
|
|
6
6
|
export type Bounds = [Min, Max];
|
|
7
7
|
|
|
8
|
+
// There is a certain error in the calculation of text bounds.
|
|
9
|
+
const EPSILON = 1e-2;
|
|
10
|
+
|
|
8
11
|
export function parseAABB(min2: AABB): Bounds {
|
|
9
12
|
const { min, max } = min2;
|
|
10
13
|
return [
|
|
@@ -17,21 +20,36 @@ export function parseAABB(min2: AABB): Bounds {
|
|
|
17
20
|
* Whether the `point` in `bounds`.
|
|
18
21
|
* @param point
|
|
19
22
|
* @param bounds
|
|
23
|
+
* @param threshold
|
|
20
24
|
*/
|
|
21
|
-
export function isInBounds(
|
|
25
|
+
export function isInBounds(
|
|
26
|
+
point: Vector2,
|
|
27
|
+
bounds: Bounds,
|
|
28
|
+
threshold = EPSILON,
|
|
29
|
+
): boolean {
|
|
22
30
|
const [x, y] = point;
|
|
23
31
|
const [min, max] = bounds;
|
|
24
|
-
return
|
|
32
|
+
return (
|
|
33
|
+
x >= min[0] - threshold &&
|
|
34
|
+
x <= max[0] + threshold &&
|
|
35
|
+
y >= min[1] - threshold &&
|
|
36
|
+
y <= max[1] + threshold
|
|
37
|
+
);
|
|
25
38
|
}
|
|
26
39
|
|
|
27
40
|
/**
|
|
28
41
|
* Whether `b1` is overflow from `b2`.
|
|
29
42
|
* @param b1
|
|
30
43
|
* @param b2
|
|
44
|
+
* @param threshold The threshold to determine whether the bounds is overflowed, default is 0.
|
|
31
45
|
*/
|
|
32
|
-
export function isOverflow(
|
|
46
|
+
export function isOverflow(
|
|
47
|
+
b1: Bounds,
|
|
48
|
+
b2: Bounds,
|
|
49
|
+
threshold = EPSILON,
|
|
50
|
+
): boolean {
|
|
33
51
|
const [min, max] = b1;
|
|
34
|
-
return !(isInBounds(min, b2) && isInBounds(max, b2));
|
|
52
|
+
return !(isInBounds(min, b2, threshold) && isInBounds(max, b2, threshold));
|
|
35
53
|
}
|
|
36
54
|
|
|
37
55
|
/**
|
package/src/utils/helper.ts
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { lowerFirst, upperFirst, isPlainObject } from '@antv/util';
|
|
3
|
+
import { Band, Base, Constant } from '@antv/scale';
|
|
4
|
+
import { G2Element } from './selection';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Get element's ancestor view node.
|
|
8
|
+
* @param elemenet G2 element.
|
|
9
|
+
* @returns Element's ancestor view node.
|
|
10
|
+
*/
|
|
11
|
+
export function getViewFromElement(element: G2Element) {
|
|
12
|
+
let current = element as G2Element;
|
|
13
|
+
while (current) {
|
|
14
|
+
if (current.attributes?.class === 'view') return current;
|
|
15
|
+
current = current.parentNode as G2Element;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @description Get element's original data.
|
|
22
|
+
* @param elemenet G2 element.
|
|
23
|
+
* @returns The original data of the element.
|
|
24
|
+
*/
|
|
25
|
+
export function dataOf(element: G2Element) {
|
|
26
|
+
const view = getViewFromElement(element);
|
|
27
|
+
const datum = element.__data__;
|
|
28
|
+
const { markKey, index, seriesIndex } = datum;
|
|
29
|
+
const { markState } = view.__data__;
|
|
30
|
+
const selectedMark: any = Array.from(markState.keys()).find(
|
|
31
|
+
(mark) => (mark as any).key === markKey,
|
|
32
|
+
);
|
|
33
|
+
if (!selectedMark) return;
|
|
34
|
+
if (seriesIndex) {
|
|
35
|
+
return seriesIndex.map((i) => selectedMark.data[i]);
|
|
36
|
+
}
|
|
37
|
+
return selectedMark.data[index];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description Get element's series name.
|
|
42
|
+
* @param elemenet G2 element.
|
|
43
|
+
* @returns The series name of the element.
|
|
44
|
+
*/
|
|
45
|
+
export function seriesOf(elemenet: G2Element): string {
|
|
46
|
+
const viewData = getViewFromElement(elemenet).__data__;
|
|
47
|
+
const { scale } = viewData;
|
|
48
|
+
return groupNameOf(scale, elemenet.__data__);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get group name with view's scale and element's datum.
|
|
53
|
+
*/
|
|
54
|
+
export function groupNameOf(scale: Record<string, Base<any>>, datum) {
|
|
55
|
+
const { color: scaleColor, series: scaleSeries, facet = false } = scale;
|
|
56
|
+
const { color, series } = datum;
|
|
57
|
+
const invertAble = (scale) => {
|
|
58
|
+
return (
|
|
59
|
+
scale &&
|
|
60
|
+
scale.invert &&
|
|
61
|
+
!(scale instanceof Band) &&
|
|
62
|
+
!(scale instanceof Constant)
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
// For non constant color channel.
|
|
66
|
+
if (invertAble(scaleSeries)) {
|
|
67
|
+
const cloned = scaleSeries.clone();
|
|
68
|
+
return cloned.invert(series);
|
|
69
|
+
}
|
|
70
|
+
if (
|
|
71
|
+
series &&
|
|
72
|
+
scaleSeries instanceof Band &&
|
|
73
|
+
scaleSeries.invert(series) !== color &&
|
|
74
|
+
!facet
|
|
75
|
+
) {
|
|
76
|
+
return scaleSeries.invert(series);
|
|
77
|
+
}
|
|
78
|
+
if (invertAble(scaleColor)) {
|
|
79
|
+
const name = scaleColor.invert(color);
|
|
80
|
+
// For threshold scale.
|
|
81
|
+
if (Array.isArray(name)) return null;
|
|
82
|
+
return name;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
3
86
|
|
|
4
87
|
export function identity<T>(x: T): T {
|
|
5
88
|
return x;
|