@visactor/vchart 1.0.1-alpha.2 → 1.1.0-beta.0
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/build/index.js +6014 -5864
- package/build/index.min.js +2 -2
- package/cjs/chart/area/area.d.ts +1 -0
- package/cjs/chart/area/area.js +4 -1
- package/cjs/chart/area/area.js.map +1 -1
- package/cjs/chart/bar/bar.d.ts +1 -0
- package/cjs/chart/bar/bar.js +4 -1
- package/cjs/chart/bar/bar.js.map +1 -1
- package/cjs/chart/base-chart.js +2 -1
- package/cjs/chart/base-chart.js.map +1 -1
- package/cjs/chart/box-plot/box-plot.js +2 -2
- package/cjs/chart/box-plot/box-plot.js.map +1 -1
- package/cjs/chart/histogram/histogram.d.ts +1 -0
- package/cjs/chart/histogram/histogram.js +4 -1
- package/cjs/chart/histogram/histogram.js.map +1 -1
- package/cjs/chart/line/line.d.ts +1 -0
- package/cjs/chart/line/line.js +4 -1
- package/cjs/chart/line/line.js.map +1 -1
- package/cjs/chart/range-area/range-area.d.ts +1 -0
- package/cjs/chart/range-area/range-area.js +4 -1
- package/cjs/chart/range-area/range-area.js.map +1 -1
- package/cjs/chart/range-column/range-column.d.ts +1 -0
- package/cjs/chart/range-column/range-column.js +4 -1
- package/cjs/chart/range-column/range-column.js.map +1 -1
- package/cjs/chart/sequence/sequence.js +1 -1
- package/cjs/chart/sequence/sequence.js.map +1 -1
- package/cjs/chart/util.d.ts +2 -0
- package/cjs/chart/util.js +23 -0
- package/cjs/chart/util.js.map +1 -0
- package/cjs/chart/waterfall/waterfall.js +2 -2
- package/cjs/chart/waterfall/waterfall.js.map +1 -1
- package/cjs/compile/grammar-item.js +2 -1
- package/cjs/component/axis/cartesian/axis.js +1 -1
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/crosshair/base.js +1 -2
- package/cjs/component/crosshair/base.js.map +1 -1
- package/cjs/component/crosshair/interface/spec.d.ts +1 -1
- package/cjs/component/crosshair/interface/spec.js.map +1 -1
- package/cjs/component/custom-mark/custom-mark.js.map +1 -1
- package/cjs/component/index.js +1 -2
- package/cjs/component/legend/base-legend.js +7 -3
- package/cjs/component/legend/base-legend.js.map +1 -1
- package/cjs/component/legend/util.d.ts +1 -1
- package/cjs/component/player/utils/transform.js +1 -3
- package/cjs/component/player/utils/transform.js.map +1 -1
- package/cjs/component/tooltip/handler/base.d.ts +5 -4
- package/cjs/component/tooltip/handler/base.js +44 -34
- package/cjs/component/tooltip/handler/base.js.map +1 -1
- package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.d.ts +2 -2
- package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
- package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/constants.d.ts +4 -0
- package/cjs/component/tooltip/handler/constants.js +5 -2
- package/cjs/component/tooltip/handler/constants.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.d.ts +6 -2
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +20 -13
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/interface.d.ts +16 -5
- package/cjs/component/tooltip/handler/dom/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/base-tooltip-model.d.ts +7 -13
- package/cjs/component/tooltip/handler/dom/model/base-tooltip-model.js +12 -27
- package/cjs/component/tooltip/handler/dom/model/base-tooltip-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/content-column-model.d.ts +13 -3
- package/cjs/component/tooltip/handler/dom/model/content-column-model.js +46 -26
- package/cjs/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/content-model.d.ts +4 -3
- package/cjs/component/tooltip/handler/dom/model/content-model.js +4 -4
- package/cjs/component/tooltip/handler/dom/model/content-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/interface.d.ts +4 -0
- package/cjs/component/tooltip/handler/dom/model/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/shape-model.d.ts +5 -5
- package/cjs/component/tooltip/handler/dom/model/shape-model.js +4 -4
- package/cjs/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/style-constants.d.ts +4 -4
- package/cjs/component/tooltip/handler/dom/model/style-constants.js +16 -18
- package/cjs/component/tooltip/handler/dom/model/style-constants.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/text-model.js +1 -0
- package/cjs/component/tooltip/handler/dom/model/text-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/title-model.d.ts +3 -2
- package/cjs/component/tooltip/handler/dom/model/title-model.js +15 -19
- package/cjs/component/tooltip/handler/dom/model/title-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/tooltip-model.d.ts +1 -2
- package/cjs/component/tooltip/handler/dom/model/tooltip-model.js +21 -16
- package/cjs/component/tooltip/handler/dom/model/tooltip-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/util.d.ts +5 -0
- package/cjs/component/tooltip/handler/dom/{utils/style.js → util.js} +32 -20
- package/cjs/component/tooltip/handler/dom/util.js.map +1 -0
- package/cjs/component/tooltip/handler/interface/index.d.ts +0 -1
- package/cjs/component/tooltip/handler/interface/index.js +1 -1
- package/cjs/component/tooltip/handler/interface/index.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/attribute.js +12 -8
- package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/common.d.ts +6 -2
- package/cjs/component/tooltip/handler/utils/common.js +30 -5
- package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/compose.d.ts +3 -2
- package/cjs/component/tooltip/handler/utils/compose.js +56 -45
- package/cjs/component/tooltip/handler/utils/compose.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/get-spec.js +64 -28
- package/cjs/component/tooltip/handler/utils/get-spec.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/style.d.ts +2 -1
- package/cjs/component/tooltip/handler/utils/style.js +4 -4
- package/cjs/component/tooltip/handler/utils/style.js.map +1 -1
- package/cjs/component/tooltip/tooltip.d.ts +3 -1
- package/cjs/component/tooltip/tooltip.js +33 -18
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/component/tooltip/utils/common.js +4 -2
- package/cjs/component/tooltip/utils/common.js.map +1 -1
- package/cjs/constant/marker.js +2 -1
- package/cjs/core/factory.js +1 -2
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/instance-manager.d.ts +1 -1
- package/cjs/core/instance-manager.js.map +1 -1
- package/cjs/core/vchart.d.ts +1 -0
- package/cjs/core/vchart.js +10 -2
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/interaction/interface.js +1 -1
- package/cjs/interaction/trigger.js +1 -1
- package/cjs/layout/base-layout.js +9 -10
- package/cjs/layout/base-layout.js.map +1 -1
- package/cjs/layout/grid-layout/grid-layout.d.ts +5 -35
- package/cjs/layout/grid-layout/grid-layout.js +2 -1
- package/cjs/layout/grid-layout/grid-layout.js.map +1 -1
- package/cjs/layout/index.d.ts +1 -2
- package/cjs/layout/index.js.map +1 -1
- package/cjs/layout/interface.d.ts +31 -3
- package/cjs/layout/interface.js.map +1 -1
- package/cjs/mark/arc-3d.js +1 -1
- package/cjs/mark/arc.d.ts +5 -4
- package/cjs/mark/arc.js +11 -13
- package/cjs/mark/arc.js.map +1 -1
- package/cjs/mark/area.js +1 -1
- package/cjs/mark/base/base-line.js +3 -3
- package/cjs/mark/base/base-line.js.map +1 -1
- package/cjs/mark/base/base-mark.d.ts +7 -0
- package/cjs/mark/base/base-mark.js +10 -6
- package/cjs/mark/base/base-mark.js.map +1 -1
- package/cjs/mark/box-plot.js +1 -1
- package/cjs/mark/cell.js +1 -1
- package/cjs/mark/utils/common.d.ts +0 -12
- package/cjs/mark/utils/common.js +2 -13
- package/cjs/mark/utils/common.js.map +1 -1
- package/cjs/model/base-model.js +1 -1
- package/cjs/model/interface.js +1 -1
- package/cjs/model/layout-item.js +2 -1
- package/cjs/model/model-state-manager.js +1 -1
- package/cjs/model/tooltip-helper.d.ts +3 -4
- package/cjs/model/tooltip-helper.js +5 -10
- package/cjs/model/tooltip-helper.js.map +1 -1
- package/cjs/plugin/interface.js +1 -1
- package/cjs/region/interface.js +1 -1
- package/cjs/region/region.js +6 -11
- package/cjs/region/region.js.map +1 -1
- package/cjs/series/base/base-series.js +1 -1
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/base/tooltip-helper.d.ts +9 -8
- package/cjs/series/base/tooltip-helper.js +23 -12
- package/cjs/series/base/tooltip-helper.js.map +1 -1
- package/cjs/series/dot/dot.js +2 -2
- package/cjs/series/dot/dot.js.map +1 -1
- package/cjs/series/dot/tooltip-helper.d.ts +1 -2
- package/cjs/series/dot/tooltip-helper.js +6 -5
- package/cjs/series/dot/tooltip-helper.js.map +1 -1
- package/cjs/series/funnel/funnel.d.ts +1 -1
- package/cjs/series/funnel/funnel.js +8 -8
- package/cjs/series/funnel/funnel.js.map +1 -1
- package/cjs/series/funnel/tooltip-helper.d.ts +5 -3
- package/cjs/series/funnel/tooltip-helper.js +10 -8
- package/cjs/series/funnel/tooltip-helper.js.map +1 -1
- package/cjs/series/interface/series.d.ts +2 -1
- package/cjs/series/interface/series.js.map +1 -1
- package/cjs/series/interface/tooltip-helper.d.ts +6 -6
- package/cjs/series/interface/tooltip-helper.js.map +1 -1
- package/cjs/series/link/link.js +2 -2
- package/cjs/series/link/link.js.map +1 -1
- package/cjs/series/treemap/treemap.js.map +1 -1
- package/cjs/series/word-cloud/base.js +2 -2
- package/cjs/series/word-cloud/base.js.map +1 -1
- package/cjs/series/word-cloud/word-cloud-3d.js +3 -3
- package/cjs/series/word-cloud/word-cloud-3d.js.map +1 -1
- package/cjs/theme/buildin-theme/index.d.ts +0 -1
- package/cjs/theme/buildin-theme/index.js +3 -3
- package/cjs/theme/buildin-theme/index.js.map +1 -1
- package/cjs/theme/buildin-theme/light/component/crosshair.js +4 -4
- package/cjs/theme/buildin-theme/light/component/crosshair.js.map +1 -1
- package/cjs/theme/buildin-theme/light/component/tooltip.js +1 -0
- package/cjs/theme/buildin-theme/light/component/tooltip.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +1 -1
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/typings/tooltip/common.d.ts +7 -1
- package/cjs/typings/tooltip/common.js.map +1 -1
- package/cjs/typings/tooltip/handler.d.ts +1 -1
- package/cjs/typings/tooltip/handler.js.map +1 -1
- package/cjs/typings/tooltip/line.d.ts +6 -4
- package/cjs/typings/tooltip/line.js.map +1 -1
- package/cjs/typings/tooltip/shape.d.ts +3 -3
- package/cjs/typings/tooltip/shape.js.map +1 -1
- package/cjs/typings/tooltip/tooltip.d.ts +11 -8
- package/cjs/typings/tooltip/tooltip.js.map +1 -1
- package/cjs/typings/visual.d.ts +4 -11
- package/cjs/typings/visual.js.map +1 -1
- package/cjs/util/debug.d.ts +3 -3
- package/cjs/util/debug.js +11 -20
- package/cjs/util/debug.js.map +1 -1
- package/cjs/util/index.d.ts +1 -0
- package/cjs/util/index.js +2 -1
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/style.js +3 -7
- package/cjs/util/style.js.map +1 -1
- package/esm/chart/area/area.d.ts +1 -0
- package/esm/chart/area/area.js +5 -0
- package/esm/chart/area/area.js.map +1 -1
- package/esm/chart/bar/bar.d.ts +1 -0
- package/esm/chart/bar/bar.js +5 -0
- package/esm/chart/bar/bar.js.map +1 -1
- package/esm/chart/base-chart.js +2 -1
- package/esm/chart/base-chart.js.map +1 -1
- package/esm/chart/box-plot/box-plot.js +3 -1
- package/esm/chart/box-plot/box-plot.js.map +1 -1
- package/esm/chart/histogram/histogram.d.ts +1 -0
- package/esm/chart/histogram/histogram.js +5 -0
- package/esm/chart/histogram/histogram.js.map +1 -1
- package/esm/chart/line/line.d.ts +1 -0
- package/esm/chart/line/line.js +5 -0
- package/esm/chart/line/line.js.map +1 -1
- package/esm/chart/range-area/range-area.d.ts +1 -0
- package/esm/chart/range-area/range-area.js +5 -0
- package/esm/chart/range-area/range-area.js.map +1 -1
- package/esm/chart/range-column/range-column.d.ts +1 -0
- package/esm/chart/range-column/range-column.js +5 -0
- package/esm/chart/range-column/range-column.js.map +1 -1
- package/esm/chart/sequence/sequence.js +2 -2
- package/esm/chart/sequence/sequence.js.map +1 -1
- package/esm/chart/util.d.ts +2 -0
- package/esm/chart/util.js +16 -0
- package/esm/chart/util.js.map +1 -0
- package/esm/chart/waterfall/waterfall.js +3 -1
- package/esm/chart/waterfall/waterfall.js.map +1 -1
- package/esm/compile/grammar-item.js +2 -1
- package/esm/component/axis/cartesian/axis.js +2 -2
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/crosshair/base.js +1 -2
- package/esm/component/crosshair/base.js.map +1 -1
- package/esm/component/crosshair/interface/spec.d.ts +1 -1
- package/esm/component/crosshair/interface/spec.js.map +1 -1
- package/esm/component/custom-mark/custom-mark.js.map +1 -1
- package/esm/component/index.js +1 -2
- package/esm/component/legend/base-legend.js +7 -3
- package/esm/component/legend/base-legend.js.map +1 -1
- package/esm/component/legend/util.d.ts +1 -1
- package/esm/component/player/utils/transform.js +1 -3
- package/esm/component/player/utils/transform.js.map +1 -1
- package/esm/component/tooltip/handler/base.d.ts +5 -4
- package/esm/component/tooltip/handler/base.js +45 -35
- package/esm/component/tooltip/handler/base.js.map +1 -1
- package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.d.ts +2 -2
- package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -3
- package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/constants.d.ts +4 -0
- package/esm/component/tooltip/handler/constants.js +9 -0
- package/esm/component/tooltip/handler/constants.js.map +1 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.d.ts +6 -2
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +20 -12
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/dom/interface.d.ts +16 -5
- package/esm/component/tooltip/handler/dom/interface.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/base-tooltip-model.d.ts +7 -13
- package/esm/component/tooltip/handler/dom/model/base-tooltip-model.js +11 -29
- package/esm/component/tooltip/handler/dom/model/base-tooltip-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/content-column-model.d.ts +13 -3
- package/esm/component/tooltip/handler/dom/model/content-column-model.js +46 -24
- package/esm/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/content-model.d.ts +4 -3
- package/esm/component/tooltip/handler/dom/model/content-model.js +5 -5
- package/esm/component/tooltip/handler/dom/model/content-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/interface.d.ts +4 -0
- package/esm/component/tooltip/handler/dom/model/interface.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/shape-model.d.ts +5 -5
- package/esm/component/tooltip/handler/dom/model/shape-model.js +4 -4
- package/esm/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/style-constants.d.ts +4 -4
- package/esm/component/tooltip/handler/dom/model/style-constants.js +18 -20
- package/esm/component/tooltip/handler/dom/model/style-constants.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/text-model.js +1 -0
- package/esm/component/tooltip/handler/dom/model/text-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/title-model.d.ts +3 -2
- package/esm/component/tooltip/handler/dom/model/title-model.js +15 -19
- package/esm/component/tooltip/handler/dom/model/title-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/tooltip-model.d.ts +1 -2
- package/esm/component/tooltip/handler/dom/model/tooltip-model.js +22 -16
- package/esm/component/tooltip/handler/dom/model/tooltip-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/util.d.ts +5 -0
- package/esm/component/tooltip/handler/dom/util.js +71 -0
- package/esm/component/tooltip/handler/dom/util.js.map +1 -0
- package/esm/component/tooltip/handler/interface/index.d.ts +0 -1
- package/esm/component/tooltip/handler/interface/index.js +0 -2
- package/esm/component/tooltip/handler/interface/index.js.map +1 -1
- package/esm/component/tooltip/handler/utils/attribute.js +11 -7
- package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/esm/component/tooltip/handler/utils/common.d.ts +6 -2
- package/esm/component/tooltip/handler/utils/common.js +25 -2
- package/esm/component/tooltip/handler/utils/common.js.map +1 -1
- package/esm/component/tooltip/handler/utils/compose.d.ts +3 -2
- package/esm/component/tooltip/handler/utils/compose.js +52 -43
- package/esm/component/tooltip/handler/utils/compose.js.map +1 -1
- package/esm/component/tooltip/handler/utils/get-spec.js +60 -23
- package/esm/component/tooltip/handler/utils/get-spec.js.map +1 -1
- package/esm/component/tooltip/handler/utils/style.d.ts +2 -1
- package/esm/component/tooltip/handler/utils/style.js +4 -4
- package/esm/component/tooltip/handler/utils/style.js.map +1 -1
- package/esm/component/tooltip/tooltip.d.ts +3 -1
- package/esm/component/tooltip/tooltip.js +33 -18
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/component/tooltip/utils/common.js +4 -2
- package/esm/component/tooltip/utils/common.js.map +1 -1
- package/esm/constant/marker.js +2 -1
- package/esm/core/factory.js +1 -2
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/instance-manager.d.ts +1 -1
- package/esm/core/instance-manager.js.map +1 -1
- package/esm/core/vchart.d.ts +1 -0
- package/esm/core/vchart.js +9 -2
- package/esm/core/vchart.js.map +1 -1
- package/esm/interaction/interface.js +1 -1
- package/esm/interaction/trigger.js +1 -1
- package/esm/layout/base-layout.js +9 -10
- package/esm/layout/base-layout.js.map +1 -1
- package/esm/layout/grid-layout/grid-layout.d.ts +5 -35
- package/esm/layout/grid-layout/grid-layout.js +2 -1
- package/esm/layout/grid-layout/grid-layout.js.map +1 -1
- package/esm/layout/index.d.ts +1 -2
- package/esm/layout/index.js.map +1 -1
- package/esm/layout/interface.d.ts +31 -3
- package/esm/layout/interface.js.map +1 -1
- package/esm/mark/arc-3d.js +1 -1
- package/esm/mark/arc.d.ts +5 -4
- package/esm/mark/arc.js +11 -13
- package/esm/mark/arc.js.map +1 -1
- package/esm/mark/area.js +1 -1
- package/esm/mark/base/base-line.js +2 -4
- package/esm/mark/base/base-line.js.map +1 -1
- package/esm/mark/base/base-mark.d.ts +7 -0
- package/esm/mark/base/base-mark.js +9 -7
- package/esm/mark/base/base-mark.js.map +1 -1
- package/esm/mark/box-plot.js +1 -1
- package/esm/mark/cell.js +1 -1
- package/esm/mark/utils/common.d.ts +0 -12
- package/esm/mark/utils/common.js +0 -13
- package/esm/mark/utils/common.js.map +1 -1
- package/esm/model/base-model.js +1 -1
- package/esm/model/interface.js +1 -1
- package/esm/model/layout-item.js +2 -1
- package/esm/model/model-state-manager.js +1 -1
- package/esm/model/tooltip-helper.d.ts +3 -4
- package/esm/model/tooltip-helper.js +5 -10
- package/esm/model/tooltip-helper.js.map +1 -1
- package/esm/plugin/interface.js +1 -1
- package/esm/region/interface.js +1 -1
- package/esm/region/region.js +7 -11
- package/esm/region/region.js.map +1 -1
- package/esm/series/base/base-series.js +1 -1
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/base/tooltip-helper.d.ts +9 -8
- package/esm/series/base/tooltip-helper.js +23 -12
- package/esm/series/base/tooltip-helper.js.map +1 -1
- package/esm/series/dot/dot.js +1 -3
- package/esm/series/dot/dot.js.map +1 -1
- package/esm/series/dot/tooltip-helper.d.ts +1 -2
- package/esm/series/dot/tooltip-helper.js +7 -4
- package/esm/series/dot/tooltip-helper.js.map +1 -1
- package/esm/series/funnel/funnel.d.ts +1 -1
- package/esm/series/funnel/funnel.js +8 -8
- package/esm/series/funnel/funnel.js.map +1 -1
- package/esm/series/funnel/tooltip-helper.d.ts +5 -3
- package/esm/series/funnel/tooltip-helper.js +11 -7
- package/esm/series/funnel/tooltip-helper.js.map +1 -1
- package/esm/series/interface/series.d.ts +2 -1
- package/esm/series/interface/series.js.map +1 -1
- package/esm/series/interface/tooltip-helper.d.ts +6 -6
- package/esm/series/interface/tooltip-helper.js.map +1 -1
- package/esm/series/link/link.js +1 -3
- package/esm/series/link/link.js.map +1 -1
- package/esm/series/treemap/treemap.js.map +1 -1
- package/esm/series/word-cloud/base.js +3 -3
- package/esm/series/word-cloud/base.js.map +1 -1
- package/esm/series/word-cloud/word-cloud-3d.js +2 -4
- package/esm/series/word-cloud/word-cloud-3d.js.map +1 -1
- package/esm/theme/buildin-theme/index.d.ts +0 -1
- package/esm/theme/buildin-theme/index.js +1 -5
- package/esm/theme/buildin-theme/index.js.map +1 -1
- package/esm/theme/buildin-theme/light/component/crosshair.js +4 -4
- package/esm/theme/buildin-theme/light/component/crosshair.js.map +1 -1
- package/esm/theme/buildin-theme/light/component/tooltip.js +1 -0
- package/esm/theme/buildin-theme/light/component/tooltip.js.map +1 -1
- package/esm/typings/spec/common.d.ts +1 -1
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/typings/tooltip/common.d.ts +7 -1
- package/esm/typings/tooltip/common.js.map +1 -1
- package/esm/typings/tooltip/handler.d.ts +1 -1
- package/esm/typings/tooltip/handler.js.map +1 -1
- package/esm/typings/tooltip/line.d.ts +6 -4
- package/esm/typings/tooltip/line.js.map +1 -1
- package/esm/typings/tooltip/shape.d.ts +3 -3
- package/esm/typings/tooltip/shape.js.map +1 -1
- package/esm/typings/tooltip/tooltip.d.ts +11 -8
- package/esm/typings/tooltip/tooltip.js.map +1 -1
- package/esm/typings/visual.d.ts +4 -11
- package/esm/typings/visual.js.map +1 -1
- package/esm/util/debug.d.ts +3 -3
- package/esm/util/debug.js +11 -14
- package/esm/util/debug.js.map +1 -1
- package/esm/util/index.d.ts +1 -0
- package/esm/util/index.js +2 -0
- package/esm/util/index.js.map +1 -1
- package/esm/util/style.js +3 -8
- package/esm/util/style.js.map +1 -1
- package/package.json +35 -39
- package/cjs/component/tooltip/handler/dom/utils/style.d.ts +0 -3
- package/cjs/component/tooltip/handler/dom/utils/style.js.map +0 -1
- package/cjs/component/tooltip/handler/interface/cache.d.ts +0 -28
- package/cjs/component/tooltip/handler/interface/cache.js +0 -6
- package/cjs/component/tooltip/handler/interface/cache.js.map +0 -1
- package/cjs/theme/buildin-theme/dark.d.ts +0 -2
- package/cjs/theme/buildin-theme/dark.js +0 -16
- package/cjs/theme/buildin-theme/dark.js.map +0 -1
- package/esm/component/tooltip/handler/dom/utils/style.d.ts +0 -3
- package/esm/component/tooltip/handler/dom/utils/style.js +0 -59
- package/esm/component/tooltip/handler/dom/utils/style.js.map +0 -1
- package/esm/component/tooltip/handler/interface/cache.d.ts +0 -28
- package/esm/component/tooltip/handler/interface/cache.js +0 -2
- package/esm/component/tooltip/handler/interface/cache.js.map +0 -1
- package/esm/theme/buildin-theme/dark.d.ts +0 -2
- package/esm/theme/buildin-theme/dark.js +0 -12
- package/esm/theme/buildin-theme/dark.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Maybe } from '@visactor/vutils';
|
|
2
|
+
import type { ITooltipStyle } from '../interface';
|
|
3
|
+
import type { IDomTooltipStyle } from './interface';
|
|
4
|
+
import type { TooltipAttributes } from '@visactor/vrender-components';
|
|
5
|
+
export declare function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isValid, merge, isArray } from "../../../../util";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0, getPixelPropertyStr = (num, defaultStr) => isValid(num) ? isArray(num) ? num.map((n => `${n}px`)).join(" ") : `${num}px` : null != defaultStr ? defaultStr : "initial";
|
|
4
|
+
|
|
5
|
+
export function getDomStyles(style, attributeCache) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
|
+
const {panel: {fill: fillColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth}, padding: padding, key: key, value: value, title: title, shape: shape, maxWidth: maxWidth, minWidth: minWidth, enterable: enterable, spaceRow: spaceRow, transitionDuration: transitionDuration} = style, backgroundColor = fillColor, styles = {
|
|
8
|
+
panel: {
|
|
9
|
+
width: getPixelPropertyStr(null === (_a = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _a ? void 0 : _a.width),
|
|
10
|
+
height: getPixelPropertyStr(null === (_b = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _b ? void 0 : _b.height),
|
|
11
|
+
paddingBottom: getPixelPropertyStr(padding.bottom),
|
|
12
|
+
paddingLeft: getPixelPropertyStr(padding.left),
|
|
13
|
+
paddingRight: getPixelPropertyStr(padding.right),
|
|
14
|
+
paddingTop: getPixelPropertyStr(padding.top),
|
|
15
|
+
borderColor: strokeColor,
|
|
16
|
+
borderWidth: getPixelPropertyStr(lineWidth),
|
|
17
|
+
borderRadius: getPixelPropertyStr(cornerRadius),
|
|
18
|
+
backgroundColor: backgroundColor ? `${backgroundColor}` : "transparent",
|
|
19
|
+
boxShadow: shadow ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}` : "initial",
|
|
20
|
+
maxWidth: getPixelPropertyStr(maxWidth),
|
|
21
|
+
minWidth: getPixelPropertyStr(minWidth),
|
|
22
|
+
pointerEvents: enterable ? "auto" : "none",
|
|
23
|
+
transitionDuration: transitionDuration ? `${transitionDuration}ms` : "initial",
|
|
24
|
+
transitionProperty: transitionDuration ? "transform" : "initial",
|
|
25
|
+
transitionTimingFunction: transitionDuration ? "ease-out" : "initial"
|
|
26
|
+
},
|
|
27
|
+
title: getLabelStyle(title),
|
|
28
|
+
content: {},
|
|
29
|
+
shapeColumn: {
|
|
30
|
+
item: getShapeStyle(shape),
|
|
31
|
+
width: getPixelPropertyStr(shape.size),
|
|
32
|
+
marginRight: getPixelPropertyStr(null !== (_c = shape.spacing) && void 0 !== _c ? _c : 8)
|
|
33
|
+
},
|
|
34
|
+
keyColumn: {
|
|
35
|
+
item: getLabelStyle(key),
|
|
36
|
+
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.keyWidth),
|
|
37
|
+
marginRight: getPixelPropertyStr(null !== (_d = key.spacing) && void 0 !== _d ? _d : 26)
|
|
38
|
+
},
|
|
39
|
+
valueColumn: {
|
|
40
|
+
item: getLabelStyle(value),
|
|
41
|
+
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.valueWidth),
|
|
42
|
+
marginRight: getPixelPropertyStr(null !== (_e = value.spacing) && void 0 !== _e ? _e : 0)
|
|
43
|
+
},
|
|
44
|
+
spaceRow: getPixelPropertyStr(spaceRow)
|
|
45
|
+
};
|
|
46
|
+
if (isValid(spaceRow)) {
|
|
47
|
+
const gapUnit = spaceRow / 2;
|
|
48
|
+
[ styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
|
|
49
|
+
obj.marginTop = getPixelPropertyStr(gapUnit), obj.marginBottom = obj.marginTop;
|
|
50
|
+
})), styles.content.marginTop = getPixelPropertyStr(-gapUnit), styles.content.marginBottom = styles.content.marginTop;
|
|
51
|
+
} else [ styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
|
|
52
|
+
obj.marginTop = "initial", obj.marginBottom = "initial";
|
|
53
|
+
}));
|
|
54
|
+
return styles;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getLabelStyle(labelStyle, defaultStyle) {
|
|
58
|
+
if (!labelStyle) return;
|
|
59
|
+
const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight} = merge({}, defaultStyle, labelStyle), styleObj = {};
|
|
60
|
+
return styleObj.fontFamily = labelFont, styleObj.fontSize = getPixelPropertyStr(labelFontSize),
|
|
61
|
+
styleObj.color = labelColor, styleObj.textAlign = textAlign, styleObj.lineHeight = getPixelPropertyStr(lineHeight),
|
|
62
|
+
styleObj.fontWeight = fontWeight, styleObj;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getShapeStyle(shapeStyle, defaultStyle) {
|
|
66
|
+
if (!shapeStyle) return;
|
|
67
|
+
const {size: size} = merge({}, defaultStyle, shapeStyle), styleObj = {};
|
|
68
|
+
return styleObj.width = getPixelPropertyStr(size), styleObj.height = styleObj.width,
|
|
69
|
+
styleObj;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAC3E,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,GAAG,IAAI,CAAC;KACnB;IACD,OAAO,UAAU,aAAV,UAAU,c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SAAS,CAAC;IAChC,QAAQ,CAAC,QAAQ,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,GAAG,UAAoB,CAAC;IACtC,QAAQ,CAAC,SAAS,GAAG,SAAsB,CAAC;IAC5C,QAAQ,CAAC,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,GAAG,UAAwB,CAAC;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CACpB,UAAmC,EACnC,YAA8C;IAE9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"util.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport type { FontWeight, TextAlign } from '../../../../typings';\nimport { isValid, merge, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, IMargin, IShapeStyle, IDomTooltipStyle } from './interface';\nimport type { TooltipAttributes } from '@visactor/vrender-components';\n\nconst DEFAULT_SHAPE_SPACING = 8;\nconst DEFAULT_KEY_SPACING = 26;\nconst DEFAULT_VALUE_SPACING = 0;\n\nconst getPixelPropertyStr = (num?: number | number[], defaultStr?: string) => {\n if (isValid(num)) {\n if (isArray(num)) {\n return num.map(n => `${n}px`).join(' ');\n }\n return `${num}px`;\n }\n return defaultStr ?? 'initial';\n};\n\nexport function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel: {\n fill: fillColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth\n },\n padding,\n key,\n value,\n title,\n shape,\n maxWidth,\n minWidth,\n enterable,\n spaceRow,\n transitionDuration\n } = style;\n\n const backgroundColor = fillColor as string;\n\n const styles = {\n panel: {\n width: getPixelPropertyStr(attributeCache?.panel?.width),\n height: getPixelPropertyStr(attributeCache?.panel?.height),\n paddingBottom: getPixelPropertyStr(padding.bottom),\n paddingLeft: getPixelPropertyStr(padding.left),\n paddingRight: getPixelPropertyStr(padding.right),\n paddingTop: getPixelPropertyStr(padding.top),\n borderColor: strokeColor,\n borderWidth: getPixelPropertyStr(lineWidth),\n borderRadius: getPixelPropertyStr(cornerRadius),\n backgroundColor: backgroundColor ? `${backgroundColor}` : 'transparent',\n boxShadow: shadow\n ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}`\n : 'initial',\n maxWidth: getPixelPropertyStr(maxWidth),\n minWidth: getPixelPropertyStr(minWidth),\n pointerEvents: enterable ? 'auto' : 'none',\n transitionDuration: transitionDuration ? `${transitionDuration}ms` : 'initial',\n transitionProperty: transitionDuration ? 'transform' : 'initial',\n transitionTimingFunction: transitionDuration ? 'ease-out' : 'initial'\n },\n title: getLabelStyle(title),\n content: {},\n shapeColumn: {\n item: getShapeStyle(shape),\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING)\n },\n keyColumn: {\n item: getLabelStyle(key),\n width: getPixelPropertyStr(attributeCache?.keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n item: getLabelStyle(value),\n width: getPixelPropertyStr(attributeCache?.valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\n },\n spaceRow: getPixelPropertyStr(spaceRow)\n } as IDomTooltipStyle;\n\n if (isValid(spaceRow)) {\n const gapUnit = spaceRow / 2;\n ([styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(obj => {\n obj.marginTop = getPixelPropertyStr(gapUnit);\n obj.marginBottom = obj.marginTop;\n });\n styles.content.marginTop = getPixelPropertyStr(-gapUnit);\n styles.content.marginBottom = styles.content.marginTop;\n } else {\n ([styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(\n obj => {\n obj.marginTop = 'initial';\n obj.marginBottom = 'initial';\n }\n );\n }\n return styles;\n}\n\nfunction getLabelStyle(labelStyle?: ITextStyle, defaultStyle?: Partial<ITextStyle>): ILabelStyle | undefined {\n if (!labelStyle) {\n return undefined;\n }\n const {\n fontFamily: labelFont,\n fontSize: labelFontSize,\n fill: labelColor,\n textAlign,\n lineHeight,\n fontWeight\n } = merge({}, defaultStyle, labelStyle) as ITextStyle;\n const styleObj: ILabelStyle = {};\n\n styleObj.fontFamily = labelFont;\n styleObj.fontSize = getPixelPropertyStr(labelFontSize);\n styleObj.color = labelColor as string;\n styleObj.textAlign = textAlign as TextAlign;\n styleObj.lineHeight = getPixelPropertyStr(lineHeight);\n styleObj.fontWeight = fontWeight as FontWeight;\n return styleObj;\n}\n\nfunction getShapeStyle(\n shapeStyle?: ITooltipTheme['shape'],\n defaultStyle?: Partial<ITooltipTheme['shape']>\n): IShapeStyle | undefined {\n if (!shapeStyle) {\n return undefined;\n }\n const { size } = merge({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n styleObj.height = styleObj.width;\n return styleObj;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/interface/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/interface/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","file":"index.js","sourcesContent":["export * from './style';\n"]}
|
|
@@ -40,25 +40,26 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
40
40
|
attribute.title.shape = titleShapeAttrs, maxWidth += shapeStyle.size + shapeStyle.spacing,
|
|
41
41
|
titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);
|
|
42
42
|
}
|
|
43
|
-
attribute.title.width = maxWidth, attribute.title.height = titleMaxHeight, containerHeight += titleMaxHeight
|
|
43
|
+
attribute.title.width = maxWidth, attribute.title.height = titleMaxHeight, containerHeight += titleMaxHeight;
|
|
44
44
|
}
|
|
45
45
|
if (content.length) {
|
|
46
46
|
const filteredContent = content.filter((item => (item.key || item.value) && !1 !== item.visible));
|
|
47
47
|
if (filteredContent.length) {
|
|
48
|
+
titleVisible && (containerHeight += spaceRow);
|
|
48
49
|
let hasContentShape = !1;
|
|
49
|
-
const keyWidths = [], valueWidths = [], keyTextMeasure = initTextMeasure(keyStyle), valueTextMeasure = initTextMeasure(valueStyle);
|
|
50
|
+
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [], keyTextMeasure = initTextMeasure(keyStyle), valueTextMeasure = initTextMeasure(valueStyle);
|
|
50
51
|
attribute.content = filteredContent.map(((item, i) => {
|
|
51
52
|
const itemAttrs = {
|
|
52
53
|
height: 0,
|
|
53
54
|
spaceRow: spaceRow
|
|
54
55
|
};
|
|
55
56
|
let itemHeight = 0;
|
|
56
|
-
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value} = item;
|
|
57
|
+
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value, isKeyAdaptive: isKeyAdaptive} = item;
|
|
57
58
|
if (isValid(key)) {
|
|
58
59
|
const {width: width, height: height} = keyTextMeasure.quickMeasure(key);
|
|
59
60
|
itemAttrs.key = {
|
|
60
61
|
text: key
|
|
61
|
-
}, keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
62
|
+
}, isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
62
63
|
}
|
|
63
64
|
if (isValid(value)) {
|
|
64
65
|
const {width: width, height: height} = valueTextMeasure.quickMeasure(value);
|
|
@@ -69,16 +70,19 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
69
70
|
if (hasShape && builtinSymbolsMap[shapeType]) {
|
|
70
71
|
hasContentShape = !0;
|
|
71
72
|
const shape = {
|
|
73
|
+
visible: !0,
|
|
72
74
|
symbolType: shapeType
|
|
73
75
|
};
|
|
74
76
|
shapeHollow ? shape.stroke = shapeColor : shape.fill = shapeColor, itemHeight = Math.max(shapeStyle.size, itemHeight),
|
|
75
77
|
itemAttrs.shape = shape;
|
|
76
|
-
}
|
|
78
|
+
} else itemAttrs.shape = {
|
|
79
|
+
visible: !1
|
|
80
|
+
};
|
|
77
81
|
return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += spaceRow),
|
|
78
82
|
itemAttrs;
|
|
79
83
|
}));
|
|
80
|
-
const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
|
|
81
|
-
maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing +
|
|
84
|
+
const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0, shapeWidth = hasContentShape ? shapeStyle.size + shapeStyle.spacing : 0;
|
|
85
|
+
maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth),
|
|
82
86
|
attribute.hasContentShape = hasContentShape, attribute.keyWidth = maxKeyWidth, attribute.valueWidth = maxValueWidth;
|
|
83
87
|
}
|
|
84
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,aAA6B,EAAE,KAAoB,EAAqB,EAAE;IAC7G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE5G,MAAM,SAAS,mCACV,KAAK,KAER,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAEX,UAAU,EAAE;YACV,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EACD,YAAY,EAAE;YACZ,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EAED,eAAe,EAAE,KAAK,EACtB,QAAQ,EAAE,CAAC,EACX,UAAU,EAAE,CAAC,GACd,CAAC;IACD,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACnE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,aAAa,CAAC;IAEnD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,eAAe,GAAG,OAAO,CAAC,GAAG,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AAW;gBACT,aAAa;gBACb,QAAQ,CAAC,OAAO;gBAChB,UAAU,CAAC,OAAO;gBAClB,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9D,QAAQ,CACT,CAAC;YACF,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;YAC5C,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC;YACjC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC;SACtC;KACF;IAED,MAAM,aAAa,GAAmB;QACpC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK;QAC9C,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IAC5C,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual } from '../../../../typings';\nimport type { ITooltipStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { initTextMeasure } from '../../../../util';\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nexport const getTooltipAttributes = (actualTooltip: IToolTipActual, style: ITooltipStyle): TooltipAttributes => {\n const { spaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor\n } = title;\n attribute.title.visible = titleVisible;\n if (titleVisible) {\n const { width, height } = initTextMeasure(titleStyle as any).quickMeasure(titleValue);\n attribute.title.value = {\n // width, height,\n text: titleValue\n };\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight + spaceRow;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n let hasContentShape = false;\n const keyWidths: number[] = [];\n const valueWidths: number[] = [];\n\n const keyTextMeasure = initTextMeasure(keyStyle as any);\n const valueTextMeasure = initTextMeasure(valueStyle as any);\n\n attribute.content = filteredContent.map((item, i) => {\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow };\n let itemHeight = 0;\n const { hasShape, key, shapeColor, shapeHollow, shapeType = '', value } = item;\n if (isValid(key)) {\n const { width, height } = keyTextMeasure.quickMeasure(key);\n itemAttrs.key = {\n text: key as any\n };\n keyWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const { width, height } = valueTextMeasure.quickMeasure(value);\n itemAttrs.value = {\n text: value as any\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape && builtinSymbolsMap[shapeType]) {\n hasContentShape = true;\n const shape: TooltipSymbolAttrs = {\n symbolType: shapeType\n };\n if (shapeHollow) {\n shape.stroke = shapeColor;\n } else {\n shape.fill = shapeColor;\n }\n itemHeight = Math.max(shapeStyle.size, itemHeight);\n itemAttrs.shape = shape;\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n maxWidth = Math.max(\n maxKeyWidth +\n maxValueWidth +\n keyStyle.spacing +\n valueStyle.spacing +\n (hasContentShape ? shapeStyle.size + shapeStyle.spacing : 0),\n maxWidth\n );\n attribute.hasContentShape = hasContentShape;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,aAA6B,EAAE,KAAoB,EAAqB,EAAE;IAC7G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAA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Q,GAAG,IAAI,CAAC,GAAG,CACjB,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,GAAG,UAAU,EAChF,mBAAmB,GAAG,UAAU,EAChC,QAAQ,CACT,CAAC;YACF,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;YAC5C,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC;YACjC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC;SACtC;KACF;IAED,MAAM,aAAa,GAAmB;QACpC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK;QAC9C,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IAC5C,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual } from '../../../../typings';\nimport type { ITooltipStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { initTextMeasure } from '../../../../util';\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nexport const getTooltipAttributes = (actualTooltip: IToolTipActual, style: ITooltipStyle): TooltipAttributes => {\n const { spaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor\n } = title;\n attribute.title.visible = titleVisible;\n if (titleVisible) {\n const { width, height } = initTextMeasure(titleStyle as any).quickMeasure(titleValue);\n attribute.title.value = {\n // width, height,\n text: titleValue\n };\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n if (titleVisible) {\n containerHeight += spaceRow; // title 与 content 之前的间隔\n }\n\n let hasContentShape = false;\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n\n const keyTextMeasure = initTextMeasure(keyStyle as any);\n const valueTextMeasure = initTextMeasure(valueStyle as any);\n\n attribute.content = filteredContent.map((item, i) => {\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow };\n let itemHeight = 0;\n const { hasShape, key, shapeColor, shapeHollow, shapeType = '', value, isKeyAdaptive } = item;\n if (isValid(key)) {\n const { width, height } = keyTextMeasure.quickMeasure(key);\n itemAttrs.key = {\n text: key as any\n };\n if (!isKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const { width, height } = valueTextMeasure.quickMeasure(value);\n itemAttrs.value = {\n text: value as any\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape && builtinSymbolsMap[shapeType]) {\n hasContentShape = true;\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: shapeType\n };\n if (shapeHollow) {\n shape.stroke = shapeColor;\n } else {\n shape.fill = shapeColor;\n }\n itemHeight = Math.max(shapeStyle.size, itemHeight);\n itemAttrs.shape = shape;\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n const shapeWidth = hasContentShape ? shapeStyle.size + shapeStyle.spacing : 0; // shape 列宽度\n maxWidth = Math.max(\n maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth,\n maxAdaptiveKeyWidth + shapeWidth,\n maxWidth\n );\n attribute.hasContentShape = hasContentShape;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Datum } from '@visactor/vgrammar';
|
|
2
|
+
import type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';
|
|
3
|
+
import type { TooltipHandlerParams } from '../../interface';
|
|
2
4
|
export declare function escapeHTML(value: any): string;
|
|
3
|
-
export declare const
|
|
5
|
+
export declare const getTooltipContentValue: <T>(field?: TooltipContentProperty<T>, datum?: any, params?: TooltipHandlerParams) => T;
|
|
6
|
+
export declare const getTooltipPatternValue: <T>(field?: MaybeArray<TooltipPatternProperty<T>>, data?: TooltipData, params?: TooltipHandlerParams) => MaybeArray<TooltipPatternProperty<T>> extends TooltipPatternProperty<T>[] ? MaybeArray<T> : T;
|
|
7
|
+
export declare function getFirstDatumFromTooltipData(data: TooltipData): Datum;
|
|
4
8
|
export declare function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined;
|
|
5
9
|
export declare function convertToColorString(color: any, defaultColor?: string): string;
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import { isFunction, isObject, isString, isNil } from "../../../../util";
|
|
1
|
+
import { isFunction, isObject, isString, isNil, isArray, isValid } from "../../../../util";
|
|
2
2
|
|
|
3
3
|
export function escapeHTML(value) {
|
|
4
4
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\(/g, "(");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const getTooltipContentValue = (field, datum, params) => isNil(field) ? field : isFunction(field) ? field(datum, params) : field;
|
|
8
|
+
|
|
9
|
+
export const getTooltipPatternValue = (field, data, params) => {
|
|
10
|
+
if (isNil(field)) return field;
|
|
11
|
+
if (isArray(field)) {
|
|
12
|
+
const result = [];
|
|
13
|
+
return field.forEach((item => {
|
|
14
|
+
if (isFunction(item)) {
|
|
15
|
+
const value = item(data, params);
|
|
16
|
+
isValid(value) && result.push(value);
|
|
17
|
+
} else result.push(item);
|
|
18
|
+
})), result;
|
|
19
|
+
}
|
|
20
|
+
return isFunction(field) ? field(data, params) : field;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function getFirstDatumFromTooltipData(data) {
|
|
24
|
+
var _a;
|
|
25
|
+
const dimInfoList = (null === (_a = data[0]) || void 0 === _a ? void 0 : _a.series) ? [ {
|
|
26
|
+
data: data,
|
|
27
|
+
value: ""
|
|
28
|
+
} ] : data;
|
|
29
|
+
for (const {data: dataList} of dimInfoList) for (const {datum: datumList} of dataList) for (const datumItem of null != datumList ? datumList : []) if (datumItem) return datumItem;
|
|
30
|
+
}
|
|
8
31
|
|
|
9
32
|
export function pickFirstValidValue(isValid, ...elements) {
|
|
10
33
|
for (const ele of elements) if (isValid(ele)) return ele;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAS,MAAM,kBAAkB,CAAC;AAiBlG,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6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,mBAAmB,CAAI,OAA6B,EAAE,GAAG,QAAa;IACpF,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;QAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC;SACZ;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAGD,MAAM,UAAU,oBAAoB,CAAC,KAAU,EAAE,eAAuB,MAAM;IAC5E,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IACD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAK,KAAwB,CAAC,KAAK,IAAK,KAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAC5F,OAAQ,KAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC;KACjE;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar';\nimport type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';\nimport { isFunction, isObject, isString, isNil, isArray, isValid, field } from '../../../../util';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\n\ninterface IGradientColor {\n [key: string]: any;\n stops: {\n offset: number;\n color: string;\n }[];\n}\n\n/**\n * Escape special HTML characters.\n *\n * @param value A value to convert to string and HTML-escape.\n */\nexport function escapeHTML(value: any): string {\n return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\\(/g, '(');\n}\n\nexport const getTooltipContentValue = <T>(\n field?: TooltipContentProperty<T>,\n datum?: any,\n params?: TooltipHandlerParams\n): T | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isFunction(field)) {\n return field(datum, params);\n }\n return field;\n};\n\nexport const getTooltipPatternValue = <T>(\n field?: MaybeArray<TooltipPatternProperty<T>>,\n data?: TooltipData,\n params?: TooltipHandlerParams\n): (typeof field extends Array<TooltipPatternProperty<T>> ? MaybeArray<T> : T) | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isArray(field)) {\n const result: T[] = [];\n field.forEach(item => {\n if (isFunction(item)) {\n const value = item(data, params);\n if (isValid(value)) {\n result.push(value);\n }\n } else {\n result.push(item);\n }\n });\n return result as any;\n }\n if (isFunction(field)) {\n return field(data, params);\n }\n return field;\n};\n\nexport function getFirstDatumFromTooltipData(data: TooltipData): Datum {\n // 找到第一个可用的datum\n const dimInfoList: IDimensionInfo[] = (data as IDimensionData[])[0]?.series\n ? [{ data: data as IDimensionData[], value: '' }]\n : (data as IDimensionInfo[]);\n for (const { data: dataList } of dimInfoList) {\n for (const { datum: datumList } of dataList) {\n for (const datumItem of datumList ?? []) {\n if (datumItem) {\n return datumItem;\n }\n }\n }\n }\n}\n\nexport function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined {\n for (const ele of elements) {\n if (isValid(ele)) {\n return ele;\n }\n }\n return undefined;\n}\n\n// 针对渐变色,受底层渲染引擎影响,不一定都能绘制正确,所以这里取 colorStop 的第一个颜色作为 color\nexport function convertToColorString(color: any, defaultColor: string = '#000') {\n if (!color) {\n return defaultColor;\n }\n if (isString(color)) {\n return color;\n }\n\n if (isObject(color) && (color as IGradientColor).stops && (color as IGradientColor).stops[0]) {\n return (color as IGradientColor).stops[0].color || defaultColor;\n }\n\n return defaultColor;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TooltipContent } from '../../tooltip';
|
|
2
2
|
import type { IToolTipLinePattern, ITooltipPattern, TooltipData, IToolTipLineActual } from '../../../../typings/tooltip';
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
3
|
+
import type { TooltipHandlerParams } from '../../interface';
|
|
4
|
+
export declare const getShowContent: (pattern: ITooltipPattern, data: TooltipData, params: TooltipHandlerParams) => TooltipContent | null;
|
|
5
|
+
export declare const getOneLineData: (datum: any, config: IToolTipLinePattern, params: TooltipHandlerParams) => IToolTipLineActual;
|
|
@@ -1,71 +1,80 @@
|
|
|
1
|
-
import { isValid, isNil } from "../../../../util";
|
|
1
|
+
import { isValid, isNil, array } from "../../../../util";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getFirstDatumFromTooltipData, getTooltipContentValue, getTooltipPatternValue } from "./common";
|
|
4
4
|
|
|
5
5
|
import { getTooltipActualActiveType } from "../../utils";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { TOOLTIP_MAX_LINE_COUNT, TOOLTIP_OTHERS_LINE } from "../constants";
|
|
8
|
+
|
|
9
|
+
export const getShowContent = (pattern, data, params) => {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
if (!data || "mouseout" === (null === (_a = null == params ? void 0 : params.event) || void 0 === _a ? void 0 : _a.type)) return null;
|
|
12
|
+
const patternTitle = getTooltipPatternValue(pattern.title, data, params), patternContent = array(getTooltipPatternValue(pattern.content, data, params)), tooltipContent = {
|
|
11
13
|
title: {
|
|
12
|
-
value: null === (_b = null
|
|
14
|
+
value: null === (_b = null == patternTitle ? void 0 : patternTitle.value) || void 0 === _b ? void 0 : _b.toString(),
|
|
13
15
|
hasShape: !1,
|
|
14
16
|
shapeType: void 0,
|
|
15
17
|
shapeHollow: void 0
|
|
16
18
|
},
|
|
17
19
|
content: []
|
|
18
|
-
};
|
|
19
|
-
if (
|
|
20
|
-
if (tooltipContent.title.hasShape =
|
|
21
|
-
let datum;
|
|
20
|
+
}, {maxLineCount: maxLineCount = TOOLTIP_MAX_LINE_COUNT} = pattern, patternTitleVisible = !1 !== getTooltipContentValue(null == patternTitle ? void 0 : patternTitle.visible, data, params);
|
|
21
|
+
if (patternTitle && patternTitleVisible) {
|
|
22
|
+
if (tooltipContent.title.hasShape = patternTitle.hasShape, isValid(patternTitle.value)) {
|
|
22
23
|
tooltipContent.title = {
|
|
23
|
-
hasShape:
|
|
24
|
-
shapeHollow:
|
|
24
|
+
hasShape: patternTitle.hasShape,
|
|
25
|
+
shapeHollow: patternTitle.shapeHollow
|
|
25
26
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
value: ""
|
|
29
|
-
} ] : data;
|
|
30
|
-
for (const {data: dataList} of dimInfoList) {
|
|
31
|
-
for (const {datum: datumList} of dataList) {
|
|
32
|
-
for (const datumItem of null != datumList ? datumList : []) if (datumItem) {
|
|
33
|
-
datum = datumItem;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
if (datum) break;
|
|
37
|
-
}
|
|
38
|
-
if (datum) break;
|
|
39
|
-
}
|
|
40
|
-
tooltipContent.title.value = getTooltipValue(null === (_f = pattern.title) || void 0 === _f ? void 0 : _f.value, datum);
|
|
27
|
+
const datum = getFirstDatumFromTooltipData(data);
|
|
28
|
+
tooltipContent.title.value = getTooltipContentValue(null == patternTitle ? void 0 : patternTitle.value, datum, params);
|
|
41
29
|
}
|
|
42
30
|
} else tooltipContent.title = {
|
|
43
31
|
hasShape: !1,
|
|
44
32
|
visible: !1
|
|
45
33
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
|
|
34
|
+
if ("mark" === pattern.activeType) for (const content of null != patternContent ? patternContent : []) {
|
|
35
|
+
const oneLineData = getOneLineData(null === (_c = data[0]) || void 0 === _c ? void 0 : _c.datum[0], content, params);
|
|
36
|
+
if (!1 !== oneLineData.visible) {
|
|
37
|
+
if (tooltipContent.content.length === maxLineCount - 1) {
|
|
38
|
+
tooltipContent.content.push(Object.assign(Object.assign({}, oneLineData), TOOLTIP_OTHERS_LINE));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
if (!(tooltipContent.content.length < maxLineCount)) break;
|
|
42
|
+
tooltipContent.content.push(oneLineData);
|
|
43
|
+
}
|
|
44
|
+
} else if ("dimension" === pattern.activeType) for (const {data: d} of data) {
|
|
45
|
+
for (const {datum: datum, series: series} of d) {
|
|
46
|
+
if (!getTooltipActualActiveType(null === (_d = series.tooltipHelper) || void 0 === _d ? void 0 : _d.spec).includes("dimension")) continue;
|
|
47
|
+
const contentPatterns = null !== (_e = null == patternContent ? void 0 : patternContent.filter((c => isNil(c.seriesId) || c.seriesId === series.id))) && void 0 !== _e ? _e : [];
|
|
48
|
+
for (const datumItem of datum) {
|
|
49
|
+
for (const linePattern of contentPatterns) {
|
|
50
|
+
const oneLineData = getOneLineData(datumItem, linePattern, params);
|
|
51
|
+
if (!1 !== oneLineData.visible) {
|
|
52
|
+
if (tooltipContent.content.length === maxLineCount - 1) {
|
|
53
|
+
tooltipContent.content.push(Object.assign(Object.assign({}, oneLineData), TOOLTIP_OTHERS_LINE));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (!(tooltipContent.content.length < maxLineCount)) break;
|
|
57
|
+
tooltipContent.content.push(oneLineData);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
61
|
+
}
|
|
62
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
63
|
+
}
|
|
64
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
65
|
+
}
|
|
66
|
+
return tooltipContent.title && (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType ? (isNil(tooltipContent.title.shapeType) && (tooltipContent.title.shapeType = tooltipContent.content[0].shapeType),
|
|
59
67
|
isNil(tooltipContent.title.shapeColor) && (tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor)) : tooltipContent.title.hasShape = !1),
|
|
60
68
|
tooltipContent;
|
|
61
69
|
};
|
|
62
70
|
|
|
63
|
-
export const getOneLineData = (datum, config) => {
|
|
64
|
-
const key =
|
|
71
|
+
export const getOneLineData = (datum, config, params) => {
|
|
72
|
+
const key = getTooltipContentValue(config.key, datum, params), value = getTooltipContentValue(config.value, datum, params), visible = !1 !== getTooltipContentValue(config.visible, datum, params) && (isValid(key) || isValid(value)), isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params), shapeType = getTooltipContentValue(config.shapeType, datum, params), shapeColor = getTooltipContentValue(config.shapeColor, datum, params);
|
|
65
73
|
return {
|
|
66
74
|
key: key,
|
|
67
75
|
value: value,
|
|
68
76
|
visible: visible,
|
|
77
|
+
isKeyAdaptive: isKeyAdaptive,
|
|
69
78
|
hasShape: config.hasShape,
|
|
70
79
|
shapeType: shapeType,
|
|
71
80
|
shapeHollow: config.shapeHollow,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQlD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAUzD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAwB,EACxB,IAAiB,EACjB,KAAiB,EACM,EAAE;;IACzB,IACE,CAAC,IAAI;QAEL,KAAK,CAAC,IAAI,KAAK,UAAU,EACzB;QACA,OAAO,IAAI,CAAC;KACb;IACD,MAAM,cAAc,GAAmB;QACrC,KAAK,EAAE;YACL,KAAK,EAAE,MAAA,MAAA,OAAO,CAAC,KAAK,0CAAE,KAAK,0CAAE,QAAQ,EAAE;YACvC,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,SAAS;YACpB,WAAW,EAAE,SAAS;SACvB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;IAGF,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE;QACrD,cAAc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,CAAC;AACJ,CAAC,CAAC","file":"compose.js","sourcesContent":["import { isValid, isNil } from '../../../../util';\nimport type { TooltipContent } from '../../tooltip';\nimport type {\n IToolTipLinePattern,\n ITooltipPattern,\n TooltipData,\n IToolTipLineActual\n} from '../../../../typings/tooltip';\nimport { getTooltipValue } from './common';\nimport { getTooltipActualActiveType } from '../../utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension/interface';\n\n/**\n * 获得tooltip的实际显示内容\n * @param pattern\n * @param data\n * @param event\n * @returns\n */\nexport const getShowContent = (\n pattern: ITooltipPattern,\n data: TooltipData,\n event: MouseEvent\n): TooltipContent | null => {\n if (\n !data ||\n // data.key === undefined ||\n event.type === 'mouseout'\n ) {\n return null;\n }\n const tooltipContent: TooltipContent = {\n title: {\n value: pattern.title?.value?.toString(),\n hasShape: false,\n shapeType: undefined,\n shapeHollow: undefined\n },\n content: []\n };\n\n /** title */\n if (!pattern.title || pattern.title.visible === false) {\n tooltipContent.title = {\n hasShape: false,\n visible: false\n };\n } else {\n tooltipContent.title.hasShape = pattern.title.hasShape;\n if (isValid(pattern.title) && isValid(pattern.title.value)) {\n tooltipContent.title = {\n hasShape: pattern.title?.hasShape,\n shapeHollow: pattern.title?.shapeHollow\n };\n // 找到第一个可用的datum\n let datum: any;\n const dimInfoList: IDimensionInfo[] = (data as IDimensionData[])[0]?.series\n ? [{ data: data as IDimensionData[], value: '' }]\n : (data as IDimensionInfo[]);\n for (const { data: dataList } of dimInfoList) {\n for (const { datum: datumList } of dataList) {\n for (const datumItem of datumList ?? []) {\n if (datumItem) {\n datum = datumItem;\n break;\n }\n }\n if (datum) {\n break;\n }\n }\n if (datum) {\n break;\n }\n }\n tooltipContent.title.value = getTooltipValue(pattern.title?.value, datum);\n }\n }\n\n /** content */\n if (pattern.activeType === 'mark') {\n pattern.content?.forEach(content => {\n const oneLineData = getOneLineData((data as IDimensionData[])[0]?.datum[0], content);\n if (oneLineData.visible !== false) {\n tooltipContent.content.push(oneLineData);\n }\n });\n } else if (pattern.activeType === 'dimension') {\n (data as IDimensionInfo[]).forEach(({ data: d }) =>\n d.forEach(({ datum, series }) => {\n if (!getTooltipActualActiveType(series.tooltipHelper?.spec).includes('dimension')) {\n return;\n }\n const contentPatterns =\n pattern.content?.filter(\n c => isNil(c.seriesId) || c.seriesId === series.id // 匹配对应series\n ) ?? [];\n datum.forEach(datumItem =>\n contentPatterns.forEach(c => {\n const oneLineData = getOneLineData(datumItem, c);\n if (oneLineData.visible !== false) {\n tooltipContent.content.push(oneLineData);\n }\n })\n );\n })\n );\n }\n\n if (tooltipContent.title) {\n // TODO:对 title shape 的支持目前还不完整,尚没有相关需求\n if (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType) {\n if (isNil(tooltipContent.title.shapeType)) {\n tooltipContent.title.shapeType = tooltipContent.content[0].shapeType;\n }\n if (isNil(tooltipContent.title.shapeColor)) {\n tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor;\n }\n } else {\n tooltipContent.title.hasShape = false;\n }\n }\n\n return tooltipContent;\n};\n\n/**\n * 获得tooltip的单行实际显示内容\n * @param datum\n * @param config\n * @returns\n */\nexport const getOneLineData = (datum: any, config: IToolTipLinePattern): IToolTipLineActual => {\n const key = getTooltipValue(config.key, datum);\n const value = getTooltipValue(config.value, datum);\n const visible: boolean = isValid(key) || isValid(value);\n\n const shapeType = getTooltipValue(config.shapeType, datum);\n const shapeColor = getTooltipValue(config.shapeColor, datum);\n\n return {\n key,\n value,\n visible,\n hasShape: config.hasShape,\n shapeType: shapeType as any,\n shapeHollow: config.shapeHollow,\n shapeColor\n };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQzD,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACx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;IAE5E,OAAO;QACL,GAAG;QACH,KAAK;QACL,OAAO;QACP,aAAa;QACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,SAAgB;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC,CAAC","file":"compose.js","sourcesContent":["import { isValid, isNil, array } from '../../../../util';\nimport type { TooltipContent } from '../../tooltip';\nimport type {\n IToolTipLinePattern,\n ITooltipPattern,\n TooltipData,\n IToolTipLineActual\n} from '../../../../typings/tooltip';\nimport { getFirstDatumFromTooltipData, getTooltipContentValue, getTooltipPatternValue } from './common';\nimport { getTooltipActualActiveType } from '../../utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension/interface';\nimport type { TooltipHandlerParams } from '../../interface';\nimport { TOOLTIP_MAX_LINE_COUNT, TOOLTIP_OTHERS_LINE } from '../constants';\n\n/**\n * 获得tooltip的实际显示内容\n * @param pattern\n * @param data\n * @param event\n * @returns\n */\nexport const getShowContent = (\n pattern: ITooltipPattern,\n data: TooltipData,\n params: TooltipHandlerParams\n): TooltipContent | null => {\n if (\n !data ||\n // data.key === undefined ||\n params?.event?.type === 'mouseout'\n ) {\n return null;\n }\n\n const patternTitle = getTooltipPatternValue(pattern.title, data, params);\n const patternContent = array(getTooltipPatternValue(pattern.content, data, params));\n\n const tooltipContent: Required<TooltipContent> = {\n title: {\n value: patternTitle?.value?.toString(),\n hasShape: false,\n shapeType: undefined,\n shapeHollow: undefined\n },\n content: []\n };\n\n const { maxLineCount = TOOLTIP_MAX_LINE_COUNT } = pattern;\n\n /** title */\n const patternTitleVisible = getTooltipContentValue(patternTitle?.visible, data, params) !== false;\n if (!patternTitle || !patternTitleVisible) {\n tooltipContent.title = {\n hasShape: false,\n visible: false\n };\n } else {\n tooltipContent.title.hasShape = patternTitle.hasShape;\n if (isValid(patternTitle.value)) {\n tooltipContent.title = {\n hasShape: patternTitle.hasShape,\n shapeHollow: patternTitle.shapeHollow\n };\n // 找到第一个可用的datum\n const datum = getFirstDatumFromTooltipData(data);\n tooltipContent.title.value = getTooltipContentValue(patternTitle?.value, datum, params);\n }\n }\n\n /** content */\n if (pattern.activeType === 'mark') {\n for (const content of patternContent ?? []) {\n const oneLineData = getOneLineData((data as IDimensionData[])[0]?.datum[0], content, params);\n if (oneLineData.visible !== false) {\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n }\n } else if (pattern.activeType === 'dimension') {\n for (const { data: d } of data as IDimensionInfo[]) {\n for (const { datum, series } of d) {\n if (!getTooltipActualActiveType(series.tooltipHelper?.spec).includes('dimension')) {\n continue;\n }\n const contentPatterns =\n patternContent?.filter(\n c => isNil(c.seriesId) || c.seriesId === series.id // 匹配对应series\n ) ?? [];\n for (const datumItem of datum) {\n for (const linePattern of contentPatterns) {\n const oneLineData = getOneLineData(datumItem, linePattern, params);\n if (oneLineData.visible === false) {\n continue;\n }\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n }\n\n if (tooltipContent.title) {\n // TODO:对 title shape 的支持目前还不完整,尚没有相关需求\n if (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType) {\n if (isNil(tooltipContent.title.shapeType)) {\n tooltipContent.title.shapeType = tooltipContent.content[0].shapeType;\n }\n if (isNil(tooltipContent.title.shapeColor)) {\n tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor;\n }\n } else {\n tooltipContent.title.hasShape = false;\n }\n }\n\n return tooltipContent;\n};\n\n/**\n * 获得tooltip的单行实际显示内容\n * @param datum\n * @param config\n * @returns\n */\nexport const getOneLineData = (\n datum: any,\n config: IToolTipLinePattern,\n params: TooltipHandlerParams\n): IToolTipLineActual => {\n const key = getTooltipContentValue(config.key, datum, params);\n const value = getTooltipContentValue(config.value, datum, params);\n const visible: boolean =\n getTooltipContentValue(config.visible, datum, params) !== false && (isValid(key) || isValid(value));\n const isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params);\n\n const shapeType = getTooltipContentValue(config.shapeType, datum, params);\n const shapeColor = getTooltipContentValue(config.shapeColor, datum, params);\n\n return {\n key,\n value,\n visible,\n isKeyAdaptive,\n hasShape: config.hasShape,\n shapeType: shapeType as any,\n shapeHollow: config.shapeHollow,\n shapeColor\n };\n};\n"]}
|
|
@@ -1,33 +1,65 @@
|
|
|
1
|
-
import { cloneDeep, isValid,
|
|
1
|
+
import { cloneDeep, isValid, merge, array, isFunction, isNil } from "../../../../util";
|
|
2
2
|
|
|
3
3
|
import { makeDefaultPattern } from "./pattern";
|
|
4
4
|
|
|
5
|
+
import { getTooltipActualActiveType } from "../../utils";
|
|
6
|
+
|
|
5
7
|
export const getTooltipSpecForShow = (activeType, globalSpec, series, dimensionInfo) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
7
9
|
const finalSpec = Object.assign(Object.assign({}, globalSpec), {
|
|
8
10
|
activeType: activeType
|
|
9
11
|
});
|
|
10
12
|
let defaultPattern = {}, userPattern = {};
|
|
11
13
|
if ("mark" === activeType && series) {
|
|
12
14
|
const seriesSpec = null !== (_b = null === (_a = series.tooltipHelper) || void 0 === _a ? void 0 : _a.spec) && void 0 !== _b ? _b : {};
|
|
13
|
-
if (isValid(seriesSpec.visible) || isValid(seriesSpec.activeType) ? finalSpec.visible =
|
|
14
|
-
finalSpec.handler = null !== (
|
|
15
|
-
null === (
|
|
16
|
-
defaultPattern = makeDefaultPattern(series, "mark")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
if (isValid(seriesSpec.visible) || isValid(seriesSpec.activeType) ? finalSpec.visible = getTooltipActualActiveType(seriesSpec).includes("mark") : isValid(globalSpec.visible) || isValid(globalSpec.activeType) ? finalSpec.visible = getTooltipActualActiveType(globalSpec).includes("mark") : finalSpec.visible = !0,
|
|
16
|
+
finalSpec.handler = null !== (_d = null !== (_c = seriesSpec.handler) && void 0 !== _c ? _c : globalSpec.handler) && void 0 !== _d ? _d : void 0,
|
|
17
|
+
null === (_e = finalSpec.handler) || void 0 === _e ? void 0 : _e.showTooltip) return finalSpec;
|
|
18
|
+
defaultPattern = null !== (_f = makeDefaultPattern(series, "mark")) && void 0 !== _f ? _f : {},
|
|
19
|
+
userPattern = merge({}, cloneDeep(globalSpec.mark), cloneDeep(seriesSpec.mark));
|
|
20
|
+
} else if ("dimension" === activeType && (null == dimensionInfo ? void 0 : dimensionInfo.length)) {
|
|
21
|
+
const seriesList = dimensionInfo.reduce(((list, cur) => list.concat(cur.data.map((data => data.series)).filter(isValid))), []);
|
|
22
|
+
if (seriesList.every((series => {
|
|
23
|
+
var _a;
|
|
24
|
+
return !getTooltipActualActiveType(null === (_a = series.tooltipHelper) || void 0 === _a ? void 0 : _a.spec).includes("dimension");
|
|
25
|
+
})) ? finalSpec.visible = !1 : isValid(globalSpec.visible) || isValid(globalSpec.activeType) ? finalSpec.visible = getTooltipActualActiveType(globalSpec).includes("dimension") : finalSpec.visible = !0,
|
|
26
|
+
finalSpec.handler = null !== (_g = globalSpec.handler) && void 0 !== _g ? _g : void 0,
|
|
27
|
+
null === (_h = finalSpec.handler) || void 0 === _h ? void 0 : _h.showTooltip) return finalSpec;
|
|
28
|
+
const patternList = [];
|
|
29
|
+
dimensionInfo[0].data.forEach((data => {
|
|
30
|
+
const {series: series} = data, mockDimensionInfo = [ Object.assign(Object.assign({}, dimensionInfo[0]), {
|
|
31
|
+
data: [ data ]
|
|
32
|
+
}) ], pattern = makeDefaultPattern(series, "dimension", mockDimensionInfo);
|
|
33
|
+
pattern && patternList.push(pattern);
|
|
34
|
+
}));
|
|
35
|
+
const defaultPatternContent = [];
|
|
36
|
+
patternList.forEach((({content: content}) => {
|
|
37
|
+
isFunction(content) ? defaultPatternContent.push(content) : defaultPatternContent.push(...array(content));
|
|
38
|
+
})), defaultPattern = Object.assign(Object.assign({}, patternList[0]), {
|
|
39
|
+
content: defaultPatternContent
|
|
40
|
+
});
|
|
41
|
+
let seriesDimensionPattern = {};
|
|
42
|
+
const seriesPatternList = seriesList.filter((series => {
|
|
43
|
+
var _a;
|
|
44
|
+
const spec = null === (_a = series.tooltipHelper) || void 0 === _a ? void 0 : _a.spec;
|
|
45
|
+
return isValid(null == spec ? void 0 : spec.dimension) && getTooltipActualActiveType(spec).includes("dimension");
|
|
46
|
+
})).map((series => series.tooltipHelper.spec.dimension));
|
|
47
|
+
if (seriesPatternList.length) {
|
|
48
|
+
let seriesPatternContent = [];
|
|
49
|
+
seriesPatternList.every((({content: content}) => isNil(content))) ? seriesPatternContent = void 0 : seriesPatternList.forEach((({content: content}) => {
|
|
50
|
+
isNil(content) || (isFunction(content) ? null == seriesPatternContent || seriesPatternContent.push(content) : null == seriesPatternContent || seriesPatternContent.push(...array(content)));
|
|
51
|
+
})), seriesDimensionPattern = Object.assign(Object.assign({}, seriesPatternList[0]), {
|
|
52
|
+
content: seriesPatternContent
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
userPattern = merge({}, cloneDeep(globalSpec.dimension), seriesDimensionPattern);
|
|
24
56
|
}
|
|
25
|
-
const titleShape = {
|
|
26
|
-
hasShape: null !== (
|
|
27
|
-
shapeType: null !== (
|
|
28
|
-
shapeColor: null !== (
|
|
57
|
+
const defaultPatternTitle = defaultPattern.title, titleShape = {
|
|
58
|
+
hasShape: null !== (_j = userPattern.hasShape) && void 0 !== _j ? _j : null == defaultPatternTitle ? void 0 : defaultPatternTitle.hasShape,
|
|
59
|
+
shapeType: null !== (_k = userPattern.shapeType) && void 0 !== _k ? _k : null == defaultPatternTitle ? void 0 : defaultPatternTitle.shapeType,
|
|
60
|
+
shapeColor: null !== (_l = userPattern.shapeColor) && void 0 !== _l ? _l : null == defaultPatternTitle ? void 0 : defaultPatternTitle.shapeColor
|
|
29
61
|
};
|
|
30
|
-
isValid(userPattern.title) ? userPattern.title = Object.assign(Object.assign(Object.assign({}, defaultPattern.title), titleShape), userPattern.title) : userPattern.title = Object.assign(Object.assign({}, defaultPattern.title), titleShape);
|
|
62
|
+
isValid(userPattern.title) ? isFunction(userPattern.title) || (userPattern.title = Object.assign(Object.assign(Object.assign({}, defaultPattern.title), titleShape), userPattern.title)) : userPattern.title = Object.assign(Object.assign({}, defaultPattern.title), titleShape);
|
|
31
63
|
const getContentShape = defaultContentLine => {
|
|
32
64
|
var _a, _b, _c;
|
|
33
65
|
return {
|
|
@@ -35,11 +67,16 @@ export const getTooltipSpecForShow = (activeType, globalSpec, series, dimensionI
|
|
|
35
67
|
shapeType: null !== (_b = userPattern.shapeType) && void 0 !== _b ? _b : null == defaultContentLine ? void 0 : defaultContentLine.shapeType,
|
|
36
68
|
shapeColor: null !== (_c = userPattern.shapeColor) && void 0 !== _c ? _c : null == defaultContentLine ? void 0 : defaultContentLine.shapeColor
|
|
37
69
|
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
}, defaultPatternContent = array(defaultPattern.content);
|
|
71
|
+
if (isValid(userPattern.content)) {
|
|
72
|
+
if (!isFunction(userPattern.content)) {
|
|
73
|
+
const userPatternContent = array(userPattern.content);
|
|
74
|
+
userPatternContent.forEach(((line, i) => {
|
|
75
|
+
userPatternContent[i] = Object.assign(Object.assign({}, getContentShape(defaultPatternContent[0])), line);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
} else userPattern.content = defaultPatternContent.map((line => Object.assign(Object.assign({}, line), getContentShape(line))));
|
|
79
|
+
return finalSpec[activeType] = Object.assign(Object.assign(Object.assign({}, defaultPattern), userPattern), {
|
|
43
80
|
activeType: activeType
|
|
44
81
|
}), finalSpec;
|
|
45
82
|
};
|