@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
|
@@ -4,19 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.getDomStyles = void 0;
|
|
6
6
|
|
|
7
|
-
const util_1 = require("
|
|
7
|
+
const util_1 = require("../../../../util"), DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0, getPixelPropertyStr = (num, defaultStr) => (0,
|
|
8
8
|
util_1.isValid)(num) ? (0, util_1.isArray)(num) ? num.map((n => `${n}px`)).join(" ") : `${num}px` : null != defaultStr ? defaultStr : "initial";
|
|
9
9
|
|
|
10
|
-
function getDomStyles(style) {
|
|
11
|
-
|
|
10
|
+
function getDomStyles(style, attributeCache) {
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
|
+
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 = {
|
|
12
13
|
panel: {
|
|
14
|
+
width: getPixelPropertyStr(null === (_a = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _a ? void 0 : _a.width),
|
|
15
|
+
height: getPixelPropertyStr(null === (_b = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _b ? void 0 : _b.height),
|
|
13
16
|
paddingBottom: getPixelPropertyStr(padding.bottom),
|
|
14
17
|
paddingLeft: getPixelPropertyStr(padding.left),
|
|
15
18
|
paddingRight: getPixelPropertyStr(padding.right),
|
|
16
19
|
paddingTop: getPixelPropertyStr(padding.top),
|
|
17
20
|
borderColor: strokeColor,
|
|
18
21
|
borderWidth: getPixelPropertyStr(lineWidth),
|
|
19
|
-
borderRadius: getPixelPropertyStr(
|
|
22
|
+
borderRadius: getPixelPropertyStr(cornerRadius),
|
|
20
23
|
backgroundColor: backgroundColor ? `${backgroundColor}` : "transparent",
|
|
21
24
|
boxShadow: shadow ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}` : "initial",
|
|
22
25
|
maxWidth: getPixelPropertyStr(maxWidth),
|
|
@@ -27,20 +30,30 @@ function getDomStyles(style) {
|
|
|
27
30
|
transitionTimingFunction: transitionDuration ? "ease-out" : "initial"
|
|
28
31
|
},
|
|
29
32
|
title: getLabelStyle(title),
|
|
30
|
-
content: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
content: {},
|
|
34
|
+
shapeColumn: {
|
|
35
|
+
item: getShapeStyle(shape),
|
|
36
|
+
width: getPixelPropertyStr(shape.size),
|
|
37
|
+
marginRight: getPixelPropertyStr(null !== (_c = shape.spacing) && void 0 !== _c ? _c : 8)
|
|
38
|
+
},
|
|
39
|
+
keyColumn: {
|
|
40
|
+
item: getLabelStyle(key),
|
|
41
|
+
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.keyWidth),
|
|
42
|
+
marginRight: getPixelPropertyStr(null !== (_d = key.spacing) && void 0 !== _d ? _d : 26)
|
|
43
|
+
},
|
|
44
|
+
valueColumn: {
|
|
45
|
+
item: getLabelStyle(value),
|
|
46
|
+
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.valueWidth),
|
|
47
|
+
marginRight: getPixelPropertyStr(null !== (_e = value.spacing) && void 0 !== _e ? _e : 0)
|
|
48
|
+
},
|
|
49
|
+
spaceRow: getPixelPropertyStr(spaceRow)
|
|
37
50
|
};
|
|
38
51
|
if ((0, util_1.isValid)(spaceRow)) {
|
|
39
52
|
const gapUnit = spaceRow / 2;
|
|
40
|
-
[ styles.
|
|
53
|
+
[ styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
|
|
41
54
|
obj.marginTop = getPixelPropertyStr(gapUnit), obj.marginBottom = obj.marginTop;
|
|
42
55
|
})), styles.content.marginTop = getPixelPropertyStr(-gapUnit), styles.content.marginBottom = styles.content.marginTop;
|
|
43
|
-
} else [ styles.content, styles.
|
|
56
|
+
} else [ styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
|
|
44
57
|
obj.marginTop = "initial", obj.marginBottom = "initial";
|
|
45
58
|
}));
|
|
46
59
|
return styles;
|
|
@@ -48,20 +61,19 @@ function getDomStyles(style) {
|
|
|
48
61
|
|
|
49
62
|
function getLabelStyle(labelStyle, defaultStyle) {
|
|
50
63
|
if (!labelStyle) return;
|
|
51
|
-
const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight
|
|
64
|
+
const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight} = (0,
|
|
52
65
|
util_1.merge)({}, defaultStyle, labelStyle), styleObj = {};
|
|
53
66
|
return styleObj.fontFamily = labelFont, styleObj.fontSize = getPixelPropertyStr(labelFontSize),
|
|
54
67
|
styleObj.color = labelColor, styleObj.textAlign = textAlign, styleObj.lineHeight = getPixelPropertyStr(lineHeight),
|
|
55
|
-
styleObj.fontWeight = fontWeight, styleObj
|
|
56
|
-
styleObj;
|
|
68
|
+
styleObj.fontWeight = fontWeight, styleObj;
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
function getShapeStyle(shapeStyle, defaultStyle) {
|
|
60
72
|
if (!shapeStyle) return;
|
|
61
|
-
const {
|
|
62
|
-
return styleObj.
|
|
63
|
-
styleObj
|
|
73
|
+
const {size: size} = (0, util_1.merge)({}, defaultStyle, shapeStyle), styleObj = {};
|
|
74
|
+
return styleObj.width = getPixelPropertyStr(size), styleObj.height = styleObj.width,
|
|
75
|
+
styleObj;
|
|
64
76
|
}
|
|
65
77
|
|
|
66
78
|
exports.getDomStyles = getDomStyles;
|
|
67
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":";;;AAEA,2CAA2D;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,IAAA,cAAO,EAAC,GAAG,CAAC,EAAE;QAChB,IAAI,IAA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AM,EACJ,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,UAAU,EAChB,SAAS,EACT,UAAU,EACV,UAAU,EACX,GAAG,IAAA,YAAK,EAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAe,CAAC;IACtD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,UAAU,GAAG,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,IAAA,YAAK,EAAC,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"]}
|
|
@@ -17,5 +17,5 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), __exportStar(require("./style"), exports)
|
|
20
|
+
}), __exportStar(require("./style"), exports);
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","file":"index.js","sourcesContent":["export * from './style';\n"]}
|
|
@@ -40,26 +40,27 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
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 = [],
|
|
50
|
-
util_1.initTextMeasure)(valueStyle);
|
|
50
|
+
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [], keyTextMeasure = (0,
|
|
51
|
+
util_1.initTextMeasure)(keyStyle), valueTextMeasure = (0, util_1.initTextMeasure)(valueStyle);
|
|
51
52
|
attribute.content = filteredContent.map(((item, i) => {
|
|
52
53
|
const itemAttrs = {
|
|
53
54
|
height: 0,
|
|
54
55
|
spaceRow: spaceRow
|
|
55
56
|
};
|
|
56
57
|
let itemHeight = 0;
|
|
57
|
-
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value} = item;
|
|
58
|
+
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value, isKeyAdaptive: isKeyAdaptive} = item;
|
|
58
59
|
if ((0, vutils_1.isValid)(key)) {
|
|
59
60
|
const {width: width, height: height} = keyTextMeasure.quickMeasure(key);
|
|
60
61
|
itemAttrs.key = {
|
|
61
62
|
text: key
|
|
62
|
-
}, keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
63
|
+
}, isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
63
64
|
}
|
|
64
65
|
if ((0, vutils_1.isValid)(value)) {
|
|
65
66
|
const {width: width, height: height} = valueTextMeasure.quickMeasure(value);
|
|
@@ -70,16 +71,19 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
70
71
|
if (hasShape && vrender_1.builtinSymbolsMap[shapeType]) {
|
|
71
72
|
hasContentShape = !0;
|
|
72
73
|
const shape = {
|
|
74
|
+
visible: !0,
|
|
73
75
|
symbolType: shapeType
|
|
74
76
|
};
|
|
75
77
|
shapeHollow ? shape.stroke = shapeColor : shape.fill = shapeColor, itemHeight = Math.max(shapeStyle.size, itemHeight),
|
|
76
78
|
itemAttrs.shape = shape;
|
|
77
|
-
}
|
|
79
|
+
} else itemAttrs.shape = {
|
|
80
|
+
visible: !1
|
|
81
|
+
};
|
|
78
82
|
return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += spaceRow),
|
|
79
83
|
itemAttrs;
|
|
80
84
|
}));
|
|
81
|
-
const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
|
|
82
|
-
maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing +
|
|
85
|
+
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;
|
|
86
|
+
maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth),
|
|
83
87
|
attribute.hasContentShape = hasContentShape, attribute.keyWidth = maxKeyWidth, attribute.valueWidth = maxValueWidth;
|
|
84
88
|
}
|
|
85
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":";;;AAQA,6CAA2C;AAC3C,2CAAmD;AACnD,+CAAsD;AAE/C,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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rs\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,6CAA2C;AAC3C,2CAAmD;AACnD,+CAAsD;AAE/C,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,GAAG,OAAO,CAAC,MAAM,CAAC;IAGnD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,MAAM,EACJ,OAAO,EAAE,YAAY,GAAG,IAAI,EAC5B,KAAK,EAAE,UAAU,GAAG,EAAE,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,CAAC,CAAC;YAClE,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1F,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxE,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,QAAQ,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;AArKW,QAAA,oBAAoB,wBAqK/B","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;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.convertToColorString = exports.pickFirstValidValue = exports.
|
|
5
|
+
}), exports.convertToColorString = exports.pickFirstValidValue = exports.getFirstDatumFromTooltipData = exports.getTooltipPatternValue = exports.getTooltipContentValue = exports.escapeHTML = void 0;
|
|
6
6
|
|
|
7
7
|
const util_1 = require("../../../../util");
|
|
8
8
|
|
|
@@ -12,8 +12,33 @@ function escapeHTML(value) {
|
|
|
12
12
|
|
|
13
13
|
exports.escapeHTML = escapeHTML;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
util_1.isFunction)(field) ? field(datum) : field
|
|
15
|
+
const getTooltipContentValue = (field, datum, params) => (0, util_1.isNil)(field) ? field : (0,
|
|
16
|
+
util_1.isFunction)(field) ? field(datum, params) : field;
|
|
17
|
+
|
|
18
|
+
exports.getTooltipContentValue = getTooltipContentValue;
|
|
19
|
+
|
|
20
|
+
const getTooltipPatternValue = (field, data, params) => {
|
|
21
|
+
if ((0, util_1.isNil)(field)) return field;
|
|
22
|
+
if ((0, util_1.isArray)(field)) {
|
|
23
|
+
const result = [];
|
|
24
|
+
return field.forEach((item => {
|
|
25
|
+
if ((0, util_1.isFunction)(item)) {
|
|
26
|
+
const value = item(data, params);
|
|
27
|
+
(0, util_1.isValid)(value) && result.push(value);
|
|
28
|
+
} else result.push(item);
|
|
29
|
+
})), result;
|
|
30
|
+
}
|
|
31
|
+
return (0, util_1.isFunction)(field) ? field(data, params) : field;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function getFirstDatumFromTooltipData(data) {
|
|
35
|
+
var _a;
|
|
36
|
+
const dimInfoList = (null === (_a = data[0]) || void 0 === _a ? void 0 : _a.series) ? [ {
|
|
37
|
+
data: data,
|
|
38
|
+
value: ""
|
|
39
|
+
} ] : data;
|
|
40
|
+
for (const {data: dataList} of dimInfoList) for (const {datum: datumList} of dataList) for (const datumItem of null != datumList ? datumList : []) if (datumItem) return datumItem;
|
|
41
|
+
}
|
|
17
42
|
|
|
18
43
|
function pickFirstValidValue(isValid, ...elements) {
|
|
19
44
|
for (const ele of elements) if (isValid(ele)) return ele;
|
|
@@ -23,6 +48,6 @@ function convertToColorString(color, defaultColor = "#000") {
|
|
|
23
48
|
return color ? (0, util_1.isString)(color) ? color : (0, util_1.isObject)(color) && color.stops && color.stops[0] && color.stops[0].color || defaultColor : defaultColor;
|
|
24
49
|
}
|
|
25
50
|
|
|
26
|
-
exports.
|
|
27
|
-
exports.convertToColorString = convertToColorString;
|
|
51
|
+
exports.getTooltipPatternValue = getTooltipPatternValue, exports.getFirstDatumFromTooltipData = getFirstDatumFromTooltipData,
|
|
52
|
+
exports.pickFirstValidValue = pickFirstValidValue, exports.convertToColorString = convertToColorString;
|
|
28
53
|
//# sourceMappingURL=common.js.map
|
|
@@ -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,2CAAkG;AAiBlG,SAAgB,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;AAFD,gCAEC;AAEM,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,iBAAU,EAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC;AAEK,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6B,EAC4D,EAAE;IAC3F,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,EA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,QAAQ,EAAE;QAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC;SACZ;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,kDAOC;AAGD,SAAgB,oBAAoB,CAAC,KAAU,EAAE,eAAuB,MAAM;IAC5E,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IACD,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAA,eAAQ,EAAC,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;AAbD,oDAaC","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;
|
|
@@ -4,60 +4,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.getOneLineData = exports.getShowContent = void 0;
|
|
6
6
|
|
|
7
|
-
const util_1 = require("../../../../util"), common_1 = require("./common"), utils_1 = require("../../utils"), getShowContent = (pattern, data,
|
|
8
|
-
var _a, _b, _c, _d, _e
|
|
9
|
-
if (!data || "mouseout" === event.type) return null;
|
|
10
|
-
const
|
|
7
|
+
const util_1 = require("../../../../util"), common_1 = require("./common"), utils_1 = require("../../utils"), constants_1 = require("../constants"), getShowContent = (pattern, data, params) => {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
if (!data || "mouseout" === (null === (_a = null == params ? void 0 : params.event) || void 0 === _a ? void 0 : _a.type)) return null;
|
|
10
|
+
const patternTitle = (0, common_1.getTooltipPatternValue)(pattern.title, data, params), patternContent = (0,
|
|
11
|
+
util_1.array)((0, common_1.getTooltipPatternValue)(pattern.content, data, params)), tooltipContent = {
|
|
11
12
|
title: {
|
|
12
|
-
value: null === (_b = null
|
|
13
|
+
value: null === (_b = null == patternTitle ? void 0 : patternTitle.value) || void 0 === _b ? void 0 : _b.toString(),
|
|
13
14
|
hasShape: !1,
|
|
14
15
|
shapeType: void 0,
|
|
15
16
|
shapeHollow: void 0
|
|
16
17
|
},
|
|
17
18
|
content: []
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
util_1.isValid)(
|
|
22
|
-
let datum;
|
|
19
|
+
}, {maxLineCount: maxLineCount = constants_1.TOOLTIP_MAX_LINE_COUNT} = pattern, patternTitleVisible = !1 !== (0,
|
|
20
|
+
common_1.getTooltipContentValue)(null == patternTitle ? void 0 : patternTitle.visible, data, params);
|
|
21
|
+
if (patternTitle && patternTitleVisible) {
|
|
22
|
+
if (tooltipContent.title.hasShape = patternTitle.hasShape, (0, util_1.isValid)(patternTitle.value)) {
|
|
23
23
|
tooltipContent.title = {
|
|
24
|
-
hasShape:
|
|
25
|
-
shapeHollow:
|
|
24
|
+
hasShape: patternTitle.hasShape,
|
|
25
|
+
shapeHollow: patternTitle.shapeHollow
|
|
26
26
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
value: ""
|
|
30
|
-
} ] : data;
|
|
31
|
-
for (const {data: dataList} of dimInfoList) {
|
|
32
|
-
for (const {datum: datumList} of dataList) {
|
|
33
|
-
for (const datumItem of null != datumList ? datumList : []) if (datumItem) {
|
|
34
|
-
datum = datumItem;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
if (datum) break;
|
|
38
|
-
}
|
|
39
|
-
if (datum) break;
|
|
40
|
-
}
|
|
41
|
-
tooltipContent.title.value = (0, common_1.getTooltipValue)(null === (_f = pattern.title) || void 0 === _f ? void 0 : _f.value, datum);
|
|
27
|
+
const datum = (0, common_1.getFirstDatumFromTooltipData)(data);
|
|
28
|
+
tooltipContent.title.value = (0, common_1.getTooltipContentValue)(null == patternTitle ? void 0 : patternTitle.value, datum, params);
|
|
42
29
|
}
|
|
43
30
|
} else tooltipContent.title = {
|
|
44
31
|
hasShape: !1,
|
|
45
32
|
visible: !1
|
|
46
33
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
34
|
+
if ("mark" === pattern.activeType) for (const content of null != patternContent ? patternContent : []) {
|
|
35
|
+
const oneLineData = (0, exports.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), constants_1.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 (!(0, utils_1.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 => (0,
|
|
48
|
+
util_1.isNil)(c.seriesId) || c.seriesId === series.id))) && void 0 !== _e ? _e : [];
|
|
49
|
+
for (const datumItem of datum) {
|
|
50
|
+
for (const linePattern of contentPatterns) {
|
|
51
|
+
const oneLineData = (0, exports.getOneLineData)(datumItem, linePattern, params);
|
|
52
|
+
if (!1 !== oneLineData.visible) {
|
|
53
|
+
if (tooltipContent.content.length === maxLineCount - 1) {
|
|
54
|
+
tooltipContent.content.push(Object.assign(Object.assign({}, oneLineData), constants_1.TOOLTIP_OTHERS_LINE));
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (!(tooltipContent.content.length < maxLineCount)) break;
|
|
58
|
+
tooltipContent.content.push(oneLineData);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
62
|
+
}
|
|
63
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
64
|
+
}
|
|
65
|
+
if (tooltipContent.content.length >= maxLineCount) break;
|
|
66
|
+
}
|
|
67
|
+
return tooltipContent.title && (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType ? ((0,
|
|
61
68
|
util_1.isNil)(tooltipContent.title.shapeType) && (tooltipContent.title.shapeType = tooltipContent.content[0].shapeType),
|
|
62
69
|
(0, util_1.isNil)(tooltipContent.title.shapeColor) && (tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor)) : tooltipContent.title.hasShape = !1),
|
|
63
70
|
tooltipContent;
|
|
@@ -65,14 +72,18 @@ const util_1 = require("../../../../util"), common_1 = require("./common"), util
|
|
|
65
72
|
|
|
66
73
|
exports.getShowContent = getShowContent;
|
|
67
74
|
|
|
68
|
-
const getOneLineData = (datum, config) => {
|
|
69
|
-
const key = (0, common_1.
|
|
70
|
-
|
|
71
|
-
common_1.
|
|
75
|
+
const getOneLineData = (datum, config, params) => {
|
|
76
|
+
const key = (0, common_1.getTooltipContentValue)(config.key, datum, params), value = (0,
|
|
77
|
+
common_1.getTooltipContentValue)(config.value, datum, params), visible = !1 !== (0,
|
|
78
|
+
common_1.getTooltipContentValue)(config.visible, datum, params) && ((0, util_1.isValid)(key) || (0,
|
|
79
|
+
util_1.isValid)(value)), isKeyAdaptive = (0, common_1.getTooltipContentValue)(config.isKeyAdaptive, datum, params), shapeType = (0,
|
|
80
|
+
common_1.getTooltipContentValue)(config.shapeType, datum, params), shapeColor = (0,
|
|
81
|
+
common_1.getTooltipContentValue)(config.shapeColor, datum, params);
|
|
72
82
|
return {
|
|
73
83
|
key: key,
|
|
74
84
|
value: value,
|
|
75
85
|
visible: visible,
|
|
86
|
+
isKeyAdaptive: isKeyAdaptive,
|
|
76
87
|
hasShape: config.hasShape,
|
|
77
88
|
shapeType: shapeType,
|
|
78
89
|
shapeHollow: config.shapeHollow,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/compose.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAQlD,qCAA2C;AAC3C,uCAAyD;AAUlD,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,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AAC,GAAG,CAAC,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;IAExD,MAAM,SAAS,GAAG,IAAA,wBAAe,EAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAA,wBAAe,EAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAE7D,OAAO;QACL,GAAG;QACH,KAAK;QACL,OAAO;QACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,SAAgB;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,cAAc,kBAiBzB","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,2CAAyD;AAQzD,qCAAwG;AACxG,uCAAyD;AAGzD,4CAA2E;AASpE,MAAM,cAAc,GAAG,CAC5B,OAAwB,EACxB,IAAiB,EACjB,MAA4B,EACL,EAAE;;IACzB,IACE,CAAC,IAAI;QAEL,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,IAAI,MAAK,UAAU,EAClC;QACA,OAAO,IAAI,CAAC;KACb;IAED,MAAM,YAAY,GAAG,IAAA,+BAAsB,EAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,IAAA,YAAK,EAAC,IAAA,+BAAsB,EAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAEpF,MAAM,cAAc,GAA6B;QAC/C,KAAK,EAAE;YACL,KAAK,EAAE,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,0CAAE,QAAQ,EAAE;YACtC,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,SAAS;YACpB,WAAW,EAAE,SAAS;SACvB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,MAAM,EAAE,YAAY,GAAG,kCAAsB,EAAE,GAAG,OAAO,CAAC;IAG1D,MAAM,mBAAmB,GAAG,IAAA,+BAAsB,EAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,KAAK,CAAC;IAClG,IAAI,C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,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC;IACtG,MAAM,aAAa,GAAG,IAAA,+BAAsB,EAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,IAAA,+BAAsB,EAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAG,IAAA,+BAAsB,EAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;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;AAxBW,QAAA,cAAc,kBAwBzB","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"]}
|