@antv/g2 4.1.25 → 4.1.29
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/CHANGELOG.md +1116 -0
- package/{README.zh-CN.md → README.en-US.md} +39 -38
- package/README.md +39 -38
- package/dist/g2.min.js +31 -3
- package/dist/g2.min.js.map +1 -1
- package/esm/animate/index.js +1 -1
- package/esm/animate/index.js.map +1 -1
- package/esm/animate/interface.js +1 -0
- package/esm/chart/chart.js +1 -3
- package/esm/chart/chart.js.map +1 -1
- package/esm/chart/controller/annotation.js +14 -44
- package/esm/chart/controller/annotation.js.map +1 -1
- package/esm/chart/controller/coordinate.js +1 -2
- package/esm/chart/controller/coordinate.js.map +1 -1
- package/esm/chart/controller/scrollbar.js +3 -7
- package/esm/chart/controller/scrollbar.js.map +1 -1
- package/esm/chart/controller/slider.js +1 -2
- package/esm/chart/controller/slider.js.map +1 -1
- package/esm/chart/controller/tooltip.js +12 -7
- package/esm/chart/controller/tooltip.js.map +1 -1
- package/esm/chart/layout/auto.js +2 -2
- package/esm/chart/layout/auto.js.map +1 -1
- package/esm/chart/layout/constraint/bounds.d.ts +32 -0
- package/esm/chart/layout/constraint/bounds.js +30 -0
- package/esm/chart/layout/constraint/bounds.js.map +1 -0
- package/esm/chart/layout/constraint/constraint.d.ts +31 -0
- package/esm/chart/layout/constraint/constraint.js +81 -0
- package/esm/chart/layout/constraint/constraint.js.map +1 -0
- package/esm/chart/layout/constraint/gauss.d.ts +11 -0
- package/esm/chart/layout/constraint/gauss.js +63 -0
- package/esm/chart/layout/constraint/gauss.js.map +1 -0
- package/esm/chart/layout/constraint/index.d.ts +5 -0
- package/esm/chart/layout/constraint/index.js +30 -0
- package/esm/chart/layout/constraint/index.js.map +1 -0
- package/esm/chart/layout/constraint/solver.d.ts +40 -0
- package/esm/chart/layout/constraint/solver.js +77 -0
- package/esm/chart/layout/constraint/solver.js.map +1 -0
- package/esm/chart/layout/constraint/types.d.ts +21 -0
- package/esm/chart/layout/constraint/types.js +13 -0
- package/esm/chart/layout/constraint/types.js.map +1 -0
- package/esm/chart/layout/constraint/variable.d.ts +24 -0
- package/esm/chart/layout/constraint/variable.js +28 -0
- package/esm/chart/layout/constraint/variable.js.map +1 -0
- package/esm/chart/layout/padding-cal.js +2 -2
- package/esm/chart/layout/padding-cal.js.map +1 -1
- package/esm/chart/view.d.ts +41 -1
- package/esm/chart/view.js +65 -9
- package/esm/chart/view.js.map +1 -1
- package/esm/core.d.ts +1 -1
- package/esm/core.js +1 -1
- package/esm/core.js.map +1 -1
- package/esm/facet/facet.d.ts +5 -0
- package/esm/facet/facet.js +47 -12
- package/esm/facet/facet.js.map +1 -1
- package/esm/facet/tree.js +1 -1
- package/esm/facet/tree.js.map +1 -1
- package/esm/geometry/base.d.ts +34 -7
- package/esm/geometry/base.js +131 -74
- package/esm/geometry/base.js.map +1 -1
- package/esm/geometry/element/index.js.map +1 -1
- package/esm/geometry/heatmap.d.ts +1 -2
- package/esm/geometry/heatmap.js +13 -13
- package/esm/geometry/heatmap.js.map +1 -1
- package/esm/geometry/label/base.js +1 -1
- package/esm/geometry/label/base.js.map +1 -1
- package/esm/geometry/label/interface.js +1 -0
- package/esm/geometry/label/layout/interval/adjust-position.js.map +1 -1
- package/esm/geometry/label/layout/interval/hide-overlap.js.map +1 -1
- package/esm/geometry/label/layout/path/adjust-position.js.map +1 -1
- package/esm/geometry/label/layout/pie/distribute.js +1 -1
- package/esm/geometry/label/layout/pie/distribute.js.map +1 -1
- package/esm/geometry/label/layout/point/adjust-position.js.map +1 -1
- package/esm/geometry/label/pie.js +1 -2
- package/esm/geometry/label/pie.js.map +1 -1
- package/esm/geometry/path.d.ts +1 -2
- package/esm/geometry/path.js +46 -20
- package/esm/geometry/path.js.map +1 -1
- package/esm/geometry/shape/schema/index.js +1 -1
- package/esm/geometry/shape/schema/index.js.map +1 -1
- package/esm/geometry/util/diff.d.ts +11 -0
- package/esm/geometry/util/diff.js +30 -0
- package/esm/geometry/util/diff.js.map +1 -0
- package/esm/interface.d.ts +11 -10
- package/esm/interface.js +1 -0
- package/esm/interface.js.map +1 -1
- package/esm/theme/style-sheet/dark.d.ts +2 -2
- package/esm/theme/style-sheet/dark.js +2 -2
- package/esm/theme/style-sheet/dark.js.map +1 -1
- package/esm/theme/style-sheet/light.d.ts +2 -2
- package/esm/theme/style-sheet/light.js +2 -2
- package/esm/theme/style-sheet/light.js.map +1 -1
- package/esm/theme/util/create-by-style-sheet.js +1 -1
- package/esm/theme/util/create-by-style-sheet.js.map +1 -1
- package/esm/util/annotation.js +2 -0
- package/esm/util/annotation.js.map +1 -1
- package/esm/util/attr.js +2 -2
- package/esm/util/attr.js.map +1 -1
- package/esm/util/collision-detect.js +2 -2
- package/esm/util/collision-detect.js.map +1 -1
- package/esm/util/facet.js +1 -1
- package/esm/util/facet.js.map +1 -1
- package/esm/util/helper.d.ts +1 -1
- package/esm/util/helper.js +3 -3
- package/esm/util/helper.js.map +1 -1
- package/esm/util/legend.js +2 -1
- package/esm/util/legend.js.map +1 -1
- package/esm/util/padding.js +3 -3
- package/esm/util/padding.js.map +1 -1
- package/esm/util/scale.js +3 -4
- package/esm/util/scale.js.map +1 -1
- package/esm/util/stat.js +2 -2
- package/esm/util/stat.js.map +1 -1
- package/esm/util/text.js +2 -2
- package/esm/util/text.js.map +1 -1
- package/esm/util/types.js +1 -0
- package/lib/animate/animation/fade.js +3 -3
- package/lib/animate/animation/fade.js.map +1 -1
- package/lib/animate/animation/grow-in.js +3 -3
- package/lib/animate/animation/grow-in.js.map +1 -1
- package/lib/animate/animation/sector-path-update.js +11 -11
- package/lib/animate/animation/sector-path-update.js.map +1 -1
- package/lib/animate/animation/wave-in.js +2 -2
- package/lib/animate/animation/wave-in.js.map +1 -1
- package/lib/animate/animation/zoom.js +2 -2
- package/lib/animate/animation/zoom.js.map +1 -1
- package/lib/animate/index.js +10 -10
- package/lib/animate/index.js.map +1 -1
- package/lib/api.js +1 -1
- package/lib/api.js.map +1 -1
- package/lib/base.js +2 -2
- package/lib/base.js.map +1 -1
- package/lib/chart/chart.js +12 -14
- package/lib/chart/chart.js.map +1 -1
- package/lib/chart/controller/annotation.js +67 -97
- package/lib/chart/controller/annotation.js.map +1 -1
- package/lib/chart/controller/axis.js +64 -64
- package/lib/chart/controller/axis.js.map +1 -1
- package/lib/chart/controller/base.js +1 -1
- package/lib/chart/controller/base.js.map +1 -1
- package/lib/chart/controller/coordinate.js +6 -7
- package/lib/chart/controller/coordinate.js.map +1 -1
- package/lib/chart/controller/gesture.js +1 -1
- package/lib/chart/controller/gesture.js.map +1 -1
- package/lib/chart/controller/legend.js +45 -45
- package/lib/chart/controller/legend.js.map +1 -1
- package/lib/chart/controller/scrollbar.js +26 -30
- package/lib/chart/controller/scrollbar.js.map +1 -1
- package/lib/chart/controller/slider.js +25 -26
- package/lib/chart/controller/slider.js.map +1 -1
- package/lib/chart/controller/tooltip.js +45 -40
- package/lib/chart/controller/tooltip.js.map +1 -1
- package/lib/chart/index.js +7 -3
- package/lib/chart/index.js.map +1 -1
- package/lib/chart/layout/auto.js +6 -6
- package/lib/chart/layout/auto.js.map +1 -1
- package/lib/chart/layout/constraint/bounds.d.ts +32 -0
- package/lib/chart/layout/constraint/bounds.js +33 -0
- package/lib/chart/layout/constraint/bounds.js.map +1 -0
- package/lib/chart/layout/constraint/constraint.d.ts +31 -0
- package/lib/chart/layout/constraint/constraint.js +84 -0
- package/lib/chart/layout/constraint/constraint.js.map +1 -0
- package/lib/chart/layout/constraint/gauss.d.ts +11 -0
- package/lib/chart/layout/constraint/gauss.js +68 -0
- package/lib/chart/layout/constraint/gauss.js.map +1 -0
- package/lib/chart/layout/constraint/index.d.ts +5 -0
- package/lib/chart/layout/constraint/index.js +38 -0
- package/lib/chart/layout/constraint/index.js.map +1 -0
- package/lib/chart/layout/constraint/solver.d.ts +40 -0
- package/lib/chart/layout/constraint/solver.js +80 -0
- package/lib/chart/layout/constraint/solver.js.map +1 -0
- package/lib/chart/layout/constraint/types.d.ts +21 -0
- package/lib/chart/layout/constraint/types.js +16 -0
- package/lib/chart/layout/constraint/types.js.map +1 -0
- package/lib/chart/layout/constraint/variable.d.ts +24 -0
- package/lib/chart/layout/constraint/variable.js +31 -0
- package/lib/chart/layout/constraint/variable.js.map +1 -0
- package/lib/chart/layout/padding-cal.js +1 -1
- package/lib/chart/layout/padding-cal.js.map +1 -1
- package/lib/chart/util/scale-pool.js +12 -12
- package/lib/chart/util/scale-pool.js.map +1 -1
- package/lib/chart/view.d.ts +41 -1
- package/lib/chart/view.js +142 -86
- package/lib/chart/view.js.map +1 -1
- package/lib/component/labels.js +32 -32
- package/lib/component/labels.js.map +1 -1
- package/lib/component/update-label.js +4 -4
- package/lib/component/update-label.js.map +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/core.js +8 -8
- package/lib/core.js.map +1 -1
- package/lib/dependents.js +1 -1
- package/lib/facet/circle.js +10 -10
- package/lib/facet/circle.js.map +1 -1
- package/lib/facet/facet.d.ts +5 -0
- package/lib/facet/facet.js +56 -21
- package/lib/facet/facet.js.map +1 -1
- package/lib/facet/index.js +7 -5
- package/lib/facet/index.js.map +1 -1
- package/lib/facet/list.js +9 -9
- package/lib/facet/list.js.map +1 -1
- package/lib/facet/matrix.js +13 -13
- package/lib/facet/matrix.js.map +1 -1
- package/lib/facet/mirror.js +10 -10
- package/lib/facet/mirror.js.map +1 -1
- package/lib/facet/rect.js +16 -16
- package/lib/facet/rect.js.map +1 -1
- package/lib/facet/tree.js +10 -10
- package/lib/facet/tree.js.map +1 -1
- package/lib/geometry/area.js +2 -2
- package/lib/geometry/area.js.map +1 -1
- package/lib/geometry/base.d.ts +34 -7
- package/lib/geometry/base.js +203 -146
- package/lib/geometry/base.js.map +1 -1
- package/lib/geometry/edge.js +2 -2
- package/lib/geometry/edge.js.map +1 -1
- package/lib/geometry/element/index.js +22 -22
- package/lib/geometry/element/index.js.map +1 -1
- package/lib/geometry/heatmap.d.ts +1 -2
- package/lib/geometry/heatmap.js +18 -18
- package/lib/geometry/heatmap.js.map +1 -1
- package/lib/geometry/interval.js +7 -7
- package/lib/geometry/interval.js.map +1 -1
- package/lib/geometry/label/base.js +33 -33
- package/lib/geometry/label/base.js.map +1 -1
- package/lib/geometry/label/interval.js +15 -15
- package/lib/geometry/label/interval.js.map +1 -1
- package/lib/geometry/label/layout/adjust-color.js +1 -1
- package/lib/geometry/label/layout/adjust-color.js.map +1 -1
- package/lib/geometry/label/layout/hide-overlap.js +3 -3
- package/lib/geometry/label/layout/hide-overlap.js.map +1 -1
- package/lib/geometry/label/layout/interval/adjust-position.js +2 -2
- package/lib/geometry/label/layout/interval/adjust-position.js.map +1 -1
- package/lib/geometry/label/layout/interval/hide-overlap.js +7 -7
- package/lib/geometry/label/layout/interval/hide-overlap.js.map +1 -1
- package/lib/geometry/label/layout/limit-in-canvas.js +2 -2
- package/lib/geometry/label/layout/limit-in-canvas.js.map +1 -1
- package/lib/geometry/label/layout/limit-in-plot.js +5 -5
- package/lib/geometry/label/layout/limit-in-plot.js.map +1 -1
- package/lib/geometry/label/layout/limit-in-shape.js +1 -1
- package/lib/geometry/label/layout/limit-in-shape.js.map +1 -1
- package/lib/geometry/label/layout/overlap.js +2 -2
- package/lib/geometry/label/layout/overlap.js.map +1 -1
- package/lib/geometry/label/layout/path/adjust-position.js +5 -5
- package/lib/geometry/label/layout/path/adjust-position.js.map +1 -1
- package/lib/geometry/label/layout/pie/distribute.js +8 -8
- package/lib/geometry/label/layout/pie/distribute.js.map +1 -1
- package/lib/geometry/label/layout/pie/outer.js +16 -16
- package/lib/geometry/label/layout/pie/outer.js.map +1 -1
- package/lib/geometry/label/layout/pie/spider.js +18 -18
- package/lib/geometry/label/layout/pie/spider.js.map +1 -1
- package/lib/geometry/label/layout/point/adjust-position.js +5 -5
- package/lib/geometry/label/layout/point/adjust-position.js.map +1 -1
- package/lib/geometry/label/pie.js +8 -9
- package/lib/geometry/label/pie.js.map +1 -1
- package/lib/geometry/label/polar.js +14 -14
- package/lib/geometry/label/polar.js.map +1 -1
- package/lib/geometry/label/util/index.js +4 -4
- package/lib/geometry/label/util/index.js.map +1 -1
- package/lib/geometry/line.js +2 -2
- package/lib/geometry/line.js.map +1 -1
- package/lib/geometry/path.d.ts +1 -2
- package/lib/geometry/path.js +50 -24
- package/lib/geometry/path.js.map +1 -1
- package/lib/geometry/point.js +3 -3
- package/lib/geometry/point.js.map +1 -1
- package/lib/geometry/polygon.js +5 -5
- package/lib/geometry/polygon.js.map +1 -1
- package/lib/geometry/schema.js +4 -4
- package/lib/geometry/schema.js.map +1 -1
- package/lib/geometry/shape/area/index.js +4 -4
- package/lib/geometry/shape/area/index.js.map +1 -1
- package/lib/geometry/shape/area/line.js +2 -2
- package/lib/geometry/shape/area/line.js.map +1 -1
- package/lib/geometry/shape/area/smooth-line.js +2 -2
- package/lib/geometry/shape/area/smooth-line.js.map +1 -1
- package/lib/geometry/shape/area/smooth.js +2 -2
- package/lib/geometry/shape/area/smooth.js.map +1 -1
- package/lib/geometry/shape/area/util.js +5 -5
- package/lib/geometry/shape/area/util.js.map +1 -1
- package/lib/geometry/shape/base.js +11 -11
- package/lib/geometry/shape/base.js.map +1 -1
- package/lib/geometry/shape/edge/arc.js +11 -11
- package/lib/geometry/shape/edge/arc.js.map +1 -1
- package/lib/geometry/shape/edge/index.js +6 -6
- package/lib/geometry/shape/edge/index.js.map +1 -1
- package/lib/geometry/shape/edge/smooth.js +4 -4
- package/lib/geometry/shape/edge/smooth.js.map +1 -1
- package/lib/geometry/shape/edge/util.js +1 -1
- package/lib/geometry/shape/edge/util.js.map +1 -1
- package/lib/geometry/shape/edge/vhv.js +4 -4
- package/lib/geometry/shape/edge/vhv.js.map +1 -1
- package/lib/geometry/shape/interval/funnel.js +5 -5
- package/lib/geometry/shape/interval/funnel.js.map +1 -1
- package/lib/geometry/shape/interval/hollow-rect.js +7 -7
- package/lib/geometry/shape/interval/hollow-rect.js.map +1 -1
- package/lib/geometry/shape/interval/index.js +10 -10
- package/lib/geometry/shape/interval/index.js.map +1 -1
- package/lib/geometry/shape/interval/line.js +7 -7
- package/lib/geometry/shape/interval/line.js.map +1 -1
- package/lib/geometry/shape/interval/pyramid.js +5 -5
- package/lib/geometry/shape/interval/pyramid.js.map +1 -1
- package/lib/geometry/shape/interval/tick.js +4 -4
- package/lib/geometry/shape/interval/tick.js.map +1 -1
- package/lib/geometry/shape/interval/util.js +8 -8
- package/lib/geometry/shape/interval/util.js.map +1 -1
- package/lib/geometry/shape/line/index.js +11 -11
- package/lib/geometry/shape/line/index.js.map +1 -1
- package/lib/geometry/shape/line/step.js +7 -7
- package/lib/geometry/shape/line/step.js.map +1 -1
- package/lib/geometry/shape/point/hollow.js +3 -3
- package/lib/geometry/shape/point/hollow.js.map +1 -1
- package/lib/geometry/shape/point/image.js +2 -2
- package/lib/geometry/shape/point/image.js.map +1 -1
- package/lib/geometry/shape/point/index.js +5 -5
- package/lib/geometry/shape/point/index.js.map +1 -1
- package/lib/geometry/shape/point/solid.js +3 -3
- package/lib/geometry/shape/point/solid.js.map +1 -1
- package/lib/geometry/shape/point/util.js +3 -3
- package/lib/geometry/shape/point/util.js.map +1 -1
- package/lib/geometry/shape/polygon/index.js +7 -7
- package/lib/geometry/shape/polygon/index.js.map +1 -1
- package/lib/geometry/shape/polygon/square.js +5 -5
- package/lib/geometry/shape/polygon/square.js.map +1 -1
- package/lib/geometry/shape/schema/box.js +6 -6
- package/lib/geometry/shape/schema/box.js.map +1 -1
- package/lib/geometry/shape/schema/candle.js +5 -5
- package/lib/geometry/shape/schema/candle.js.map +1 -1
- package/lib/geometry/shape/schema/index.js +2 -2
- package/lib/geometry/shape/schema/index.js.map +1 -1
- package/lib/geometry/shape/util/get-path-points.js +4 -4
- package/lib/geometry/shape/util/get-path-points.js.map +1 -1
- package/lib/geometry/shape/util/get-style.js +4 -4
- package/lib/geometry/shape/util/get-style.js.map +1 -1
- package/lib/geometry/shape/util/path.js +7 -6
- package/lib/geometry/shape/util/path.js.map +1 -1
- package/lib/geometry/shape/util/split-points.js +2 -2
- package/lib/geometry/shape/util/split-points.js.map +1 -1
- package/lib/geometry/shape/violin/hollow.js +8 -8
- package/lib/geometry/shape/violin/hollow.js.map +1 -1
- package/lib/geometry/shape/violin/index.js +9 -9
- package/lib/geometry/shape/violin/index.js.map +1 -1
- package/lib/geometry/shape/violin/smooth.js +4 -4
- package/lib/geometry/shape/violin/smooth.js.map +1 -1
- package/lib/geometry/util/diff.d.ts +11 -0
- package/lib/geometry/util/diff.js +34 -0
- package/lib/geometry/util/diff.js.map +1 -0
- package/lib/geometry/util/get-shape-type.js +1 -1
- package/lib/geometry/util/get-shape-type.js.map +1 -1
- package/lib/geometry/util/group-data.js +1 -1
- package/lib/geometry/util/group-data.js.map +1 -1
- package/lib/geometry/util/is-model-change.js +2 -2
- package/lib/geometry/util/is-model-change.js.map +1 -1
- package/lib/geometry/util/parse-fields.js +1 -1
- package/lib/geometry/util/parse-fields.js.map +1 -1
- package/lib/geometry/util/shape-size.js +9 -9
- package/lib/geometry/util/shape-size.js.map +1 -1
- package/lib/geometry/violin.js +5 -5
- package/lib/geometry/violin.js.map +1 -1
- package/lib/index.js +193 -193
- package/lib/index.js.map +1 -1
- package/lib/interaction/action/active-region.js +19 -19
- package/lib/interaction/action/active-region.js.map +1 -1
- package/lib/interaction/action/base.js +1 -1
- package/lib/interaction/action/base.js.map +1 -1
- package/lib/interaction/action/callback.js +2 -2
- package/lib/interaction/action/callback.js.map +1 -1
- package/lib/interaction/action/component/list-active.js +2 -2
- package/lib/interaction/action/component/list-active.js.map +1 -1
- package/lib/interaction/action/component/list-checked.js +5 -5
- package/lib/interaction/action/component/list-checked.js.map +1 -1
- package/lib/interaction/action/component/list-highlight-util.js +1 -1
- package/lib/interaction/action/component/list-highlight-util.js.map +1 -1
- package/lib/interaction/action/component/list-highlight.js +7 -7
- package/lib/interaction/action/component/list-highlight.js.map +1 -1
- package/lib/interaction/action/component/list-selected.js +2 -2
- package/lib/interaction/action/component/list-selected.js.map +1 -1
- package/lib/interaction/action/component/list-state.js +15 -15
- package/lib/interaction/action/component/list-state.js.map +1 -1
- package/lib/interaction/action/component/list-unchecked.js +2 -2
- package/lib/interaction/action/component/list-unchecked.js.map +1 -1
- package/lib/interaction/action/component/tooltip/ellipsis-text.js +6 -6
- package/lib/interaction/action/component/tooltip/ellipsis-text.js.map +1 -1
- package/lib/interaction/action/component/tooltip/geometry.js +4 -4
- package/lib/interaction/action/component/tooltip/geometry.js.map +1 -1
- package/lib/interaction/action/component/tooltip/sibling.js +7 -7
- package/lib/interaction/action/component/tooltip/sibling.js.map +1 -1
- package/lib/interaction/action/cursor.js +2 -2
- package/lib/interaction/action/cursor.js.map +1 -1
- package/lib/interaction/action/data/filter.js +7 -7
- package/lib/interaction/action/data/filter.js.map +1 -1
- package/lib/interaction/action/data/range-filter.js +3 -3
- package/lib/interaction/action/data/range-filter.js.map +1 -1
- package/lib/interaction/action/data/sibling-filter.js +6 -6
- package/lib/interaction/action/data/sibling-filter.js.map +1 -1
- package/lib/interaction/action/element/active.js +2 -2
- package/lib/interaction/action/element/active.js.map +1 -1
- package/lib/interaction/action/element/filter.js +16 -16
- package/lib/interaction/action/element/filter.js.map +1 -1
- package/lib/interaction/action/element/highlight-by-color.js +5 -5
- package/lib/interaction/action/element/highlight-by-color.js.map +1 -1
- package/lib/interaction/action/element/highlight-by-x.js +6 -6
- package/lib/interaction/action/element/highlight-by-x.js.map +1 -1
- package/lib/interaction/action/element/highlight-util.js +3 -3
- package/lib/interaction/action/element/highlight-util.js.map +1 -1
- package/lib/interaction/action/element/highlight.js +8 -8
- package/lib/interaction/action/element/highlight.js.map +1 -1
- package/lib/interaction/action/element/link-by-color.js +9 -9
- package/lib/interaction/action/element/link-by-color.js.map +1 -1
- package/lib/interaction/action/element/range-active.js +2 -2
- package/lib/interaction/action/element/range-active.js.map +1 -1
- package/lib/interaction/action/element/range-highlight.js +4 -4
- package/lib/interaction/action/element/range-highlight.js.map +1 -1
- package/lib/interaction/action/element/range-selected.js +2 -2
- package/lib/interaction/action/element/range-selected.js.map +1 -1
- package/lib/interaction/action/element/range-state.js +18 -18
- package/lib/interaction/action/element/range-state.js.map +1 -1
- package/lib/interaction/action/element/selected.js +2 -2
- package/lib/interaction/action/element/selected.js.map +1 -1
- package/lib/interaction/action/element/sibling-filter.js +18 -18
- package/lib/interaction/action/element/sibling-filter.js.map +1 -1
- package/lib/interaction/action/element/single-active.js +2 -2
- package/lib/interaction/action/element/single-active.js.map +1 -1
- package/lib/interaction/action/element/single-highlight.js +5 -5
- package/lib/interaction/action/element/single-highlight.js.map +1 -1
- package/lib/interaction/action/element/single-selected.js +2 -2
- package/lib/interaction/action/element/single-selected.js.map +1 -1
- package/lib/interaction/action/element/single-state.js +5 -5
- package/lib/interaction/action/element/single-state.js.map +1 -1
- package/lib/interaction/action/element/state-base.js +4 -4
- package/lib/interaction/action/element/state-base.js.map +1 -1
- package/lib/interaction/action/element/state.js +13 -13
- package/lib/interaction/action/element/state.js.map +1 -1
- package/lib/interaction/action/index.js +5 -1
- package/lib/interaction/action/index.js.map +1 -1
- package/lib/interaction/action/mask/base.js +5 -5
- package/lib/interaction/action/mask/base.js.map +1 -1
- package/lib/interaction/action/mask/circle.js +4 -4
- package/lib/interaction/action/mask/circle.js.map +1 -1
- package/lib/interaction/action/mask/dim-rect.js +6 -6
- package/lib/interaction/action/mask/dim-rect.js.map +1 -1
- package/lib/interaction/action/mask/path.js +3 -3
- package/lib/interaction/action/mask/path.js.map +1 -1
- package/lib/interaction/action/mask/rect.js +4 -4
- package/lib/interaction/action/mask/rect.js.map +1 -1
- package/lib/interaction/action/mask/smooth-path.js +3 -3
- package/lib/interaction/action/mask/smooth-path.js.map +1 -1
- package/lib/interaction/action/register.js +2 -2
- package/lib/interaction/action/register.js.map +1 -1
- package/lib/interaction/action/util.js +13 -13
- package/lib/interaction/action/util.js.map +1 -1
- package/lib/interaction/action/view/button.js +6 -6
- package/lib/interaction/action/view/button.js.map +1 -1
- package/lib/interaction/action/view/drag.js +3 -3
- package/lib/interaction/action/view/drag.js.map +1 -1
- package/lib/interaction/action/view/move.js +2 -2
- package/lib/interaction/action/view/move.js.map +1 -1
- package/lib/interaction/action/view/scale-transform.js +1 -1
- package/lib/interaction/action/view/scale-transform.js.map +1 -1
- package/lib/interaction/action/view/scale-translate.js +4 -4
- package/lib/interaction/action/view/scale-translate.js.map +1 -1
- package/lib/interaction/action/view/scale-zoom.js +3 -3
- package/lib/interaction/action/view/scale-zoom.js.map +1 -1
- package/lib/interaction/context.js +5 -5
- package/lib/interaction/context.js.map +1 -1
- package/lib/interaction/grammar-interaction.js +20 -20
- package/lib/interaction/grammar-interaction.js.map +1 -1
- package/lib/interaction/index.js +7 -7
- package/lib/interaction/index.js.map +1 -1
- package/lib/interface.d.ts +11 -10
- package/lib/interface.js.map +1 -1
- package/lib/theme/index.js +3 -3
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/style-sheet/dark.d.ts +2 -2
- package/lib/theme/style-sheet/dark.js +5 -4
- package/lib/theme/style-sheet/dark.js.map +1 -1
- package/lib/theme/style-sheet/light.d.ts +2 -2
- package/lib/theme/style-sheet/light.js +5 -4
- package/lib/theme/style-sheet/light.js.map +1 -1
- package/lib/theme/util/create-by-style-sheet.js +12 -12
- package/lib/theme/util/create-by-style-sheet.js.map +1 -1
- package/lib/theme/util/create-theme.js +3 -3
- package/lib/theme/util/create-theme.js.map +1 -1
- package/lib/theme/util/index.js +1 -0
- package/lib/theme/util/index.js.map +1 -1
- package/lib/util/annotation.js +4 -2
- package/lib/util/annotation.js.map +1 -1
- package/lib/util/attr.js +1 -1
- package/lib/util/attr.js.map +1 -1
- package/lib/util/axis.js +8 -8
- package/lib/util/axis.js.map +1 -1
- package/lib/util/bbox.js +4 -3
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/collision-detect.js +1 -1
- package/lib/util/collision-detect.js.map +1 -1
- package/lib/util/color.js +3 -2
- package/lib/util/color.js.map +1 -1
- package/lib/util/coordinate.js +5 -5
- package/lib/util/coordinate.js.map +1 -1
- package/lib/util/dom.js +1 -1
- package/lib/util/facet.js +1 -1
- package/lib/util/facet.js.map +1 -1
- package/lib/util/graphics.js +5 -5
- package/lib/util/graphics.js.map +1 -1
- package/lib/util/grid.js +5 -5
- package/lib/util/grid.js.map +1 -1
- package/lib/util/helper.d.ts +1 -1
- package/lib/util/helper.js +5 -5
- package/lib/util/helper.js.map +1 -1
- package/lib/util/legend.js +19 -18
- package/lib/util/legend.js.map +1 -1
- package/lib/util/padding.js +4 -4
- package/lib/util/padding.js.map +1 -1
- package/lib/util/scale.js +11 -12
- package/lib/util/scale.js.map +1 -1
- package/lib/util/stat.js +3 -3
- package/lib/util/stat.js.map +1 -1
- package/lib/util/text.js +12 -11
- package/lib/util/text.js.map +1 -1
- package/lib/util/tooltip.js +21 -21
- package/lib/util/tooltip.js.map +1 -1
- package/package.json +21 -27
- package/src/chart/controller/annotation.ts +14 -7
- package/src/chart/controller/tooltip.ts +11 -1
- package/src/chart/layout/constraint/bounds.ts +52 -0
- package/src/chart/layout/constraint/constraint.ts +98 -0
- package/src/chart/layout/constraint/gauss.ts +71 -0
- package/src/chart/layout/constraint/index.ts +30 -0
- package/src/chart/layout/constraint/solver.ts +98 -0
- package/src/chart/layout/constraint/types.ts +29 -0
- package/src/chart/layout/constraint/variable.ts +33 -0
- package/src/chart/view.ts +70 -5
- package/src/core.ts +1 -1
- package/src/facet/facet.ts +50 -20
- package/src/geometry/base.ts +133 -60
- package/src/geometry/heatmap.ts +17 -18
- package/src/geometry/path.ts +48 -22
- package/src/geometry/util/diff.ts +29 -0
- package/src/interface.ts +8 -6
- package/src/theme/style-sheet/dark.ts +2 -2
- package/src/theme/style-sheet/light.ts +2 -2
- package/src/util/annotation.ts +3 -1
- package/src/util/helper.ts +3 -3
- package/src/util/legend.ts +7 -4
package/src/geometry/base.ts
CHANGED
|
@@ -57,6 +57,7 @@ import { getShapeFactory } from './shape/base';
|
|
|
57
57
|
import { group } from './util/group-data';
|
|
58
58
|
import { isModelChange } from './util/is-model-change';
|
|
59
59
|
import { parseFields } from './util/parse-fields';
|
|
60
|
+
import { diff } from './util/diff';
|
|
60
61
|
import { getXDimensionLength } from '../util/coordinate';
|
|
61
62
|
|
|
62
63
|
/** @ignore */
|
|
@@ -925,21 +926,21 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
925
926
|
}
|
|
926
927
|
|
|
927
928
|
this.defaultSize = undefined;
|
|
928
|
-
this.elements = [];
|
|
929
929
|
this.elementsMap = {};
|
|
930
|
+
this.elements = [];
|
|
930
931
|
const offscreenGroup = this.getOffscreenGroup();
|
|
931
932
|
offscreenGroup.clear();
|
|
932
933
|
|
|
933
934
|
const beforeMappingData = this.beforeMappingData;
|
|
934
935
|
const dataArray = this.beforeMapping(beforeMappingData);
|
|
935
936
|
|
|
936
|
-
|
|
937
|
-
for (let
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
mappingArray.push(mappingData);
|
|
941
|
-
this.createElements(mappingData, index, isUpdate);
|
|
937
|
+
this.dataArray = new Array(dataArray.length);
|
|
938
|
+
for (let i = 0; i < dataArray.length; i++) {
|
|
939
|
+
const data = dataArray[i];
|
|
940
|
+
this.dataArray[i] = this.mapping(data);
|
|
942
941
|
}
|
|
942
|
+
this.updateElements(this.dataArray, isUpdate);
|
|
943
|
+
this.lastElementsMap = this.elementsMap;
|
|
943
944
|
|
|
944
945
|
if (this.canDoGroupAnimation(isUpdate)) {
|
|
945
946
|
// 如果用户没有配置 appear.animation,就默认走整体动画
|
|
@@ -957,20 +958,9 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
957
958
|
|
|
958
959
|
// 添加 label
|
|
959
960
|
if (this.labelOption) {
|
|
960
|
-
this.renderLabels(flatten(
|
|
961
|
+
this.renderLabels(flatten(this.dataArray) as unknown as MappingDatum[], isUpdate);
|
|
961
962
|
}
|
|
962
963
|
|
|
963
|
-
this.dataArray = mappingArray;
|
|
964
|
-
|
|
965
|
-
// 销毁被删除的 elements
|
|
966
|
-
each(this.lastElementsMap, (deletedElement: Element) => {
|
|
967
|
-
// 更新动画配置,用户有可能在更新之前有对动画进行配置操作
|
|
968
|
-
deletedElement.animate = this.animateOption;
|
|
969
|
-
deletedElement.destroy();
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
this.lastElementsMap = this.elementsMap;
|
|
973
|
-
|
|
974
964
|
// 缓存,用于更新
|
|
975
965
|
this.lastAttributeOption = {
|
|
976
966
|
...this.attributeOption,
|
|
@@ -1112,10 +1102,27 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1112
1102
|
return attr.mapping(...params);
|
|
1113
1103
|
}
|
|
1114
1104
|
|
|
1105
|
+
/**
|
|
1106
|
+
* 获取对应的 adjust 实例
|
|
1107
|
+
* @param adjustType
|
|
1108
|
+
* @returns
|
|
1109
|
+
*/
|
|
1115
1110
|
public getAdjust(adjustType: string) {
|
|
1116
1111
|
return this.adjusts[adjustType];
|
|
1117
1112
|
}
|
|
1118
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* 获得 coordinate 实例
|
|
1116
|
+
* @returns
|
|
1117
|
+
*/
|
|
1118
|
+
public getCoordinate() {
|
|
1119
|
+
return this.coordinate;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
public getData() {
|
|
1123
|
+
return this.data;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1119
1126
|
/**
|
|
1120
1127
|
* 获取 shape 对应的 marker 样式。
|
|
1121
1128
|
* @param shapeName shape 具体名字
|
|
@@ -1142,9 +1149,18 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1142
1149
|
* @returns
|
|
1143
1150
|
*/
|
|
1144
1151
|
public getElementsBy(condition: (element: Element) => boolean): Element[] {
|
|
1145
|
-
return this.elements.filter((element) =>
|
|
1146
|
-
|
|
1147
|
-
|
|
1152
|
+
return this.elements.filter((element) => condition(element));
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* 获取 Geometry 的所有 Elements。
|
|
1157
|
+
*
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* getElements();
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
public getElements() {
|
|
1163
|
+
return this.elements;
|
|
1148
1164
|
}
|
|
1149
1165
|
|
|
1150
1166
|
/**
|
|
@@ -1220,7 +1236,7 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1220
1236
|
*/
|
|
1221
1237
|
public getScaleFields(): string[] {
|
|
1222
1238
|
const fields = [];
|
|
1223
|
-
const tmpMap =
|
|
1239
|
+
const tmpMap = new Map();
|
|
1224
1240
|
const { attributeOption, labelOption, tooltipOption } = this;
|
|
1225
1241
|
// 获取图形属性上的 fields
|
|
1226
1242
|
for (const attributeType in attributeOption) {
|
|
@@ -1275,13 +1291,33 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1275
1291
|
}
|
|
1276
1292
|
}
|
|
1277
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* 获得所有的字段
|
|
1296
|
+
*/
|
|
1297
|
+
public getFields() {
|
|
1298
|
+
const uniqMap = new Map<string, boolean>();
|
|
1299
|
+
const fields = [];
|
|
1300
|
+
|
|
1301
|
+
Object.values(this.attributeOption).forEach((cfg) => {
|
|
1302
|
+
const fs = cfg?.fields || [];
|
|
1303
|
+
fs.forEach((f) => {
|
|
1304
|
+
if (!uniqMap.has(f)) {
|
|
1305
|
+
fields.push(f);
|
|
1306
|
+
}
|
|
1307
|
+
uniqMap.set(f, true);
|
|
1308
|
+
});
|
|
1309
|
+
}, []);
|
|
1310
|
+
|
|
1311
|
+
return fields;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1278
1314
|
/**
|
|
1279
1315
|
* 获取当前配置中的所有分组 & 分类的字段。
|
|
1280
1316
|
* @return fields string[]
|
|
1281
1317
|
*/
|
|
1282
1318
|
public getGroupFields(): string[] {
|
|
1283
1319
|
const groupFields = [];
|
|
1284
|
-
const tmpMap =
|
|
1320
|
+
const tmpMap = new Map(); // 用于去重过滤
|
|
1285
1321
|
for (let index = 0, length = GROUP_ATTRS.length; index < length; index++) {
|
|
1286
1322
|
const attributeName = GROUP_ATTRS[index];
|
|
1287
1323
|
const cfg = this.attributeOption[attributeName];
|
|
@@ -1301,6 +1337,22 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1301
1337
|
return [x, y];
|
|
1302
1338
|
}
|
|
1303
1339
|
|
|
1340
|
+
/**
|
|
1341
|
+
* x 字段
|
|
1342
|
+
* @returns
|
|
1343
|
+
*/
|
|
1344
|
+
public getXField(): string {
|
|
1345
|
+
return get(this.getXYFields(), [0]);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* y 字段
|
|
1350
|
+
* @returns
|
|
1351
|
+
*/
|
|
1352
|
+
public getYField(): string {
|
|
1353
|
+
return get(this.getXYFields(), [1]);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1304
1356
|
/**
|
|
1305
1357
|
* 获取该 Geometry 下所有生成的 shapes。
|
|
1306
1358
|
* @returns shapes
|
|
@@ -1458,52 +1510,73 @@ export default class Geometry<S extends ShapePoint = ShapePoint> extends Base {
|
|
|
1458
1510
|
return cfg;
|
|
1459
1511
|
}
|
|
1460
1512
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1513
|
+
protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false): void {
|
|
1514
|
+
const keyDatum = new Map<string, MappingDatum>();
|
|
1515
|
+
const keys: string[] = [];
|
|
1516
|
+
|
|
1517
|
+
// 用来保持 diff 元素之后 added, updated 的相对顺序
|
|
1518
|
+
const keyIndex = new Map<string, number>();
|
|
1519
|
+
let index = 0;
|
|
1520
|
+
|
|
1521
|
+
// 获得更新数据所有的 keys
|
|
1522
|
+
// 将更新的数据用 key 索引
|
|
1523
|
+
for (let i = 0; i < mappingDataArray.length; i++) {
|
|
1524
|
+
const mappingData = mappingDataArray[i];
|
|
1525
|
+
for (let j = 0; j < mappingData.length; j++) {
|
|
1526
|
+
const mappingDatum = mappingData[j];
|
|
1527
|
+
const key = this.getElementId(mappingDatum);
|
|
1528
|
+
const finalKey = keyDatum.has(key) ? `${key}-${i}-${j}` : key;
|
|
1529
|
+
keys.push(finalKey);
|
|
1530
|
+
keyDatum.set(finalKey, mappingDatum);
|
|
1531
|
+
keyIndex.set(finalKey, index);
|
|
1532
|
+
index++;
|
|
1475
1533
|
}
|
|
1534
|
+
}
|
|
1476
1535
|
|
|
1477
|
-
|
|
1478
|
-
if (!result) {
|
|
1479
|
-
// 创建新的 element
|
|
1480
|
-
result = this.createElement(mappingDatum, isUpdate);
|
|
1481
|
-
} else {
|
|
1482
|
-
// element 已经创建
|
|
1483
|
-
const currentShapeCfg = this.getDrawCfg(mappingDatum);
|
|
1484
|
-
const preShapeCfg = result.getModel();
|
|
1485
|
-
if (this.isCoordinateChanged || isModelChange(currentShapeCfg, preShapeCfg)) {
|
|
1486
|
-
result.animate = this.animateOption;
|
|
1487
|
-
// 通过绘制数据的变更来判断是否需要更新,因为用户有可能会修改图形属性映射
|
|
1488
|
-
result.update(currentShapeCfg); // 更新对应的 element
|
|
1489
|
-
}
|
|
1536
|
+
this.elements = new Array(index);
|
|
1490
1537
|
|
|
1491
|
-
|
|
1538
|
+
const { added, updated, removed } = diff(this.lastElementsMap, keys);
|
|
1539
|
+
|
|
1540
|
+
// 新建 element
|
|
1541
|
+
for (const key of added) {
|
|
1542
|
+
const mappingDatum = keyDatum.get(key);
|
|
1543
|
+
const element = this.createElement(mappingDatum, isUpdate);
|
|
1544
|
+
const i = keyIndex.get(key);
|
|
1545
|
+
this.elements[i] = element;
|
|
1546
|
+
this.elementsMap[key] = element;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// 更新 element
|
|
1550
|
+
for (const key of updated) {
|
|
1551
|
+
const element = this.lastElementsMap[key];
|
|
1552
|
+
const mappingDatum = keyDatum.get(key);
|
|
1553
|
+
const currentShapeCfg = this.getDrawCfg(mappingDatum);
|
|
1554
|
+
const preShapeCfg = element.getModel();
|
|
1555
|
+
const i = keyIndex.get(key);
|
|
1556
|
+
if (this.isCoordinateChanged || isModelChange(currentShapeCfg, preShapeCfg)) {
|
|
1557
|
+
element.animate = this.animateOption;
|
|
1558
|
+
// 通过绘制数据的变更来判断是否需要更新,因为用户有可能会修改图形属性映射
|
|
1559
|
+
element.update(currentShapeCfg); // 更新对应的 element
|
|
1492
1560
|
}
|
|
1561
|
+
this.elements[i] = element;
|
|
1562
|
+
this.elementsMap[key] = element;
|
|
1563
|
+
}
|
|
1493
1564
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1565
|
+
// 销毁被删除的 elements
|
|
1566
|
+
for (const key of removed) {
|
|
1567
|
+
const element = this.lastElementsMap[key];
|
|
1568
|
+
// 更新动画配置,用户有可能在更新之前有对动画进行配置操作
|
|
1569
|
+
element.animate = this.animateOption;
|
|
1570
|
+
element.destroy();
|
|
1496
1571
|
}
|
|
1497
1572
|
|
|
1498
1573
|
// 对 elements 的 zIndex 进行反序
|
|
1499
1574
|
if (this.zIndexReversed) {
|
|
1500
|
-
const length = elements.length;
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1575
|
+
const length = this.elements.length;
|
|
1576
|
+
for (let i = 0; i < length; i++) {
|
|
1577
|
+
this.elements[i].shape.setZIndex(length - i);
|
|
1578
|
+
}
|
|
1504
1579
|
}
|
|
1505
|
-
|
|
1506
|
-
return elements;
|
|
1507
1580
|
}
|
|
1508
1581
|
|
|
1509
1582
|
/**
|
package/src/geometry/heatmap.ts
CHANGED
|
@@ -16,19 +16,20 @@ export default class Heatmap extends Geometry {
|
|
|
16
16
|
private shadowCanvas: HTMLCanvasElement;
|
|
17
17
|
private imageShape: IShape;
|
|
18
18
|
|
|
19
|
-
protected
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false) {
|
|
20
|
+
for (let i = 0; i < mappingDataArray.length; i++) {
|
|
21
|
+
const mappingData = mappingDataArray[i];
|
|
22
|
+
const range = this.prepareRange(mappingData);
|
|
23
|
+
const radius = this.prepareSize();
|
|
24
|
+
|
|
25
|
+
let blur = get(this.styleOption, ['cfg', 'shadowBlur']);
|
|
26
|
+
if (!isNumber(blur)) {
|
|
27
|
+
blur = radius / 2;
|
|
28
|
+
}
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
blur = radius / 2;
|
|
30
|
+
this.prepareGreyScaleBlurredCircle(radius, blur);
|
|
31
|
+
this.drawWithRange(mappingData, range, radius, blur);
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
this.prepareGreyScaleBlurredCircle(radius, blur);
|
|
29
|
-
this.drawWithRange(mappingData, range, radius, blur);
|
|
30
|
-
|
|
31
|
-
return null;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/** 热力图暂时不支持 callback 回调(文档需要说明下) */
|
|
@@ -209,16 +210,14 @@ export default class Heatmap extends Geometry {
|
|
|
209
210
|
private getShapeInfo(mappingData: MappingDatum[]): ShapeInfo {
|
|
210
211
|
const shapeCfg = this.getDrawCfg(mappingData[0]);
|
|
211
212
|
|
|
213
|
+
const data = mappingData.map((obj: Datum) => {
|
|
214
|
+
return obj[FIELD_ORIGIN];
|
|
215
|
+
});
|
|
216
|
+
|
|
212
217
|
return {
|
|
213
218
|
...shapeCfg,
|
|
214
219
|
mappingData,
|
|
215
|
-
data
|
|
220
|
+
data,
|
|
216
221
|
};
|
|
217
222
|
}
|
|
218
|
-
|
|
219
|
-
private getData(mappingData: MappingDatum[]): Data {
|
|
220
|
-
return mappingData.map((obj: Datum) => {
|
|
221
|
-
return obj[FIELD_ORIGIN];
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
223
|
}
|
package/src/geometry/path.ts
CHANGED
|
@@ -5,6 +5,7 @@ import Element from './element';
|
|
|
5
5
|
/** 引入对应的 ShapeFactory */
|
|
6
6
|
import './shape/line';
|
|
7
7
|
import { isModelChange } from './util/is-model-change';
|
|
8
|
+
import { diff } from './util/diff';
|
|
8
9
|
|
|
9
10
|
/** Path 构造函数参数类型 */
|
|
10
11
|
export interface PathCfg extends GeometryCfg {
|
|
@@ -40,39 +41,64 @@ export default class Path extends Geometry {
|
|
|
40
41
|
* @param [isUpdate]
|
|
41
42
|
* @returns elements
|
|
42
43
|
*/
|
|
43
|
-
protected
|
|
44
|
+
protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false) {
|
|
44
45
|
// Path 的每个 element 对应一组数据
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const keyData = new Map<string, MappingDatum[]>();
|
|
47
|
+
const keyIndex = new Map<string, number>();
|
|
48
|
+
const keys: string[] = [];
|
|
48
49
|
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
const
|
|
50
|
+
let index = 0;
|
|
51
|
+
for (let i = 0; i < mappingDataArray.length; i++) {
|
|
52
|
+
const mappingData = mappingDataArray[i];
|
|
53
|
+
const key = this.getElementId(mappingData);
|
|
54
|
+
keys.push(key);
|
|
55
|
+
keyData.set(key, mappingData);
|
|
56
|
+
keyIndex.set(key, index);
|
|
57
|
+
index++;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.elements = new Array(index);
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
const { added, updated, removed } = diff(this.lastElementsMap, keys);
|
|
63
|
+
|
|
64
|
+
for (const key of added) {
|
|
65
|
+
const mappingData = keyData.get(key);
|
|
66
|
+
const shapeFactory = this.getShapeFactory();
|
|
67
|
+
const shapeCfg = this.getShapeInfo(mappingData);
|
|
68
|
+
const i = keyIndex.get(key);
|
|
69
|
+
const element = new Element({
|
|
54
70
|
shapeFactory,
|
|
55
|
-
container,
|
|
71
|
+
container: this.container,
|
|
56
72
|
offscreenGroup: this.getOffscreenGroup(),
|
|
57
73
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
element.geometry = this;
|
|
75
|
+
element.animate = this.animateOption;
|
|
76
|
+
element.draw(shapeCfg, isUpdate); // 绘制 shape
|
|
77
|
+
this.elementsMap[key] = element;
|
|
78
|
+
this.elements[i] = element;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const key of updated) {
|
|
82
|
+
const mappingData = keyData.get(key);
|
|
83
|
+
const element = this.lastElementsMap[key];
|
|
84
|
+
const i = keyIndex.get(key);
|
|
85
|
+
const shapeCfg = this.getShapeInfo(mappingData);
|
|
86
|
+
const preShapeCfg = element.getModel();
|
|
64
87
|
if (this.isCoordinateChanged || isModelChange(preShapeCfg, shapeCfg)) {
|
|
65
|
-
|
|
88
|
+
element.animate = this.animateOption;
|
|
66
89
|
// 通过绘制数据的变更来判断是否需要更新,因为用户有可能会修改图形属性映射
|
|
67
|
-
|
|
90
|
+
element.update(shapeCfg); // 更新对应的 element
|
|
68
91
|
}
|
|
69
|
-
|
|
92
|
+
this.elementsMap[key] = element;
|
|
93
|
+
this.elements[i] = element;
|
|
70
94
|
}
|
|
71
95
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
96
|
+
for (const key of removed) {
|
|
97
|
+
const element = this.lastElementsMap[key];
|
|
98
|
+
// 更新动画配置,用户有可能在更新之前有对动画进行配置操作
|
|
99
|
+
element.animate = this.animateOption;
|
|
100
|
+
element.destroy();
|
|
101
|
+
}
|
|
76
102
|
}
|
|
77
103
|
|
|
78
104
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对比当前元素和之前的元素,返回 added, updated, removed
|
|
3
|
+
* @param keyItem 之前的元素的,按照 key-item 的 object 的形式存储
|
|
4
|
+
* @param keys 现在的元素,按照 array 的形式存储
|
|
5
|
+
* @returns 由 added, updated, removed array 构成的 object
|
|
6
|
+
*/
|
|
7
|
+
export function diff(keyItem: Record<string, any>, keys: string[]) {
|
|
8
|
+
const added = [];
|
|
9
|
+
const updated = [];
|
|
10
|
+
const removed = [];
|
|
11
|
+
const keyIncluded = new Map<string, boolean>();
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < keys.length; i++) {
|
|
14
|
+
const key = keys[i];
|
|
15
|
+
if (keyItem[key]) updated.push(key);
|
|
16
|
+
else added.push(key);
|
|
17
|
+
keyIncluded.set(key, true);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Object.keys(keyItem).forEach((key) => {
|
|
21
|
+
if (!keyIncluded.has(key)) removed.push(key);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
added,
|
|
26
|
+
updated,
|
|
27
|
+
removed,
|
|
28
|
+
};
|
|
29
|
+
}
|
package/src/interface.ts
CHANGED
|
@@ -899,7 +899,7 @@ export interface LegendItem {
|
|
|
899
899
|
/** 值 */
|
|
900
900
|
value: any;
|
|
901
901
|
/** 图形标记 */
|
|
902
|
-
marker?: MarkerCfg;
|
|
902
|
+
marker?: MarkerCfg | ((name: string, index: number, item: { name: string; value: string } & MarkerCfg) => MarkerCfg);
|
|
903
903
|
/** 初始是否处于未激活状态 */
|
|
904
904
|
unchecked?: boolean;
|
|
905
905
|
}
|
|
@@ -1665,6 +1665,8 @@ export interface FacetCfg<D> {
|
|
|
1665
1665
|
readonly type?: string;
|
|
1666
1666
|
/** view 创建回调。 */
|
|
1667
1667
|
readonly eachView: (innerView: View, facet?: D) => any;
|
|
1668
|
+
/** 分面 view 之间的间隔, 百分比或像素值 */
|
|
1669
|
+
readonly spacing?: [number | string, number | string];
|
|
1668
1670
|
/** facet view padding。 */
|
|
1669
1671
|
readonly padding?: ViewPadding;
|
|
1670
1672
|
/** 是否显示标题。 */
|
|
@@ -1729,7 +1731,7 @@ export interface RectCfg extends FacetCfg<RectData> {
|
|
|
1729
1731
|
readonly rowTitle?: FacetTitle;
|
|
1730
1732
|
}
|
|
1731
1733
|
|
|
1732
|
-
export
|
|
1734
|
+
export type RectData = FacetData;
|
|
1733
1735
|
|
|
1734
1736
|
// ===================== mirror 相关类型定义 =====================
|
|
1735
1737
|
/** mirror 分面类型配置 */
|
|
@@ -1740,7 +1742,7 @@ export interface MirrorCfg extends FacetCfg<MirrorData> {
|
|
|
1740
1742
|
readonly title?: FacetTitle;
|
|
1741
1743
|
}
|
|
1742
1744
|
|
|
1743
|
-
export
|
|
1745
|
+
export type MirrorData = FacetData;
|
|
1744
1746
|
|
|
1745
1747
|
// ===================== list 相关类型定义 =====================
|
|
1746
1748
|
/** list 分面类型配置 */
|
|
@@ -1764,7 +1766,7 @@ export interface MatrixCfg extends FacetCfg<MirrorData> {
|
|
|
1764
1766
|
readonly rowTitle?: FacetTitle;
|
|
1765
1767
|
}
|
|
1766
1768
|
|
|
1767
|
-
export
|
|
1769
|
+
export type MatrixData = FacetData;
|
|
1768
1770
|
|
|
1769
1771
|
// ===================== circle 相关类型定义 =====================
|
|
1770
1772
|
/** circle 分面类型配置 */
|
|
@@ -1773,7 +1775,7 @@ export interface CircleCfg extends FacetCfg<CircleData> {
|
|
|
1773
1775
|
readonly title?: FacetTitle;
|
|
1774
1776
|
}
|
|
1775
1777
|
|
|
1776
|
-
export
|
|
1778
|
+
export type CircleData = FacetData;
|
|
1777
1779
|
|
|
1778
1780
|
// ===================== tree 相关类型定义 =====================
|
|
1779
1781
|
|
|
@@ -2085,7 +2087,7 @@ export interface StyleSheet {
|
|
|
2085
2087
|
/** Geometry overflowLabel 文本描边粗细 */
|
|
2086
2088
|
overflowLabelBorder?: number;
|
|
2087
2089
|
|
|
2088
|
-
/** Geometry label
|
|
2090
|
+
/** Geometry label 文本连接线粗细 */
|
|
2089
2091
|
labelLineBorder?: number;
|
|
2090
2092
|
/** Geometry label 文本连接线颜色 */
|
|
2091
2093
|
labelLineBorderColor?: string;
|
|
@@ -81,7 +81,7 @@ export const createDarkStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
81
81
|
paletteSemanticGreen = '#30BF78',
|
|
82
82
|
paletteSemanticYellow = '#FAAD14',
|
|
83
83
|
paletteSequence = SINGLE_SEQUENCE,
|
|
84
|
-
fontFamily = `"
|
|
84
|
+
fontFamily = `"Segoe UI", Roboto, "Helvetica Neue", Arial,
|
|
85
85
|
"Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
|
86
86
|
"Noto Color Emoji"`,
|
|
87
87
|
} = cfg;
|
|
@@ -358,7 +358,7 @@ export const createDarkStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
358
358
|
/** Geometry label 文本描边粗细 */
|
|
359
359
|
overflowLabelBorder: 1,
|
|
360
360
|
|
|
361
|
-
/** Geometry label
|
|
361
|
+
/** Geometry label 文本连接线粗细 */
|
|
362
362
|
labelLineBorder: 1,
|
|
363
363
|
/** Geometry label 文本连接线颜色 */
|
|
364
364
|
labelLineBorderColor: BLACK_COLORS[25],
|
|
@@ -81,7 +81,7 @@ export const createLightStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
81
81
|
paletteSemanticGreen = '#30BF78',
|
|
82
82
|
paletteSemanticYellow = '#FAAD14',
|
|
83
83
|
paletteSequence = SINGLE_SEQUENCE,
|
|
84
|
-
fontFamily = `"
|
|
84
|
+
fontFamily = `"Segoe UI", Roboto, "Helvetica Neue", Arial,
|
|
85
85
|
"Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
|
86
86
|
"Noto Color Emoji"`,
|
|
87
87
|
} = cfg;
|
|
@@ -354,7 +354,7 @@ export const createLightStyleSheet = (cfg: StyleSheetCfg = {}) => {
|
|
|
354
354
|
/** Geometry overflowLabel 文本描边粗细 */
|
|
355
355
|
overflowLabelBorder: 1,
|
|
356
356
|
|
|
357
|
-
/** Geometry label
|
|
357
|
+
/** Geometry label 文本连接线粗细 */
|
|
358
358
|
labelLineBorder: 1,
|
|
359
359
|
/** Geometry label 文本连接线颜色 */
|
|
360
360
|
labelLineBorderColor: BLACK_COLORS[25],
|
package/src/util/annotation.ts
CHANGED
|
@@ -15,6 +15,8 @@ export function getNormalizedValue(val: number | string, scale: Scale) {
|
|
|
15
15
|
switch (val) {
|
|
16
16
|
case 'start':
|
|
17
17
|
return 0;
|
|
18
|
+
case 'center':
|
|
19
|
+
return 0.5;
|
|
18
20
|
case 'end':
|
|
19
21
|
return 1;
|
|
20
22
|
case 'median': {
|
|
@@ -37,4 +39,4 @@ export function getNormalizedValue(val: number | string, scale: Scale) {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
return scale.scale(scaled);
|
|
40
|
-
}
|
|
42
|
+
}
|
package/src/util/helper.ts
CHANGED
|
@@ -63,11 +63,11 @@ export function omit<T = any>(obj: T, keys: string[]): T {
|
|
|
63
63
|
* @param targetArray
|
|
64
64
|
* @param map
|
|
65
65
|
*/
|
|
66
|
-
export function uniq(sourceArray: any[], targetArray: any[] = [], map:
|
|
66
|
+
export function uniq(sourceArray: any[], targetArray: any[] = [], map: Map<any, boolean> = new Map()) {
|
|
67
67
|
for (const source of sourceArray) {
|
|
68
|
-
if (!map
|
|
68
|
+
if (!map.has(source)) {
|
|
69
69
|
targetArray.push(source);
|
|
70
|
-
map
|
|
70
|
+
map.set(source, true);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
return targetArray;
|
package/src/util/legend.ts
CHANGED
|
@@ -145,10 +145,13 @@ export function getCustomLegendItems(themeMarker: object, userMarker: object, cu
|
|
|
145
145
|
// 如果有自定义的 item,那么就直接使用,并合并主题的 marker 配置
|
|
146
146
|
return customItems.map((item: LegendItem, index: number) => {
|
|
147
147
|
let markerCfg = userMarker;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
if (isFunction(markerCfg)) {
|
|
149
|
+
markerCfg = markerCfg(item.name, index, deepMix({}, themeMarker, item))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const itemMarker = isFunction(item.marker) ? item.marker(item.name, index, deepMix({}, themeMarker, item)) : item.marker;
|
|
153
|
+
|
|
154
|
+
const marker = deepMix({}, themeMarker, markerCfg, itemMarker);
|
|
152
155
|
setMarkerSymbol(marker);
|
|
153
156
|
|
|
154
157
|
item.marker = marker;
|