@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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gaussian elimination
|
|
3
|
+
* @param array a matrix
|
|
4
|
+
* @return array x solution vector
|
|
5
|
+
*/
|
|
6
|
+
export function gauss(a) {
|
|
7
|
+
var row = a.length;
|
|
8
|
+
var col = a[0].length;
|
|
9
|
+
var m = row; // 方程的个数
|
|
10
|
+
var n = col - 1; // 变量的个数(最后一列是常量)
|
|
11
|
+
/**
|
|
12
|
+
* 先对 a 进行排序,排序规则为:
|
|
13
|
+
* - 第 i 列对应从 i 行到最后一行的最大值,放到当前行
|
|
14
|
+
*/
|
|
15
|
+
for (var i = 0; i < n; i++) {
|
|
16
|
+
// 1. 找到这一列的最大值、已经行索引
|
|
17
|
+
var max = Number.MIN_SAFE_INTEGER;
|
|
18
|
+
var maxRow = void 0;
|
|
19
|
+
// 找到这一列的最大值、已经行索引
|
|
20
|
+
for (var j = i; j < m; j++) {
|
|
21
|
+
if (Math.abs(a[j][i]) > max) {
|
|
22
|
+
max = Math.abs(a[j][i]);
|
|
23
|
+
maxRow = j;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// 2. 找到这一列的最大值之后,交换行
|
|
27
|
+
var tmp = a[maxRow];
|
|
28
|
+
a[maxRow] = a[i];
|
|
29
|
+
a[i] = tmp;
|
|
30
|
+
// 3. 这一行下面,在这一列上的数据全部为 0
|
|
31
|
+
for (var j = i + 1; j < m; j++) {
|
|
32
|
+
// 配平系数
|
|
33
|
+
var c = -a[j][i] / a[i][i];
|
|
34
|
+
// 这一行的元素全部处理
|
|
35
|
+
for (var k = i; k < n + 1; k++) {
|
|
36
|
+
a[j][k] += (c * a[i][k]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 反向迭代,计算变量值
|
|
42
|
+
*/
|
|
43
|
+
var b = new Array(n).fill(0);
|
|
44
|
+
// 只有 n 个变量(n 后的方程直接忽略)
|
|
45
|
+
for (var i = n - 1; i >= 0; i--) {
|
|
46
|
+
b[i] = a[i][n] / a[i][i];
|
|
47
|
+
// 向上带入归零
|
|
48
|
+
for (var j = i - 1; j >= 0; j--) {
|
|
49
|
+
var c = -a[j][i] / a[i][i];
|
|
50
|
+
a[j][i] += (a[i][i] * c);
|
|
51
|
+
a[j][n] += (a[i][n] * c);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return b;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 乘法
|
|
58
|
+
* @param v
|
|
59
|
+
*/
|
|
60
|
+
export function multiply(v) {
|
|
61
|
+
return v.reduce(function (r, c) { return r * c; }, 1);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=gauss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gauss.js","sourceRoot":"","sources":["../../../../src/chart/layout/constraint/gauss.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,CAAa;IACjC,IAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACrB,IAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAExB,IAAM,CAAC,GAAG,GAAG,CAAC,CAAM,QAAQ;IAC5B,IAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAE,iBAAiB;IAErC;;;OAGG;IACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,qBAAqB;QACrB,IAAI,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAClC,IAAI,MAAM,SAAA,CAAC;QACX,kBAAkB;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE;gBAC3B,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SAC1B;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAW;IAClC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,EAAE,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Gaussian elimination\n * @param array a matrix\n * @return array x solution vector\n */\nexport function gauss(a: number[][]): number[] {\n const row = a.length;\n const col = a[0].length;\n\n const m = row; // 方程的个数\n const n = col - 1; // 变量的个数(最后一列是常量)\n\n /**\n * 先对 a 进行排序,排序规则为:\n * - 第 i 列对应从 i 行到最后一行的最大值,放到当前行\n */\n for (let i = 0; i < n; i++) {\n // 1. 找到这一列的最大值、已经行索引\n let max = Number.MIN_SAFE_INTEGER;\n let maxRow;\n // 找到这一列的最大值、已经行索引\n for (let j = i; j < m; j++) {\n if (Math.abs(a[j][i]) > max) {\n max = Math.abs(a[j][i]);\n maxRow = j;\n }\n }\n\n // 2. 找到这一列的最大值之后,交换行\n const tmp = a[maxRow];\n a[maxRow] = a[i];\n a[i] = tmp;\n\n // 3. 这一行下面,在这一列上的数据全部为 0\n for (let j = i + 1; j < m; j++) {\n // 配平系数\n const c = -a[j][i] / a[i][i];\n // 这一行的元素全部处理\n for (let k = i; k < n + 1; k++) {\n a[j][k] += (c * a[i][k]);\n }\n }\n }\n\n /**\n * 反向迭代,计算变量值\n */\n const b = new Array(n).fill(0);\n\n // 只有 n 个变量(n 后的方程直接忽略)\n for (let i = n - 1; i >= 0; i--) {\n b[i] = a[i][n] / a[i][i];\n\n // 向上带入归零\n for (let j = i - 1; j >= 0; j--) {\n const c = -a[j][i] / a[i][i];\n a[j][i] += (a[i][i] * c);\n a[j][n] += (a[i][n] * c);\n }\n }\n\n return b;\n}\n\n/**\n * 乘法\n * @param v \n */\nexport function multiply(v: number[]) {\n return v.reduce((r, c) => r * c, 1);\n}"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
> 先做一个针对 G2 场景的极简版本,只有 EQ,而没有不等式的!
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Solver, Constraint, Bounds, Operator } from './constraint';
|
|
7
|
+
|
|
8
|
+
const solver = new Solver();
|
|
9
|
+
|
|
10
|
+
const b1 = new Bounds();
|
|
11
|
+
const b2 = new Bounds();
|
|
12
|
+
|
|
13
|
+
// -1 * b1.x + b2.width - 200 = 0
|
|
14
|
+
const c1 = new Constraint(Operator.EQ, [-1, b1.x], b2.width, -200);
|
|
15
|
+
// -1 * b1.x + b1.width - 400 < 0
|
|
16
|
+
const c2 = new Constraint(Operator.LT, [-1, b1.x], b1.width, -400);
|
|
17
|
+
|
|
18
|
+
solver.addConstraint(c1, c2);
|
|
19
|
+
|
|
20
|
+
// get the b1 b2's layout information
|
|
21
|
+
const layout = solver.calc();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
export { Solver } from './solver';
|
|
26
|
+
export { Bounds } from './bounds';
|
|
27
|
+
export { Variable } from './variable';
|
|
28
|
+
export { Constraint } from './constraint';
|
|
29
|
+
export { Operator } from './types';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/chart/layout/constraint/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*\n\n> 先做一个针对 G2 场景的极简版本,只有 EQ,而没有不等式的!\n\n```ts\nimport { Solver, Constraint, Bounds, Operator } from './constraint';\n\nconst solver = new Solver();\n\nconst b1 = new Bounds();\nconst b2 = new Bounds();\n\n// -1 * b1.x + b2.width - 200 = 0\nconst c1 = new Constraint(Operator.EQ, [-1, b1.x], b2.width, -200);\n// -1 * b1.x + b1.width - 400 < 0\nconst c2 = new Constraint(Operator.LT, [-1, b1.x], b1.width, -400);\n\nsolver.addConstraint(c1, c2);\n\n// get the b1 b2's layout information\nconst layout = solver.calc();\n```\n\n */\n\nexport { Solver } from './solver';\nexport { Bounds } from './bounds';\nexport { Variable } from './variable';\nexport { Constraint } from './constraint';\nexport { Operator } from './types';\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Constraint } from './constraint';
|
|
2
|
+
import type { Variable } from './variable';
|
|
3
|
+
/**
|
|
4
|
+
* 约束布局构建和计算,目前针对 G2 的场景:
|
|
5
|
+
* - 一定都是等式
|
|
6
|
+
* - 一定有解
|
|
7
|
+
* 所以将算法退化成多元一次方程组的解法,直接使用高斯消元法(o(n^2))
|
|
8
|
+
*/
|
|
9
|
+
export declare class Solver {
|
|
10
|
+
/**
|
|
11
|
+
* 存在的约束
|
|
12
|
+
*/
|
|
13
|
+
constraints: Constraint[];
|
|
14
|
+
variables: Variable[];
|
|
15
|
+
/**
|
|
16
|
+
* 条件数量
|
|
17
|
+
*/
|
|
18
|
+
private m;
|
|
19
|
+
/**
|
|
20
|
+
* 变量(元)数量
|
|
21
|
+
*/
|
|
22
|
+
private n;
|
|
23
|
+
/**
|
|
24
|
+
* 添加多条约束
|
|
25
|
+
* @param constraint
|
|
26
|
+
*/
|
|
27
|
+
addConstraint(...constraints: Constraint[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* 计算返回布局
|
|
30
|
+
*/
|
|
31
|
+
calc(): Variable[];
|
|
32
|
+
/**
|
|
33
|
+
* 获取约束中所有的变量
|
|
34
|
+
*/
|
|
35
|
+
private getVariables;
|
|
36
|
+
/**
|
|
37
|
+
* 获得高斯消元的矩阵
|
|
38
|
+
*/
|
|
39
|
+
private getGaussMatrix;
|
|
40
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { uniq } from '@antv/util';
|
|
2
|
+
import { gauss } from './gauss';
|
|
3
|
+
/**
|
|
4
|
+
* 约束布局构建和计算,目前针对 G2 的场景:
|
|
5
|
+
* - 一定都是等式
|
|
6
|
+
* - 一定有解
|
|
7
|
+
* 所以将算法退化成多元一次方程组的解法,直接使用高斯消元法(o(n^2))
|
|
8
|
+
*/
|
|
9
|
+
var Solver = /** @class */ (function () {
|
|
10
|
+
function Solver() {
|
|
11
|
+
/**
|
|
12
|
+
* 存在的约束
|
|
13
|
+
*/
|
|
14
|
+
this.constraints = [];
|
|
15
|
+
this.variables = [];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 添加多条约束
|
|
19
|
+
* @param constraint
|
|
20
|
+
*/
|
|
21
|
+
Solver.prototype.addConstraint = function () {
|
|
22
|
+
var _a;
|
|
23
|
+
var constraints = [];
|
|
24
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
|
+
constraints[_i] = arguments[_i];
|
|
26
|
+
}
|
|
27
|
+
(_a = this.constraints).push.apply(_a, constraints);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 计算返回布局
|
|
31
|
+
*/
|
|
32
|
+
Solver.prototype.calc = function () {
|
|
33
|
+
// 1. 拿到变量
|
|
34
|
+
this.variables = this.getVariables();
|
|
35
|
+
this.m = this.constraints.length;
|
|
36
|
+
this.n = this.variables.length;
|
|
37
|
+
// 2. 获取消元矩阵
|
|
38
|
+
var matrix = this.getGaussMatrix();
|
|
39
|
+
// 3. 求解
|
|
40
|
+
var result = gauss(matrix);
|
|
41
|
+
this.variables.forEach(function (v, idx) {
|
|
42
|
+
v.value = result[idx];
|
|
43
|
+
});
|
|
44
|
+
return this.variables;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 获取约束中所有的变量
|
|
48
|
+
*/
|
|
49
|
+
Solver.prototype.getVariables = function () {
|
|
50
|
+
var vars = [];
|
|
51
|
+
for (var i = 0; i < this.constraints.length; i++) {
|
|
52
|
+
var constraint = this.constraints[i];
|
|
53
|
+
vars = vars.concat(constraint.getVariables());
|
|
54
|
+
}
|
|
55
|
+
return uniq(vars);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 获得高斯消元的矩阵
|
|
59
|
+
*/
|
|
60
|
+
Solver.prototype.getGaussMatrix = function () {
|
|
61
|
+
var variableMap = new Map();
|
|
62
|
+
for (var i = 0; i < this.n; i++) {
|
|
63
|
+
var variable = this.variables[i];
|
|
64
|
+
variableMap.set(variable, i);
|
|
65
|
+
}
|
|
66
|
+
var matrix = [];
|
|
67
|
+
for (var i = 0; i < this.m; i++) {
|
|
68
|
+
var constraint = this.constraints[i];
|
|
69
|
+
var arr = constraint.getGaussArr(variableMap);
|
|
70
|
+
matrix.push(arr);
|
|
71
|
+
}
|
|
72
|
+
return matrix;
|
|
73
|
+
};
|
|
74
|
+
return Solver;
|
|
75
|
+
}());
|
|
76
|
+
export { Solver };
|
|
77
|
+
//# sourceMappingURL=solver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solver.js","sourceRoot":"","sources":["../../../../src/chart/layout/constraint/solver.ts"],"names":[],"mappings":"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AAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;SAC/C;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACK,+BAAc,GAAtB;QACE,IAAM,WAAW,GAAG,IAAI,GAAG,EAAoB,CAAC;QAEhD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/B,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;SAC9B;QAED,IAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/B,IAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEvC,IAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAEhD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,aAAC;AAAD,CAAC,AAtFD,IAsFC","sourcesContent":["import { uniq } from '@antv/util';\nimport type { Constraint } from './constraint';\nimport { gauss } from './gauss';\nimport type { Variable } from './variable';\n\n/**\n * 约束布局构建和计算,目前针对 G2 的场景:\n * - 一定都是等式\n * - 一定有解\n * 所以将算法退化成多元一次方程组的解法,直接使用高斯消元法(o(n^2))\n */\nexport class Solver {\n \n /**\n * 存在的约束\n */\n public constraints: Constraint[] = [];\n\n public variables: Variable[] = [];\n\n /**\n * 条件数量\n */\n private m: number;\n\n /**\n * 变量(元)数量\n */\n private n: number;\n\n /**\n * 添加多条约束\n * @param constraint\n */\n public addConstraint(...constraints: Constraint[]) {\n this.constraints.push(...constraints);\n }\n\n /**\n * 计算返回布局\n */\n public calc() {\n // 1. 拿到变量\n this.variables = this.getVariables();\n\n this.m = this.constraints.length;\n this.n = this.variables.length;\n \n // 2. 获取消元矩阵\n const matrix = this.getGaussMatrix();\n\n // 3. 求解\n const result = gauss(matrix);\n\n this.variables.forEach((v, idx) => {\n v.value = result[idx];\n });\n\n return this.variables;\n }\n\n /**\n * 获取约束中所有的变量\n */\n private getVariables() {\n let vars = [];\n for (let i = 0; i < this.constraints.length; i++) {\n const constraint = this.constraints[i];\n\n vars = vars.concat(constraint.getVariables());\n }\n\n return uniq(vars);\n }\n\n /**\n * 获得高斯消元的矩阵\n */\n private getGaussMatrix() {\n const variableMap = new Map<Variable, number>();\n \n for (let i = 0; i < this.n; i++) {\n const variable = this.variables[i];\n variableMap.set(variable, i);\n }\n\n const matrix = [];\n for (let i = 0; i < this.m; i++) {\n const constraint = this.constraints[i];\n \n const arr = constraint.getGaussArr(variableMap);\n\n matrix.push(arr);\n }\n \n return matrix;\n }\n}"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Variable } from './variable';
|
|
2
|
+
/**
|
|
3
|
+
* 操作符的枚举值
|
|
4
|
+
*/
|
|
5
|
+
export declare enum Operator {
|
|
6
|
+
EQ = "eq"
|
|
7
|
+
}
|
|
8
|
+
export declare type BoxObject = {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 几种情况
|
|
16
|
+
* - 200
|
|
17
|
+
* - variable
|
|
18
|
+
* - [200, 2]
|
|
19
|
+
* - [2, variable]
|
|
20
|
+
*/
|
|
21
|
+
export declare type Element = Variable | number | (Variable | number)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/chart/layout/constraint/types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,YAAY;IACZ,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;AACjB,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB","sourcesContent":["import type { Variable } from './variable'\n\n/**\n * 操作符的枚举值\n */\nexport enum Operator {\n EQ = 'eq',\n // 暂时不支持不等式组\n // GT = 'gt',\n // LT = 'lt',\n // GTE = 'gte',\n // LTE = 'lte',\n}\n\nexport type BoxObject = {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * 几种情况\n * - 200\n * - variable\n * - [200, 2]\n * - [2, variable]\n */\nexport type Element = Variable | number | (Variable | number)[];\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 定义一个变量
|
|
3
|
+
*/
|
|
4
|
+
export declare class Variable {
|
|
5
|
+
/**
|
|
6
|
+
* 变量的名称
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* 实际的值
|
|
11
|
+
*/
|
|
12
|
+
value: number;
|
|
13
|
+
/**
|
|
14
|
+
* 判断是否为一个变量
|
|
15
|
+
* @param v
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
static isVariable(v: any): v is Variable;
|
|
19
|
+
/**
|
|
20
|
+
* 构造方法
|
|
21
|
+
* @param name
|
|
22
|
+
*/
|
|
23
|
+
constructor(name?: string);
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { uniqueId } from '@antv/util';
|
|
2
|
+
/**
|
|
3
|
+
* 定义一个变量
|
|
4
|
+
*/
|
|
5
|
+
var Variable = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* 构造方法
|
|
8
|
+
* @param name
|
|
9
|
+
*/
|
|
10
|
+
function Variable(name) {
|
|
11
|
+
/**
|
|
12
|
+
* 变量的名称
|
|
13
|
+
*/
|
|
14
|
+
this.name = '';
|
|
15
|
+
this.name = name !== null && name !== void 0 ? name : "\uD835\uDCB3" + uniqueId('_');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 判断是否为一个变量
|
|
19
|
+
* @param v
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
Variable.isVariable = function (v) {
|
|
23
|
+
return v instanceof Variable;
|
|
24
|
+
};
|
|
25
|
+
return Variable;
|
|
26
|
+
}());
|
|
27
|
+
export { Variable };
|
|
28
|
+
//# sourceMappingURL=variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.js","sourceRoot":"","sources":["../../../../src/chart/layout/constraint/variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH;IAoBE;;;OAGG;IACH,kBAAY,IAAa;QAvBzB;;WAEG;QACI,SAAI,GAAG,EAAE,CAAC;QAqBf,IAAI,CAAC,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,iBAAK,QAAQ,CAAC,GAAG,CAAG,CAAC;IAC3C,CAAC;IAfD;;;;OAIG;IACW,mBAAU,GAAxB,UAAyB,CAAM;QAC7B,OAAO,CAAC,YAAY,QAAQ,CAAC;IAC/B,CAAC;IASH,eAAC;AAAD,CAAC,AA3BD,IA2BC","sourcesContent":["import { uniqueId } from '@antv/util';\n\n/**\n * 定义一个变量\n */\nexport class Variable {\n /**\n * 变量的名称\n */\n public name = '';\n\n /**\n * 实际的值\n */\n public value: number;\n\n /**\n * 判断是否为一个变量\n * @param v \n * @returns \n */\n public static isVariable(v: any): v is Variable {\n return v instanceof Variable;\n }\n\n /**\n * 构造方法\n * @param name\n */\n constructor(name?: string) {\n this.name = name ?? `𝒳${uniqueId('_')}`;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
2
|
import { DIRECTION } from '../../constant';
|
|
3
3
|
/** @ignore */
|
|
4
4
|
var PaddingCal = /** @class */ (function () {
|
|
@@ -100,7 +100,7 @@ var PaddingCal = /** @class */ (function () {
|
|
|
100
100
|
* clone 一个 padding cal
|
|
101
101
|
*/
|
|
102
102
|
PaddingCal.prototype.clone = function () {
|
|
103
|
-
return new (PaddingCal.bind.apply(PaddingCal,
|
|
103
|
+
return new (PaddingCal.bind.apply(PaddingCal, __spreadArray([void 0], this.getPadding(), false)))();
|
|
104
104
|
};
|
|
105
105
|
return PaddingCal;
|
|
106
106
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding-cal.js","sourceRoot":"","sources":["../../../src/chart/layout/padding-cal.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ3C,cAAc;AACd;IAiBE;;;;;;OAMG;IACH,oBAAY,GAAe,EAAE,KAAiB,EAAE,MAAkB,EAAE,IAAgB;QAAxE,oBAAA,EAAA,OAAe;QAAE,sBAAA,EAAA,SAAiB;QAAE,uBAAA,EAAA,UAAkB;QAAE,qBAAA,EAAA,QAAgB;QAClF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAvBD;;;;;;OAMG;IACW,mBAAQ,GAAtB,UAAuB,GAAe,EAAE,KAAiB,EAAE,MAAkB,EAAE,IAAgB;QAAxE,oBAAA,EAAA,OAAe;QAAE,sBAAA,EAAA,SAAiB;QAAE,uBAAA,EAAA,UAAkB;QAAE,qBAAA,EAAA,QAAgB;QAC7F,OAAO,IAAI,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAgBD;;;OAGG;IACI,wBAAG,GAAV,UAA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AAC,UAAU,EAAE,aAAE;IAC9C,CAAC;IACH,iBAAC;AAAD,CAAC,AAjHD,IAiHC","sourcesContent":["import { DIRECTION } from '../../constant';\nimport { BBox } from '../../dependents';\nimport { Padding } from '../../interface';\n\nexport type PaddingCalCtor = {\n readonly instance: (top?: number, right?: number, bottom?: number, left?: number) => PaddingCal;\n};\n\n/** @ignore */\nexport class PaddingCal {\n private top: number;\n private right: number;\n private bottom: number;\n private left: number;\n\n /**\n * 使用静态方法创建一个\n * @param top\n * @param right\n * @param bottom\n * @param left\n */\n public static instance(top: number = 0, right: number = 0, bottom: number = 0, left: number = 0) {\n return new PaddingCal(top, right, bottom, left);\n }\n\n /**\n * 初始的 padding 数据\n * @param top\n * @param right\n * @param bottom\n * @param left\n */\n constructor(top: number = 0, right: number = 0, bottom: number = 0, left: number = 0) {\n this.top = top;\n this.right = right;\n this.bottom = bottom;\n this.left = left;\n }\n\n /**\n * 取最大区间\n * @param padding\n */\n public max(padding: Padding): PaddingCal {\n const [top, right, bottom, left] = padding;\n\n this.top = Math.max(this.top, top);\n this.right = Math.max(this.right, right);\n this.bottom = Math.max(this.bottom, bottom);\n this.left = Math.max(this.left, left);\n\n return this;\n }\n\n /**\n * 四周增加 padding\n * @param padding\n */\n public shrink(padding: Padding): PaddingCal {\n const [top, right, bottom, left] = padding;\n\n this.top += top;\n this.right += right;\n this.bottom += bottom;\n this.left += left;\n\n return this;\n }\n\n /**\n * 在某一个方向增加 padding\n * @param bbox\n * @param direction\n */\n public inc(bbox: BBox, direction: DIRECTION): PaddingCal {\n const { width, height } = bbox;\n\n switch (direction) {\n case DIRECTION.TOP:\n case DIRECTION.TOP_LEFT:\n case DIRECTION.TOP_RIGHT:\n this.top += height;\n break;\n\n case DIRECTION.RIGHT:\n case DIRECTION.RIGHT_TOP:\n case DIRECTION.RIGHT_BOTTOM:\n this.right += width;\n break;\n\n case DIRECTION.BOTTOM:\n case DIRECTION.BOTTOM_LEFT:\n case DIRECTION.BOTTOM_RIGHT:\n this.bottom += height;\n break;\n\n case DIRECTION.LEFT:\n case DIRECTION.LEFT_TOP:\n case DIRECTION.LEFT_BOTTOM:\n this.left += width;\n break;\n default:\n break;\n }\n\n return this;\n }\n\n /**\n * 获得最终的 padding\n */\n public getPadding(): Padding {\n return [this.top, this.right, this.bottom, this.left];\n }\n\n /**\n * clone 一个 padding cal\n */\n public clone(): PaddingCal {\n return new PaddingCal(...this.getPadding());\n }\n}\n"]}
|
package/esm/chart/view.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Attribute, Coordinate, ICanvas, IGroup, Scale } from '../dependents';
|
|
2
|
-
import { AxisOption, ComponentOption, CoordinateCfg, CoordinateOption, Data, Datum, FacetCfgMap, FilterCondition, LegendOption, LooseObject, Options, Point, Region, ScaleOption, TooltipOption, ViewCfg, ViewPadding, ViewAppendPadding, EventPayload } from '../interface';
|
|
2
|
+
import { AxisOption, ComponentOption, CoordinateCfg, CoordinateOption, Data, Datum, FacetCfgMap, FilterCondition, LegendOption, LooseObject, Options, Point, Region, ScaleOption, TooltipOption, ViewCfg, ViewPadding, ViewAppendPadding, EventPayload, Padding } from '../interface';
|
|
3
3
|
import { LAYER } from '../constant';
|
|
4
4
|
import Base from '../base';
|
|
5
5
|
import { Facet } from '../facet';
|
|
6
6
|
import Geometry from '../geometry/base';
|
|
7
|
+
import Element from '../geometry/element';
|
|
7
8
|
import { Interaction } from '../interaction';
|
|
8
9
|
import { BBox } from '../util/bbox';
|
|
9
10
|
import Annotation from './controller/annotation';
|
|
@@ -449,6 +450,11 @@ export declare class View extends Base {
|
|
|
449
450
|
* @param field 数据字段名称
|
|
450
451
|
* @param key id
|
|
451
452
|
*/
|
|
453
|
+
getScale(field: string, key?: string): Scale;
|
|
454
|
+
/**
|
|
455
|
+
* @deprecated
|
|
456
|
+
* This method will be removed at G2 V4.1. Please use `getScale`.
|
|
457
|
+
*/
|
|
452
458
|
getScaleByField(field: string, key?: string): Scale;
|
|
453
459
|
/**
|
|
454
460
|
* 返回所有配置信息。
|
|
@@ -460,6 +466,40 @@ export declare class View extends Base {
|
|
|
460
466
|
* @returns 处理过滤器之后的数据。
|
|
461
467
|
*/
|
|
462
468
|
getData(): Data;
|
|
469
|
+
/**
|
|
470
|
+
* 获取原始数据
|
|
471
|
+
* @returns 传入 G2 的原始数据
|
|
472
|
+
*/
|
|
473
|
+
getOriginalData(): Data;
|
|
474
|
+
/**
|
|
475
|
+
* 获取布局后的边距 padding
|
|
476
|
+
* @returns
|
|
477
|
+
*/
|
|
478
|
+
getPadding(): Padding;
|
|
479
|
+
/**
|
|
480
|
+
* 获取当前 view 有的 geometries
|
|
481
|
+
* @returns
|
|
482
|
+
*/
|
|
483
|
+
getGeometries(): Geometry<import("../interface").ShapePoint>[];
|
|
484
|
+
/**
|
|
485
|
+
* 获取 view 中的所有 geome
|
|
486
|
+
*/
|
|
487
|
+
getElements(): Element[];
|
|
488
|
+
/**
|
|
489
|
+
* 根据一定的规则查找 Geometry 的 Elements。
|
|
490
|
+
*
|
|
491
|
+
* ```typescript
|
|
492
|
+
* getElementsBy((element) => {
|
|
493
|
+
* const data = element.getData();
|
|
494
|
+
*
|
|
495
|
+
* return data.a === 'a';
|
|
496
|
+
* });
|
|
497
|
+
* ```
|
|
498
|
+
*
|
|
499
|
+
* @param condition 定义查找规则的回调函数。
|
|
500
|
+
* @returns
|
|
501
|
+
*/
|
|
502
|
+
getElementsBy(condition: (element: Element) => boolean): Element[];
|
|
463
503
|
/**
|
|
464
504
|
* 获得绘制的层级 group。
|
|
465
505
|
* @param layer 层级名称。
|
package/esm/chart/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __assign, __extends, __rest,
|
|
2
|
-
import { clone, deepMix, each, filter, find, flatten, get, isBoolean, isFunction, isNil, isObject, isString, isUndefined, mix, remove, set, size, uniqueId, isEqual, isPlainObject, } from '@antv/util';
|
|
1
|
+
import { __assign, __extends, __rest, __spreadArray } from "tslib";
|
|
2
|
+
import { clone, deepMix, each, filter, find, flatten, get, isBoolean, isFunction, isNil, isObject, isString, isUndefined, mix, remove, set, size, uniqueId, isEqual, isPlainObject, reduce, } from '@antv/util';
|
|
3
3
|
import { GROUP_Z_INDEX, LAYER, PLOT_EVENTS, VIEW_LIFE_CIRCLE } from '../constant';
|
|
4
4
|
import Base from '../base';
|
|
5
5
|
import { getFacet } from '../facet';
|
|
@@ -40,7 +40,7 @@ var View = /** @class */ (function (_super) {
|
|
|
40
40
|
// 配置信息存储
|
|
41
41
|
_this.options = {
|
|
42
42
|
data: [],
|
|
43
|
-
animate: true,
|
|
43
|
+
animate: true, // 默认开启动画
|
|
44
44
|
}; // 初始化为空
|
|
45
45
|
/** 配置开启的组件插件,默认为全局配置的组件。 */
|
|
46
46
|
_this.usedControllers = getComponentControllerNames();
|
|
@@ -168,6 +168,7 @@ var View = /** @class */ (function (_super) {
|
|
|
168
168
|
geometries[i].clear();
|
|
169
169
|
// view 中使用 geometry 的时候,还需要清空它的容器,不然下一次 chart.geometry() 的时候,又创建了一个,导致泄露, #2799。
|
|
170
170
|
geometries[i].container.remove(true);
|
|
171
|
+
geometries[i].labelsContainer.remove(true);
|
|
171
172
|
}
|
|
172
173
|
this.geometries = [];
|
|
173
174
|
// 3. 清空 controllers
|
|
@@ -651,14 +652,16 @@ var View = /** @class */ (function (_super) {
|
|
|
651
652
|
View.prototype.getYScales = function () {
|
|
652
653
|
// 拿到所有的 Geometry 的 Y scale,然后去重
|
|
653
654
|
var tmpMap = {};
|
|
654
|
-
|
|
655
|
+
var yScales = [];
|
|
656
|
+
this.geometries.forEach(function (g) {
|
|
655
657
|
var yScale = g.getYScale();
|
|
656
658
|
var field = yScale.field;
|
|
657
659
|
if (!tmpMap[field]) {
|
|
658
660
|
tmpMap[field] = true;
|
|
659
|
-
|
|
661
|
+
yScales.push(yScale);
|
|
660
662
|
}
|
|
661
663
|
});
|
|
664
|
+
return yScales;
|
|
662
665
|
};
|
|
663
666
|
/**
|
|
664
667
|
* 获取 x 轴或者 y 轴对应的所有 scale 实例。
|
|
@@ -682,11 +685,18 @@ var View = /** @class */ (function (_super) {
|
|
|
682
685
|
* @param field 数据字段名称
|
|
683
686
|
* @param key id
|
|
684
687
|
*/
|
|
685
|
-
View.prototype.
|
|
688
|
+
View.prototype.getScale = function (field, key) {
|
|
686
689
|
var defaultKey = key ? key : this.getScaleKey(field);
|
|
687
690
|
// 调用根节点 view 的方法获取
|
|
688
691
|
return this.getRootView().scalePool.getScale(defaultKey);
|
|
689
692
|
};
|
|
693
|
+
/**
|
|
694
|
+
* @deprecated
|
|
695
|
+
* This method will be removed at G2 V4.1. Please use `getScale`.
|
|
696
|
+
*/
|
|
697
|
+
View.prototype.getScaleByField = function (field, key) {
|
|
698
|
+
return this.getScale(field, key);
|
|
699
|
+
};
|
|
690
700
|
/**
|
|
691
701
|
* 返回所有配置信息。
|
|
692
702
|
* @returns 所有的 view API 配置。
|
|
@@ -701,6 +711,52 @@ var View = /** @class */ (function (_super) {
|
|
|
701
711
|
View.prototype.getData = function () {
|
|
702
712
|
return this.filteredData;
|
|
703
713
|
};
|
|
714
|
+
/**
|
|
715
|
+
* 获取原始数据
|
|
716
|
+
* @returns 传入 G2 的原始数据
|
|
717
|
+
*/
|
|
718
|
+
View.prototype.getOriginalData = function () {
|
|
719
|
+
return this.options.data;
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* 获取布局后的边距 padding
|
|
723
|
+
* @returns
|
|
724
|
+
*/
|
|
725
|
+
View.prototype.getPadding = function () {
|
|
726
|
+
return this.autoPadding.getPadding();
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* 获取当前 view 有的 geometries
|
|
730
|
+
* @returns
|
|
731
|
+
*/
|
|
732
|
+
View.prototype.getGeometries = function () {
|
|
733
|
+
return this.geometries;
|
|
734
|
+
};
|
|
735
|
+
/**
|
|
736
|
+
* 获取 view 中的所有 geome
|
|
737
|
+
*/
|
|
738
|
+
View.prototype.getElements = function () {
|
|
739
|
+
return reduce(this.geometries, function (elements, geometry) {
|
|
740
|
+
return elements.concat(geometry.getElements());
|
|
741
|
+
}, []);
|
|
742
|
+
};
|
|
743
|
+
/**
|
|
744
|
+
* 根据一定的规则查找 Geometry 的 Elements。
|
|
745
|
+
*
|
|
746
|
+
* ```typescript
|
|
747
|
+
* getElementsBy((element) => {
|
|
748
|
+
* const data = element.getData();
|
|
749
|
+
*
|
|
750
|
+
* return data.a === 'a';
|
|
751
|
+
* });
|
|
752
|
+
* ```
|
|
753
|
+
*
|
|
754
|
+
* @param condition 定义查找规则的回调函数。
|
|
755
|
+
* @returns
|
|
756
|
+
*/
|
|
757
|
+
View.prototype.getElementsBy = function (condition) {
|
|
758
|
+
return this.getElements().filter(function (el) { return condition(el); });
|
|
759
|
+
};
|
|
704
760
|
/**
|
|
705
761
|
* 获得绘制的层级 group。
|
|
706
762
|
* @param layer 层级名称。
|
|
@@ -1346,7 +1402,7 @@ var View = /** @class */ (function (_super) {
|
|
|
1346
1402
|
};
|
|
1347
1403
|
View.prototype.getScaleFields = function () {
|
|
1348
1404
|
var fields = [];
|
|
1349
|
-
var tmpMap =
|
|
1405
|
+
var tmpMap = new Map();
|
|
1350
1406
|
var geometries = this.geometries;
|
|
1351
1407
|
for (var i = 0; i < geometries.length; i++) {
|
|
1352
1408
|
var geometry = geometries[i];
|
|
@@ -1357,7 +1413,7 @@ var View = /** @class */ (function (_super) {
|
|
|
1357
1413
|
};
|
|
1358
1414
|
View.prototype.getGroupedFields = function () {
|
|
1359
1415
|
var fields = [];
|
|
1360
|
-
var tmpMap =
|
|
1416
|
+
var tmpMap = new Map();
|
|
1361
1417
|
var geometries = this.geometries;
|
|
1362
1418
|
for (var i = 0; i < geometries.length; i++) {
|
|
1363
1419
|
var geometry = geometries[i];
|
|
@@ -1381,7 +1437,7 @@ var View = /** @class */ (function (_super) {
|
|
|
1381
1437
|
*/
|
|
1382
1438
|
View.prototype.adjustCategoryScaleRange = function () {
|
|
1383
1439
|
var _this = this;
|
|
1384
|
-
var xyScales =
|
|
1440
|
+
var xyScales = __spreadArray([this.getXScale()], this.getYScales(), true).filter(function (e) { return !!e; });
|
|
1385
1441
|
var coordinate = this.getCoordinate();
|
|
1386
1442
|
var scaleOptions = this.options.scales;
|
|
1387
1443
|
each(xyScales, function (scale) {
|