@antv/g2plot 2.4.26 → 2.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2plot.min.js +2 -2
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/brush.d.ts +1 -1
- package/esm/adaptor/common.js +2 -2
- package/esm/adaptor/common.js.map +1 -1
- package/esm/adaptor/conversion-tag.js +4 -4
- package/esm/adaptor/conversion-tag.js.map +1 -1
- package/esm/adaptor/geometries/area.js +5 -2
- package/esm/adaptor/geometries/area.js.map +1 -1
- package/esm/adaptor/geometries/base.d.ts +3 -3
- package/esm/adaptor/geometries/base.js +6 -6
- package/esm/adaptor/geometries/base.js.map +1 -1
- package/esm/adaptor/pattern.d.ts +6 -1
- package/esm/adaptor/pattern.js +2 -2
- package/esm/adaptor/pattern.js.map +1 -1
- package/esm/core/adaptor.d.ts +2 -2
- package/esm/core/adaptor.js +1 -0
- package/esm/core/plot.d.ts +1 -1
- package/esm/core/plot.js +2 -2
- package/esm/core/plot.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interactions/actions/drill-down.d.ts +2 -2
- package/esm/interactions/actions/drill-down.js +3 -3
- package/esm/interactions/actions/drill-down.js.map +1 -1
- package/esm/interactions/actions/reset-button.js.map +1 -1
- package/esm/interactions/brush.d.ts +2 -2
- package/esm/interactions/brush.js +34 -34
- package/esm/interactions/brush.js.map +1 -1
- package/esm/lab.js +3 -3
- package/esm/lab.js.map +1 -1
- package/esm/plots/_template/adaptor.js +1 -1
- package/esm/plots/_template/adaptor.js.map +1 -1
- package/esm/plots/_template/types.js +1 -0
- package/esm/plots/area/adaptor.js +6 -2
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/types.d.ts +5 -1
- package/esm/plots/area/types.js +1 -0
- package/esm/plots/area/types.js.map +1 -1
- package/esm/plots/bar/types.js +1 -0
- package/esm/plots/bidirectional-bar/adaptor.js.map +1 -1
- package/esm/plots/bidirectional-bar/types.js +1 -0
- package/esm/plots/box/types.js +1 -0
- package/esm/plots/bullet/adaptor.js +11 -11
- package/esm/plots/bullet/adaptor.js.map +1 -1
- package/esm/plots/bullet/types.d.ts +2 -2
- package/esm/plots/bullet/types.js +1 -0
- package/esm/plots/bullet/utils.d.ts +1 -1
- package/esm/plots/bullet/utils.js +2 -2
- package/esm/plots/bullet/utils.js.map +1 -1
- package/esm/plots/chord/adaptor.js +3 -3
- package/esm/plots/chord/adaptor.js.map +1 -1
- package/esm/plots/chord/constant.js +1 -1
- package/esm/plots/chord/constant.js.map +1 -1
- package/esm/plots/chord/types.js +1 -0
- package/esm/plots/circle-packing/adaptor.js +5 -5
- package/esm/plots/circle-packing/adaptor.js.map +1 -1
- package/esm/plots/circle-packing/types.js +1 -0
- package/esm/plots/circle-packing/utils.js +1 -1
- package/esm/plots/circle-packing/utils.js.map +1 -1
- package/esm/plots/column/adaptor.js +10 -6
- package/esm/plots/column/adaptor.js.map +1 -1
- package/esm/plots/column/types.d.ts +1 -1
- package/esm/plots/column/types.js +1 -0
- package/esm/plots/dual-axes/adaptor.js.map +1 -1
- package/esm/plots/dual-axes/types.d.ts +5 -5
- package/esm/plots/dual-axes/util/legend.js +1 -1
- package/esm/plots/dual-axes/util/legend.js.map +1 -1
- package/esm/plots/dual-axes/util/option.js.map +1 -1
- package/esm/plots/facet/adaptor.d.ts +1 -1
- package/esm/plots/facet/index.d.ts +1 -1
- package/esm/plots/facet/types.d.ts +5 -5
- package/esm/plots/facet/types.js +1 -0
- package/esm/plots/funnel/adaptor.js +3 -3
- package/esm/plots/funnel/adaptor.js.map +1 -1
- package/esm/plots/funnel/geometries/compare.js.map +1 -1
- package/esm/plots/funnel/interactions/index.js +1 -1
- package/esm/plots/funnel/interactions/index.js.map +1 -1
- package/esm/plots/funnel/types.d.ts +1 -1
- package/esm/plots/funnel/types.js +1 -0
- package/esm/plots/gauge/adaptor.js +4 -4
- package/esm/plots/gauge/adaptor.js.map +1 -1
- package/esm/plots/gauge/shapes/indicator.js.map +1 -1
- package/esm/plots/gauge/shapes/meter-gauge.js.map +1 -1
- package/esm/plots/gauge/types.d.ts +4 -4
- package/esm/plots/gauge/utils.js +1 -1
- package/esm/plots/gauge/utils.js.map +1 -1
- package/esm/plots/heatmap/adaptor.js.map +1 -1
- package/esm/plots/heatmap/shapes/circle.js.map +1 -1
- package/esm/plots/heatmap/shapes/square.js.map +1 -1
- package/esm/plots/heatmap/types.js +1 -0
- package/esm/plots/histogram/types.js +1 -0
- package/esm/plots/line/types.js +1 -0
- package/esm/plots/liquid/adaptor.js +1 -1
- package/esm/plots/liquid/adaptor.js.map +1 -1
- package/esm/plots/liquid/shapes/liquid.js +5 -5
- package/esm/plots/liquid/shapes/liquid.js.map +1 -1
- package/esm/plots/liquid/types.d.ts +4 -4
- package/esm/plots/liquid/types.js +1 -0
- package/esm/plots/mix/interactions/association.js.map +1 -1
- package/esm/plots/mix/types.d.ts +3 -3
- package/esm/plots/mix/types.js +1 -0
- package/esm/plots/mix/utils.d.ts +2 -2
- package/esm/plots/mix/utils.js +1 -1
- package/esm/plots/mix/utils.js.map +1 -1
- package/esm/plots/pie/adaptor.js +2 -2
- package/esm/plots/pie/adaptor.js.map +1 -1
- package/esm/plots/pie/types.d.ts +1 -1
- package/esm/plots/pie/types.js +1 -0
- package/esm/plots/progress/types.js +1 -0
- package/esm/plots/progress/utils.js +2 -2
- package/esm/plots/progress/utils.js.map +1 -1
- package/esm/plots/radar/types.js +1 -0
- package/esm/plots/radial-bar/adaptor.js +2 -2
- package/esm/plots/radial-bar/adaptor.js.map +1 -1
- package/esm/plots/radial-bar/types.d.ts +7 -1
- package/esm/plots/radial-bar/types.js +1 -0
- package/esm/plots/radial-bar/types.js.map +1 -1
- package/esm/plots/ring-progress/adaptor.js +1 -1
- package/esm/plots/ring-progress/adaptor.js.map +1 -1
- package/esm/plots/ring-progress/types.js +1 -0
- package/esm/plots/rose/adaptor.js +2 -1
- package/esm/plots/rose/adaptor.js.map +1 -1
- package/esm/plots/rose/types.d.ts +7 -1
- package/esm/plots/rose/types.js +1 -0
- package/esm/plots/rose/types.js.map +1 -1
- package/esm/plots/sankey/adaptor.js +5 -5
- package/esm/plots/sankey/adaptor.js.map +1 -1
- package/esm/plots/sankey/circle.js +3 -3
- package/esm/plots/sankey/circle.js.map +1 -1
- package/esm/plots/sankey/helper.js +3 -3
- package/esm/plots/sankey/helper.js.map +1 -1
- package/esm/plots/sankey/interactions/actions/node-drag.js +2 -2
- package/esm/plots/sankey/interactions/actions/node-drag.js.map +1 -1
- package/esm/plots/sankey/layout.d.ts +11 -11
- package/esm/plots/sankey/layout.js.map +1 -1
- package/esm/plots/sankey/sankey/sankey.d.ts +1 -1
- package/esm/plots/sankey/types.d.ts +1 -1
- package/esm/plots/sankey/types.js +1 -0
- package/esm/plots/scatter/adaptor.js +18 -4
- package/esm/plots/scatter/adaptor.js.map +1 -1
- package/esm/plots/scatter/index.js.map +1 -1
- package/esm/plots/scatter/types.d.ts +16 -1
- package/esm/plots/scatter/types.js +1 -0
- package/esm/plots/scatter/types.js.map +1 -1
- package/esm/plots/scatter/util.d.ts +15 -1
- package/esm/plots/scatter/util.js +45 -2
- package/esm/plots/scatter/util.js.map +1 -1
- package/esm/plots/stock/types.js +1 -0
- package/esm/plots/sunburst/adaptor.js +6 -5
- package/esm/plots/sunburst/adaptor.js.map +1 -1
- package/esm/plots/sunburst/types.d.ts +7 -1
- package/esm/plots/sunburst/types.js +1 -0
- package/esm/plots/sunburst/types.js.map +1 -1
- package/esm/plots/sunburst/utils.js +4 -4
- package/esm/plots/sunburst/utils.js.map +1 -1
- package/esm/plots/tiny-area/types.js +1 -0
- package/esm/plots/tiny-column/constants.js +1 -1
- package/esm/plots/tiny-column/constants.js.map +1 -1
- package/esm/plots/tiny-column/types.js +1 -0
- package/esm/plots/tiny-line/constants.js +1 -1
- package/esm/plots/tiny-line/constants.js.map +1 -1
- package/esm/plots/tiny-line/types.js +1 -0
- package/esm/plots/tiny-line/utils.js +1 -1
- package/esm/plots/tiny-line/utils.js.map +1 -1
- package/esm/plots/treemap/adaptor.js +3 -3
- package/esm/plots/treemap/adaptor.js.map +1 -1
- package/esm/plots/treemap/types.js +1 -0
- package/esm/plots/venn/layout/layout.js +1 -0
- package/esm/plots/venn/layout/layout.js.map +1 -1
- package/esm/plots/venn/shape.js.map +1 -1
- package/esm/plots/venn/types.d.ts +2 -2
- package/esm/plots/venn/utils.d.ts +1 -1
- package/esm/plots/violin/constant.js +2 -0
- package/esm/plots/violin/constant.js.map +1 -1
- package/esm/plots/violin/types.js +1 -0
- package/esm/plots/violin/utils.d.ts +2 -2
- package/esm/plots/waterfall/adaptor.js +5 -4
- package/esm/plots/waterfall/adaptor.js.map +1 -1
- package/esm/plots/waterfall/shape.js.map +1 -1
- package/esm/plots/waterfall/types.d.ts +9 -3
- package/esm/plots/waterfall/types.js +1 -0
- package/esm/plots/waterfall/types.js.map +1 -1
- package/esm/plots/waterfall/utils.js +1 -1
- package/esm/plots/waterfall/utils.js.map +1 -1
- package/esm/plots/word-cloud/adaptor.js +2 -2
- package/esm/plots/word-cloud/adaptor.js.map +1 -1
- package/esm/plots/word-cloud/shapes/word-cloud.js.map +1 -1
- package/esm/plots/word-cloud/types.d.ts +2 -2
- package/esm/plots/word-cloud/types.js +1 -0
- package/esm/types/animation.d.ts +1 -1
- package/esm/types/animation.js +1 -0
- package/esm/types/annotation.d.ts +2 -2
- package/esm/types/annotation.js +1 -0
- package/esm/types/attr.d.ts +7 -7
- package/esm/types/attr.js +1 -0
- package/esm/types/axis.d.ts +1 -1
- package/esm/types/axis.js +1 -0
- package/esm/types/button.d.ts +1 -1
- package/esm/types/button.js +1 -0
- package/esm/types/common.d.ts +13 -13
- package/esm/types/common.js +1 -0
- package/esm/types/coordinate.d.ts +1 -1
- package/esm/types/coordinate.js +1 -0
- package/esm/types/drill-down.d.ts +1 -1
- package/esm/types/drill-down.js +1 -0
- package/esm/types/index.d.ts +1 -1
- package/esm/types/interaction.d.ts +2 -2
- package/esm/types/interaction.js +1 -0
- package/esm/types/label.d.ts +1 -1
- package/esm/types/label.js +1 -0
- package/esm/types/legend.d.ts +1 -1
- package/esm/types/legend.js +1 -0
- package/esm/types/locale.d.ts +1 -1
- package/esm/types/locale.js +1 -0
- package/esm/types/meta.d.ts +1 -1
- package/esm/types/meta.js +1 -0
- package/esm/types/pattern.d.ts +4 -4
- package/esm/types/pattern.js +1 -0
- package/esm/types/relation-data.d.ts +3 -3
- package/esm/types/relation-data.js +1 -0
- package/esm/types/scrollbar.d.ts +1 -1
- package/esm/types/scrollbar.js +1 -0
- package/esm/types/slider.d.ts +1 -1
- package/esm/types/slider.js +1 -0
- package/esm/types/state.d.ts +4 -4
- package/esm/types/state.js +1 -0
- package/esm/types/statistic.d.ts +3 -3
- package/esm/types/statistic.js +1 -0
- package/esm/types/tooltip.d.ts +3 -3
- package/esm/types/tooltip.js +1 -0
- package/esm/utils/color/blend.js +1 -1
- package/esm/utils/color/blend.js.map +1 -1
- package/esm/utils/conversion.js +1 -1
- package/esm/utils/conversion.js.map +1 -1
- package/esm/utils/flow.d.ts +1 -1
- package/esm/utils/hierarchy/pack.d.ts +1 -1
- package/esm/utils/hierarchy/partition.d.ts +1 -1
- package/esm/utils/hierarchy/partition.js.map +1 -1
- package/esm/utils/hierarchy/types.js +1 -0
- package/esm/utils/hierarchy/util.js +1 -1
- package/esm/utils/hierarchy/util.js.map +1 -1
- package/esm/utils/invariant.js +4 -4
- package/esm/utils/invariant.js.map +1 -1
- package/esm/utils/matrix.js +2 -2
- package/esm/utils/matrix.js.map +1 -1
- package/esm/utils/measure-text.js +3 -3
- package/esm/utils/measure-text.js.map +1 -1
- package/esm/utils/pattern/index.d.ts +1 -1
- package/esm/utils/pattern/line.js +1 -1
- package/esm/utils/pattern/line.js.map +1 -1
- package/esm/utils/pattern/util.js +2 -2
- package/esm/utils/pattern/util.js.map +1 -1
- package/esm/utils/statistic.js +9 -9
- package/esm/utils/statistic.js.map +1 -1
- package/esm/utils/template.js +1 -1
- package/esm/utils/template.js.map +1 -1
- package/esm/utils/tooltip.js +1 -1
- package/esm/utils/tooltip.js.map +1 -1
- package/esm/utils/transform/chord.d.ts +4 -4
- package/esm/utils/transform/chord.js +4 -4
- package/esm/utils/transform/chord.js.map +1 -1
- package/esm/utils/transform/histogram.d.ts +1 -1
- package/esm/utils/transform/histogram.js +3 -3
- package/esm/utils/transform/histogram.js.map +1 -1
- package/esm/utils/transform/percent.js +2 -2
- package/esm/utils/transform/percent.js.map +1 -1
- package/esm/utils/transform/word-cloud.d.ts +1 -1
- package/esm/utils/transform/word-cloud.js +2 -1
- package/esm/utils/transform/word-cloud.js.map +1 -1
- package/lib/adaptor/brush.d.ts +1 -1
- package/lib/adaptor/brush.js +3 -3
- package/lib/adaptor/brush.js.map +1 -1
- package/lib/adaptor/common.js +10 -10
- package/lib/adaptor/common.js.map +1 -1
- package/lib/adaptor/connected-area.js +2 -2
- package/lib/adaptor/connected-area.js.map +1 -1
- package/lib/adaptor/conversion-tag.js +9 -9
- package/lib/adaptor/conversion-tag.js.map +1 -1
- package/lib/adaptor/geometries/area.js +7 -4
- package/lib/adaptor/geometries/area.js.map +1 -1
- package/lib/adaptor/geometries/base.d.ts +3 -3
- package/lib/adaptor/geometries/base.js +17 -17
- package/lib/adaptor/geometries/base.js.map +1 -1
- package/lib/adaptor/geometries/edge.js +2 -2
- package/lib/adaptor/geometries/edge.js.map +1 -1
- package/lib/adaptor/geometries/index.js +1 -0
- package/lib/adaptor/geometries/index.js.map +1 -1
- package/lib/adaptor/geometries/interval.js +4 -4
- package/lib/adaptor/geometries/interval.js.map +1 -1
- package/lib/adaptor/geometries/line.js +3 -3
- package/lib/adaptor/geometries/line.js.map +1 -1
- package/lib/adaptor/geometries/point.js +2 -2
- package/lib/adaptor/geometries/point.js.map +1 -1
- package/lib/adaptor/geometries/polygon.js +2 -2
- package/lib/adaptor/geometries/polygon.js.map +1 -1
- package/lib/adaptor/geometries/schema.js +2 -2
- package/lib/adaptor/geometries/schema.js.map +1 -1
- package/lib/adaptor/geometries/violin.js +2 -2
- package/lib/adaptor/geometries/violin.js.map +1 -1
- package/lib/adaptor/pattern.d.ts +6 -1
- package/lib/adaptor/pattern.js +4 -4
- package/lib/adaptor/pattern.js.map +1 -1
- package/lib/core/adaptor.d.ts +2 -2
- package/lib/core/global.js +1 -1
- package/lib/core/global.js.map +1 -1
- package/lib/core/locale.js +1 -1
- package/lib/core/locale.js.map +1 -1
- package/lib/core/plot.d.ts +1 -1
- package/lib/core/plot.js +13 -13
- package/lib/core/plot.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/interactions/actions/drill-down.d.ts +2 -2
- package/lib/interactions/actions/drill-down.js +12 -12
- package/lib/interactions/actions/drill-down.js.map +1 -1
- package/lib/interactions/actions/reset-button.js +3 -3
- package/lib/interactions/actions/reset-button.js.map +1 -1
- package/lib/interactions/brush.d.ts +2 -2
- package/lib/interactions/brush.js +42 -42
- package/lib/interactions/brush.js.map +1 -1
- package/lib/interactions/drag-move.js +1 -1
- package/lib/interactions/drag-move.js.map +1 -1
- package/lib/interactions/drill-down.js +4 -4
- package/lib/interactions/drill-down.js.map +1 -1
- package/lib/lab.js +3 -3
- package/lib/lab.js.map +1 -1
- package/lib/plots/_template/adaptor.js +3 -3
- package/lib/plots/_template/adaptor.js.map +1 -1
- package/lib/plots/area/adaptor.js +17 -13
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/constants.js +1 -1
- package/lib/plots/area/constants.js.map +1 -1
- package/lib/plots/area/index.js +2 -2
- package/lib/plots/area/index.js.map +1 -1
- package/lib/plots/area/types.d.ts +5 -1
- package/lib/plots/area/types.js.map +1 -1
- package/lib/plots/bar/adaptor.js +6 -6
- package/lib/plots/bar/adaptor.js.map +1 -1
- package/lib/plots/bar/constants.js +1 -1
- package/lib/plots/bar/constants.js.map +1 -1
- package/lib/plots/bar/index.js +2 -2
- package/lib/plots/bar/index.js.map +1 -1
- package/lib/plots/bidirectional-bar/adaptor.js +41 -41
- package/lib/plots/bidirectional-bar/adaptor.js.map +1 -1
- package/lib/plots/bidirectional-bar/index.js +4 -4
- package/lib/plots/bidirectional-bar/index.js.map +1 -1
- package/lib/plots/bidirectional-bar/utils.js +1 -1
- package/lib/plots/bidirectional-bar/utils.js.map +1 -1
- package/lib/plots/box/adaptor.js +10 -10
- package/lib/plots/box/adaptor.js.map +1 -1
- package/lib/plots/box/constant.js +1 -1
- package/lib/plots/box/constant.js.map +1 -1
- package/lib/plots/box/index.js +1 -1
- package/lib/plots/box/index.js.map +1 -1
- package/lib/plots/box/utils.js +3 -2
- package/lib/plots/box/utils.js.map +1 -1
- package/lib/plots/bullet/adaptor.js +37 -37
- package/lib/plots/bullet/adaptor.js.map +1 -1
- package/lib/plots/bullet/constant.js +1 -1
- package/lib/plots/bullet/constant.js.map +1 -1
- package/lib/plots/bullet/index.js +2 -2
- package/lib/plots/bullet/index.js.map +1 -1
- package/lib/plots/bullet/types.d.ts +2 -2
- package/lib/plots/bullet/utils.d.ts +1 -1
- package/lib/plots/bullet/utils.js +2 -2
- package/lib/plots/bullet/utils.js.map +1 -1
- package/lib/plots/chord/adaptor.js +8 -8
- package/lib/plots/chord/adaptor.js.map +1 -1
- package/lib/plots/chord/constant.js +2 -2
- package/lib/plots/chord/constant.js.map +1 -1
- package/lib/plots/circle-packing/adaptor.js +20 -20
- package/lib/plots/circle-packing/adaptor.js.map +1 -1
- package/lib/plots/circle-packing/utils.js +4 -4
- package/lib/plots/circle-packing/utils.js.map +1 -1
- package/lib/plots/column/adaptor.js +23 -19
- package/lib/plots/column/adaptor.js.map +1 -1
- package/lib/plots/column/constants.js +1 -1
- package/lib/plots/column/constants.js.map +1 -1
- package/lib/plots/column/index.js +2 -2
- package/lib/plots/column/index.js.map +1 -1
- package/lib/plots/column/types.d.ts +1 -1
- package/lib/plots/dual-axes/adaptor.js +63 -63
- package/lib/plots/dual-axes/adaptor.js.map +1 -1
- package/lib/plots/dual-axes/index.js +1 -1
- package/lib/plots/dual-axes/index.js.map +1 -1
- package/lib/plots/dual-axes/types.d.ts +5 -5
- package/lib/plots/dual-axes/util/geometry.js +9 -9
- package/lib/plots/dual-axes/util/geometry.js.map +1 -1
- package/lib/plots/dual-axes/util/legend.js +9 -9
- package/lib/plots/dual-axes/util/legend.js.map +1 -1
- package/lib/plots/dual-axes/util/option.js +8 -8
- package/lib/plots/dual-axes/util/option.js.map +1 -1
- package/lib/plots/dual-axes/util/render-sider.js +6 -5
- package/lib/plots/dual-axes/util/render-sider.js.map +1 -1
- package/lib/plots/facet/adaptor.d.ts +1 -1
- package/lib/plots/facet/adaptor.js +10 -10
- package/lib/plots/facet/adaptor.js.map +1 -1
- package/lib/plots/facet/index.d.ts +1 -1
- package/lib/plots/facet/types.d.ts +5 -5
- package/lib/plots/facet/utils.js +9 -9
- package/lib/plots/facet/utils.js.map +1 -1
- package/lib/plots/funnel/adaptor.js +14 -14
- package/lib/plots/funnel/adaptor.js.map +1 -1
- package/lib/plots/funnel/geometries/basic.js +10 -10
- package/lib/plots/funnel/geometries/basic.js.map +1 -1
- package/lib/plots/funnel/geometries/common.js +6 -6
- package/lib/plots/funnel/geometries/common.js.map +1 -1
- package/lib/plots/funnel/geometries/compare.js +12 -12
- package/lib/plots/funnel/geometries/compare.js.map +1 -1
- package/lib/plots/funnel/geometries/dynamic-height.js +9 -9
- package/lib/plots/funnel/geometries/dynamic-height.js.map +1 -1
- package/lib/plots/funnel/geometries/facet.js +2 -2
- package/lib/plots/funnel/geometries/facet.js.map +1 -1
- package/lib/plots/funnel/index.js +5 -5
- package/lib/plots/funnel/index.js.map +1 -1
- package/lib/plots/funnel/interactions/funnel-conversion-tag.js +5 -5
- package/lib/plots/funnel/interactions/funnel-conversion-tag.js.map +1 -1
- package/lib/plots/funnel/interactions/index.js +3 -3
- package/lib/plots/funnel/interactions/index.js.map +1 -1
- package/lib/plots/funnel/types.d.ts +1 -1
- package/lib/plots/gauge/adaptor.js +16 -16
- package/lib/plots/gauge/adaptor.js.map +1 -1
- package/lib/plots/gauge/index.js +3 -3
- package/lib/plots/gauge/index.js.map +1 -1
- package/lib/plots/gauge/shapes/indicator.js +1 -1
- package/lib/plots/gauge/shapes/indicator.js.map +1 -1
- package/lib/plots/gauge/shapes/meter-gauge.js +2 -2
- package/lib/plots/gauge/shapes/meter-gauge.js.map +1 -1
- package/lib/plots/gauge/types.d.ts +4 -4
- package/lib/plots/gauge/utils.js +4 -4
- package/lib/plots/gauge/utils.js.map +1 -1
- package/lib/plots/heatmap/adaptor.js +10 -10
- package/lib/plots/heatmap/adaptor.js.map +1 -1
- package/lib/plots/heatmap/constant.js +1 -1
- package/lib/plots/heatmap/constant.js.map +1 -1
- package/lib/plots/heatmap/shapes/circle.js +1 -1
- package/lib/plots/heatmap/shapes/circle.js.map +1 -1
- package/lib/plots/heatmap/shapes/square.js +1 -1
- package/lib/plots/heatmap/shapes/square.js.map +1 -1
- package/lib/plots/histogram/adaptor.js +7 -7
- package/lib/plots/histogram/adaptor.js.map +1 -1
- package/lib/plots/histogram/constant.js +1 -1
- package/lib/plots/histogram/constant.js.map +1 -1
- package/lib/plots/histogram/index.js +1 -1
- package/lib/plots/histogram/index.js.map +1 -1
- package/lib/plots/line/adaptor.js +13 -13
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/constants.js +1 -1
- package/lib/plots/line/constants.js.map +1 -1
- package/lib/plots/line/index.js +1 -1
- package/lib/plots/line/index.js.map +1 -1
- package/lib/plots/line/interactions/index.js +2 -2
- package/lib/plots/line/interactions/index.js.map +1 -1
- package/lib/plots/line/interactions/marker-active.js +5 -5
- package/lib/plots/line/interactions/marker-active.js.map +1 -1
- package/lib/plots/liquid/adaptor.js +8 -8
- package/lib/plots/liquid/adaptor.js.map +1 -1
- package/lib/plots/liquid/index.js +3 -3
- package/lib/plots/liquid/index.js.map +1 -1
- package/lib/plots/liquid/shapes/liquid.js +12 -12
- package/lib/plots/liquid/shapes/liquid.js.map +1 -1
- package/lib/plots/liquid/types.d.ts +4 -4
- package/lib/plots/mix/adaptor.js +17 -17
- package/lib/plots/mix/adaptor.js.map +1 -1
- package/lib/plots/mix/interactions/association.js +22 -22
- package/lib/plots/mix/interactions/association.js.map +1 -1
- package/lib/plots/mix/interactions/utils.js +3 -3
- package/lib/plots/mix/interactions/utils.js.map +1 -1
- package/lib/plots/mix/types.d.ts +3 -3
- package/lib/plots/mix/utils.d.ts +2 -2
- package/lib/plots/mix/utils.js +2 -2
- package/lib/plots/mix/utils.js.map +1 -1
- package/lib/plots/pie/adaptor.js +38 -38
- package/lib/plots/pie/adaptor.js.map +1 -1
- package/lib/plots/pie/contants.js +1 -1
- package/lib/plots/pie/contants.js.map +1 -1
- package/lib/plots/pie/index.js +4 -4
- package/lib/plots/pie/index.js.map +1 -1
- package/lib/plots/pie/interactions/actions/legend-active.js +3 -3
- package/lib/plots/pie/interactions/actions/legend-active.js.map +1 -1
- package/lib/plots/pie/interactions/actions/statistic-active.js +7 -7
- package/lib/plots/pie/interactions/actions/statistic-active.js.map +1 -1
- package/lib/plots/pie/interactions/index.js +4 -4
- package/lib/plots/pie/interactions/index.js.map +1 -1
- package/lib/plots/pie/types.d.ts +1 -1
- package/lib/plots/pie/utils.js +4 -4
- package/lib/plots/pie/utils.js.map +1 -1
- package/lib/plots/progress/adaptor.js +5 -5
- package/lib/plots/progress/adaptor.js.map +1 -1
- package/lib/plots/progress/index.js +1 -1
- package/lib/plots/progress/index.js.map +1 -1
- package/lib/plots/progress/utils.js +3 -3
- package/lib/plots/progress/utils.js.map +1 -1
- package/lib/plots/radar/adaptor.js +10 -10
- package/lib/plots/radar/adaptor.js.map +1 -1
- package/lib/plots/radar/index.js +1 -1
- package/lib/plots/radar/index.js.map +1 -1
- package/lib/plots/radar/interactions/index.js +2 -2
- package/lib/plots/radar/interactions/index.js.map +1 -1
- package/lib/plots/radar/interactions/radar-tooltip-action.js +3 -3
- package/lib/plots/radar/interactions/radar-tooltip-action.js.map +1 -1
- package/lib/plots/radial-bar/adaptor.js +13 -13
- package/lib/plots/radial-bar/adaptor.js.map +1 -1
- package/lib/plots/radial-bar/constant.js +1 -1
- package/lib/plots/radial-bar/constant.js.map +1 -1
- package/lib/plots/radial-bar/index.js +1 -1
- package/lib/plots/radial-bar/index.js.map +1 -1
- package/lib/plots/radial-bar/types.d.ts +7 -1
- package/lib/plots/radial-bar/types.js.map +1 -1
- package/lib/plots/ring-progress/adaptor.js +5 -5
- package/lib/plots/ring-progress/adaptor.js.map +1 -1
- package/lib/plots/ring-progress/index.js +2 -2
- package/lib/plots/ring-progress/index.js.map +1 -1
- package/lib/plots/rose/adaptor.js +11 -10
- package/lib/plots/rose/adaptor.js.map +1 -1
- package/lib/plots/rose/constant.js +1 -1
- package/lib/plots/rose/constant.js.map +1 -1
- package/lib/plots/rose/types.d.ts +7 -1
- package/lib/plots/rose/types.js.map +1 -1
- package/lib/plots/sankey/adaptor.js +12 -12
- package/lib/plots/sankey/adaptor.js.map +1 -1
- package/lib/plots/sankey/circle.js +4 -4
- package/lib/plots/sankey/circle.js.map +1 -1
- package/lib/plots/sankey/helper.js +6 -6
- package/lib/plots/sankey/helper.js.map +1 -1
- package/lib/plots/sankey/index.js +4 -4
- package/lib/plots/sankey/index.js.map +1 -1
- package/lib/plots/sankey/interactions/actions/node-drag.js +8 -8
- package/lib/plots/sankey/interactions/actions/node-drag.js.map +1 -1
- package/lib/plots/sankey/interactions/node-draggable.js +2 -2
- package/lib/plots/sankey/interactions/node-draggable.js.map +1 -1
- package/lib/plots/sankey/layout.d.ts +11 -11
- package/lib/plots/sankey/layout.js +3 -3
- package/lib/plots/sankey/layout.js.map +1 -1
- package/lib/plots/sankey/sankey/align.js +1 -1
- package/lib/plots/sankey/sankey/align.js.map +1 -1
- package/lib/plots/sankey/sankey/index.js +1 -1
- package/lib/plots/sankey/sankey/sankey.d.ts +1 -1
- package/lib/plots/sankey/sankey/sankey.js +9 -9
- package/lib/plots/sankey/sankey/sankey.js.map +1 -1
- package/lib/plots/sankey/types.d.ts +1 -1
- package/lib/plots/scatter/adaptor.js +33 -19
- package/lib/plots/scatter/adaptor.js.map +1 -1
- package/lib/plots/scatter/constant.js +1 -1
- package/lib/plots/scatter/constant.js.map +1 -1
- package/lib/plots/scatter/index.js +4 -4
- package/lib/plots/scatter/index.js.map +1 -1
- package/lib/plots/scatter/types.d.ts +16 -1
- package/lib/plots/scatter/types.js.map +1 -1
- package/lib/plots/scatter/util.d.ts +15 -1
- package/lib/plots/scatter/util.js +61 -15
- package/lib/plots/scatter/util.js.map +1 -1
- package/lib/plots/stock/adaptor.js +7 -7
- package/lib/plots/stock/adaptor.js.map +1 -1
- package/lib/plots/stock/constant.js +1 -1
- package/lib/plots/stock/constant.js.map +1 -1
- package/lib/plots/stock/index.js +1 -1
- package/lib/plots/stock/index.js.map +1 -1
- package/lib/plots/stock/utils.js +2 -2
- package/lib/plots/stock/utils.js.map +1 -1
- package/lib/plots/sunburst/adaptor.js +22 -21
- package/lib/plots/sunburst/adaptor.js.map +1 -1
- package/lib/plots/sunburst/constant.js +1 -1
- package/lib/plots/sunburst/constant.js.map +1 -1
- package/lib/plots/sunburst/types.d.ts +7 -1
- package/lib/plots/sunburst/types.js.map +1 -1
- package/lib/plots/sunburst/utils.js +4 -4
- package/lib/plots/sunburst/utils.js.map +1 -1
- package/lib/plots/tiny-area/adaptor.js +11 -11
- package/lib/plots/tiny-area/adaptor.js.map +1 -1
- package/lib/plots/tiny-area/index.js +2 -2
- package/lib/plots/tiny-area/index.js.map +1 -1
- package/lib/plots/tiny-column/adaptor.js +4 -4
- package/lib/plots/tiny-column/adaptor.js.map +1 -1
- package/lib/plots/tiny-column/constants.js +1 -1
- package/lib/plots/tiny-column/constants.js.map +1 -1
- package/lib/plots/tiny-column/index.js +2 -2
- package/lib/plots/tiny-column/index.js.map +1 -1
- package/lib/plots/tiny-line/adaptor.js +6 -6
- package/lib/plots/tiny-line/adaptor.js.map +1 -1
- package/lib/plots/tiny-line/constants.js +1 -1
- package/lib/plots/tiny-line/constants.js.map +1 -1
- package/lib/plots/tiny-line/index.js +2 -2
- package/lib/plots/tiny-line/index.js.map +1 -1
- package/lib/plots/tiny-line/utils.js +1 -1
- package/lib/plots/tiny-line/utils.js.map +1 -1
- package/lib/plots/treemap/adaptor.js +13 -13
- package/lib/plots/treemap/adaptor.js.map +1 -1
- package/lib/plots/treemap/index.js +3 -3
- package/lib/plots/treemap/index.js.map +1 -1
- package/lib/plots/treemap/utils.js +4 -4
- package/lib/plots/treemap/utils.js.map +1 -1
- package/lib/plots/venn/adaptor.js +18 -18
- package/lib/plots/venn/adaptor.js.map +1 -1
- package/lib/plots/venn/interactions/actions/active.js +2 -2
- package/lib/plots/venn/interactions/actions/active.js.map +1 -1
- package/lib/plots/venn/interactions/actions/highlight.js +2 -2
- package/lib/plots/venn/interactions/actions/highlight.js.map +1 -1
- package/lib/plots/venn/interactions/actions/selected.js +4 -4
- package/lib/plots/venn/interactions/actions/selected.js.map +1 -1
- package/lib/plots/venn/interactions/index.js +10 -10
- package/lib/plots/venn/interactions/index.js.map +1 -1
- package/lib/plots/venn/label.js +1 -1
- package/lib/plots/venn/label.js.map +1 -1
- package/lib/plots/venn/layout/diagram.js +10 -10
- package/lib/plots/venn/layout/diagram.js.map +1 -1
- package/lib/plots/venn/layout/layout.js +14 -13
- package/lib/plots/venn/layout/layout.js.map +1 -1
- package/lib/plots/venn/shape.js +3 -3
- package/lib/plots/venn/shape.js.map +1 -1
- package/lib/plots/venn/types.d.ts +2 -2
- package/lib/plots/venn/utils.d.ts +1 -1
- package/lib/plots/venn/utils.js +8 -8
- package/lib/plots/venn/utils.js.map +1 -1
- package/lib/plots/violin/adaptor.js +22 -22
- package/lib/plots/violin/adaptor.js.map +1 -1
- package/lib/plots/violin/constant.js +3 -1
- package/lib/plots/violin/constant.js.map +1 -1
- package/lib/plots/violin/index.js +1 -1
- package/lib/plots/violin/index.js.map +1 -1
- package/lib/plots/violin/utils.d.ts +2 -2
- package/lib/plots/violin/utils.js +18 -15
- package/lib/plots/violin/utils.js.map +1 -1
- package/lib/plots/waterfall/adaptor.js +21 -20
- package/lib/plots/waterfall/adaptor.js.map +1 -1
- package/lib/plots/waterfall/index.js +1 -1
- package/lib/plots/waterfall/index.js.map +1 -1
- package/lib/plots/waterfall/shape.js +3 -3
- package/lib/plots/waterfall/shape.js.map +1 -1
- package/lib/plots/waterfall/types.d.ts +9 -3
- package/lib/plots/waterfall/types.js.map +1 -1
- package/lib/plots/waterfall/utils.js +5 -5
- package/lib/plots/waterfall/utils.js.map +1 -1
- package/lib/plots/word-cloud/adaptor.js +6 -6
- package/lib/plots/word-cloud/adaptor.js.map +1 -1
- package/lib/plots/word-cloud/constant.js +1 -1
- package/lib/plots/word-cloud/constant.js.map +1 -1
- package/lib/plots/word-cloud/index.js +2 -2
- package/lib/plots/word-cloud/index.js.map +1 -1
- package/lib/plots/word-cloud/shapes/word-cloud.js +1 -1
- package/lib/plots/word-cloud/shapes/word-cloud.js.map +1 -1
- package/lib/plots/word-cloud/types.d.ts +2 -2
- package/lib/plots/word-cloud/utils.js +13 -13
- package/lib/plots/word-cloud/utils.js.map +1 -1
- package/lib/plugin/index.js +1 -1
- package/lib/plugin/index.js.map +1 -1
- package/lib/types/animation.d.ts +1 -1
- package/lib/types/annotation.d.ts +2 -2
- package/lib/types/attr.d.ts +7 -7
- package/lib/types/axis.d.ts +1 -1
- package/lib/types/button.d.ts +1 -1
- package/lib/types/common.d.ts +13 -13
- package/lib/types/coordinate.d.ts +1 -1
- package/lib/types/drill-down.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interaction.d.ts +2 -2
- package/lib/types/label.d.ts +1 -1
- package/lib/types/legend.d.ts +1 -1
- package/lib/types/locale.d.ts +1 -1
- package/lib/types/meta.d.ts +1 -1
- package/lib/types/pattern.d.ts +4 -4
- package/lib/types/relation-data.d.ts +3 -3
- package/lib/types/scrollbar.d.ts +1 -1
- package/lib/types/slider.d.ts +1 -1
- package/lib/types/state.d.ts +4 -4
- package/lib/types/statistic.d.ts +3 -3
- package/lib/types/tooltip.d.ts +3 -3
- package/lib/utils/color/blend.js +4 -3
- package/lib/utils/color/blend.js.map +1 -1
- package/lib/utils/conversion.js +2 -2
- package/lib/utils/conversion.js.map +1 -1
- package/lib/utils/data.js +7 -7
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/deep-assign.js +2 -1
- package/lib/utils/deep-assign.js.map +1 -1
- package/lib/utils/flow.d.ts +1 -1
- package/lib/utils/geometry.js +5 -5
- package/lib/utils/geometry.js.map +1 -1
- package/lib/utils/hierarchy/pack.d.ts +1 -1
- package/lib/utils/hierarchy/pack.js +4 -4
- package/lib/utils/hierarchy/pack.js.map +1 -1
- package/lib/utils/hierarchy/partition.d.ts +1 -1
- package/lib/utils/hierarchy/partition.js +6 -6
- package/lib/utils/hierarchy/partition.js.map +1 -1
- package/lib/utils/hierarchy/treemap.js +4 -4
- package/lib/utils/hierarchy/treemap.js.map +1 -1
- package/lib/utils/hierarchy/util.js +6 -6
- package/lib/utils/hierarchy/util.js.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/invariant.js +3 -3
- package/lib/utils/invariant.js.map +1 -1
- package/lib/utils/label.js +1 -1
- package/lib/utils/label.js.map +1 -1
- package/lib/utils/matrix.js +1 -1
- package/lib/utils/matrix.js.map +1 -1
- package/lib/utils/measure-text.js +5 -5
- package/lib/utils/measure-text.js.map +1 -1
- package/lib/utils/padding.js +2 -2
- package/lib/utils/padding.js.map +1 -1
- package/lib/utils/path.js +3 -2
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/pattern/dot.js +7 -7
- package/lib/utils/pattern/dot.js.map +1 -1
- package/lib/utils/pattern/index.d.ts +1 -1
- package/lib/utils/pattern/index.js +3 -3
- package/lib/utils/pattern/index.js.map +1 -1
- package/lib/utils/pattern/line.js +6 -6
- package/lib/utils/pattern/line.js.map +1 -1
- package/lib/utils/pattern/square.js +7 -7
- package/lib/utils/pattern/square.js.map +1 -1
- package/lib/utils/pattern/util.js +2 -2
- package/lib/utils/pattern/util.js.map +1 -1
- package/lib/utils/statistic.js +24 -22
- package/lib/utils/statistic.js.map +1 -1
- package/lib/utils/template.js +2 -2
- package/lib/utils/template.js.map +1 -1
- package/lib/utils/tooltip.js +3 -3
- package/lib/utils/tooltip.js.map +1 -1
- package/lib/utils/transform/chord.d.ts +4 -4
- package/lib/utils/transform/chord.js +8 -8
- package/lib/utils/transform/chord.js.map +1 -1
- package/lib/utils/transform/histogram.d.ts +1 -1
- package/lib/utils/transform/histogram.js +14 -14
- package/lib/utils/transform/histogram.js.map +1 -1
- package/lib/utils/transform/percent.js +10 -10
- package/lib/utils/transform/percent.js.map +1 -1
- package/lib/utils/transform/word-cloud.d.ts +1 -1
- package/lib/utils/transform/word-cloud.js +5 -4
- package/lib/utils/transform/word-cloud.js.map +1 -1
- package/lib/utils/view.js +2 -2
- package/lib/utils/view.js.map +1 -1
- package/package.json +7 -7
- package/src/adaptor/geometries/area.ts +8 -5
- package/src/index.ts +1 -1
- package/src/plots/area/adaptor.ts +6 -1
- package/src/plots/area/types.ts +10 -1
- package/src/plots/bidirectional-bar/adaptor.ts +1 -1
- package/src/plots/column/adaptor.ts +1 -1
- package/src/plots/radial-bar/adaptor.ts +2 -2
- package/src/plots/radial-bar/types.ts +10 -1
- package/src/plots/rose/adaptor.ts +2 -1
- package/src/plots/rose/types.ts +7 -1
- package/src/plots/sankey/layout.ts +1 -1
- package/src/plots/scatter/adaptor.ts +20 -2
- package/src/plots/scatter/types.ts +16 -0
- package/src/plots/scatter/util.ts +55 -2
- package/src/plots/sunburst/adaptor.ts +2 -1
- package/src/plots/sunburst/types.ts +9 -1
- package/src/plots/waterfall/adaptor.ts +20 -4
- package/src/plots/waterfall/types.ts +7 -1
- package/src/utils/hierarchy/partition.ts +1 -1
- package/CHANGELOG.md +0 -1669
package/lib/adaptor/pattern.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Params } from '../core/adaptor';
|
|
2
2
|
import { Options } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 使用 Pattern 通道的 options,要求有 colorField/seriesField/stackField 作为分类字段(进行颜色映射)
|
|
5
|
+
*/
|
|
6
|
+
type OptionsRequiredInPattern = Omit<Options, 'data'>;
|
|
3
7
|
/**
|
|
4
8
|
* Pattern 通道,处理图案填充
|
|
5
9
|
* 🚀 目前支持图表类型:饼图、柱状图、条形图、玉珏图等(不支持在多 view 图表中,后续按需扩展)
|
|
@@ -7,4 +11,5 @@ import { Options } from '../types';
|
|
|
7
11
|
* @param key key of style property
|
|
8
12
|
* @returns
|
|
9
13
|
*/
|
|
10
|
-
export declare function pattern(key: string): <O extends
|
|
14
|
+
export declare function pattern(key: string): <O extends OptionsRequiredInPattern = OptionsRequiredInPattern>(params: Params<O>) => Params<O>;
|
|
15
|
+
export {};
|
package/lib/adaptor/pattern.js
CHANGED
|
@@ -35,7 +35,7 @@ function pattern(key) {
|
|
|
35
35
|
var colorAttribute = (_b = (_a = chart.geometries) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.getAttribute('color');
|
|
36
36
|
if (colorAttribute) {
|
|
37
37
|
var colorField = colorAttribute.getFields()[0];
|
|
38
|
-
var seriesValue = util_1.get(datum, colorField);
|
|
38
|
+
var seriesValue = (0, util_1.get)(datum, colorField);
|
|
39
39
|
color = g2_1.Util.getMappingValue(colorAttribute, seriesValue, ((_c = colorAttribute.values) === null || _c === void 0 ? void 0 : _c[0]) || defaultColor);
|
|
40
40
|
}
|
|
41
41
|
var pattern = patternOption;
|
|
@@ -46,12 +46,12 @@ function pattern(key) {
|
|
|
46
46
|
// 2. 如果 pattern 不是 CanvasPattern,则进一步处理,否则直接赋予给 fill
|
|
47
47
|
if (pattern instanceof CanvasPattern === false) {
|
|
48
48
|
// 通过 createPattern(PatternStyle) 转换为 CanvasPattern
|
|
49
|
-
pattern = pattern_1.getCanvasPattern(utils_1.deepAssign({}, { cfg: { backgroundColor: color } }, pattern));
|
|
49
|
+
pattern = (0, pattern_1.getCanvasPattern)((0, utils_1.deepAssign)({}, { cfg: { backgroundColor: color } }, pattern));
|
|
50
50
|
}
|
|
51
51
|
var styleOption = options[key];
|
|
52
|
-
return tslib_1.__assign(tslib_1.__assign({}, (typeof styleOption === 'function' ? styleOption.call.apply(styleOption, tslib_1.
|
|
52
|
+
return tslib_1.__assign(tslib_1.__assign({}, (typeof styleOption === 'function' ? styleOption.call.apply(styleOption, tslib_1.__spreadArray([_this, datum], args, false)) : styleOption || {})), { fill: pattern || color });
|
|
53
53
|
};
|
|
54
|
-
return utils_1.deepAssign({}, params, { options: (_a = {}, _a[key] = style, _a) });
|
|
54
|
+
return (0, utils_1.deepAssign)({}, params, { options: (_a = {}, _a[key] = style, _a) });
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
exports.pattern = pattern;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/adaptor/pattern.ts"],"names":[],"mappings":";;;;AAAA,+BAAgC;AAChC,mCAAiC;AAGjC,kCAAsC;AACtC,4CAAoD;AAOpD;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,GAAW;IAAnC,iBA8CC;IA7CC,OAAO,UAAgE,MAAiB;;QAC9E,IAAA,OAAO,GAAY,MAAM,QAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;QAC1B,IAAS,aAAa,GAAK,OAAO,QAAZ,CAAa;QAE3C,sBAAsB;QACtB,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,MAAM,CAAC;SACf;QAED,+BAA+B;QAE/B,IAAM,KAAK,GAAc,UAAC,KAAa;;YAAE,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,6BAAc;;YAC7C,IAAA,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,qFAAqF;YACrF,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;gBACvC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,KAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;aAClD;YAED,qDAAqD;YACrD,IAAI,OAAO,YAAY,aAAa,KAAK,KAAK,EAAE;gBAC9C,mDAAmD;gBACnD,OAAO,GAAG,IAAA,0BAAgB,EAAC,IAAA,kBAAU,EAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;aAC1F;YAED,IAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAc,CAAC;YAE9C,6CACK,CAAC,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,OAAhB,WAAW,yBAAM,KAAI,EAAE,KAAK,GAAK,IAAI,UAAE,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,KACnG,IAAI,EAAE,OAAO,IAAI,KAAK,IACtB;QACJ,CAAC,CAAC;QAEF,OAAO,IAAA,kBAAU,EAAC,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,YAAI,GAAC,GAAG,IAAG,KAAK,KAAE,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AA9CD,0BA8CC","sourcesContent":["import { Util } from '@antv/g2';\nimport { get } from '@antv/util';\nimport { Params } from '../core/adaptor';\nimport { Datum, Options, StyleAttr } from '../types';\nimport { deepAssign } from '../utils';\nimport { getCanvasPattern } from '../utils/pattern';\n\n/**\n * 使用 Pattern 通道的 options,要求有 colorField/seriesField/stackField 作为分类字段(进行颜色映射)\n */\ntype OptionsRequiredInPattern = Omit<Options, 'data'>;\n\n/**\n * Pattern 通道,处理图案填充\n * 🚀 目前支持图表类型:饼图、柱状图、条形图、玉珏图等(不支持在多 view 图表中,后续按需扩展)\n *\n * @param key key of style property\n * @returns\n */\nexport function pattern(key: string) {\n return <O extends OptionsRequiredInPattern = OptionsRequiredInPattern>(params: Params<O>): Params<O> => {\n const { options, chart } = params;\n const { pattern: patternOption } = options;\n\n // 没有 pattern 配置,则直接返回\n if (!patternOption) {\n return params;\n }\n\n /** ~~~~~~~ 进行贴图图案处理 ~~~~~~~ */\n\n const style: StyleAttr = (datum?: Datum, ...args: any[]) => {\n const { defaultColor } = chart.getTheme();\n let color = defaultColor;\n\n const colorAttribute = chart.geometries?.[0]?.getAttribute('color');\n if (colorAttribute) {\n const colorField = colorAttribute.getFields()[0];\n const seriesValue = get(datum, colorField);\n color = Util.getMappingValue(colorAttribute, seriesValue, colorAttribute.values?.[0] || defaultColor);\n }\n\n let pattern: CanvasPattern = patternOption as CanvasPattern;\n\n // 1. 如果 patternOption 是一个回调,则获取回调结果。`(datum: Datum, color: string) => CanvasPattern`\n if (typeof patternOption === 'function') {\n pattern = patternOption.call(this, datum, color);\n }\n\n // 2. 如果 pattern 不是 CanvasPattern,则进一步处理,否则直接赋予给 fill\n if (pattern instanceof CanvasPattern === false) {\n // 通过 createPattern(PatternStyle) 转换为 CanvasPattern\n pattern = getCanvasPattern(deepAssign({}, { cfg: { backgroundColor: color } }, pattern));\n }\n\n const styleOption = options[key] as StyleAttr;\n\n return {\n ...(typeof styleOption === 'function' ? styleOption.call(this, datum, ...args) : styleOption || {}),\n fill: pattern || color,\n };\n };\n\n return deepAssign({}, params, { options: { [key]: style } });\n };\n}\n"]}
|
package/lib/core/adaptor.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { View } from '@antv/g2';
|
|
|
2
2
|
/**
|
|
3
3
|
* adaptor flow 的参数
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type Params<O> = {
|
|
6
6
|
readonly chart: View;
|
|
7
7
|
readonly options: O;
|
|
8
8
|
/** 一些存储一些扩展信息,用户上游 adaptor 向下游传递临时数据 */
|
|
@@ -12,4 +12,4 @@ export declare type Params<O> = {
|
|
|
12
12
|
* schema 转 G2 的适配器基类
|
|
13
13
|
* 使用 纯函数的方式,这里只是类型定义
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type Adaptor<O> = (params: Params<O>) => void;
|
package/lib/core/global.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.GLOBAL = {
|
|
|
15
15
|
* @param value
|
|
16
16
|
*/
|
|
17
17
|
function setGlobal(datum) {
|
|
18
|
-
util_1.each(datum, function (v, k) { return (exports.GLOBAL[k] = v); });
|
|
18
|
+
(0, util_1.each)(datum, function (v, k) { return (exports.GLOBAL[k] = v); });
|
|
19
19
|
}
|
|
20
20
|
exports.setGlobal = setGlobal;
|
|
21
21
|
//# sourceMappingURL=global.js.map
|
package/lib/core/global.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/core/global.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC;;GAEG;AACU,QAAA,MAAM,GAAG;IACpB,WAAW;IACX,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,SAAS,CAAC,KAA0B;IAClD,WAAI,
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/core/global.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC;;GAEG;AACU,QAAA,MAAM,GAAG;IACpB,WAAW;IACX,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;;;GAIG;AACH,SAAgB,SAAS,CAAC,KAA0B;IAClD,IAAA,WAAI,EAAC,KAAK,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,cAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAf,CAAe,CAAC,CAAC;AACzC,CAAC;AAFD,8BAEC","sourcesContent":["import { each } from '@antv/util';\n/**\n * @file 全局的一些变量定义:含国际化、主题...\n */\nexport const GLOBAL = {\n /** 全局语言 */\n locale: 'en-US',\n};\n\n/**\n * 全局变量设置\n * @param key\n * @param value\n */\nexport function setGlobal(datum: Record<string, any>): void {\n each(datum, (v, k) => (GLOBAL[k] = v));\n}\n"]}
|
package/lib/core/locale.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.registerLocale = registerLocale;
|
|
|
22
22
|
function getLocale(locale) {
|
|
23
23
|
return {
|
|
24
24
|
get: function (key, obj) {
|
|
25
|
-
return utils_1.template(util_1.get(LocaleMap[locale], key) || util_1.get(LocaleMap[global_1.GLOBAL.locale], key) || util_1.get(LocaleMap['en-US'], key) || key, obj);
|
|
25
|
+
return (0, utils_1.template)((0, util_1.get)(LocaleMap[locale], key) || (0, util_1.get)(LocaleMap[global_1.GLOBAL.locale], key) || (0, util_1.get)(LocaleMap['en-US'], key) || key, obj);
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
}
|
package/lib/core/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/core/locale.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEjC,kCAAoC;AACpC,mCAAkC;AAElC,IAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,SAAiB;IAC9D,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AAChC,CAAC;AAFD,wCAEC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,OAAO;QACL,GAAG,EAAE,UAAC,GAAsB,EAAE,GAAyB;YACrD,OAAO,gBAAQ,
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/core/locale.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEjC,kCAAoC;AACpC,mCAAkC;AAElC,IAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,SAAiB;IAC9D,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AAChC,CAAC;AAFD,wCAEC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,OAAO;QACL,GAAG,EAAE,UAAC,GAAsB,EAAE,GAAyB;YACrD,OAAO,IAAA,gBAAQ,EACb,IAAA,UAAG,EAAC,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,IAAA,UAAG,EAAC,SAAS,CAAC,eAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,IAAA,UAAG,EAAC,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,EACxG,GAAG,CACJ,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AATD,8BASC","sourcesContent":["import { get } from '@antv/util';\nimport { Locale } from '../types/locale';\nimport { template } from '../utils';\nimport { GLOBAL } from './global';\n\nconst LocaleMap = {};\n\n/**\n * register a locale\n * @param locale\n * @param localeObj\n */\nexport function registerLocale(locale: string, localeObj: Locale) {\n LocaleMap[locale] = localeObj;\n}\n\n/**\n * get locale of specific language\n * @param lang\n * @returns\n */\nexport function getLocale(locale: string) {\n return {\n get: (key: string | string[], obj?: Record<string, any>) => {\n return template(\n get(LocaleMap[locale], key) || get(LocaleMap[GLOBAL.locale], key) || get(LocaleMap['en-US'], key) || key,\n obj\n );\n },\n };\n}\n"]}
|
package/lib/core/plot.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Chart, View } from '@antv/g2';
|
|
|
3
3
|
import { Annotation, Options, StateCondition, StateName, StateObject } from '../types';
|
|
4
4
|
import { Adaptor } from './adaptor';
|
|
5
5
|
/** 单独 pick 出来的用于基类的类型定义 */
|
|
6
|
-
export
|
|
6
|
+
export type PickOptions = Pick<Options, 'width' | 'height' | 'padding' | 'appendPadding' | 'renderer' | 'pixelRatio' | 'autoFit' | 'syncViewPadding' | 'supportCSSTransform' | 'limitInPlot' | 'locale' | 'defaultInteractions'>;
|
|
7
7
|
/** plot 图表容器的配置 */
|
|
8
8
|
export declare const PLOT_CONTAINER_OPTIONS: string[];
|
|
9
9
|
/**
|
package/lib/core/plot.js
CHANGED
|
@@ -26,7 +26,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
26
26
|
function Plot(container, options) {
|
|
27
27
|
var _this = _super.call(this) || this;
|
|
28
28
|
_this.container = typeof container === 'string' ? document.getElementById(container) : container;
|
|
29
|
-
_this.options = utils_1.deepAssign({}, _this.getDefaultOptions(), options);
|
|
29
|
+
_this.options = (0, utils_1.deepAssign)({}, _this.getDefaultOptions(), options);
|
|
30
30
|
_this.createG2();
|
|
31
31
|
_this.bindEvents();
|
|
32
32
|
return _this;
|
|
@@ -60,7 +60,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
60
60
|
*/
|
|
61
61
|
Plot.prototype.createG2 = function () {
|
|
62
62
|
var _a = this.options, width = _a.width, height = _a.height, defaultInteractions = _a.defaultInteractions;
|
|
63
|
-
this.chart = new g2_1.Chart(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ container: this.container, autoFit: false }, this.getChartSize(width, height)), { localRefresh: false }), utils_1.pick(this.options, exports.PLOT_CONTAINER_OPTIONS)), { defaultInteractions: defaultInteractions }));
|
|
63
|
+
this.chart = new g2_1.Chart(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ container: this.container, autoFit: false }, this.getChartSize(width, height)), { localRefresh: false }), (0, utils_1.pick)(this.options, exports.PLOT_CONTAINER_OPTIONS)), { defaultInteractions: defaultInteractions }));
|
|
64
64
|
// 给容器增加标识,知道图表的来源区别于 G2
|
|
65
65
|
this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');
|
|
66
66
|
};
|
|
@@ -70,7 +70,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
70
70
|
* @param height
|
|
71
71
|
*/
|
|
72
72
|
Plot.prototype.getChartSize = function (width, height) {
|
|
73
|
-
var chartSize = utils_1.getContainerSize(this.container);
|
|
73
|
+
var chartSize = (0, utils_1.getContainerSize)(this.container);
|
|
74
74
|
return { width: width || chartSize.width || 400, height: height || chartSize.height || 400 };
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
@@ -129,7 +129,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
129
129
|
* @param options
|
|
130
130
|
*/
|
|
131
131
|
Plot.prototype.updateOption = function (options) {
|
|
132
|
-
this.options = utils_1.deepAssign({}, this.options, options);
|
|
132
|
+
this.options = (0, utils_1.deepAssign)({}, this.options, options);
|
|
133
133
|
};
|
|
134
134
|
/**
|
|
135
135
|
* 设置状态
|
|
@@ -139,8 +139,8 @@ var Plot = /** @class */ (function (_super) {
|
|
|
139
139
|
*/
|
|
140
140
|
Plot.prototype.setState = function (type, condition, status) {
|
|
141
141
|
if (status === void 0) { status = true; }
|
|
142
|
-
var elements = utils_1.getAllElementsRecursively(this.chart);
|
|
143
|
-
util_1.each(elements, function (ele) {
|
|
142
|
+
var elements = (0, utils_1.getAllElementsRecursively)(this.chart);
|
|
143
|
+
(0, util_1.each)(elements, function (ele) {
|
|
144
144
|
if (condition(ele.getData())) {
|
|
145
145
|
ele.setState(type, status);
|
|
146
146
|
}
|
|
@@ -150,12 +150,12 @@ var Plot = /** @class */ (function (_super) {
|
|
|
150
150
|
* 获取状态
|
|
151
151
|
*/
|
|
152
152
|
Plot.prototype.getStates = function () {
|
|
153
|
-
var elements = utils_1.getAllElementsRecursively(this.chart);
|
|
153
|
+
var elements = (0, utils_1.getAllElementsRecursively)(this.chart);
|
|
154
154
|
var stateObjects = [];
|
|
155
|
-
util_1.each(elements, function (element) {
|
|
155
|
+
(0, util_1.each)(elements, function (element) {
|
|
156
156
|
var data = element.getData();
|
|
157
157
|
var states = element.getStates();
|
|
158
|
-
util_1.each(states, function (state) {
|
|
158
|
+
(0, util_1.each)(states, function (state) {
|
|
159
159
|
stateObjects.push({ data: data, state: state, geometry: element.geometry, element: element });
|
|
160
160
|
});
|
|
161
161
|
});
|
|
@@ -185,7 +185,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
185
185
|
*/
|
|
186
186
|
Plot.prototype.addAnnotations = function (annotations, view) {
|
|
187
187
|
view = view ? view : this.chart;
|
|
188
|
-
var incoming = tslib_1.
|
|
188
|
+
var incoming = tslib_1.__spreadArray([], annotations, true);
|
|
189
189
|
var controller = view.getController('annotation');
|
|
190
190
|
var current = controller.getComponents().map(function (co) { return co.extra; });
|
|
191
191
|
controller.clear(true);
|
|
@@ -193,7 +193,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
193
193
|
var annotation = current[i];
|
|
194
194
|
var findIndex = incoming.findIndex(function (item) { return item.id && item.id === annotation.id; });
|
|
195
195
|
if (findIndex !== -1) {
|
|
196
|
-
annotation = utils_1.deepAssign({}, annotation, incoming[findIndex]);
|
|
196
|
+
annotation = (0, utils_1.deepAssign)({}, annotation, incoming[findIndex]);
|
|
197
197
|
incoming.splice(findIndex, 1);
|
|
198
198
|
}
|
|
199
199
|
controller.annotation(annotation);
|
|
@@ -266,9 +266,9 @@ var Plot = /** @class */ (function (_super) {
|
|
|
266
266
|
}
|
|
267
267
|
var _a = this.options.autoFit, autoFit = _a === void 0 ? true : _a;
|
|
268
268
|
if (autoFit) {
|
|
269
|
-
this.unbind = size_sensor_1.bind(this.container, function () {
|
|
269
|
+
this.unbind = (0, size_sensor_1.bind)(this.container, function () {
|
|
270
270
|
// 获取最新的宽高信息
|
|
271
|
-
var _a = utils_1.getContainerSize(_this.container), width = _a.width, height = _a.height;
|
|
271
|
+
var _a = (0, utils_1.getContainerSize)(_this.container), width = _a.width, height = _a.height;
|
|
272
272
|
// 主要是防止绑定的时候触发 resize 回调
|
|
273
273
|
if (width !== _this.chart.width || height !== _this.chart.height) {
|
|
274
274
|
_this.triggerResize();
|
package/lib/core/plot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/core/plot.ts"],"names":[],"mappings":";;;;AAAA,8EAAqC;AACrC,+BAAuD;A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S,EAAE;gBACjC,YAAY;gBACN,IAAA,KAAoB,wBAAgB,CAAC,KAAI,CAAC,SAAS,CAAC,EAAlD,KAAK,WAAA,EAAE,MAAM,YAAqC,CAAC;gBAE3D,yBAAyB;gBACzB,IAAI,KAAK,KAAK,KAAI,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM,KAAK,KAAI,CAAC,KAAK,CAAC,MAAM,EAAE;oBAC9D,KAAI,CAAC,aAAa,EAAE,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,+BAAgB,GAAxB;QACE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;IACH,CAAC;IACH,WAAC;AAAD,CAAC,AAzTD,CAA0D,uBAAE,GAyT3D;AAzTqB,oBAAI","sourcesContent":["import EE from '@antv/event-emitter';\nimport { Chart, Element, Event, View } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { bind } from 'size-sensor';\nimport { Annotation, Options, Size, StateCondition, StateName, StateObject } from '../types';\nimport { deepAssign, getAllElementsRecursively, getContainerSize, pick } from '../utils';\nimport { Adaptor } from './adaptor';\n\n/** 单独 pick 出来的用于基类的类型定义 */\nexport type PickOptions = Pick<\n Options,\n | 'width'\n | 'height'\n | 'padding'\n | 'appendPadding'\n | 'renderer'\n | 'pixelRatio'\n | 'autoFit'\n | 'syncViewPadding'\n | 'supportCSSTransform'\n | 'limitInPlot'\n | 'locale'\n | 'defaultInteractions'\n>;\n\nconst SOURCE_ATTRIBUTE_NAME = 'data-chart-source-type';\n\n/** plot 图表容器的配置 */\nexport const PLOT_CONTAINER_OPTIONS = [\n 'padding',\n 'appendPadding',\n 'renderer',\n 'pixelRatio',\n 'syncViewPadding',\n 'supportCSSTransform',\n 'limitInPlot',\n];\n\n/**\n * 所有 plot 的基类\n */\nexport abstract class Plot<O extends PickOptions> extends EE {\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n static getDefaultOptions(): any {\n return {\n renderer: 'canvas',\n xAxis: {\n nice: true,\n label: {\n autoRotate: false,\n autoHide: { type: 'equidistance', cfg: { minGap: 6 } },\n },\n },\n yAxis: {\n nice: true,\n label: {\n autoHide: true,\n autoRotate: false,\n },\n },\n animation: true,\n };\n }\n\n /** plot 类型名称 */\n public abstract readonly type: string;\n /** plot 的 schema 配置 */\n public options: O;\n /** plot 绘制的 dom */\n public readonly container: HTMLElement;\n /** G2 chart 实例 */\n public chart: Chart;\n /** resizer unbind */\n private unbind: () => void;\n\n constructor(container: string | HTMLElement, options: O) {\n super();\n this.container = typeof container === 'string' ? document.getElementById(container) : container;\n\n this.options = deepAssign({}, this.getDefaultOptions(), options);\n\n this.createG2();\n\n this.bindEvents();\n }\n\n /**\n * 创建 G2 实例\n */\n private createG2() {\n const { width, height, defaultInteractions } = this.options;\n\n this.chart = new Chart({\n container: this.container,\n autoFit: false, // G2Plot 使用 size-sensor 进行 autoFit\n ...this.getChartSize(width, height),\n localRefresh: false, // 默认关闭,目前 G 还有一些位置问题,难以排查!\n ...pick(this.options, PLOT_CONTAINER_OPTIONS),\n defaultInteractions,\n });\n\n // 给容器增加标识,知道图表的来源区别于 G2\n this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');\n }\n\n /**\n * 计算默认的 chart 大小。逻辑简化:如果存在 width 或 height,则直接使用,否则使用容器大小\n * @param width\n * @param height\n */\n private getChartSize(width: number, height: number): Size {\n const chartSize = getContainerSize(this.container);\n return { width: width || chartSize.width || 400, height: height || chartSize.height || 400 };\n }\n\n /**\n * 绑定代理所有 G2 的事件\n */\n private bindEvents() {\n if (this.chart) {\n this.chart.on('*', (e: Event) => {\n if (e?.type) {\n this.emit(e.type, e);\n }\n });\n }\n }\n\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n protected getDefaultOptions(): any {\n return Plot.getDefaultOptions();\n }\n\n /**\n * 每个组件有自己的 schema adaptor\n */\n protected abstract getSchemaAdaptor(): Adaptor<O>;\n\n /**\n * 绘制\n */\n public render() {\n // 暴力处理,先清空再渲染,需要 G2 层自行做好更新渲染\n this.chart.clear();\n // 因为子 view 会继承父 view 的 options 配置(包括 legend,所以会导致 legend 重复创建)\n // 所以这里给 chart 实例的 options 配置清空\n // 最好的解法是在 G2 view.clear 方法的时候,重置 options 配置。或者提供方法去 resetOptions\n // #1684 理论上在多 view 图形上,只要存在 custom legend,都存在类似问题(子弹图、双轴图)\n // @ts-ignore\n this.chart.options = {\n data: [],\n animate: true,\n };\n this.chart.views = []; // 删除已有的 views\n // 执行 adaptor\n this.execAdaptor();\n // 渲染\n this.chart.render();\n // 绑定\n this.bindSizeSensor();\n }\n\n /**\n * 更新: 更新配置且重新渲染\n * @param options\n */\n public update(options: Partial<O>) {\n this.updateOption(options);\n this.render();\n }\n\n /**\n * 更新配置\n * @param options\n */\n protected updateOption(options: Partial<O>) {\n this.options = deepAssign({}, this.options, options);\n }\n\n /**\n * 设置状态\n * @param type 状态类型,支持 'active' | 'inactive' | 'selected' 三种\n * @param conditions 条件,支持数组\n * @param status 是否激活,默认 true\n */\n public setState(type: StateName, condition: StateCondition, status: boolean = true) {\n const elements = getAllElementsRecursively(this.chart);\n\n each(elements, (ele: Element) => {\n if (condition(ele.getData())) {\n ele.setState(type, status);\n }\n });\n }\n\n /**\n * 获取状态\n */\n public getStates(): StateObject[] {\n const elements = getAllElementsRecursively(this.chart);\n\n const stateObjects: StateObject[] = [];\n each(elements, (element: Element) => {\n const data = element.getData();\n const states = element.getStates();\n each(states, (state) => {\n stateObjects.push({ data, state, geometry: element.geometry, element });\n });\n });\n\n return stateObjects;\n }\n\n /**\n * 更新数据\n * @override\n * @param options\n */\n public changeData(data: any) {\n // @ts-ignore\n this.update({ data });\n // TODO: 临时方案,最好使用下面的方式去更新数据\n // this.chart.changeData(data);\n }\n\n /**\n * 修改画布大小\n * @param width\n * @param height\n */\n public changeSize(width: number, height: number) {\n this.chart.changeSize(width, height);\n }\n\n /**\n * 增加图表标注。通过 id 标识,如果匹配到,就做更新\n */\n public addAnnotations(annotations: Annotation[], view?: View): void {\n view = view ? view : this.chart;\n const incoming = [...annotations];\n const controller = view.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n let annotation = current[i];\n\n const findIndex = incoming.findIndex((item) => item.id && item.id === annotation.id);\n if (findIndex !== -1) {\n annotation = deepAssign({}, annotation, incoming[findIndex]);\n incoming.splice(findIndex, 1);\n }\n controller.annotation(annotation);\n }\n\n incoming.forEach((annotation) => controller.annotation(annotation));\n view.render(true);\n }\n\n /**\n * 删除图表标注。通过 id 标识,如果匹配到,就做删除\n */\n public removeAnnotations(annotations: Array<{ id: string } & Partial<Annotation>>): void {\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n const annotation = current[i];\n\n if (!annotations.find((item) => item.id && item.id === annotation.id)) {\n controller.annotation(annotation);\n }\n }\n\n this.chart.render(true);\n }\n /**\n * 销毁\n */\n public destroy() {\n // 取消 size-sensor 的绑定\n this.unbindSizeSensor();\n // G2 的销毁\n this.chart.destroy();\n // 清空已经绑定的事件\n this.off();\n\n this.container.removeAttribute(SOURCE_ATTRIBUTE_NAME);\n }\n\n /**\n * 执行 adaptor 操作\n */\n protected execAdaptor() {\n const adaptor = this.getSchemaAdaptor();\n\n const { padding, appendPadding } = this.options;\n // 更新 padding\n this.chart.padding = padding;\n // 更新 appendPadding\n this.chart.appendPadding = appendPadding;\n\n // 转化成 G2 API\n adaptor({\n chart: this.chart,\n options: this.options,\n });\n }\n\n /**\n * 当图表容器大小变化的时候,执行的函数\n */\n protected triggerResize() {\n this.chart.forceFit();\n }\n\n /**\n * 绑定 dom 容器大小变化的事件\n */\n private bindSizeSensor() {\n if (this.unbind) {\n return;\n }\n\n const { autoFit = true } = this.options;\n if (autoFit) {\n this.unbind = bind(this.container, () => {\n // 获取最新的宽高信息\n const { width, height } = getContainerSize(this.container);\n\n // 主要是防止绑定的时候触发 resize 回调\n if (width !== this.chart.width || height !== this.chart.height) {\n this.triggerResize();\n }\n });\n }\n }\n\n /**\n * 取消绑定\n */\n private unbindSizeSensor() {\n if (this.unbind) {\n this.unbind();\n this.unbind = undefined;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/core/plot.ts"],"names":[],"mappings":";;;;AAAA,8EAAqC;AACrC,+BAAuD;AACvD,mCAAkC;AAClC,2CAAmC;AAEnC,kCAAyF;AAoBzF,IAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,mBAAmB;AACN,QAAA,sBAAsB,GAAG;IACpC,SAAS;IACT,eAAe;IACf,UAAU;IACV,YAAY;IACZ,iBAAiB;IACjB,qBAAqB;IACrB,aAAa;CACd,CAAC;AAEF;;GAEG;AACH;IAA0D,gCAAE;IAqC1D,cAAY,SAA+B,EAAE,OAAU;QAAvD,YACE,iBAAO,SAQR;QAPC,KAAI,CAAC,SAAS,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEhG,KAAI,CAAC,OAAO,GAAG,IAAA,kBAAU,EAAC,EAAE,EAAE,KAAI,CAAC,iBAAiB,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjE,KAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,KAAI,CAAC,UAAU,EAAE,CAAC;;IACpB,CAAC;IA7CD;;;OAGG;IACI,sBAAiB,GAAxB;QACE,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE;oBACL,UAAU,EAAE,KAAK;oBACjB,QAAQ,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,E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YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACO,4BAAa,GAAvB;QACE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACK,6BAAc,GAAtB;QAAA,iBAiBC;QAhBC,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,OAAO;SACR;QAEO,IAAA,KAAmB,IAAI,CAAC,OAAO,QAAjB,EAAd,OAAO,mBAAG,IAAI,KAAA,CAAkB;QACxC,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,MAAM,GAAG,IAAA,kBAAI,EAAC,IAAI,CAAC,SAAS,EAAE;gBACjC,YAAY;gBACN,IAAA,KAAoB,IAAA,wBAAgB,EAAC,KAAI,CAAC,SAAS,CAAC,EAAlD,KAAK,WAAA,EAAE,MAAM,YAAqC,CAAC;gBAE3D,yBAAyB;gBACzB,IAAI,KAAK,KAAK,KAAI,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM,KAAK,KAAI,CAAC,KAAK,CAAC,MAAM,EAAE;oBAC9D,KAAI,CAAC,aAAa,EAAE,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,+BAAgB,GAAxB;QACE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;IACH,CAAC;IACH,WAAC;AAAD,CAAC,AAzTD,CAA0D,uBAAE,GAyT3D;AAzTqB,oBAAI","sourcesContent":["import EE from '@antv/event-emitter';\nimport { Chart, Element, Event, View } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { bind } from 'size-sensor';\nimport { Annotation, Options, Size, StateCondition, StateName, StateObject } from '../types';\nimport { deepAssign, getAllElementsRecursively, getContainerSize, pick } from '../utils';\nimport { Adaptor } from './adaptor';\n\n/** 单独 pick 出来的用于基类的类型定义 */\nexport type PickOptions = Pick<\n Options,\n | 'width'\n | 'height'\n | 'padding'\n | 'appendPadding'\n | 'renderer'\n | 'pixelRatio'\n | 'autoFit'\n | 'syncViewPadding'\n | 'supportCSSTransform'\n | 'limitInPlot'\n | 'locale'\n | 'defaultInteractions'\n>;\n\nconst SOURCE_ATTRIBUTE_NAME = 'data-chart-source-type';\n\n/** plot 图表容器的配置 */\nexport const PLOT_CONTAINER_OPTIONS = [\n 'padding',\n 'appendPadding',\n 'renderer',\n 'pixelRatio',\n 'syncViewPadding',\n 'supportCSSTransform',\n 'limitInPlot',\n];\n\n/**\n * 所有 plot 的基类\n */\nexport abstract class Plot<O extends PickOptions> extends EE {\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n static getDefaultOptions(): any {\n return {\n renderer: 'canvas',\n xAxis: {\n nice: true,\n label: {\n autoRotate: false,\n autoHide: { type: 'equidistance', cfg: { minGap: 6 } },\n },\n },\n yAxis: {\n nice: true,\n label: {\n autoHide: true,\n autoRotate: false,\n },\n },\n animation: true,\n };\n }\n\n /** plot 类型名称 */\n public abstract readonly type: string;\n /** plot 的 schema 配置 */\n public options: O;\n /** plot 绘制的 dom */\n public readonly container: HTMLElement;\n /** G2 chart 实例 */\n public chart: Chart;\n /** resizer unbind */\n private unbind: () => void;\n\n constructor(container: string | HTMLElement, options: O) {\n super();\n this.container = typeof container === 'string' ? document.getElementById(container) : container;\n\n this.options = deepAssign({}, this.getDefaultOptions(), options);\n\n this.createG2();\n\n this.bindEvents();\n }\n\n /**\n * 创建 G2 实例\n */\n private createG2() {\n const { width, height, defaultInteractions } = this.options;\n\n this.chart = new Chart({\n container: this.container,\n autoFit: false, // G2Plot 使用 size-sensor 进行 autoFit\n ...this.getChartSize(width, height),\n localRefresh: false, // 默认关闭,目前 G 还有一些位置问题,难以排查!\n ...pick(this.options, PLOT_CONTAINER_OPTIONS),\n defaultInteractions,\n });\n\n // 给容器增加标识,知道图表的来源区别于 G2\n this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');\n }\n\n /**\n * 计算默认的 chart 大小。逻辑简化:如果存在 width 或 height,则直接使用,否则使用容器大小\n * @param width\n * @param height\n */\n private getChartSize(width: number, height: number): Size {\n const chartSize = getContainerSize(this.container);\n return { width: width || chartSize.width || 400, height: height || chartSize.height || 400 };\n }\n\n /**\n * 绑定代理所有 G2 的事件\n */\n private bindEvents() {\n if (this.chart) {\n this.chart.on('*', (e: Event) => {\n if (e?.type) {\n this.emit(e.type, e);\n }\n });\n }\n }\n\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n protected getDefaultOptions(): any {\n return Plot.getDefaultOptions();\n }\n\n /**\n * 每个组件有自己的 schema adaptor\n */\n protected abstract getSchemaAdaptor(): Adaptor<O>;\n\n /**\n * 绘制\n */\n public render() {\n // 暴力处理,先清空再渲染,需要 G2 层自行做好更新渲染\n this.chart.clear();\n // 因为子 view 会继承父 view 的 options 配置(包括 legend,所以会导致 legend 重复创建)\n // 所以这里给 chart 实例的 options 配置清空\n // 最好的解法是在 G2 view.clear 方法的时候,重置 options 配置。或者提供方法去 resetOptions\n // #1684 理论上在多 view 图形上,只要存在 custom legend,都存在类似问题(子弹图、双轴图)\n // @ts-ignore\n this.chart.options = {\n data: [],\n animate: true,\n };\n this.chart.views = []; // 删除已有的 views\n // 执行 adaptor\n this.execAdaptor();\n // 渲染\n this.chart.render();\n // 绑定\n this.bindSizeSensor();\n }\n\n /**\n * 更新: 更新配置且重新渲染\n * @param options\n */\n public update(options: Partial<O>) {\n this.updateOption(options);\n this.render();\n }\n\n /**\n * 更新配置\n * @param options\n */\n protected updateOption(options: Partial<O>) {\n this.options = deepAssign({}, this.options, options);\n }\n\n /**\n * 设置状态\n * @param type 状态类型,支持 'active' | 'inactive' | 'selected' 三种\n * @param conditions 条件,支持数组\n * @param status 是否激活,默认 true\n */\n public setState(type: StateName, condition: StateCondition, status: boolean = true) {\n const elements = getAllElementsRecursively(this.chart);\n\n each(elements, (ele: Element) => {\n if (condition(ele.getData())) {\n ele.setState(type, status);\n }\n });\n }\n\n /**\n * 获取状态\n */\n public getStates(): StateObject[] {\n const elements = getAllElementsRecursively(this.chart);\n\n const stateObjects: StateObject[] = [];\n each(elements, (element: Element) => {\n const data = element.getData();\n const states = element.getStates();\n each(states, (state) => {\n stateObjects.push({ data, state, geometry: element.geometry, element });\n });\n });\n\n return stateObjects;\n }\n\n /**\n * 更新数据\n * @override\n * @param options\n */\n public changeData(data: any) {\n // @ts-ignore\n this.update({ data });\n // TODO: 临时方案,最好使用下面的方式去更新数据\n // this.chart.changeData(data);\n }\n\n /**\n * 修改画布大小\n * @param width\n * @param height\n */\n public changeSize(width: number, height: number) {\n this.chart.changeSize(width, height);\n }\n\n /**\n * 增加图表标注。通过 id 标识,如果匹配到,就做更新\n */\n public addAnnotations(annotations: Annotation[], view?: View): void {\n view = view ? view : this.chart;\n const incoming = [...annotations];\n const controller = view.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n let annotation = current[i];\n\n const findIndex = incoming.findIndex((item) => item.id && item.id === annotation.id);\n if (findIndex !== -1) {\n annotation = deepAssign({}, annotation, incoming[findIndex]);\n incoming.splice(findIndex, 1);\n }\n controller.annotation(annotation);\n }\n\n incoming.forEach((annotation) => controller.annotation(annotation));\n view.render(true);\n }\n\n /**\n * 删除图表标注。通过 id 标识,如果匹配到,就做删除\n */\n public removeAnnotations(annotations: Array<{ id: string } & Partial<Annotation>>): void {\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n const annotation = current[i];\n\n if (!annotations.find((item) => item.id && item.id === annotation.id)) {\n controller.annotation(annotation);\n }\n }\n\n this.chart.render(true);\n }\n /**\n * 销毁\n */\n public destroy() {\n // 取消 size-sensor 的绑定\n this.unbindSizeSensor();\n // G2 的销毁\n this.chart.destroy();\n // 清空已经绑定的事件\n this.off();\n\n this.container.removeAttribute(SOURCE_ATTRIBUTE_NAME);\n }\n\n /**\n * 执行 adaptor 操作\n */\n protected execAdaptor() {\n const adaptor = this.getSchemaAdaptor();\n\n const { padding, appendPadding } = this.options;\n // 更新 padding\n this.chart.padding = padding;\n // 更新 appendPadding\n this.chart.appendPadding = appendPadding;\n\n // 转化成 G2 API\n adaptor({\n chart: this.chart,\n options: this.options,\n });\n }\n\n /**\n * 当图表容器大小变化的时候,执行的函数\n */\n protected triggerResize() {\n this.chart.forceFit();\n }\n\n /**\n * 绑定 dom 容器大小变化的事件\n */\n private bindSizeSensor() {\n if (this.unbind) {\n return;\n }\n\n const { autoFit = true } = this.options;\n if (autoFit) {\n this.unbind = bind(this.container, () => {\n // 获取最新的宽高信息\n const { width, height } = getContainerSize(this.container);\n\n // 主要是防止绑定的时候触发 resize 回调\n if (width !== this.chart.width || height !== this.chart.height) {\n this.triggerResize();\n }\n });\n }\n }\n\n /**\n * 取消绑定\n */\n private unbindSizeSensor() {\n if (this.unbind) {\n this.unbind();\n this.unbind = undefined;\n }\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.flow = exports.P = exports.WordCloud = exports.Waterfall = exports.Violin = exports.Venn = exports.Treemap = exports.TinyLine = exports.TinyColumn = exports.TinyArea = exports.Sunburst = exports.Stock = exports.Scatter = exports.Sankey = exports.Rose = exports.RingProgress = exports.RadialBar = exports.Radar = exports.Progress = exports.Pie = exports.MultiView = exports.Mix = exports.Liquid = exports.addWaterWave = exports.Line = exports.Histogram = exports.Heatmap = exports.Gauge = exports.FUNNEL_CONVERSATION_FIELD = exports.Funnel = exports.Facet = exports.DualAxes = exports.Column = exports.CirclePacking = exports.Chord = exports.Bullet = exports.Box = exports.BidirectionalBar = exports.Bar = exports.Area = exports.Lab = exports.Plot = exports.setGlobal = exports.schema = exports.polygon = exports.point = exports.line = exports.interval = exports.area = exports.version = void 0;
|
|
4
|
+
exports.adaptors = exports.registerLocale = exports.G2 = exports.getCanvasPattern = exports.measureTextWidth = void 0;
|
|
4
5
|
var tslib_1 = require("tslib");
|
|
5
|
-
exports.version = '2.4.
|
|
6
|
+
exports.version = '2.4.27';
|
|
6
7
|
// G2 自定义能力透出
|
|
7
8
|
var G2 = tslib_1.__importStar(require("@antv/g2"));
|
|
8
9
|
exports.G2 = G2;
|
|
@@ -152,7 +153,7 @@ Object.defineProperty(exports, "measureTextWidth", { enumerable: true, get: func
|
|
|
152
153
|
var pattern_1 = require("./utils/pattern");
|
|
153
154
|
Object.defineProperty(exports, "getCanvasPattern", { enumerable: true, get: function () { return pattern_1.getCanvasPattern; } });
|
|
154
155
|
/** default locale register */
|
|
155
|
-
locale_1.registerLocale('en-US', en_US_1.EN_US_LOCALE);
|
|
156
|
-
locale_1.registerLocale('zh-CN', zh_CN_1.ZH_CN_LOCALE);
|
|
156
|
+
(0, locale_1.registerLocale)('en-US', en_US_1.EN_US_LOCALE);
|
|
157
|
+
(0, locale_1.registerLocale)('zh-CN', zh_CN_1.ZH_CN_LOCALE);
|
|
157
158
|
exports.adaptors = { scale: common_1.scale, legend: common_1.legend, tooltip: common_1.tooltip, annotation: common_1.annotation, interaction: common_1.interaction, theme: common_1.theme, animation: common_1.animation };
|
|
158
159
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,mDAA+B;AA2ItB,gBAAE;AA1IX,uCAAuC;AACvC,2CAAqG;AACrG,QAAQ;AACR,wCAA+C;AAyItC,+FAzIA,uBAAc,OAyIA;AAxIvB,yCAA+C;AAC/C,yCAA+C;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AACV,SAAS;AACT,kDAAwB;AACxB,uCAAuC;AACvC,iCAAiD;AAAxC,6FAAA,IAAI,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAC/B,8BAA8B;AAC9B,2CAAmD;AAA1C,2GAAA,gBAAgB,OAAA;AAKzB,8BAA8B;AAC9B,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AACtC,uBAAc,CAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AAEzB,QAAA,QAAQ,GAAG,EAAE,KAAK,gBAAA,EAAE,MAAM,iBAAA,EAAE,OAAO,kBAAA,EAAE,UAAU,qBAAA,EAAE,WAAW,sBAAA,EAAE,KAAK,gBAAA,EAAE,SAAS,oBAAA,EAAE,CAAC","sourcesContent":["export const version = '2.4.26';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { animation, annotation, interaction, legend, scale, theme, tooltip } from './adaptor/common';\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { area, interval, line, point, polygon, schema } from './adaptor/geometries';\nexport type {\n AreaGeometryOptions,\n IntervalGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { addWaterWave, Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n// 已经废弃,更名为 Mix\nexport { Mix as Mix, Mix as MultiView } from './plots/mix';\nexport type { MixOptions, MixOptions as MultiViewOptions } from './plots/mix';\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n// 类型定义导出\nexport * from './types';\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\nexport { G2 };\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,mDAA+B;AA2ItB,gBAAE;AA1IX,uCAAuC;AACvC,2CAAqG;AACrG,QAAQ;AACR,wCAA+C;AAyItC,+FAzIA,uBAAc,OAyIA;AAxIvB,yCAA+C;AAC/C,yCAA+C;AAC/C,0CAA0C;AAC1C,mDAAoF;AAA3E,kGAAA,IAAI,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,kGAAA,IAAI,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,oGAAA,MAAM,OAAA;AAWrD,WAAW;AACX,wCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAClB,uBAAuB;AACvB,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,oDAAoD;AACpD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAEb,yDAAyD;AACzD,mCAAkC;AAAzB,0FAAA,GAAG,OAAA;AAEZ,+DAA+D;AAC/D,+DAA6D;AAApD,qHAAA,gBAAgB,OAAA;AAEzB,8FAA8F;AAC9F,mCAAkC;AAAzB,0FAAA,GAAG,OAAA;AAEZ,6DAA6D;AAC7D,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,uGAAuG;AACvG,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AAEd,6GAA6G;AAC7G,yDAAuD;AAA9C,+GAAA,aAAa,OAAA;AAEtB,uDAAuD;AACvD,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,iEAAiE;AACjE,+CAA6C;AAApC,qGAAA,QAAQ,OAAA;AAEjB,2DAA2D;AAC3D,uCAAsC;AAA7B,8FAAA,KAAK,O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C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,2DAA2D;AAC3D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AAEb,qGAAqG;AACrG,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,sDAAsD;AACtD,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAElB,uEAAuE;AACvE,iDAA+C;AAAtC,uGAAA,SAAS,OAAA;AAElB,2BAA2B;AAC3B,mEAAmE;AACnE,mCAA6B;AAApB,2FAAA,CAAC,OAAA;AACV,SAAS;AACT,kDAAwB;AACxB,uCAAuC;AACvC,iCAAiD;AAAxC,6FAAA,IAAI,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAC/B,8BAA8B;AAC9B,2CAAmD;AAA1C,2GAAA,gBAAgB,OAAA;AAKzB,8BAA8B;AAC9B,IAAA,uBAAc,EAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AACtC,IAAA,uBAAc,EAAC,OAAO,EAAE,oBAAY,CAAC,CAAC;AAEzB,QAAA,QAAQ,GAAG,EAAE,KAAK,gBAAA,EAAE,MAAM,iBAAA,EAAE,OAAO,kBAAA,EAAE,UAAU,qBAAA,EAAE,WAAW,sBAAA,EAAE,KAAK,gBAAA,EAAE,SAAS,oBAAA,EAAE,CAAC","sourcesContent":["export const version = '2.4.27';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { animation, annotation, interaction, legend, scale, theme, tooltip } from './adaptor/common';\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { area, interval, line, point, polygon, schema } from './adaptor/geometries';\nexport type {\n AreaGeometryOptions,\n IntervalGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { addWaterWave, Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n// 已经废弃,更名为 Mix\nexport { Mix as Mix, Mix as MultiView } from './plots/mix';\nexport type { MixOptions, MixOptions as MultiViewOptions } from './plots/mix';\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n// 类型定义导出\nexport * from './types';\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\nexport { G2 };\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n"]}
|
|
@@ -12,7 +12,7 @@ export declare const HIERARCHY_DATA_TRANSFORM_PARAMS = "hierarchy-data-transform
|
|
|
12
12
|
/**
|
|
13
13
|
* Hierarchy plot 节点的数据
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type HierarchyNode<N = any /** 节点 */> = {
|
|
16
16
|
/** 节点的原始数据,树型结构(todo 是否更正 key 为 origin) */
|
|
17
17
|
data: {
|
|
18
18
|
name: string;
|
|
@@ -31,7 +31,7 @@ export declare type HierarchyNode<N = any /** 节点 */> = {
|
|
|
31
31
|
parent: N;
|
|
32
32
|
children: N[];
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
type HistoryCache = {
|
|
35
35
|
name: string;
|
|
36
36
|
id: string;
|
|
37
37
|
children: Data;
|
|
@@ -55,7 +55,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
55
55
|
* 点击事件, 下钻数据,并绘制面包屑
|
|
56
56
|
*/
|
|
57
57
|
DrillDownAction.prototype.click = function () {
|
|
58
|
-
var data = util_1.get(this.context, ['event', 'data', 'data']);
|
|
58
|
+
var data = (0, util_1.get)(this.context, ['event', 'data', 'data']);
|
|
59
59
|
if (!data)
|
|
60
60
|
return false;
|
|
61
61
|
this.drill(data);
|
|
@@ -91,7 +91,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
91
91
|
* 返回上一层
|
|
92
92
|
*/
|
|
93
93
|
DrillDownAction.prototype.back = function () {
|
|
94
|
-
if (util_1.size(this.historyCache)) {
|
|
94
|
+
if ((0, util_1.size)(this.historyCache)) {
|
|
95
95
|
this.backTo(this.historyCache.slice(0, -1));
|
|
96
96
|
}
|
|
97
97
|
};
|
|
@@ -112,7 +112,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
112
112
|
*/
|
|
113
113
|
DrillDownAction.prototype.drill = function (nodeInfo) {
|
|
114
114
|
var view = this.context.view;
|
|
115
|
-
var transformData = util_1.get(view, ['interactions', 'drill-down', 'cfg', 'transformData'], function (v) { return v; });
|
|
115
|
+
var transformData = (0, util_1.get)(view, ['interactions', 'drill-down', 'cfg', 'transformData'], function (v) { return v; });
|
|
116
116
|
// 重新 update 数据
|
|
117
117
|
var drillData = transformData(tslib_1.__assign({ data: nodeInfo.data }, nodeInfo[exports.HIERARCHY_DATA_TRANSFORM_PARAMS]));
|
|
118
118
|
view.changeData(drillData);
|
|
@@ -122,7 +122,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
122
122
|
while (node) {
|
|
123
123
|
var nodeData = node.data;
|
|
124
124
|
historyCache.unshift({
|
|
125
|
-
id: nodeData.name
|
|
125
|
+
id: "".concat(nodeData.name, "_").concat(node.height, "_").concat(node.depth),
|
|
126
126
|
name: nodeData.name,
|
|
127
127
|
// children 是实际数据
|
|
128
128
|
children: transformData(tslib_1.__assign({ data: nodeData }, nodeInfo[exports.HIERARCHY_DATA_TRANSFORM_PARAMS])),
|
|
@@ -140,7 +140,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
var view = this.context.view;
|
|
143
|
-
var data = util_1.last(historyCache).children; // 处理后的数组
|
|
143
|
+
var data = (0, util_1.last)(historyCache).children; // 处理后的数组
|
|
144
144
|
view.changeData(data);
|
|
145
145
|
if (historyCache.length > 1) {
|
|
146
146
|
this.historyCache = historyCache;
|
|
@@ -157,8 +157,8 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
157
157
|
*/
|
|
158
158
|
DrillDownAction.prototype.getButtonCfg = function () {
|
|
159
159
|
var view = this.context.view;
|
|
160
|
-
var drillDownConfig = util_1.get(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);
|
|
161
|
-
return deep_assign_1.deepAssign(this.breadCrumbCfg, drillDownConfig === null || drillDownConfig === void 0 ? void 0 : drillDownConfig.breadCrumb, this.cfg);
|
|
160
|
+
var drillDownConfig = (0, util_1.get)(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);
|
|
161
|
+
return (0, deep_assign_1.deepAssign)(this.breadCrumbCfg, drillDownConfig === null || drillDownConfig === void 0 ? void 0 : drillDownConfig.breadCrumb, this.cfg);
|
|
162
162
|
};
|
|
163
163
|
/**
|
|
164
164
|
* 显示面包屑
|
|
@@ -191,8 +191,8 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
191
191
|
var textShape = _this.breadCrumbGroup.addShape({
|
|
192
192
|
type: 'text',
|
|
193
193
|
id: record.id,
|
|
194
|
-
name: exports.BREAD_CRUMB_NAME
|
|
195
|
-
attrs: tslib_1.__assign(tslib_1.__assign({ text: index === 0 && !util_1.isNil(config.rootText) ? config.rootText : record.name }, config.textStyle), { x: left, y: 0 }),
|
|
194
|
+
name: "".concat(exports.BREAD_CRUMB_NAME, "_").concat(record.name, "_text"),
|
|
195
|
+
attrs: tslib_1.__assign(tslib_1.__assign({ text: index === 0 && !(0, util_1.isNil)(config.rootText) ? config.rootText : record.name }, config.textStyle), { x: left, y: 0 }),
|
|
196
196
|
});
|
|
197
197
|
var textShapeBox = textShape.getBBox();
|
|
198
198
|
left += textShapeBox.width + PADDING;
|
|
@@ -200,7 +200,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
200
200
|
textShape.on('click', function (event) {
|
|
201
201
|
var _a;
|
|
202
202
|
var targetId = event.target.get('id');
|
|
203
|
-
if (targetId !== ((_a = util_1.last(cache)) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
203
|
+
if (targetId !== ((_a = (0, util_1.last)(cache)) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
204
204
|
var newHistoryCache = cache.slice(0, cache.findIndex(function (d) { return d.id === targetId; }) + 1);
|
|
205
205
|
_this.backTo(newHistoryCache);
|
|
206
206
|
}
|
|
@@ -209,7 +209,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
209
209
|
textShape.on('mouseenter', function (event) {
|
|
210
210
|
var _a;
|
|
211
211
|
var targetId = event.target.get('id');
|
|
212
|
-
if (targetId !== ((_a = util_1.last(cache)) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
212
|
+
if (targetId !== ((_a = (0, util_1.last)(cache)) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
213
213
|
textShape.attr(config.activeTextStyle);
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
@@ -223,7 +223,7 @@ var DrillDownAction = /** @class */ (function (_super) {
|
|
|
223
223
|
// 添加反斜杠
|
|
224
224
|
var dividerShape = _this.breadCrumbGroup.addShape({
|
|
225
225
|
type: 'text',
|
|
226
|
-
name: config.name
|
|
226
|
+
name: "".concat(config.name, "_").concat(record.name, "_divider"),
|
|
227
227
|
attrs: tslib_1.__assign(tslib_1.__assign({ text: config.dividerText }, config.textStyle), { x: left, y: 0 }),
|
|
228
228
|
});
|
|
229
229
|
var dividerBox = dividerShape.getBBox();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../../src/interactions/actions/drill-down.ts"],"names":[],"mappings":";;;;AAAA,+BAAgD;AAChD,mCAAoD;AAGpD,uDAAqD;AAErD,oBAAoB;AACpB,IAAM,OAAO,GAAG,CAAC,CAAC;AAClB,eAAe;AACf,IAAM,YAAY,GAAG,CAAC,CAAC;AACvB,iBAAiB;AACJ,QAAA,WAAW,GAAG,CAAC,CAAC;AAE7B,oCAA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I,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;SAC7B;IACH,CAAC;IAED;;;OAGG;IACI,iCAAO,GAAd;QACE,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;SAC/B;QACD,iBAAM,OAAO,WAAE,CAAC;IAClB,CAAC;IACH,sBAAC;AAAD,CAAC,AA7OD,CAAqC,WAAM,GA6O1C;AA7OY,0CAAe","sourcesContent":["import { Action, IGroup, Util } from '@antv/g2';\nimport { get, isNil, last, size } from '@antv/util';\nimport { Data } from '../../types';\nimport { DrillDownCfg } from '../../types/drill-down';\nimport { deepAssign } from '../../utils/deep-assign';\n\n// 面包屑文字和分割符'/'之间的距离\nconst PADDING = 4;\n// 面包屑位置距离树图的距离\nconst PADDING_LEFT = 0;\n// 面包屑位置距离树图的顶部距离\nexport const PADDING_TOP = 5;\n\n/** Group name of breadCrumb: 面包屑 */\nexport const BREAD_CRUMB_NAME = 'drilldown-bread-crumb';\n\n// 面包屑默认配置\nexport const DEFAULT_BREAD_CRUMB_CONFIG: DrillDownCfg['breadCrumb'] = {\n /** 位置,默认:左上角 */\n position: 'top-left',\n dividerText: '/',\n textStyle: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.65)',\n cursor: 'pointer',\n },\n activeTextStyle: {\n fill: '#87B5FF',\n },\n};\n\n/**\n * hierarchy 数据转换的参数\n */\nexport const HIERARCHY_DATA_TRANSFORM_PARAMS = 'hierarchy-data-transform-params';\n\n/**\n * Hierarchy plot 节点的数据\n */\nexport type HierarchyNode<N = any /** 节点 */> = {\n /** 节点的原始数据,树型结构(todo 是否更正 key 为 origin) */\n data: { name: string; value?: any; children: { name: string; value?: any }[] };\n /** 在构建节点数据时候,增加的扩展配置, 用于存储 transformData 的入参配置 */\n [HIERARCHY_DATA_TRANSFORM_PARAMS]: object;\n /** 当前的层级结构,每一次下钻都会更新. 不是 unique */\n depth: number;\n /** 当前所处高度,depth + height = 总的层级 */\n height: number;\n parent: N;\n children: N[];\n};\n\ntype HistoryCache = {\n name: string;\n id: string;\n children: Data;\n}[];\n\n/**\n * @description 下钻交互的 action\n * @author liuzhenying\n *\n * 适用于:hierarchy plot\n */\nexport class DrillDownAction extends Action {\n /** Action name */\n public name = 'drill-down';\n\n // 存储历史下钻数据\n protected historyCache: HistoryCache = [];\n // 面包屑 group\n private breadCrumbGroup: IGroup = null;\n // 面包屑基础配置\n private breadCrumbCfg: DrillDownCfg['breadCrumb'] = DEFAULT_BREAD_CRUMB_CONFIG;\n\n /**\n * 点击事件, 下钻数据,并绘制面包屑\n */\n public click() {\n const data = get(this.context, ['event', 'data', 'data']);\n if (!data) return false;\n\n this.drill(data);\n this.drawBreadCrumb();\n }\n\n /**\n * 重置位置,初始化及触发 chart afterchangesize 回调时使用\n */\n public resetPosition() {\n // 当在第一层级未绘制面包屑,此时 changedata 触发 resetPosition 函数,需判断 this.breadCrumbGroup 是否存在\n if (!this.breadCrumbGroup) return;\n const coordinate = this.context.view.getCoordinate();\n const breadCrumbGroup = this.breadCrumbGroup;\n const bbox = breadCrumbGroup.getBBox();\n\n const { position } = this.getButtonCfg();\n\n // @todo 后续抽取一个函数来处理,以及增加 margin 或者 padding 的设置\n // 非 polar 的,需要使用 coordinate,除却图表组件\n let point = { x: coordinate.start.x, y: coordinate.end.y - (bbox.height + PADDING_TOP * 2) };\n if (coordinate.isPolar) {\n // 默认,左上角直接出发\n point = { x: 0, y: 0 };\n }\n if (position === 'bottom-left') {\n // 涉及到坐标反转的问题\n point = { x: coordinate.start.x, y: coordinate.start.y };\n }\n /** PADDING_LEFT, PADDING_TOP 与画布边缘的距离 */\n const matrix = Util.transform(null, [['t', point.x + PADDING_LEFT, point.y + bbox.height + PADDING_TOP]]);\n breadCrumbGroup.setMatrix(matrix);\n }\n\n /**\n * 返回上一层\n */\n public back(): void {\n if (size(this.historyCache)) {\n this.backTo(this.historyCache.slice(0, -1));\n }\n }\n\n /**\n * 重置\n */\n public reset(): void {\n if (this.historyCache[0]) {\n this.backTo(this.historyCache.slice(0, 1));\n }\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n\n /**\n * 下钻数据并更新 view 显示层\n * @param nodeInfo 下钻数据\n */\n protected drill(nodeInfo: HierarchyNode) {\n const { view } = this.context;\n const transformData = get(view, ['interactions', 'drill-down', 'cfg', 'transformData'], (v) => v);\n\n // 重新 update 数据\n const drillData = transformData({ data: nodeInfo.data, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] });\n view.changeData(drillData);\n\n // 存储历史记录\n const historyCache: HistoryCache = [];\n\n let node = nodeInfo;\n while (node) {\n const nodeData = node.data;\n historyCache.unshift({\n id: `${nodeData.name}_${node.height}_${node.depth}`,\n name: nodeData.name,\n // children 是实际数据\n children: transformData({ data: nodeData, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] }),\n });\n node = node.parent;\n }\n\n this.historyCache = (this.historyCache || []).slice(0, -1).concat(historyCache);\n }\n\n /**\n * 回退事件,点击面包屑时触发\n * @param historyCache 当前要回退到的历史\n */\n protected backTo(historyCache: HistoryCache) {\n if (!historyCache || historyCache.length <= 0) {\n return;\n }\n\n const { view } = this.context;\n const data = last(historyCache).children; // 处理后的数组\n view.changeData(data);\n\n if (historyCache.length > 1) {\n this.historyCache = historyCache;\n this.drawBreadCrumb();\n } else {\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n }\n\n /**\n * 获取 mix 默认的配置和用户配置\n */\n private getButtonCfg() {\n const { view } = this.context;\n const drillDownConfig: DrillDownCfg = get(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);\n\n return deepAssign(this.breadCrumbCfg, drillDownConfig?.breadCrumb, this.cfg);\n }\n\n /**\n * 显示面包屑\n */\n private drawBreadCrumb() {\n this.drawBreadCrumbGroup();\n this.resetPosition();\n this.breadCrumbGroup.show();\n }\n\n /**\n * 绘制 Button 和 文本\n */\n private drawBreadCrumbGroup() {\n const config = this.getButtonCfg();\n const cache = this.historyCache;\n\n // 初始化面包屑 group\n if (!this.breadCrumbGroup) {\n this.breadCrumbGroup = this.context.view.foregroundGroup.addGroup({\n name: BREAD_CRUMB_NAME,\n });\n } else {\n this.breadCrumbGroup.clear();\n }\n\n // 绘制面包屑\n let left = 0;\n cache.forEach((record, index) => {\n // 添加文本\n const textShape = this.breadCrumbGroup.addShape({\n type: 'text',\n id: record.id,\n name: `${BREAD_CRUMB_NAME}_${record.name}_text`,\n attrs: {\n text: index === 0 && !isNil(config.rootText) ? config.rootText : record.name,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const textShapeBox = textShape.getBBox();\n left += textShapeBox.width + PADDING;\n\n // 增加文本事件\n textShape.on('click', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n const newHistoryCache = cache.slice(0, cache.findIndex((d) => d.id === targetId) + 1);\n this.backTo(newHistoryCache);\n }\n });\n // active 效果内置\n textShape.on('mouseenter', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n textShape.attr(config.activeTextStyle);\n } else {\n textShape.attr({ cursor: 'default' });\n }\n });\n textShape.on('mouseleave', () => {\n textShape.attr(config.textStyle);\n });\n\n if (index < cache.length - 1) {\n // 添加反斜杠\n const dividerShape = this.breadCrumbGroup.addShape({\n type: 'text',\n name: `${config.name}_${record.name}_divider`,\n attrs: {\n text: config.dividerText,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const dividerBox = dividerShape.getBBox();\n left += dividerBox.width + PADDING;\n }\n });\n }\n\n /**\n * 隐藏面包屑\n */\n private hideCrumbGroup() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.hide();\n }\n }\n\n /**\n * @override\n * destroy: 销毁资源\n */\n public destroy() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.remove();\n }\n super.destroy();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"drill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AAM,CAAC,IAAI,aAAU;oBAC7C,KAAK,sCACH,IAAI,EAAE,MAAM,CAAC,WAAW,IACrB,MAAM,CAAC,SAAS,KACnB,CAAC,EAAE,IAAI,EACP,CAAC,EAAE,CAAC,GACL;iBACF,CAAC,CAAC;gBAEH,IAAM,UAAU,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC1C,IAAI,IAAI,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC;aACpC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,wCAAc,GAAtB;QACE,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;SAC7B;IACH,CAAC;IAED;;;OAGG;IACI,iCAAO,GAAd;QACE,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;SAC/B;QACD,iBAAM,OAAO,WAAE,CAAC;IAClB,CAAC;IACH,sBAAC;AAAD,CAAC,AA7OD,CAAqC,WAAM,GA6O1C;AA7OY,0CAAe","sourcesContent":["import { Action, IGroup, Util } from '@antv/g2';\nimport { get, isNil, last, size } from '@antv/util';\nimport { Data } from '../../types';\nimport { DrillDownCfg } from '../../types/drill-down';\nimport { deepAssign } from '../../utils/deep-assign';\n\n// 面包屑文字和分割符'/'之间的距离\nconst PADDING = 4;\n// 面包屑位置距离树图的距离\nconst PADDING_LEFT = 0;\n// 面包屑位置距离树图的顶部距离\nexport const PADDING_TOP = 5;\n\n/** Group name of breadCrumb: 面包屑 */\nexport const BREAD_CRUMB_NAME = 'drilldown-bread-crumb';\n\n// 面包屑默认配置\nexport const DEFAULT_BREAD_CRUMB_CONFIG: DrillDownCfg['breadCrumb'] = {\n /** 位置,默认:左上角 */\n position: 'top-left',\n dividerText: '/',\n textStyle: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.65)',\n cursor: 'pointer',\n },\n activeTextStyle: {\n fill: '#87B5FF',\n },\n};\n\n/**\n * hierarchy 数据转换的参数\n */\nexport const HIERARCHY_DATA_TRANSFORM_PARAMS = 'hierarchy-data-transform-params';\n\n/**\n * Hierarchy plot 节点的数据\n */\nexport type HierarchyNode<N = any /** 节点 */> = {\n /** 节点的原始数据,树型结构(todo 是否更正 key 为 origin) */\n data: { name: string; value?: any; children: { name: string; value?: any }[] };\n /** 在构建节点数据时候,增加的扩展配置, 用于存储 transformData 的入参配置 */\n [HIERARCHY_DATA_TRANSFORM_PARAMS]: object;\n /** 当前的层级结构,每一次下钻都会更新. 不是 unique */\n depth: number;\n /** 当前所处高度,depth + height = 总的层级 */\n height: number;\n parent: N;\n children: N[];\n};\n\ntype HistoryCache = {\n name: string;\n id: string;\n children: Data;\n}[];\n\n/**\n * @description 下钻交互的 action\n * @author liuzhenying\n *\n * 适用于:hierarchy plot\n */\nexport class DrillDownAction extends Action {\n /** Action name */\n public name = 'drill-down';\n\n // 存储历史下钻数据\n protected historyCache: HistoryCache = [];\n // 面包屑 group\n private breadCrumbGroup: IGroup = null;\n // 面包屑基础配置\n private breadCrumbCfg: DrillDownCfg['breadCrumb'] = DEFAULT_BREAD_CRUMB_CONFIG;\n\n /**\n * 点击事件, 下钻数据,并绘制面包屑\n */\n public click() {\n const data = get(this.context, ['event', 'data', 'data']);\n if (!data) return false;\n\n this.drill(data);\n this.drawBreadCrumb();\n }\n\n /**\n * 重置位置,初始化及触发 chart afterchangesize 回调时使用\n */\n public resetPosition() {\n // 当在第一层级未绘制面包屑,此时 changedata 触发 resetPosition 函数,需判断 this.breadCrumbGroup 是否存在\n if (!this.breadCrumbGroup) return;\n const coordinate = this.context.view.getCoordinate();\n const breadCrumbGroup = this.breadCrumbGroup;\n const bbox = breadCrumbGroup.getBBox();\n\n const { position } = this.getButtonCfg();\n\n // @todo 后续抽取一个函数来处理,以及增加 margin 或者 padding 的设置\n // 非 polar 的,需要使用 coordinate,除却图表组件\n let point = { x: coordinate.start.x, y: coordinate.end.y - (bbox.height + PADDING_TOP * 2) };\n if (coordinate.isPolar) {\n // 默认,左上角直接出发\n point = { x: 0, y: 0 };\n }\n if (position === 'bottom-left') {\n // 涉及到坐标反转的问题\n point = { x: coordinate.start.x, y: coordinate.start.y };\n }\n /** PADDING_LEFT, PADDING_TOP 与画布边缘的距离 */\n const matrix = Util.transform(null, [['t', point.x + PADDING_LEFT, point.y + bbox.height + PADDING_TOP]]);\n breadCrumbGroup.setMatrix(matrix);\n }\n\n /**\n * 返回上一层\n */\n public back(): void {\n if (size(this.historyCache)) {\n this.backTo(this.historyCache.slice(0, -1));\n }\n }\n\n /**\n * 重置\n */\n public reset(): void {\n if (this.historyCache[0]) {\n this.backTo(this.historyCache.slice(0, 1));\n }\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n\n /**\n * 下钻数据并更新 view 显示层\n * @param nodeInfo 下钻数据\n */\n protected drill(nodeInfo: HierarchyNode) {\n const { view } = this.context;\n const transformData = get(view, ['interactions', 'drill-down', 'cfg', 'transformData'], (v) => v);\n\n // 重新 update 数据\n const drillData = transformData({ data: nodeInfo.data, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] });\n view.changeData(drillData);\n\n // 存储历史记录\n const historyCache: HistoryCache = [];\n\n let node = nodeInfo;\n while (node) {\n const nodeData = node.data;\n historyCache.unshift({\n id: `${nodeData.name}_${node.height}_${node.depth}`,\n name: nodeData.name,\n // children 是实际数据\n children: transformData({ data: nodeData, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] }),\n });\n node = node.parent;\n }\n\n this.historyCache = (this.historyCache || []).slice(0, -1).concat(historyCache);\n }\n\n /**\n * 回退事件,点击面包屑时触发\n * @param historyCache 当前要回退到的历史\n */\n protected backTo(historyCache: HistoryCache) {\n if (!historyCache || historyCache.length <= 0) {\n return;\n }\n\n const { view } = this.context;\n const data = last(historyCache).children; // 处理后的数组\n view.changeData(data);\n\n if (historyCache.length > 1) {\n this.historyCache = historyCache;\n this.drawBreadCrumb();\n } else {\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n }\n\n /**\n * 获取 mix 默认的配置和用户配置\n */\n private getButtonCfg() {\n const { view } = this.context;\n const drillDownConfig: DrillDownCfg = get(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);\n\n return deepAssign(this.breadCrumbCfg, drillDownConfig?.breadCrumb, this.cfg);\n }\n\n /**\n * 显示面包屑\n */\n private drawBreadCrumb() {\n this.drawBreadCrumbGroup();\n this.resetPosition();\n this.breadCrumbGroup.show();\n }\n\n /**\n * 绘制 Button 和 文本\n */\n private drawBreadCrumbGroup() {\n const config = this.getButtonCfg();\n const cache = this.historyCache;\n\n // 初始化面包屑 group\n if (!this.breadCrumbGroup) {\n this.breadCrumbGroup = this.context.view.foregroundGroup.addGroup({\n name: BREAD_CRUMB_NAME,\n });\n } else {\n this.breadCrumbGroup.clear();\n }\n\n // 绘制面包屑\n let left = 0;\n cache.forEach((record, index) => {\n // 添加文本\n const textShape = this.breadCrumbGroup.addShape({\n type: 'text',\n id: record.id,\n name: `${BREAD_CRUMB_NAME}_${record.name}_text`,\n attrs: {\n text: index === 0 && !isNil(config.rootText) ? config.rootText : record.name,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const textShapeBox = textShape.getBBox();\n left += textShapeBox.width + PADDING;\n\n // 增加文本事件\n textShape.on('click', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n const newHistoryCache = cache.slice(0, cache.findIndex((d) => d.id === targetId) + 1);\n this.backTo(newHistoryCache);\n }\n });\n // active 效果内置\n textShape.on('mouseenter', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n textShape.attr(config.activeTextStyle);\n } else {\n textShape.attr({ cursor: 'default' });\n }\n });\n textShape.on('mouseleave', () => {\n textShape.attr(config.textStyle);\n });\n\n if (index < cache.length - 1) {\n // 添加反斜杠\n const dividerShape = this.breadCrumbGroup.addShape({\n type: 'text',\n name: `${config.name}_${record.name}_divider`,\n attrs: {\n text: config.dividerText,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const dividerBox = dividerShape.getBBox();\n left += dividerBox.width + PADDING;\n }\n });\n }\n\n /**\n * 隐藏面包屑\n */\n private hideCrumbGroup() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.hide();\n }\n }\n\n /**\n * @override\n * destroy: 销毁资源\n */\n public destroy() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.remove();\n }\n super.destroy();\n }\n}\n"]}
|