@antv/g2 5.4.3 → 5.4.5
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 +10 -10
- package/dist/g2.min.js +10 -10
- package/esm/animation/morphing.js.map +1 -1
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/utils.js.map +1 -1
- package/esm/animation/waveIn.js.map +1 -1
- package/esm/api/composition.js.map +1 -1
- package/esm/api/define.js.map +1 -1
- package/esm/api/mark.js.map +1 -1
- package/esm/api/node.js.map +1 -1
- package/esm/api/runtime.js +6 -2
- package/esm/api/runtime.js.map +1 -1
- package/esm/api/utils.js.map +1 -1
- package/esm/component/axis.js +3 -2
- package/esm/component/axis.js.map +1 -1
- package/esm/component/axisRadar.js.map +1 -1
- package/esm/component/constant.d.ts +8 -0
- package/esm/component/constant.js +10 -0
- package/esm/component/constant.js.map +1 -1
- package/esm/component/legendCategory.js +4 -1
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +4 -3
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/scrollbar.js +2 -1
- package/esm/component/scrollbar.js.map +1 -1
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js.map +1 -1
- package/esm/component/utils.d.ts +1 -1
- package/esm/component/utils.js.map +1 -1
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/composition/geoView.js.map +1 -1
- package/esm/composition/repeatMatrix.js.map +1 -1
- package/esm/composition/spaceFlex.js.map +1 -1
- package/esm/composition/timingKeyframe.js.map +1 -1
- package/esm/composition/utils.js.map +1 -1
- package/esm/data/cluster.d.ts +1 -1
- package/esm/data/ema.js.map +1 -1
- package/esm/data/fetch.js.map +1 -1
- package/esm/data/pick.js.map +1 -1
- package/esm/data/sankey.js.map +1 -1
- package/esm/data/sortBy.js.map +1 -1
- package/esm/data/utils/arc/arc.d.ts +6 -6
- package/esm/data/utils/arc/arc.js.map +1 -1
- package/esm/data/utils/d3-cloud/index.js.map +1 -1
- package/esm/data/utils/d3-sankey/sankey.d.ts +5 -5
- package/esm/data/utils/d3-sankey/sankey.js.map +1 -1
- package/esm/data/utils/fields.js.map +1 -1
- package/esm/data/utils/memo.js +1 -1
- package/esm/data/utils/memo.js.map +1 -1
- package/esm/data/utils/venn/circleintersection.js.map +1 -1
- package/esm/data/utils/venn/diagram.js.map +1 -1
- package/esm/data/utils/venn/fmin/bisect.js.map +1 -1
- package/esm/data/utils/venn/fmin/blas1.js.map +1 -1
- package/esm/data/utils/venn/fmin/conjugateGradient.js.map +1 -1
- package/esm/data/utils/venn/fmin/gradientDescent.js.map +1 -1
- package/esm/data/utils/venn/fmin/linesearch.js.map +1 -1
- package/esm/data/utils/venn/fmin/nelderMead.js.map +1 -1
- package/esm/data/utils/venn/layout.js.map +1 -1
- package/esm/data/wordCloud.js.map +1 -1
- package/esm/index.d.ts +6 -0
- package/esm/interaction/adaptiveFilter.js.map +1 -1
- package/esm/interaction/brushAxisHighlight.js +1 -1
- package/esm/interaction/brushAxisHighlight.js.map +1 -1
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/chartIndex.js.map +1 -1
- package/esm/interaction/drillDown.d.ts +6 -0
- package/esm/interaction/drillDown.js +210 -0
- package/esm/interaction/drillDown.js.map +1 -0
- package/esm/interaction/elementHighlight.js.map +1 -1
- package/esm/interaction/elementHoverScale.d.ts +23 -0
- package/esm/interaction/elementHoverScale.js +222 -0
- package/esm/interaction/elementHoverScale.js.map +1 -0
- package/esm/interaction/elementPointMove.js.map +1 -1
- package/esm/interaction/elementSelect.js.map +1 -1
- package/esm/interaction/event.js +10 -2
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/fisheye.js.map +1 -1
- 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/legendFilter.js +38 -16
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/interaction/legendHighlight.js.map +1 -1
- package/esm/interaction/poptip.js.map +1 -1
- package/esm/interaction/scrollbarFilter.js +2 -1
- package/esm/interaction/scrollbarFilter.js.map +1 -1
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/interaction/sliderWheel.js.map +1 -1
- package/esm/interaction/tooltip.js +6 -5
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/treemapDrillDown.js.map +1 -1
- package/esm/interaction/utils.d.ts +16 -2
- package/esm/interaction/utils.js +57 -9
- package/esm/interaction/utils.js.map +1 -1
- package/esm/label-transform/exceedAdjust.js +17 -0
- package/esm/label-transform/exceedAdjust.js.map +1 -1
- package/esm/label-transform/overflowStroke.js.map +1 -1
- package/esm/label-transform/overlapDodgeY.js.map +1 -1
- package/esm/lib/core.d.ts +3 -1
- package/esm/lib/core.js +3 -1
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/graph.d.ts +1 -0
- package/esm/lib/graph.js +2 -1
- package/esm/lib/graph.js.map +1 -1
- package/esm/lib/std.d.ts +3 -0
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/box.js +3 -3
- package/esm/mark/box.js.map +1 -1
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/mark/chord.js +2 -2
- package/esm/mark/chord.js.map +1 -1
- package/esm/mark/density.js +1 -1
- package/esm/mark/density.js.map +1 -1
- package/esm/mark/gauge.js.map +1 -1
- package/esm/mark/index.d.ts +1 -0
- package/esm/mark/index.js +1 -0
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/partition.d.ts +42 -0
- package/esm/mark/partition.js +217 -0
- package/esm/mark/partition.js.map +1 -0
- package/esm/mark/polygon.js.map +1 -1
- package/esm/mark/sankey.js.map +1 -1
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/coordinate.js.map +1 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/mark.js +2 -2
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/option-preprocess/axis-breaks.js.map +1 -1
- package/esm/runtime/option-preprocess/index.js.map +1 -1
- package/esm/runtime/option-preprocess/style.js.map +1 -1
- package/esm/runtime/plot.js +13 -2
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js.map +1 -1
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/axis-breaks/axis-breaks.js.map +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/box/violin.js.map +1 -1
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/heatmap/renderer/gradient.js.map +1 -1
- package/esm/shape/heatmap/renderer/index.js.map +1 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/funnel.js.map +1 -1
- package/esm/shape/interval/pyramid.js.map +1 -1
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/label/position/outside.js.map +1 -1
- package/esm/shape/label/position/utils.js.map +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/line/trail.js.map +1 -1
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/liquid/liquid.js.map +1 -1
- package/esm/shape/liquid/wave.js.map +1 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.d.ts +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/interaction.d.ts +23 -2
- package/esm/spec/mark.d.ts +13 -2
- package/esm/theme/create.d.ts +1 -1
- package/esm/theme/create.js +3 -2
- package/esm/theme/create.js.map +1 -1
- package/esm/theme/dark.js +5 -4
- package/esm/theme/dark.js.map +1 -1
- package/esm/transform/diffY.js.map +1 -1
- package/esm/transform/dodgeX.js.map +1 -1
- package/esm/transform/filter.js.map +1 -1
- package/esm/transform/maybeDefaultX.js.map +1 -1
- package/esm/transform/maybeDefaultY.js.map +1 -1
- package/esm/transform/maybeTitle.js.map +1 -1
- package/esm/transform/maybeVisualPosition.js +1 -1
- package/esm/transform/maybeVisualPosition.js.map +1 -1
- package/esm/transform/normalizeY.js.map +1 -1
- package/esm/transform/pack.js.map +1 -1
- package/esm/transform/sample.js.map +1 -1
- package/esm/transform/sort.js.map +1 -1
- package/esm/transform/stackEnter.js.map +1 -1
- package/esm/transform/stackY.js +2 -2
- package/esm/transform/stackY.js.map +1 -1
- package/esm/transform/symmetryY.js.map +1 -1
- package/esm/transform/utils/helper.js.map +1 -1
- package/esm/transform/utils/lttb.js.map +1 -1
- package/esm/transform/utils/order.js.map +1 -1
- package/esm/utils/angle.js.map +1 -1
- package/esm/utils/array.js.map +1 -1
- package/esm/utils/coordinate.d.ts +0 -1
- package/esm/utils/coordinate.js.map +1 -1
- package/esm/utils/expr.js.map +1 -1
- package/esm/utils/helper.js +6 -6
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/marker.d.ts +1 -1
- package/esm/utils/scale.js.map +1 -1
- package/esm/utils/selection.js.map +1 -1
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/traverse-elements.js.map +1 -1
- package/esm/utils/treeDataTransform.js.map +1 -1
- package/esm/utils/vector.js.map +1 -1
- package/lib/animation/morphing.js.map +1 -1
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/utils.js +2 -2
- package/lib/animation/utils.js.map +1 -1
- package/lib/animation/waveIn.js.map +1 -1
- package/lib/api/composition.js +2 -2
- package/lib/api/composition.js.map +1 -1
- package/lib/api/define.js +2 -3
- package/lib/api/define.js.map +1 -1
- package/lib/api/extend.js +1 -2
- package/lib/api/extend.js.map +1 -1
- package/lib/api/library.js +2 -2
- package/lib/api/library.js.map +1 -1
- package/lib/api/mark.js +2 -2
- package/lib/api/mark.js.map +1 -1
- package/lib/api/node.js.map +1 -1
- package/lib/api/runtime.js +6 -2
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/utils.js +9 -9
- package/lib/api/utils.js.map +1 -1
- package/lib/component/axis.js +5 -4
- package/lib/component/axis.js.map +1 -1
- package/lib/component/axisRadar.js.map +1 -1
- package/lib/component/axisX.js +2 -2
- package/lib/component/axisX.js.map +1 -1
- package/lib/component/constant.d.ts +8 -0
- package/lib/component/constant.js +12 -1
- package/lib/component/constant.js.map +1 -1
- package/lib/component/legendCategory.js +4 -1
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +4 -3
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/scrollbar.js +2 -1
- package/lib/component/scrollbar.js.map +1 -1
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js.map +1 -1
- package/lib/component/utils.d.ts +1 -1
- package/lib/component/utils.js +11 -11
- package/lib/component/utils.js.map +1 -1
- package/lib/composition/facetRect.js +2 -2
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/composition/geoView.js +17 -7
- package/lib/composition/geoView.js.map +1 -1
- package/lib/composition/repeatMatrix.js.map +1 -1
- package/lib/composition/spaceFlex.js.map +1 -1
- package/lib/composition/timingKeyframe.js.map +1 -1
- package/lib/composition/utils.js +4 -5
- package/lib/composition/utils.js.map +1 -1
- package/lib/data/cluster.d.ts +1 -1
- package/lib/data/ema.js +2 -2
- package/lib/data/ema.js.map +1 -1
- package/lib/data/fetch.js.map +1 -1
- package/lib/data/filter.js +2 -2
- package/lib/data/filter.js.map +1 -1
- package/lib/data/fold.js +2 -2
- package/lib/data/fold.js.map +1 -1
- package/lib/data/kde.js +2 -2
- package/lib/data/kde.js.map +1 -1
- package/lib/data/pick.js.map +1 -1
- package/lib/data/rename.js +2 -2
- package/lib/data/rename.js.map +1 -1
- package/lib/data/sankey.js.map +1 -1
- package/lib/data/sort.js +2 -2
- package/lib/data/sort.js.map +1 -1
- package/lib/data/sortBy.js.map +1 -1
- package/lib/data/utils/arc/arc.d.ts +6 -6
- package/lib/data/utils/arc/arc.js +18 -9
- package/lib/data/utils/arc/arc.js.map +1 -1
- package/lib/data/utils/arc/sort.js +4 -5
- package/lib/data/utils/arc/sort.js.map +1 -1
- package/lib/data/utils/d3-cloud/index.js +1 -2
- package/lib/data/utils/d3-cloud/index.js.map +1 -1
- package/lib/data/utils/d3-sankey/align.js +4 -5
- package/lib/data/utils/d3-sankey/align.js.map +1 -1
- package/lib/data/utils/d3-sankey/constant.js +1 -2
- package/lib/data/utils/d3-sankey/constant.js.map +1 -1
- package/lib/data/utils/d3-sankey/sankey.d.ts +5 -5
- package/lib/data/utils/d3-sankey/sankey.js +1 -2
- package/lib/data/utils/d3-sankey/sankey.js.map +1 -1
- package/lib/data/utils/fields.js +1 -2
- package/lib/data/utils/fields.js.map +1 -1
- package/lib/data/utils/flow.js +1 -2
- package/lib/data/utils/flow.js.map +1 -1
- package/lib/data/utils/memo.js +4 -5
- package/lib/data/utils/memo.js.map +1 -1
- package/lib/data/utils/venn/circleintersection.js +7 -8
- package/lib/data/utils/venn/circleintersection.js.map +1 -1
- package/lib/data/utils/venn/diagram.js +1 -2
- package/lib/data/utils/venn/diagram.js.map +1 -1
- package/lib/data/utils/venn/fmin/bisect.js +1 -2
- package/lib/data/utils/venn/fmin/bisect.js.map +1 -1
- package/lib/data/utils/venn/fmin/blas1.js +7 -8
- package/lib/data/utils/venn/fmin/blas1.js.map +1 -1
- package/lib/data/utils/venn/fmin/conjugateGradient.js +2 -3
- package/lib/data/utils/venn/fmin/conjugateGradient.js.map +1 -1
- package/lib/data/utils/venn/fmin/gradientDescent.js +2 -3
- package/lib/data/utils/venn/fmin/gradientDescent.js.map +1 -1
- package/lib/data/utils/venn/fmin/linesearch.js +1 -2
- package/lib/data/utils/venn/fmin/linesearch.js.map +1 -1
- package/lib/data/utils/venn/fmin/nelderMead.js +1 -2
- package/lib/data/utils/venn/fmin/nelderMead.js.map +1 -1
- package/lib/data/utils/venn/layout.js +10 -11
- package/lib/data/utils/venn/layout.js.map +1 -1
- package/lib/data/wordCloud.js +3 -3
- package/lib/data/wordCloud.js.map +1 -1
- package/lib/index.d.ts +6 -0
- package/lib/interaction/adaptiveFilter.js +7 -8
- package/lib/interaction/adaptiveFilter.js.map +1 -1
- package/lib/interaction/brushAxisHighlight.js +4 -4
- package/lib/interaction/brushAxisHighlight.js.map +1 -1
- package/lib/interaction/brushFilter.js +2 -3
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/brushHighlight.js +3 -4
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/brushXFilter.js +1 -2
- package/lib/interaction/brushXFilter.js.map +1 -1
- package/lib/interaction/brushXHighlight.js +2 -3
- package/lib/interaction/brushXHighlight.js.map +1 -1
- package/lib/interaction/brushYFilter.js +1 -2
- package/lib/interaction/brushYFilter.js.map +1 -1
- package/lib/interaction/brushYHighlight.js +2 -3
- package/lib/interaction/brushYHighlight.js.map +1 -1
- package/lib/interaction/chartIndex.js +1 -2
- package/lib/interaction/chartIndex.js.map +1 -1
- package/lib/interaction/drillDown.d.ts +6 -0
- package/lib/interaction/drillDown.js +213 -0
- package/lib/interaction/drillDown.js.map +1 -0
- package/lib/interaction/elementHighlight.js +2 -3
- package/lib/interaction/elementHighlight.js.map +1 -1
- package/lib/interaction/elementHighlightByColor.js +1 -2
- package/lib/interaction/elementHighlightByColor.js.map +1 -1
- package/lib/interaction/elementHighlightByX.js +1 -2
- package/lib/interaction/elementHighlightByX.js.map +1 -1
- package/lib/interaction/elementHoverScale.d.ts +23 -0
- package/lib/interaction/elementHoverScale.js +226 -0
- package/lib/interaction/elementHoverScale.js.map +1 -0
- package/lib/interaction/elementPointMove.js +1 -2
- package/lib/interaction/elementPointMove.js.map +1 -1
- package/lib/interaction/elementSelect.js +2 -3
- package/lib/interaction/elementSelect.js.map +1 -1
- package/lib/interaction/elementSelectByColor.js +1 -2
- package/lib/interaction/elementSelectByColor.js.map +1 -1
- package/lib/interaction/elementSelectByX.js +1 -2
- package/lib/interaction/elementSelectByX.js.map +1 -1
- package/lib/interaction/event.js +11 -4
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/fisheye.js +1 -2
- package/lib/interaction/fisheye.js.map +1 -1
- 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/legendFilter.js +50 -28
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/interaction/legendHighlight.js +1 -2
- package/lib/interaction/legendHighlight.js.map +1 -1
- package/lib/interaction/poptip.js +1 -2
- package/lib/interaction/poptip.js.map +1 -1
- package/lib/interaction/scrollbarFilter.js +4 -3
- package/lib/interaction/scrollbarFilter.js.map +1 -1
- package/lib/interaction/sliderFilter.js +2 -2
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/interaction/sliderWheel.js +1 -2
- package/lib/interaction/sliderWheel.js.map +1 -1
- package/lib/interaction/tooltip.js +12 -12
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/treemapDrillDown.js +1 -2
- package/lib/interaction/treemapDrillDown.js.map +1 -1
- package/lib/interaction/utils.d.ts +16 -2
- package/lib/interaction/utils.js +91 -43
- package/lib/interaction/utils.js.map +1 -1
- package/lib/label-transform/exceedAdjust.js +17 -0
- package/lib/label-transform/exceedAdjust.js.map +1 -1
- package/lib/label-transform/overflowStroke.js.map +1 -1
- package/lib/label-transform/overlapDodgeY.js.map +1 -1
- package/lib/label-transform/utils.js +2 -3
- package/lib/label-transform/utils.js.map +1 -1
- package/lib/lib/builtinlib.js +1 -2
- package/lib/lib/builtinlib.js.map +1 -1
- package/lib/lib/core.d.ts +3 -1
- package/lib/lib/core.js +3 -2
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/geo.js +1 -2
- package/lib/lib/geo.js.map +1 -1
- package/lib/lib/graph.d.ts +1 -0
- package/lib/lib/graph.js +2 -2
- package/lib/lib/graph.js.map +1 -1
- package/lib/lib/lite.js +1 -2
- package/lib/lib/lite.js.map +1 -1
- package/lib/lib/plot.js +1 -2
- package/lib/lib/plot.js.map +1 -1
- package/lib/lib/std.d.ts +3 -0
- package/lib/lib/std.js +1 -2
- package/lib/lib/std.js.map +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/box.js +3 -3
- package/lib/mark/box.js.map +1 -1
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/mark/chord.js +2 -2
- package/lib/mark/chord.js.map +1 -1
- package/lib/mark/density.js +1 -1
- package/lib/mark/density.js.map +1 -1
- package/lib/mark/gauge.js.map +1 -1
- package/lib/mark/index.d.ts +1 -0
- package/lib/mark/index.js +3 -1
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/partition.d.ts +42 -0
- package/lib/mark/partition.js +223 -0
- package/lib/mark/partition.js.map +1 -0
- package/lib/mark/polygon.js.map +1 -1
- package/lib/mark/range.js +2 -2
- package/lib/mark/range.js.map +1 -1
- package/lib/mark/sankey.js.map +1 -1
- package/lib/mark/utils.js +16 -17
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/component.js +10 -11
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/coordinate.js +12 -13
- package/lib/runtime/coordinate.js.map +1 -1
- package/lib/runtime/layout.js +4 -5
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/library.js +2 -3
- package/lib/runtime/library.js.map +1 -1
- package/lib/runtime/mark.js +4 -5
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/option-preprocess/axis-breaks.js +2 -2
- package/lib/runtime/option-preprocess/axis-breaks.js.map +1 -1
- package/lib/runtime/option-preprocess/index.js +1 -2
- package/lib/runtime/option-preprocess/index.js.map +1 -1
- package/lib/runtime/option-preprocess/style.js +1 -2
- package/lib/runtime/option-preprocess/style.js.map +1 -1
- package/lib/runtime/plot.js +15 -5
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +3 -4
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +27 -18
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +13 -13
- package/lib/runtime/transform.js.map +1 -1
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/axis-breaks/axis-breaks.js.map +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/box/violin.js.map +1 -1
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/heatmap/renderer/gradient.js +1 -2
- package/lib/shape/heatmap/renderer/gradient.js.map +1 -1
- package/lib/shape/heatmap/renderer/index.js +1 -2
- package/lib/shape/heatmap/renderer/index.js.map +1 -1
- package/lib/shape/interval/color.js +2 -2
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/funnel.js.map +1 -1
- package/lib/shape/interval/pyramid.js.map +1 -1
- package/lib/shape/label/label.js +17 -7
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.js +1 -2
- package/lib/shape/label/position/area.js.map +1 -1
- package/lib/shape/label/position/default.js +6 -7
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/label/position/outside.js +5 -6
- package/lib/shape/label/position/outside.js.map +1 -1
- package/lib/shape/label/position/spider.js +1 -2
- package/lib/shape/label/position/spider.js.map +1 -1
- package/lib/shape/label/position/surround.js +1 -2
- package/lib/shape/label/position/surround.js.map +1 -1
- package/lib/shape/label/position/utils.js +2 -3
- package/lib/shape/label/position/utils.js.map +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/line/trail.js.map +1 -1
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/liquid/liquid.js.map +1 -1
- package/lib/shape/liquid/wave.js +1 -2
- package/lib/shape/liquid/wave.js.map +1 -1
- package/lib/shape/point/color.js +2 -2
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.d.ts +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/utils.js +11 -12
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/interaction.d.ts +23 -2
- package/lib/spec/mark.d.ts +13 -2
- package/lib/theme/create.d.ts +1 -1
- package/lib/theme/create.js +4 -4
- package/lib/theme/create.js.map +1 -1
- package/lib/theme/dark.js +5 -4
- package/lib/theme/dark.js.map +1 -1
- package/lib/transform/diffY.js.map +1 -1
- package/lib/transform/dodgeX.js.map +1 -1
- package/lib/transform/filter.js.map +1 -1
- package/lib/transform/jitter.js +3 -3
- package/lib/transform/jitter.js.map +1 -1
- package/lib/transform/maybeDefaultX.js.map +1 -1
- package/lib/transform/maybeDefaultY.js.map +1 -1
- package/lib/transform/maybeTitle.js.map +1 -1
- package/lib/transform/maybeVisualPosition.js +1 -1
- package/lib/transform/maybeVisualPosition.js.map +1 -1
- package/lib/transform/normalizeY.js.map +1 -1
- package/lib/transform/pack.js.map +1 -1
- package/lib/transform/sample.js.map +1 -1
- package/lib/transform/sort.js.map +1 -1
- package/lib/transform/stackEnter.js.map +1 -1
- package/lib/transform/stackY.js +2 -2
- package/lib/transform/stackY.js.map +1 -1
- package/lib/transform/symmetryY.js.map +1 -1
- package/lib/transform/utils/helper.js +8 -9
- package/lib/transform/utils/helper.js.map +1 -1
- package/lib/transform/utils/lttb.js +1 -2
- package/lib/transform/utils/lttb.js.map +1 -1
- package/lib/transform/utils/order.js +4 -5
- package/lib/transform/utils/order.js.map +1 -1
- package/lib/utils/angle.js +3 -4
- package/lib/utils/angle.js.map +1 -1
- package/lib/utils/array.js +9 -10
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bounds.js +4 -5
- package/lib/utils/bounds.js.map +1 -1
- package/lib/utils/color.js +1 -2
- package/lib/utils/color.js.map +1 -1
- package/lib/utils/coordinate.d.ts +0 -1
- package/lib/utils/coordinate.js +14 -15
- package/lib/utils/coordinate.js.map +1 -1
- package/lib/utils/createElement.js +1 -2
- package/lib/utils/createElement.js.map +1 -1
- package/lib/utils/dateFormat.js +1 -2
- package/lib/utils/dateFormat.js.map +1 -1
- package/lib/utils/expr.js +2 -2
- package/lib/utils/expr.js.map +1 -1
- package/lib/utils/flow.js +1 -2
- package/lib/utils/flow.js.map +1 -1
- package/lib/utils/helper.js +30 -31
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/lru.js +1 -2
- package/lib/utils/lru.js.map +1 -1
- package/lib/utils/mark.js +4 -5
- package/lib/utils/mark.js.map +1 -1
- package/lib/utils/marker.d.ts +1 -1
- package/lib/utils/marker.js +4 -4
- package/lib/utils/marker.js.map +1 -1
- package/lib/utils/number.js +2 -3
- package/lib/utils/number.js.map +1 -1
- package/lib/utils/scale.js +7 -7
- package/lib/utils/scale.js.map +1 -1
- package/lib/utils/selection.js +2 -2
- package/lib/utils/selection.js.map +1 -1
- package/lib/utils/size.js +2 -3
- package/lib/utils/size.js.map +1 -1
- package/lib/utils/string.js +2 -3
- package/lib/utils/string.js.map +1 -1
- package/lib/utils/style.js +4 -5
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/traverse-elements.js +1 -2
- package/lib/utils/traverse-elements.js.map +1 -1
- package/lib/utils/treeDataTransform.js +1 -2
- package/lib/utils/treeDataTransform.js.map +1 -1
- package/lib/utils/vector.js +8 -9
- package/lib/utils/vector.js.map +1 -1
- package/package.json +6 -5
- package/src/api/runtime.ts +5 -0
- package/src/component/axis.ts +3 -0
- package/src/component/constant.ts +12 -0
- package/src/component/legendCategory.ts +4 -1
- package/src/component/legendContinuous.ts +2 -0
- package/src/component/scrollbar.ts +2 -1
- package/src/interaction/drillDown.ts +258 -0
- package/src/interaction/elementHoverScale.ts +285 -0
- package/src/interaction/event.ts +10 -2
- package/src/interaction/index.ts +2 -0
- package/src/interaction/legendFilter.ts +42 -7
- package/src/interaction/scrollbarFilter.ts +2 -1
- package/src/interaction/tooltip.ts +6 -5
- package/src/interaction/utils.ts +65 -8
- package/src/label-transform/exceedAdjust.ts +22 -0
- package/src/lib/core.ts +4 -0
- package/src/lib/graph.ts +10 -1
- package/src/mark/index.ts +1 -0
- package/src/mark/partition.ts +312 -0
- package/src/runtime/mark.ts +2 -2
- package/src/runtime/plot.ts +11 -1
- package/src/spec/interaction.ts +28 -1
- package/src/spec/mark.ts +18 -0
- package/src/theme/create.ts +3 -1
- package/src/theme/dark.ts +5 -4
- package/src/utils/helper.ts +6 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { deepMix, throttle } from '@antv/util';
|
|
3
|
+
import { Base } from '@antv/scale';
|
|
3
4
|
import { subObject } from '../utils/helper';
|
|
4
5
|
import { ANNOTATION_MARKS } from '../component/constant';
|
|
5
6
|
import { useState, setCursor, restoreCursor } from './utils';
|
|
@@ -69,6 +70,21 @@ export function attributesOf(root) {
|
|
|
69
70
|
return child.attributes;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
function getScaleByMarkKey(
|
|
74
|
+
scale: Record<string, Base<any>>,
|
|
75
|
+
markKey: string,
|
|
76
|
+
channelName: string,
|
|
77
|
+
) {
|
|
78
|
+
const seriesKey = Object.keys(scale).find((channel) => {
|
|
79
|
+
if (channel.startsWith(channelName)) {
|
|
80
|
+
const options = scale[channel].getOptions();
|
|
81
|
+
return options.name === channelName && options.markKey === markKey;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return scale[seriesKey] ?? scale[channelName];
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
function legendFilterOrdinal(
|
|
73
89
|
root: DisplayObject,
|
|
74
90
|
{
|
|
@@ -493,9 +509,20 @@ async function filterView(
|
|
|
493
509
|
const { marks } = viewOptions;
|
|
494
510
|
// Add filter transform for every marks,
|
|
495
511
|
// which will skip for mark without color channel.
|
|
512
|
+
|
|
513
|
+
const channelScale = legend.attributes?.scales?.find(
|
|
514
|
+
(s) => s.name === channel,
|
|
515
|
+
);
|
|
496
516
|
const newMarks = marks.map((mark) => {
|
|
497
|
-
|
|
517
|
+
// Only filter marks with the same scale key.
|
|
518
|
+
if (
|
|
519
|
+
// if key is not defined, use default channel name.
|
|
520
|
+
(mark.scale[channel].key ?? channel) !==
|
|
521
|
+
(channelScale?.key ?? channelScale?.name)
|
|
522
|
+
)
|
|
523
|
+
return mark;
|
|
498
524
|
|
|
525
|
+
if (mark.type === 'legends') return mark;
|
|
499
526
|
// Skip Annotation marks.
|
|
500
527
|
if (ANNOTATION_MARKS.includes(mark.type)) return mark;
|
|
501
528
|
|
|
@@ -508,16 +535,24 @@ async function filterView(
|
|
|
508
535
|
if (data.length) {
|
|
509
536
|
newTransform.splice(index + 1, 0, {
|
|
510
537
|
type: 'filter',
|
|
511
|
-
[channel]: {
|
|
538
|
+
[channel]: {
|
|
539
|
+
value,
|
|
540
|
+
ordinal,
|
|
541
|
+
},
|
|
512
542
|
});
|
|
513
543
|
}
|
|
514
544
|
|
|
515
545
|
// Set domain of scale to preserve encoding.
|
|
516
546
|
const newScale = Object.fromEntries(
|
|
517
|
-
channels.map((channel) =>
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
547
|
+
channels.map((channel) => {
|
|
548
|
+
const matchScale = getScaleByMarkKey(
|
|
549
|
+
view.scale,
|
|
550
|
+
viewOptions.key,
|
|
551
|
+
channel,
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
return [channel, { domain: matchScale.getOptions().domain }];
|
|
555
|
+
}),
|
|
521
556
|
);
|
|
522
557
|
return deepMix({}, mark, {
|
|
523
558
|
transform: newTransform,
|
|
@@ -570,7 +605,7 @@ export function LegendFilter() {
|
|
|
570
605
|
};
|
|
571
606
|
|
|
572
607
|
if (legend.className === CATEGORY_LEGEND_CLASS_NAME) {
|
|
573
|
-
return legendFilterOrdinal(
|
|
608
|
+
return legendFilterOrdinal(legend, {
|
|
574
609
|
legends: itemsOf,
|
|
575
610
|
marker: markerOf,
|
|
576
611
|
label: labelOf,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { G2_CLASS_PREFIX } from '../component/constant';
|
|
1
2
|
import { SliderFilter } from './sliderFilter';
|
|
2
3
|
|
|
3
|
-
export const SCROLLBAR_CLASS_NAME =
|
|
4
|
+
export const SCROLLBAR_CLASS_NAME = `${G2_CLASS_PREFIX}scrollbar`;
|
|
4
5
|
|
|
5
6
|
export function ScrollbarFilter(options: any = {}) {
|
|
6
7
|
return (context, _, emitter) => {
|
|
@@ -14,6 +14,7 @@ import { angle, sub, dist } from '../utils/vector';
|
|
|
14
14
|
import { invert } from '../utils/scale';
|
|
15
15
|
import { BBox } from '../runtime';
|
|
16
16
|
import { CALLBACK_ITEM_SYMBOL } from '../runtime/transform';
|
|
17
|
+
import { G2_CLASS_PREFIX, g2Selector } from '../component/constant';
|
|
17
18
|
import {
|
|
18
19
|
selectG2Elements,
|
|
19
20
|
createXKey,
|
|
@@ -79,8 +80,8 @@ function createTooltip(
|
|
|
79
80
|
offset: [number, number] = [10, 10],
|
|
80
81
|
) {
|
|
81
82
|
const defaults = {
|
|
82
|
-
'
|
|
83
|
-
'
|
|
83
|
+
[g2Selector('tooltip')]: {},
|
|
84
|
+
[g2Selector('tooltip-title')]: {
|
|
84
85
|
overflow: 'hidden',
|
|
85
86
|
'white-space': 'nowrap',
|
|
86
87
|
'text-overflow': 'ellipsis',
|
|
@@ -99,7 +100,7 @@ function createTooltip(
|
|
|
99
100
|
title: '',
|
|
100
101
|
offset,
|
|
101
102
|
template: {
|
|
102
|
-
prefixCls:
|
|
103
|
+
prefixCls: G2_CLASS_PREFIX,
|
|
103
104
|
},
|
|
104
105
|
style: deepMix(defaults, css),
|
|
105
106
|
},
|
|
@@ -529,7 +530,7 @@ function updateMarker(root, { data, style, theme }) {
|
|
|
529
530
|
const fill = type === 'hollow' ? 'transparent' : originColor;
|
|
530
531
|
const stroke = type === 'hollow' ? originColor : '#fff';
|
|
531
532
|
const shape = new Circle({
|
|
532
|
-
className:
|
|
533
|
+
className: `${G2_CLASS_PREFIX}tooltip-marker`,
|
|
533
534
|
style: {
|
|
534
535
|
cx: point[0],
|
|
535
536
|
cy: point[1],
|
|
@@ -1111,7 +1112,7 @@ export function seriesTooltip(
|
|
|
1111
1112
|
const scaleX = scale.x;
|
|
1112
1113
|
const x1 = scaleX.map(x);
|
|
1113
1114
|
const [x2, y2] = coordinate.map([x1, 0.5]);
|
|
1114
|
-
const rootBounds = root
|
|
1115
|
+
const rootBounds = bboxOf(root);
|
|
1115
1116
|
const minX = rootBounds.min[0];
|
|
1116
1117
|
const minY = rootBounds.min[1];
|
|
1117
1118
|
update({
|
package/src/interaction/utils.ts
CHANGED
|
@@ -830,17 +830,47 @@ export function extractChannelValues(view: G2ViewDescriptor): {
|
|
|
830
830
|
};
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Check if there are multiple independent axis for a given channel.
|
|
835
|
+
* Multi-axis can be defined by:
|
|
836
|
+
* 1. Explicit `independent: true` in scale configuration
|
|
837
|
+
* 2. Different `scale.key` values for the same channel name
|
|
838
|
+
*
|
|
839
|
+
* @param channel1 - Channel name (x or y)
|
|
840
|
+
* @param marks - Array of marks to check
|
|
841
|
+
* @returns true if multiple independent axis exist
|
|
842
|
+
*/
|
|
833
843
|
export function hasIndependentXYScale(
|
|
834
844
|
channel1: string,
|
|
835
845
|
marks: readonly unknown[],
|
|
836
846
|
): boolean {
|
|
837
|
-
|
|
847
|
+
const scaleKeys = new Set<string>();
|
|
848
|
+
|
|
849
|
+
for (const mark of marks) {
|
|
838
850
|
const { scale: markScale } = mark as Record<string, unknown>;
|
|
839
851
|
const channelScale = (markScale as Record<string, unknown>)?.[channel1] as
|
|
840
852
|
| Record<string, unknown>
|
|
841
853
|
| undefined;
|
|
842
|
-
|
|
843
|
-
|
|
854
|
+
|
|
855
|
+
if (!channelScale) continue;
|
|
856
|
+
|
|
857
|
+
// Early return if explicit independent flag is found
|
|
858
|
+
if (channelScale.independent) {
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// Collect scale keys, treating undefined/missing key as 'default'
|
|
863
|
+
const key = (channelScale.key as string | undefined) || 'default';
|
|
864
|
+
scaleKeys.add(key);
|
|
865
|
+
|
|
866
|
+
// Early return if multiple different keys are detected
|
|
867
|
+
if (scaleKeys.size > 1) {
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// No multiple axes detected
|
|
873
|
+
return false;
|
|
844
874
|
}
|
|
845
875
|
|
|
846
876
|
/**
|
|
@@ -928,6 +958,10 @@ export interface IndependentScaleInfo {
|
|
|
928
958
|
* This function performs a single traversal to compute all independent scale related information,
|
|
929
959
|
* avoiding repeated calculations throughout the codebase.
|
|
930
960
|
*
|
|
961
|
+
* Multi-axis detection logic:
|
|
962
|
+
* 1. Explicit independent: scale.y.independent = true
|
|
963
|
+
* 2. Different scale keys: scale.y.key = 'left' vs scale.y.key = 'right'
|
|
964
|
+
*
|
|
931
965
|
* @param view The view object containing markState
|
|
932
966
|
* @returns Complete independent scale information
|
|
933
967
|
*/
|
|
@@ -946,26 +980,49 @@ export function calculateAllIndependentScaleInfo(
|
|
|
946
980
|
const markToXScaleMap = new Map<string, string>();
|
|
947
981
|
const markToYScaleMap = new Map<string, string>();
|
|
948
982
|
|
|
949
|
-
//
|
|
983
|
+
// Track scale key assignments
|
|
984
|
+
const xScaleKeyMap = new Map<string, number>(); // key -> index
|
|
985
|
+
const yScaleKeyMap = new Map<string, number>(); // key -> index
|
|
950
986
|
let xIndex = 1;
|
|
951
987
|
let yIndex = 1;
|
|
952
988
|
|
|
989
|
+
// Single traversal to compute all classifications and mappings
|
|
953
990
|
for (const [mark] of view.markState.entries()) {
|
|
954
991
|
const markKey = mark.key;
|
|
955
992
|
|
|
956
993
|
// X axis processing
|
|
957
|
-
|
|
994
|
+
const xScaleKey = (mark?.scale?.x?.key as string) || 'x';
|
|
995
|
+
const hasExplicitIndependentX = !!mark?.scale?.x?.independent;
|
|
996
|
+
|
|
997
|
+
if (hasExplicitIndependentX || (hasIndependentX && xScaleKey !== 'x')) {
|
|
958
998
|
marksWithIndependentX.push(markKey);
|
|
959
|
-
|
|
999
|
+
|
|
1000
|
+
// Assign scale name based on key
|
|
1001
|
+
// Always use indexed names (x1, x2, ...) to avoid collision with shared 'x'
|
|
1002
|
+
if (!xScaleKeyMap.has(xScaleKey)) {
|
|
1003
|
+
xScaleKeyMap.set(xScaleKey, xIndex++);
|
|
1004
|
+
}
|
|
1005
|
+
const scaleIndex = xScaleKeyMap.get(xScaleKey);
|
|
1006
|
+
markToXScaleMap.set(markKey, `x${scaleIndex}`);
|
|
960
1007
|
} else {
|
|
961
1008
|
marksWithSharedX.push(markKey);
|
|
962
1009
|
markToXScaleMap.set(markKey, 'x');
|
|
963
1010
|
}
|
|
964
1011
|
|
|
965
1012
|
// Y axis processing
|
|
966
|
-
|
|
1013
|
+
const yScaleKey = (mark?.scale?.y?.key as string) || 'y';
|
|
1014
|
+
const hasExplicitIndependentY = !!mark?.scale?.y?.independent;
|
|
1015
|
+
|
|
1016
|
+
if (hasExplicitIndependentY || (hasIndependentY && yScaleKey !== 'y')) {
|
|
967
1017
|
marksWithIndependentY.push(markKey);
|
|
968
|
-
|
|
1018
|
+
|
|
1019
|
+
// Assign scale name based on key
|
|
1020
|
+
// Always use indexed names (y1, y2, ...) to avoid collision with shared 'y'
|
|
1021
|
+
if (!yScaleKeyMap.has(yScaleKey)) {
|
|
1022
|
+
yScaleKeyMap.set(yScaleKey, yIndex++);
|
|
1023
|
+
}
|
|
1024
|
+
const scaleIndex = yScaleKeyMap.get(yScaleKey);
|
|
1025
|
+
markToYScaleMap.set(markKey, `y${scaleIndex}`);
|
|
969
1026
|
} else {
|
|
970
1027
|
marksWithSharedY.push(markKey);
|
|
971
1028
|
markToYScaleMap.set(markKey, 'y');
|
|
@@ -29,6 +29,17 @@ const adjustPosition = (target: Bounds, edge: Bounds) => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const union = (a: AABB, b: AABB) => {
|
|
32
|
+
// Handle null bounds by returning the non-null one, or a default AABB
|
|
33
|
+
if (!a || !a.min || !a.max) {
|
|
34
|
+
if (!b || !b.min || !b.max) {
|
|
35
|
+
return { min: [0, 0], max: [0, 0] };
|
|
36
|
+
}
|
|
37
|
+
return b;
|
|
38
|
+
}
|
|
39
|
+
if (!b || !b.min || !b.max) {
|
|
40
|
+
return a;
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
return {
|
|
33
44
|
min: [Math.min(a.min[0], b.min[0]), Math.min(a.min[1], b.min[1])],
|
|
34
45
|
max: [Math.max(a.max[0], b.max[0]), Math.max(a.max[1], b.max[1])],
|
|
@@ -93,6 +104,17 @@ export const ExceedAdjust: LLC<ExceedAdjustOptions> = (options = {}) => {
|
|
|
93
104
|
labels.forEach((l) => {
|
|
94
105
|
show(l);
|
|
95
106
|
const { max, min } = union(l.getRenderBounds(), l.getBounds());
|
|
107
|
+
|
|
108
|
+
// Skip labels with invalid bounds (filtered out data points)
|
|
109
|
+
// When bounds are all zeros or invalid, it means the label shouldn't be displayed
|
|
110
|
+
if (
|
|
111
|
+
!max ||
|
|
112
|
+
!min ||
|
|
113
|
+
(max[0] === 0 && max[1] === 0 && min[0] === 0 && min[1] === 0)
|
|
114
|
+
) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
96
118
|
const [xMax, yMax] = max,
|
|
97
119
|
[xMin, yMin] = min;
|
|
98
120
|
const changeValue = adjustPosition(
|
package/src/lib/core.ts
CHANGED
|
@@ -85,6 +85,7 @@ import {
|
|
|
85
85
|
ElementHighlight,
|
|
86
86
|
ElementHighlightByX,
|
|
87
87
|
ElementHighlightByColor,
|
|
88
|
+
ElementHoverScale,
|
|
88
89
|
ElementSelect,
|
|
89
90
|
ElementSelectByX,
|
|
90
91
|
ElementSelectByColor,
|
|
@@ -105,6 +106,7 @@ import {
|
|
|
105
106
|
Poptip,
|
|
106
107
|
ScrollbarFilter,
|
|
107
108
|
TreemapDrillDown,
|
|
109
|
+
DrillDown,
|
|
108
110
|
ElementPointMove,
|
|
109
111
|
} from '../interaction';
|
|
110
112
|
import {
|
|
@@ -296,6 +298,7 @@ export function corelib() {
|
|
|
296
298
|
'interaction.elementHighlight': ElementHighlight,
|
|
297
299
|
'interaction.elementHighlightByX': ElementHighlightByX,
|
|
298
300
|
'interaction.elementHighlightByColor': ElementHighlightByColor,
|
|
301
|
+
'interaction.elementHoverScale': ElementHoverScale,
|
|
299
302
|
'interaction.elementSelect': ElementSelect,
|
|
300
303
|
'interaction.elementSelectByX': ElementSelectByX,
|
|
301
304
|
'interaction.elementSelectByColor': ElementSelectByColor,
|
|
@@ -316,6 +319,7 @@ export function corelib() {
|
|
|
316
319
|
'interaction.scrollbarFilter': ScrollbarFilter,
|
|
317
320
|
'interaction.poptip': Poptip,
|
|
318
321
|
'interaction.treemapDrillDown': TreemapDrillDown,
|
|
322
|
+
'interaction.drillDown': DrillDown,
|
|
319
323
|
'interaction.elementPointMove': ElementPointMove,
|
|
320
324
|
'composition.spaceLayer': SpaceLayer,
|
|
321
325
|
'composition.spaceFlex': SpaceFlex,
|
package/src/lib/graph.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Sankey,
|
|
3
|
+
Treemap,
|
|
4
|
+
Pack,
|
|
5
|
+
ForceGraph,
|
|
6
|
+
Tree,
|
|
7
|
+
Chord,
|
|
8
|
+
Partition,
|
|
9
|
+
} from '../mark';
|
|
2
10
|
import { Arc, Cluster } from '../data';
|
|
3
11
|
|
|
4
12
|
export function graphlib() {
|
|
@@ -11,5 +19,6 @@ export function graphlib() {
|
|
|
11
19
|
'mark.sankey': Sankey,
|
|
12
20
|
'mark.chord': Chord,
|
|
13
21
|
'mark.treemap': Treemap,
|
|
22
|
+
'mark.partition': Partition,
|
|
14
23
|
} as const;
|
|
15
24
|
}
|
package/src/mark/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { Density } from './density';
|
|
|
31
31
|
export { Heatmap } from './heatmap';
|
|
32
32
|
export { Liquid } from './liquid';
|
|
33
33
|
export { Beeswarm } from './beeswarm';
|
|
34
|
+
export { Partition } from './partition';
|
|
34
35
|
|
|
35
36
|
export type { IntervalOptions } from './interval';
|
|
36
37
|
export type { RectOptions } from './rect';
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { deepMix, pick } from '@antv/util';
|
|
2
|
+
import { CompositeMarkComponent } from '../runtime';
|
|
3
|
+
import { BaseMark, ChannelTypes, PartitionNode } from '../spec';
|
|
4
|
+
export type PartitionMark = BaseMark<'rect', 'value' | ChannelTypes>;
|
|
5
|
+
|
|
6
|
+
export interface PartitionDataNode {
|
|
7
|
+
data: PartitionNode;
|
|
8
|
+
depth: number;
|
|
9
|
+
parent: PartitionDataNode | null;
|
|
10
|
+
children: PartitionDataNode[];
|
|
11
|
+
x0: number;
|
|
12
|
+
x1: number;
|
|
13
|
+
value: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LayoutOptions {
|
|
17
|
+
valueField?: string;
|
|
18
|
+
sort?: (a: PartitionNode, b: PartitionNode) => number;
|
|
19
|
+
fillParent?: boolean; // Whether child nodes fill parent width.
|
|
20
|
+
nameField?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Partition layout algorithm.
|
|
25
|
+
* Child nodes start layout from the parent's starting position to show parent-child relationships.
|
|
26
|
+
*
|
|
27
|
+
* @param data Hierarchical data
|
|
28
|
+
* @param options Configuration options
|
|
29
|
+
*/
|
|
30
|
+
export function partitionLayout(
|
|
31
|
+
data: PartitionNode[],
|
|
32
|
+
options: LayoutOptions = {},
|
|
33
|
+
) {
|
|
34
|
+
const {
|
|
35
|
+
valueField = 'value',
|
|
36
|
+
sort,
|
|
37
|
+
fillParent = true,
|
|
38
|
+
nameField = 'name',
|
|
39
|
+
} = options;
|
|
40
|
+
|
|
41
|
+
if (!data || data.length === 0) return [];
|
|
42
|
+
|
|
43
|
+
// Build hierarchical structure
|
|
44
|
+
const buildPartition = (
|
|
45
|
+
node: PartitionNode,
|
|
46
|
+
parent: PartitionDataNode | null = null,
|
|
47
|
+
depth = 0,
|
|
48
|
+
): PartitionDataNode => {
|
|
49
|
+
const partitionNode: PartitionDataNode = {
|
|
50
|
+
data: node,
|
|
51
|
+
depth,
|
|
52
|
+
parent,
|
|
53
|
+
children: [],
|
|
54
|
+
x0: 0,
|
|
55
|
+
x1: 0,
|
|
56
|
+
value: node[valueField] || 0,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (node.children && node.children.length > 0) {
|
|
60
|
+
partitionNode.children = node.children.map((child: PartitionNode) =>
|
|
61
|
+
buildPartition(child, partitionNode, depth + 1),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return partitionNode;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Process each root node
|
|
69
|
+
const result: Array<Record<string, any>> = [];
|
|
70
|
+
let currentRootStartX = 0; // Track the starting position for the next root node
|
|
71
|
+
|
|
72
|
+
data.forEach((rootData: PartitionNode) => {
|
|
73
|
+
const root = buildPartition(rootData);
|
|
74
|
+
|
|
75
|
+
// Calculate position for each node - key point: child nodes start layout from parent's starting position
|
|
76
|
+
const calculateLayout = (
|
|
77
|
+
node: PartitionDataNode,
|
|
78
|
+
parentStartX = 0,
|
|
79
|
+
isRootNode = false,
|
|
80
|
+
parentWidth = 0, // Parent node actual width.
|
|
81
|
+
): void => {
|
|
82
|
+
if (isRootNode || node.depth === 0) {
|
|
83
|
+
// Root node: start from current root position
|
|
84
|
+
node.x0 = isRootNode ? parentStartX : 0;
|
|
85
|
+
node.x1 = node.x0 + node.value;
|
|
86
|
+
} else {
|
|
87
|
+
// Child node: start layout from parent's starting position
|
|
88
|
+
node.x0 = parentStartX;
|
|
89
|
+
if (fillParent && parentWidth > 0) {
|
|
90
|
+
// If fillParent is true, calculate width based on parent width and value ratio.
|
|
91
|
+
const siblingsTotalValue = node.parent
|
|
92
|
+
? node.parent.children.reduce((acc, child) => acc + child.value, 0)
|
|
93
|
+
: node.value;
|
|
94
|
+
const siblingsCount = node.parent ? node.parent.children.length : 1;
|
|
95
|
+
const ratio =
|
|
96
|
+
siblingsTotalValue > 0
|
|
97
|
+
? node.value / siblingsTotalValue
|
|
98
|
+
: 1 / siblingsCount;
|
|
99
|
+
node.x1 = parentStartX + parentWidth * ratio;
|
|
100
|
+
} else {
|
|
101
|
+
// If fillParent is false, use node own value as width.
|
|
102
|
+
node.x1 = parentStartX + node.value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Calculate position for child nodes - start from current node's starting position
|
|
107
|
+
let childStartX = node.x0;
|
|
108
|
+
const nodeWidth = node.x1 - node.x0;
|
|
109
|
+
|
|
110
|
+
const sortedChildren = sort
|
|
111
|
+
? [...node.children].sort(
|
|
112
|
+
(a: PartitionDataNode, b: PartitionDataNode) =>
|
|
113
|
+
sort(a.data, b.data),
|
|
114
|
+
)
|
|
115
|
+
: node.children;
|
|
116
|
+
|
|
117
|
+
if (fillParent && sortedChildren.length > 0) {
|
|
118
|
+
// fillParent mode: child nodes fill parent width proportionally.
|
|
119
|
+
const childrenTotalValue = node.children.reduce(
|
|
120
|
+
(sum, c) => sum + c.value,
|
|
121
|
+
0,
|
|
122
|
+
);
|
|
123
|
+
sortedChildren.forEach((child: PartitionDataNode) => {
|
|
124
|
+
calculateLayout(child, childStartX, false, nodeWidth);
|
|
125
|
+
const ratio =
|
|
126
|
+
childrenTotalValue > 0
|
|
127
|
+
? child.value / childrenTotalValue
|
|
128
|
+
: 1 / sortedChildren.length;
|
|
129
|
+
childStartX += nodeWidth * ratio;
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
// Non-fillParent mode: child nodes layout independently based on own value.
|
|
133
|
+
sortedChildren.forEach((child: PartitionDataNode) => {
|
|
134
|
+
calculateLayout(child, childStartX, false, 0);
|
|
135
|
+
// Next child node starts from current child node's end position.
|
|
136
|
+
childStartX += child.x1 - child.x0;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Start layout calculation from root node, using current root start position.
|
|
142
|
+
calculateLayout(root, currentRootStartX, true);
|
|
143
|
+
|
|
144
|
+
// Update the starting position for the next root node.
|
|
145
|
+
currentRootStartX += root.value;
|
|
146
|
+
|
|
147
|
+
// Convert to final format.
|
|
148
|
+
const processNode = (node: PartitionDataNode): Record<string, any> => {
|
|
149
|
+
const getName = (d: PartitionNode) => d[nameField] ?? d.name;
|
|
150
|
+
const path = [getName(node.data)];
|
|
151
|
+
let ancestorNode = node;
|
|
152
|
+
while (ancestorNode.parent) {
|
|
153
|
+
path.unshift(getName(ancestorNode.parent.data));
|
|
154
|
+
ancestorNode = ancestorNode.parent;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
...pick(node.data, [valueField]),
|
|
159
|
+
[PARTITION_PATH_FIELD]: path,
|
|
160
|
+
[PARTITION_ANCESTOR_FIELD]:
|
|
161
|
+
ancestorNode.parent?.data?.[nameField] ?? node.data[nameField],
|
|
162
|
+
name: node.data[nameField],
|
|
163
|
+
depth: node.depth,
|
|
164
|
+
value: node.value,
|
|
165
|
+
x: [node.x0, node.x1],
|
|
166
|
+
y: [node.depth, node.depth + 1],
|
|
167
|
+
// Add child node count attribute for drill-down interaction judgment.
|
|
168
|
+
[CHILD_NODE_COUNT]: node.children.length,
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Collect all nodes.
|
|
173
|
+
const collectResultNodes = (node: PartitionDataNode): void => {
|
|
174
|
+
result.push(processNode(node));
|
|
175
|
+
node.children.forEach(collectResultNodes);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
collectResultNodes(root);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type PartitionData = PartitionNode[];
|
|
185
|
+
|
|
186
|
+
export type PartitionOptions = Omit<PartitionMark, 'type'> & {
|
|
187
|
+
fillParent?: boolean; // Whether child nodes fill parent width.
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const PARTITION_TYPE = 'partition';
|
|
191
|
+
export const PARTITION_TYPE_FIELD = 'markType';
|
|
192
|
+
export const PARTITION_PATH_FIELD = 'path';
|
|
193
|
+
export const PARTITION_ANCESTOR_FIELD = 'ancestor-node';
|
|
194
|
+
export const CHILD_NODE_COUNT = 'childNodeCount';
|
|
195
|
+
|
|
196
|
+
export function transformData(
|
|
197
|
+
options: Pick<PartitionOptions, 'data' | 'encode'> & {
|
|
198
|
+
fillParent?: boolean;
|
|
199
|
+
sort?: (a: PartitionNode, b: PartitionNode) => number;
|
|
200
|
+
},
|
|
201
|
+
) {
|
|
202
|
+
const { data, encode, fillParent, sort } = options;
|
|
203
|
+
const { color, value, name } = encode as any;
|
|
204
|
+
|
|
205
|
+
const nodes = partitionLayout(data, {
|
|
206
|
+
valueField: value,
|
|
207
|
+
fillParent,
|
|
208
|
+
nameField: name,
|
|
209
|
+
sort,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return nodes.map((node: Record<string, any>) => {
|
|
213
|
+
// Handle color mapping.
|
|
214
|
+
const nodeInfo = { ...node };
|
|
215
|
+
if (color && color !== PARTITION_ANCESTOR_FIELD) {
|
|
216
|
+
nodeInfo[color] = node[color];
|
|
217
|
+
}
|
|
218
|
+
return nodeInfo;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const DEFAULT_OPTIONS = {
|
|
223
|
+
id: PARTITION_TYPE,
|
|
224
|
+
encode: {
|
|
225
|
+
x: 'x',
|
|
226
|
+
y: 'y',
|
|
227
|
+
key: PARTITION_PATH_FIELD,
|
|
228
|
+
color: PARTITION_ANCESTOR_FIELD,
|
|
229
|
+
value: 'value',
|
|
230
|
+
name: 'name',
|
|
231
|
+
},
|
|
232
|
+
labels: [
|
|
233
|
+
{
|
|
234
|
+
style: {
|
|
235
|
+
pointerEvents: 'none',
|
|
236
|
+
},
|
|
237
|
+
text: 'value',
|
|
238
|
+
position: 'inside',
|
|
239
|
+
transform: [
|
|
240
|
+
{
|
|
241
|
+
type: 'overflowHide',
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
axis: {
|
|
247
|
+
x: { title: 'Time/Order', label: true },
|
|
248
|
+
y: false,
|
|
249
|
+
},
|
|
250
|
+
style: {
|
|
251
|
+
[PARTITION_TYPE_FIELD]: PARTITION_TYPE,
|
|
252
|
+
[CHILD_NODE_COUNT]: 'childNodeCount', // Add child node count attribute for drill-down interaction.
|
|
253
|
+
},
|
|
254
|
+
state: {
|
|
255
|
+
active: { zIndex: 2 },
|
|
256
|
+
inactive: { zIndex: 1 },
|
|
257
|
+
},
|
|
258
|
+
legend: false,
|
|
259
|
+
coordinate: {
|
|
260
|
+
type: 'cartesian',
|
|
261
|
+
grid: false, // Remove grid lines.
|
|
262
|
+
},
|
|
263
|
+
interaction: {
|
|
264
|
+
drillDown: true,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const Partition: CompositeMarkComponent<PartitionOptions> = (
|
|
269
|
+
options,
|
|
270
|
+
) => {
|
|
271
|
+
const {
|
|
272
|
+
encode: encodeOption,
|
|
273
|
+
data = [],
|
|
274
|
+
layout = {},
|
|
275
|
+
...resOptions
|
|
276
|
+
} = options;
|
|
277
|
+
|
|
278
|
+
const { fillParent = true, sort } = layout as {
|
|
279
|
+
fillParent?: boolean;
|
|
280
|
+
sort?: (a: PartitionNode, b: PartitionNode) => number;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const encode = { ...DEFAULT_OPTIONS.encode, ...encodeOption };
|
|
284
|
+
const { value } = encode;
|
|
285
|
+
const rectData = transformData({ encode, data, fillParent, sort });
|
|
286
|
+
|
|
287
|
+
return [
|
|
288
|
+
deepMix({}, DEFAULT_OPTIONS, {
|
|
289
|
+
type: 'rect',
|
|
290
|
+
data: rectData,
|
|
291
|
+
encode,
|
|
292
|
+
tooltip: {
|
|
293
|
+
title: 'path',
|
|
294
|
+
items: [
|
|
295
|
+
(d: Record<string, any>) => {
|
|
296
|
+
return {
|
|
297
|
+
name: value as string,
|
|
298
|
+
value: d[value],
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
// Add basic interaction.
|
|
304
|
+
interaction: {
|
|
305
|
+
elementHighlight: true,
|
|
306
|
+
},
|
|
307
|
+
...resOptions,
|
|
308
|
+
}),
|
|
309
|
+
];
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
Partition.props = {};
|
package/src/runtime/mark.ts
CHANGED
|
@@ -39,7 +39,7 @@ export async function initializeMark(
|
|
|
39
39
|
context,
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const { encode, scale, data, tooltip, key:
|
|
42
|
+
const { encode, scale, data, tooltip, key: markKey } = transformedMark;
|
|
43
43
|
|
|
44
44
|
// Skip mark with non-tabular data. Do not skip empty
|
|
45
45
|
// data, they are useful for facet to display axes.
|
|
@@ -107,7 +107,7 @@ export async function initializeMark(
|
|
|
107
107
|
scaleKey: independent || isConstant ? Symbol('independent') : key,
|
|
108
108
|
scale: {
|
|
109
109
|
type,
|
|
110
|
-
|
|
110
|
+
markKey,
|
|
111
111
|
range: finalRange,
|
|
112
112
|
...scaleOptions,
|
|
113
113
|
quantitative,
|