@visactor/vchart 1.12.15 → 1.13.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/es5/index.js +1 -1
- package/build/index.js +2381 -1727
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/animation/utils.js +8 -6
- package/cjs/animation/utils.js.map +1 -1
- package/cjs/chart/base/base-chart.d.ts +1 -0
- package/cjs/chart/base/base-chart.js +3 -0
- package/cjs/chart/base/base-chart.js.map +1 -1
- package/cjs/chart/index.d.ts +5 -3
- package/cjs/chart/index.js +16 -2
- package/cjs/chart/index.js.map +1 -1
- package/cjs/chart/interface/chart.d.ts +1 -0
- package/cjs/chart/interface/chart.js.map +1 -1
- package/cjs/chart/interface/type.d.ts +2 -1
- package/cjs/chart/interface/type.js +1 -1
- package/cjs/chart/interface/type.js.map +1 -1
- package/cjs/chart/pictogram/index.d.ts +3 -0
- package/cjs/{plugin/components/tooltip-handler/canvas → chart/pictogram}/index.js +2 -1
- package/cjs/chart/pictogram/index.js.map +1 -0
- package/cjs/chart/pictogram/interface.d.ts +6 -0
- package/cjs/chart/pictogram/interface.js.map +1 -0
- package/cjs/chart/pictogram/pictogram-transformer.d.ts +8 -0
- package/cjs/chart/pictogram/pictogram-transformer.js +38 -0
- package/cjs/chart/pictogram/pictogram-transformer.js.map +1 -0
- package/cjs/chart/pictogram/pictogram.d.ts +12 -0
- package/cjs/chart/pictogram/pictogram.js +24 -0
- package/cjs/chart/pictogram/pictogram.js.map +1 -0
- package/cjs/chart/sankey/sankey-transformer.js +2 -1
- package/cjs/chart/sankey/sankey-transformer.js.map +1 -1
- package/cjs/chart/sankey/sankey.js +3 -2
- package/cjs/chart/sankey/sankey.js.map +1 -1
- package/cjs/compile/mark/compilable-mark.js +1 -1
- package/cjs/compile/mark/compilable-mark.js.map +1 -1
- package/cjs/component/custom-mark/custom-mark.js +7 -1
- package/cjs/component/custom-mark/custom-mark.js.map +1 -1
- package/cjs/component/geo/geo-coordinate.js +6 -6
- package/cjs/component/geo/geo-coordinate.js.map +1 -1
- package/cjs/component/tooltip/interface/theme.d.ts +2 -2
- package/cjs/component/tooltip/interface/theme.js.map +1 -1
- package/cjs/component/tooltip/utils/get-value.js +3 -1
- package/cjs/component/tooltip/utils/get-value.js.map +1 -1
- 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/vchart.d.ts +4 -1
- package/cjs/core/vchart.js +21 -7
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/transforms/pictogram.d.ts +84 -0
- package/cjs/data/transforms/pictogram.js +149 -0
- package/cjs/data/transforms/pictogram.js.map +1 -0
- package/cjs/mark/group.d.ts +3 -2
- package/cjs/mark/group.js +12 -2
- package/cjs/mark/group.js.map +1 -1
- package/cjs/mark/interface/type.d.ts +2 -1
- package/cjs/mark/interface/type.js +2 -1
- package/cjs/mark/interface/type.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/base.d.ts +4 -6
- package/cjs/plugin/components/tooltip-handler/base.js +3 -20
- package/cjs/plugin/components/tooltip-handler/base.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/{canvas/canvas-tooltip-handler.d.ts → canvas-tooltip-handler.d.ts} +8 -3
- package/cjs/plugin/components/tooltip-handler/{canvas/canvas-tooltip-handler.js → canvas-tooltip-handler.js} +15 -2
- package/cjs/plugin/components/tooltip-handler/canvas-tooltip-handler.js.map +1 -0
- package/cjs/plugin/components/tooltip-handler/constants.d.ts +7 -8
- package/cjs/plugin/components/tooltip-handler/constants.js +6 -9
- package/cjs/plugin/components/tooltip-handler/constants.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/{dom/dom-tooltip-handler.d.ts → dom-tooltip-handler.d.ts} +20 -9
- package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js +187 -0
- package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -0
- package/cjs/plugin/components/tooltip-handler/index.d.ts +2 -2
- package/cjs/plugin/components/tooltip-handler/index.js +1 -1
- package/cjs/plugin/components/tooltip-handler/index.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/interface/index.d.ts +15 -2
- package/cjs/plugin/components/tooltip-handler/interface/index.js +1 -16
- package/cjs/plugin/components/tooltip-handler/interface/index.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/attribute.d.ts +9 -2
- package/cjs/plugin/components/tooltip-handler/utils/attribute.js +36 -18
- package/cjs/plugin/components/tooltip-handler/utils/attribute.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/common.d.ts +1 -12
- package/cjs/plugin/components/tooltip-handler/utils/common.js +7 -35
- package/cjs/plugin/components/tooltip-handler/utils/common.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/style.d.ts +18 -0
- package/cjs/plugin/components/tooltip-handler/utils/style.js +94 -0
- package/cjs/plugin/components/tooltip-handler/utils/style.js.map +1 -0
- package/cjs/plugin/components/tooltip-handler/utils/svg.d.ts +2 -0
- package/cjs/plugin/components/tooltip-handler/utils/svg.js +48 -0
- package/cjs/plugin/components/tooltip-handler/utils/svg.js.map +1 -0
- package/cjs/series/base/base-series.d.ts +22 -6
- package/cjs/series/base/base-series.js +33 -24
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/interface/type.d.ts +4 -2
- package/cjs/series/interface/type.js +4 -2
- package/cjs/series/interface/type.js.map +1 -1
- package/cjs/series/pictogram/constant.d.ts +2 -0
- package/cjs/series/pictogram/constant.js +15 -0
- package/cjs/series/pictogram/constant.js.map +1 -0
- package/cjs/series/pictogram/interface.d.ts +15 -0
- package/cjs/series/pictogram/interface.js.map +1 -0
- package/cjs/series/pictogram/pictogram-transformer.d.ts +5 -0
- package/cjs/series/pictogram/pictogram-transformer.js +23 -0
- package/cjs/series/pictogram/pictogram-transformer.js.map +1 -0
- package/cjs/series/pictogram/pictogram.d.ts +77 -0
- package/cjs/series/pictogram/pictogram.js +303 -0
- package/cjs/series/pictogram/pictogram.js.map +1 -0
- package/cjs/series/pictogram/svg-source.d.ts +7 -0
- package/cjs/series/pictogram/svg-source.js +38 -0
- package/cjs/series/pictogram/svg-source.js.map +1 -0
- package/cjs/series/pictogram/tooltip-helper.d.ts +9 -0
- package/cjs/series/pictogram/tooltip-helper.js +26 -0
- package/cjs/series/pictogram/tooltip-helper.js.map +1 -0
- package/cjs/series/sankey/interface.d.ts +1 -0
- package/cjs/series/sankey/interface.js.map +1 -1
- package/cjs/series/sankey/sankey.js +4 -0
- package/cjs/series/sankey/sankey.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +1 -0
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/typings/tooltip/common.d.ts +3 -1
- package/cjs/typings/tooltip/common.js.map +1 -1
- package/esm/animation/utils.js +8 -6
- package/esm/animation/utils.js.map +1 -1
- package/esm/chart/base/base-chart.d.ts +1 -0
- package/esm/chart/base/base-chart.js +3 -0
- package/esm/chart/base/base-chart.js.map +1 -1
- package/esm/chart/index.d.ts +5 -3
- package/esm/chart/index.js +4 -2
- package/esm/chart/index.js.map +1 -1
- package/esm/chart/interface/chart.d.ts +1 -0
- package/esm/chart/interface/chart.js.map +1 -1
- package/esm/chart/interface/type.d.ts +2 -1
- package/esm/chart/interface/type.js +1 -1
- package/esm/chart/interface/type.js.map +1 -1
- package/esm/chart/pictogram/index.d.ts +3 -0
- package/esm/chart/pictogram/index.js +6 -0
- package/esm/chart/pictogram/index.js.map +1 -0
- package/esm/chart/pictogram/interface.d.ts +6 -0
- package/esm/chart/pictogram/interface.js.map +1 -0
- package/esm/chart/pictogram/pictogram-transformer.d.ts +8 -0
- package/esm/chart/pictogram/pictogram-transformer.js +32 -0
- package/esm/chart/pictogram/pictogram-transformer.js.map +1 -0
- package/esm/chart/pictogram/pictogram.d.ts +12 -0
- package/esm/chart/pictogram/pictogram.js +24 -0
- package/esm/chart/pictogram/pictogram.js.map +1 -0
- package/esm/chart/sankey/sankey-transformer.js +2 -1
- package/esm/chart/sankey/sankey-transformer.js.map +1 -1
- package/esm/chart/sankey/sankey.js +3 -1
- package/esm/chart/sankey/sankey.js.map +1 -1
- package/esm/compile/mark/compilable-mark.js +1 -1
- package/esm/compile/mark/compilable-mark.js.map +1 -1
- package/esm/component/custom-mark/custom-mark.js +7 -1
- package/esm/component/custom-mark/custom-mark.js.map +1 -1
- package/esm/component/geo/geo-coordinate.js +6 -6
- package/esm/component/geo/geo-coordinate.js.map +1 -1
- package/esm/component/tooltip/interface/theme.d.ts +2 -2
- package/esm/component/tooltip/interface/theme.js.map +1 -1
- package/esm/component/tooltip/utils/get-value.js +3 -2
- package/esm/component/tooltip/utils/get-value.js.map +1 -1
- 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/vchart.d.ts +4 -1
- package/esm/core/vchart.js +23 -6
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/transforms/pictogram.d.ts +84 -0
- package/esm/data/transforms/pictogram.js +145 -0
- package/esm/data/transforms/pictogram.js.map +1 -0
- package/esm/mark/group.d.ts +3 -2
- package/esm/mark/group.js +12 -2
- package/esm/mark/group.js.map +1 -1
- package/esm/mark/interface/type.d.ts +2 -1
- package/esm/mark/interface/type.js +2 -1
- package/esm/mark/interface/type.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/base.d.ts +4 -6
- package/esm/plugin/components/tooltip-handler/base.js +3 -22
- package/esm/plugin/components/tooltip-handler/base.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/{canvas/canvas-tooltip-handler.d.ts → canvas-tooltip-handler.d.ts} +8 -3
- package/esm/plugin/components/tooltip-handler/{canvas/canvas-tooltip-handler.js → canvas-tooltip-handler.js} +19 -5
- package/esm/plugin/components/tooltip-handler/canvas-tooltip-handler.js.map +1 -0
- package/esm/plugin/components/tooltip-handler/constants.d.ts +7 -8
- package/esm/plugin/components/tooltip-handler/constants.js +9 -4
- package/esm/plugin/components/tooltip-handler/constants.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/{dom/dom-tooltip-handler.d.ts → dom-tooltip-handler.d.ts} +20 -9
- package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js +191 -0
- package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -0
- package/esm/plugin/components/tooltip-handler/index.d.ts +2 -2
- package/esm/plugin/components/tooltip-handler/index.js +2 -2
- package/esm/plugin/components/tooltip-handler/index.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/interface/index.d.ts +15 -2
- package/esm/plugin/components/tooltip-handler/interface/index.js +1 -3
- package/esm/plugin/components/tooltip-handler/interface/index.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/attribute.d.ts +9 -2
- package/esm/plugin/components/tooltip-handler/utils/attribute.js +31 -11
- package/esm/plugin/components/tooltip-handler/utils/attribute.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/common.d.ts +1 -12
- package/esm/plugin/components/tooltip-handler/utils/common.js +3 -31
- package/esm/plugin/components/tooltip-handler/utils/common.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/style.d.ts +18 -0
- package/esm/plugin/components/tooltip-handler/utils/style.js +80 -0
- package/esm/plugin/components/tooltip-handler/utils/style.js.map +1 -0
- package/esm/plugin/components/tooltip-handler/utils/svg.d.ts +2 -0
- package/esm/plugin/components/tooltip-handler/utils/svg.js +42 -0
- package/esm/plugin/components/tooltip-handler/utils/svg.js.map +1 -0
- package/esm/series/base/base-series.d.ts +22 -6
- package/esm/series/base/base-series.js +33 -23
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/interface/type.d.ts +4 -2
- package/esm/series/interface/type.js +4 -2
- package/esm/series/interface/type.js.map +1 -1
- package/esm/series/pictogram/constant.d.ts +2 -0
- package/esm/series/pictogram/constant.js +9 -0
- package/esm/series/pictogram/constant.js.map +1 -0
- package/esm/series/pictogram/interface.d.ts +15 -0
- package/esm/series/pictogram/interface.js.map +1 -0
- package/esm/series/pictogram/pictogram-transformer.d.ts +5 -0
- package/esm/series/pictogram/pictogram-transformer.js +19 -0
- package/esm/series/pictogram/pictogram-transformer.js.map +1 -0
- package/esm/series/pictogram/pictogram.d.ts +77 -0
- package/esm/series/pictogram/pictogram.js +329 -0
- package/esm/series/pictogram/pictogram.js.map +1 -0
- package/esm/series/pictogram/svg-source.d.ts +7 -0
- package/esm/series/pictogram/svg-source.js +35 -0
- package/esm/series/pictogram/svg-source.js.map +1 -0
- package/esm/series/pictogram/tooltip-helper.d.ts +9 -0
- package/esm/series/pictogram/tooltip-helper.js +18 -0
- package/esm/series/pictogram/tooltip-helper.js.map +1 -0
- package/esm/series/sankey/interface.d.ts +1 -0
- package/esm/series/sankey/interface.js.map +1 -1
- package/esm/series/sankey/sankey.js +4 -0
- package/esm/series/sankey/sankey.js.map +1 -1
- package/esm/typings/spec/common.d.ts +1 -0
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/typings/tooltip/common.d.ts +3 -1
- package/esm/typings/tooltip/common.js.map +1 -1
- package/package.json +15 -15
- package/cjs/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/canvas/index.d.ts +0 -1
- package/cjs/plugin/components/tooltip-handler/canvas/index.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/constant.d.ts +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/constant.js +0 -6
- package/cjs/plugin/components/tooltip-handler/dom/constant.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js +0 -98
- package/cjs/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/index.d.ts +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/index.js +0 -21
- package/cjs/plugin/components/tooltip-handler/dom/index.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/interface.d.ts +0 -58
- package/cjs/plugin/components/tooltip-handler/dom/interface.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/base-tooltip-model.d.ts +0 -25
- package/cjs/plugin/components/tooltip-handler/dom/model/base-tooltip-model.js +0 -73
- package/cjs/plugin/components/tooltip-handler/dom/model/base-tooltip-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/content-column-model.d.ts +0 -23
- package/cjs/plugin/components/tooltip-handler/dom/model/content-column-model.js +0 -126
- package/cjs/plugin/components/tooltip-handler/dom/model/content-column-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/content-model.d.ts +0 -14
- package/cjs/plugin/components/tooltip-handler/dom/model/content-model.js +0 -54
- package/cjs/plugin/components/tooltip-handler/dom/model/content-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/interface.d.ts +0 -10
- package/cjs/plugin/components/tooltip-handler/dom/model/interface.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/shape-model.d.ts +0 -23
- package/cjs/plugin/components/tooltip-handler/dom/model/shape-model.js +0 -69
- package/cjs/plugin/components/tooltip-handler/dom/model/shape-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/style-constants.d.ts +0 -7
- package/cjs/plugin/components/tooltip-handler/dom/model/style-constants.js +0 -34
- package/cjs/plugin/components/tooltip-handler/dom/model/style-constants.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/text-model.d.ts +0 -5
- package/cjs/plugin/components/tooltip-handler/dom/model/text-model.js +0 -21
- package/cjs/plugin/components/tooltip-handler/dom/model/text-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/title-model.d.ts +0 -15
- package/cjs/plugin/components/tooltip-handler/dom/model/title-model.js +0 -66
- package/cjs/plugin/components/tooltip-handler/dom/model/title-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/tooltip-model.d.ts +0 -21
- package/cjs/plugin/components/tooltip-handler/dom/model/tooltip-model.js +0 -79
- package/cjs/plugin/components/tooltip-handler/dom/model/tooltip-model.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/utils/common.d.ts +0 -3
- package/cjs/plugin/components/tooltip-handler/dom/utils/common.js +0 -33
- package/cjs/plugin/components/tooltip-handler/dom/utils/common.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/utils/index.d.ts +0 -2
- package/cjs/plugin/components/tooltip-handler/dom/utils/index.js +0 -21
- package/cjs/plugin/components/tooltip-handler/dom/utils/index.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/utils/style.d.ts +0 -4
- package/cjs/plugin/components/tooltip-handler/dom/utils/style.js +0 -91
- package/cjs/plugin/components/tooltip-handler/dom/utils/style.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/interface/common.d.ts +0 -4
- package/cjs/plugin/components/tooltip-handler/interface/common.js +0 -6
- package/cjs/plugin/components/tooltip-handler/interface/common.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/interface/style.d.ts +0 -13
- package/cjs/plugin/components/tooltip-handler/interface/style.js +0 -6
- package/cjs/plugin/components/tooltip-handler/interface/style.js.map +0 -1
- package/cjs/plugin/components/tooltip-handler/utils/index.d.ts +0 -3
- package/cjs/plugin/components/tooltip-handler/utils/index.js +0 -22
- package/cjs/plugin/components/tooltip-handler/utils/index.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/canvas/index.d.ts +0 -1
- package/esm/plugin/components/tooltip-handler/canvas/index.js +0 -2
- package/esm/plugin/components/tooltip-handler/canvas/index.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/constant.d.ts +0 -1
- package/esm/plugin/components/tooltip-handler/dom/constant.js +0 -2
- package/esm/plugin/components/tooltip-handler/dom/constant.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js +0 -104
- package/esm/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/index.d.ts +0 -1
- package/esm/plugin/components/tooltip-handler/dom/index.js +0 -2
- package/esm/plugin/components/tooltip-handler/dom/index.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/interface.d.ts +0 -58
- package/esm/plugin/components/tooltip-handler/dom/interface.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/base-tooltip-model.d.ts +0 -25
- package/esm/plugin/components/tooltip-handler/dom/model/base-tooltip-model.js +0 -67
- package/esm/plugin/components/tooltip-handler/dom/model/base-tooltip-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/content-column-model.d.ts +0 -23
- package/esm/plugin/components/tooltip-handler/dom/model/content-column-model.js +0 -130
- package/esm/plugin/components/tooltip-handler/dom/model/content-column-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/content-model.d.ts +0 -14
- package/esm/plugin/components/tooltip-handler/dom/model/content-model.js +0 -52
- package/esm/plugin/components/tooltip-handler/dom/model/content-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/interface.d.ts +0 -10
- package/esm/plugin/components/tooltip-handler/dom/model/interface.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/shape-model.d.ts +0 -23
- package/esm/plugin/components/tooltip-handler/dom/model/shape-model.js +0 -66
- package/esm/plugin/components/tooltip-handler/dom/model/shape-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/style-constants.d.ts +0 -7
- package/esm/plugin/components/tooltip-handler/dom/model/style-constants.js +0 -41
- package/esm/plugin/components/tooltip-handler/dom/model/style-constants.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/text-model.d.ts +0 -5
- package/esm/plugin/components/tooltip-handler/dom/model/text-model.js +0 -13
- package/esm/plugin/components/tooltip-handler/dom/model/text-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/title-model.d.ts +0 -15
- package/esm/plugin/components/tooltip-handler/dom/model/title-model.js +0 -65
- package/esm/plugin/components/tooltip-handler/dom/model/title-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/model/tooltip-model.d.ts +0 -21
- package/esm/plugin/components/tooltip-handler/dom/model/tooltip-model.js +0 -82
- package/esm/plugin/components/tooltip-handler/dom/model/tooltip-model.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/utils/common.d.ts +0 -3
- package/esm/plugin/components/tooltip-handler/dom/utils/common.js +0 -22
- package/esm/plugin/components/tooltip-handler/dom/utils/common.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/utils/index.d.ts +0 -2
- package/esm/plugin/components/tooltip-handler/dom/utils/index.js +0 -4
- package/esm/plugin/components/tooltip-handler/dom/utils/index.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/dom/utils/style.d.ts +0 -4
- package/esm/plugin/components/tooltip-handler/dom/utils/style.js +0 -87
- package/esm/plugin/components/tooltip-handler/dom/utils/style.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/interface/common.d.ts +0 -4
- package/esm/plugin/components/tooltip-handler/interface/common.js +0 -2
- package/esm/plugin/components/tooltip-handler/interface/common.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/interface/style.d.ts +0 -13
- package/esm/plugin/components/tooltip-handler/interface/style.js +0 -2
- package/esm/plugin/components/tooltip-handler/interface/style.js.map +0 -1
- package/esm/plugin/components/tooltip-handler/utils/index.d.ts +0 -3
- package/esm/plugin/components/tooltip-handler/utils/index.js +0 -6
- package/esm/plugin/components/tooltip-handler/utils/index.js.map +0 -1
- /package/cjs/{plugin/components/tooltip-handler/dom → chart/pictogram}/interface.js +0 -0
- /package/cjs/{plugin/components/tooltip-handler/dom/model → series/pictogram}/interface.js +0 -0
- /package/esm/{plugin/components/tooltip-handler/dom → chart/pictogram}/interface.js +0 -0
- /package/esm/{plugin/components/tooltip-handler/dom/model → series/pictogram}/interface.js +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { DataView } from '@visactor/vdataset';
|
|
2
|
+
export declare const graphicAttributeTransform: {
|
|
3
|
+
group: (attributes: Record<string, any>) => {
|
|
4
|
+
visibleAll: boolean;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
fillStrokeOrder: boolean;
|
|
8
|
+
fill: any;
|
|
9
|
+
lineWidth: number;
|
|
10
|
+
stroke: any;
|
|
11
|
+
};
|
|
12
|
+
rule: (attributes: Record<string, any>) => {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
x1: number;
|
|
16
|
+
y1: number;
|
|
17
|
+
fillStrokeOrder: boolean;
|
|
18
|
+
fill: any;
|
|
19
|
+
lineWidth: number;
|
|
20
|
+
stroke: any;
|
|
21
|
+
};
|
|
22
|
+
rect: (attributes: Record<string, any>) => {
|
|
23
|
+
fill: any;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
fillStrokeOrder: boolean;
|
|
29
|
+
lineWidth: number;
|
|
30
|
+
stroke: any;
|
|
31
|
+
};
|
|
32
|
+
polygon: (attributes: Record<string, any>) => {
|
|
33
|
+
fill: any;
|
|
34
|
+
points: any;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
fillStrokeOrder: boolean;
|
|
38
|
+
lineWidth: number;
|
|
39
|
+
stroke: any;
|
|
40
|
+
};
|
|
41
|
+
line: (attributes: Record<string, any>) => {
|
|
42
|
+
points: any;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
fillStrokeOrder: boolean;
|
|
46
|
+
fill: any;
|
|
47
|
+
lineWidth: number;
|
|
48
|
+
stroke: any;
|
|
49
|
+
};
|
|
50
|
+
path: (attributes: Record<string, any>) => {
|
|
51
|
+
path: any;
|
|
52
|
+
fillStrokeOrder: boolean;
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
fill: any;
|
|
56
|
+
lineWidth: number;
|
|
57
|
+
stroke: any;
|
|
58
|
+
};
|
|
59
|
+
arc: (attributes: Record<string, any>) => {
|
|
60
|
+
outerRadius: any;
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
startAngle: number;
|
|
64
|
+
endAngle: number;
|
|
65
|
+
scaleX: number;
|
|
66
|
+
fill: any;
|
|
67
|
+
fillStrokeOrder: boolean;
|
|
68
|
+
lineWidth: number;
|
|
69
|
+
stroke: any;
|
|
70
|
+
};
|
|
71
|
+
text: (attributes: Record<string, any>, value: string) => {
|
|
72
|
+
text: string;
|
|
73
|
+
textAlign: any;
|
|
74
|
+
textBaseLine: any;
|
|
75
|
+
anchor: number[];
|
|
76
|
+
fill: any;
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
fillStrokeOrder: boolean;
|
|
80
|
+
lineWidth: number;
|
|
81
|
+
stroke: any;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export declare const pictogram: (data: DataView[]) => {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.pictogram = exports.graphicAttributeTransform = void 0;
|
|
6
|
+
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), data_1 = require("../../constant/data"), util_1 = require("../../util");
|
|
8
|
+
|
|
9
|
+
function isValidStrokeOrFill(attr) {
|
|
10
|
+
var _a;
|
|
11
|
+
return (0, vutils_1.isValid)(attr) && "none" !== attr && !(null === (_a = attr.includes) || void 0 === _a ? void 0 : _a.call(attr, "url"));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getLineWidth = attributes => {
|
|
15
|
+
const strokeWidth = parseFloat(attributes.strokeWidth);
|
|
16
|
+
if (!isNaN(strokeWidth)) return strokeWidth;
|
|
17
|
+
const stroke = attributes.stroke;
|
|
18
|
+
return stroke && isValidStrokeOrFill(stroke) ? 1 : 0;
|
|
19
|
+
}, getFill = (attributes, defaultFill) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const fill = null !== (_a = attributes.fill) && void 0 !== _a ? _a : defaultFill;
|
|
22
|
+
return fill && isValidStrokeOrFill(fill) ? fill : void 0;
|
|
23
|
+
}, getStroke = (attributes, defaultStroke) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const stroke = null !== (_a = attributes.stroke) && void 0 !== _a ? _a : defaultStroke;
|
|
26
|
+
return !(!stroke || !isValidStrokeOrFill(stroke)) && stroke;
|
|
27
|
+
}, commonAttributes = attributes => Object.assign(Object.assign({}, attributes), {
|
|
28
|
+
x: parseFloat(attributes.x) || void 0,
|
|
29
|
+
y: parseFloat(attributes.y) || void 0,
|
|
30
|
+
fillStrokeOrder: !1,
|
|
31
|
+
fill: getFill(attributes),
|
|
32
|
+
lineWidth: getLineWidth(attributes),
|
|
33
|
+
stroke: getStroke(attributes)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.graphicAttributeTransform = {
|
|
37
|
+
group: attributes => {
|
|
38
|
+
const common = commonAttributes(attributes);
|
|
39
|
+
return Object.assign(Object.assign({}, common), {
|
|
40
|
+
visibleAll: !1 !== common.visible
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
rule: attributes => Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
44
|
+
x: parseFloat(attributes.x1),
|
|
45
|
+
y: parseFloat(attributes.y1),
|
|
46
|
+
x1: parseFloat(attributes.x2),
|
|
47
|
+
y1: parseFloat(attributes.y2)
|
|
48
|
+
}),
|
|
49
|
+
rect: attributes => Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
50
|
+
fill: getFill(attributes, "#000"),
|
|
51
|
+
width: parseFloat(attributes.width),
|
|
52
|
+
height: parseFloat(attributes.height)
|
|
53
|
+
}),
|
|
54
|
+
polygon: attributes => Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
55
|
+
fill: getFill(attributes, "#000"),
|
|
56
|
+
points: attributes.points.trim().split(/\s+/).map((pair => {
|
|
57
|
+
const [x, y] = pair.split(",").map(Number);
|
|
58
|
+
return {
|
|
59
|
+
x: x,
|
|
60
|
+
y: y
|
|
61
|
+
};
|
|
62
|
+
}))
|
|
63
|
+
}),
|
|
64
|
+
line: attributes => Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
65
|
+
points: attributes.points.trim().split(/\s+/).map((pair => {
|
|
66
|
+
const [x, y] = pair.split(",").map(Number);
|
|
67
|
+
return {
|
|
68
|
+
x: x,
|
|
69
|
+
y: y
|
|
70
|
+
};
|
|
71
|
+
}))
|
|
72
|
+
}),
|
|
73
|
+
path: attributes => Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
74
|
+
path: attributes.d,
|
|
75
|
+
fillStrokeOrder: !1
|
|
76
|
+
}),
|
|
77
|
+
arc: attributes => {
|
|
78
|
+
var _a;
|
|
79
|
+
return Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
80
|
+
outerRadius: null !== (_a = attributes.r) && void 0 !== _a ? _a : attributes.ry,
|
|
81
|
+
x: parseFloat(attributes.cx),
|
|
82
|
+
y: parseFloat(attributes.cy),
|
|
83
|
+
startAngle: 0,
|
|
84
|
+
endAngle: 2 * Math.PI,
|
|
85
|
+
scaleX: parseFloat(attributes.rx) / parseFloat(attributes.ry) || 1,
|
|
86
|
+
fill: getFill(attributes, "#000")
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
text: (attributes, value) => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
return Object.assign(Object.assign({}, commonAttributes(attributes)), {
|
|
92
|
+
text: value,
|
|
93
|
+
textAlign: null !== (_a = attributes.textAlign) && void 0 !== _a ? _a : "left",
|
|
94
|
+
textBaseLine: null !== (_b = attributes.textAnchor) && void 0 !== _b ? _b : "middle",
|
|
95
|
+
anchor: [ 0, 0 ],
|
|
96
|
+
fill: getFill(attributes, "#000")
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const pictogram = data => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
if (!data || !data[0]) return {};
|
|
104
|
+
const {elements: elements} = data[0].latestData;
|
|
105
|
+
if (elements && elements.length) {
|
|
106
|
+
elements.forEach(((el, index) => {
|
|
107
|
+
var _a;
|
|
108
|
+
el[data_1.DEFAULT_DATA_INDEX] = index, el._uniqueId = `${el.id}-${index}`, el.data = void 0;
|
|
109
|
+
const {graphicType: type, transform: transform} = el;
|
|
110
|
+
let finalAttributes = {
|
|
111
|
+
visible: "hidden" !== el.attributes.visibility && "collapse" !== el.attributes.visibility
|
|
112
|
+
};
|
|
113
|
+
"text" === el.graphicType ? (0, vutils_1.merge)(finalAttributes, el._inheritStyle, null === (_a = el.parent) || void 0 === _a ? void 0 : _a._textGroupStyle, el.attributes) : "group" !== el.graphicType && (0,
|
|
114
|
+
vutils_1.merge)(finalAttributes, el._inheritStyle, el.attributes), exports.graphicAttributeTransform[type] ? el._finalAttributes = exports.graphicAttributeTransform[type](finalAttributes, el.value) : el._finalAttributes = finalAttributes,
|
|
115
|
+
transform && (el._finalAttributes.postMatrix = Object.assign({}, transform));
|
|
116
|
+
}));
|
|
117
|
+
const texts = elements.filter((el => "text" === el.tagName));
|
|
118
|
+
for (let i = 0; i < texts.length; i++) {
|
|
119
|
+
const textId = texts[i]._uniqueId, children = elements.filter((el => {
|
|
120
|
+
let result = !1, parent = el.parent;
|
|
121
|
+
for (;parent; ) {
|
|
122
|
+
if (parent._uniqueId === textId) {
|
|
123
|
+
result = !0;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
parent = parent.parent;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}));
|
|
130
|
+
if (children && children.length) {
|
|
131
|
+
let startX = null !== (_b = null === (_a = texts[i]._textGroupStyle) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0, curX = startX;
|
|
132
|
+
for (let j = 0; j < children.length; j++) {
|
|
133
|
+
const currentChild = children[j];
|
|
134
|
+
if ("group" === currentChild.graphicType) curX = startX; else if (currentChild.value && void 0 === currentChild.parent._textGroupStyle.x) {
|
|
135
|
+
const lastText = children.slice(0, j).reverse().find((c => "text" === c.graphicType && c.value));
|
|
136
|
+
if (lastText) {
|
|
137
|
+
curX += (0, util_1.measureText)(lastText.value, lastText._finalAttributes).width;
|
|
138
|
+
}
|
|
139
|
+
currentChild._finalAttributes.x = curX;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return elements;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.pictogram = pictogram;
|
|
149
|
+
//# sourceMappingURL=pictogram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data/transforms/pictogram.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAElD,8CAAyD;AACzD,qCAAyC;AAEzC,SAAS,mBAAmB,CAAC,IAAS;;IACpC,OAAO,IAAA,gBAAO,EAAC,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,qDAAG,KAAK,CAAC,CAAA,CAAC;AACrE,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,UAAe,EAAE,EAAE;IACvC,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,CAAC;IAE5C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,MAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,UAAe,EAAE,WAAoB,EAAE,EAAE;;IACxD,MAAM,IAAI,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EAAE;4BACvD,MAAM,QAAQ,GAAG,QAAQ;iCACtB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;iCACX,OAAO,EAAE;iCACT,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;4BAClD,IAAI,QAAQ,EAAE;gCACZ,MAAM,KAAK,GAAG,IAAA,kBAAW,EAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC;gCAC3E,IAAI,IAAI,KAAK,CAAC;6BACf;4BACD,YAAY,CAAC,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;yBACxC;qBACF;iBACF;aACF;SACF;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAlFW,QAAA,SAAS,aAkFpB","file":"pictogram.js","sourcesContent":["import { isValid, merge } from '@visactor/vutils';\nimport type { DataView, SVGParserResult } from '@visactor/vdataset';\nimport { DEFAULT_DATA_INDEX } from '../../constant/data';\nimport { measureText } from '../../util';\n\nfunction isValidStrokeOrFill(attr: any) {\n return isValid(attr) && attr !== 'none' && !attr.includes?.('url');\n}\n\nconst getLineWidth = (attributes: any) => {\n const strokeWidth = parseFloat(attributes['strokeWidth']);\n if (!isNaN(strokeWidth)) return strokeWidth;\n\n const stroke = attributes['stroke'];\n return stroke && isValidStrokeOrFill(stroke) ? 1 : 0;\n};\n\nconst getFill = (attributes: any, defaultFill?: string) => {\n const fill = attributes['fill'] ?? defaultFill;\n return fill && isValidStrokeOrFill(fill) ? fill : undefined;\n};\n\nconst getStroke = (attributes: any, defaultStroke?: string) => {\n const stroke = attributes['stroke'] ?? defaultStroke;\n return stroke && isValidStrokeOrFill(stroke) ? stroke : false;\n};\n\nconst commonAttributes = (attributes: Record<string, any>) => {\n return {\n ...attributes,\n x: parseFloat(attributes.x) || undefined,\n y: parseFloat(attributes.y) || undefined,\n fillStrokeOrder: false,\n fill: getFill(attributes),\n lineWidth: getLineWidth(attributes),\n stroke: getStroke(attributes)\n };\n};\n\nexport const graphicAttributeTransform = {\n group: (attributes: Record<string, any>) => {\n const common = commonAttributes(attributes);\n return {\n ...common,\n visibleAll: common['visible'] !== false\n };\n },\n rule: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n x: parseFloat(attributes.x1),\n y: parseFloat(attributes.y1),\n x1: parseFloat(attributes.x2),\n y1: parseFloat(attributes.y2)\n };\n },\n rect: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n // rect 在 chrome 下有默认黑色填充,这里保持效果一致\n fill: getFill(attributes, '#000'),\n width: parseFloat(attributes.width),\n height: parseFloat(attributes.height)\n };\n },\n polygon: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n // rect 在 chrome 下有默认黑色填充,这里保持效果一致\n fill: getFill(attributes, '#000'),\n points: attributes.points\n .trim()\n .split(/\\s+/)\n .map((pair: string) => {\n const [x, y] = pair.split(',').map(Number);\n return { x, y };\n })\n };\n },\n line: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n points: attributes.points\n .trim()\n .split(/\\s+/)\n .map((pair: string) => {\n const [x, y] = pair.split(',').map(Number);\n return { x, y };\n })\n };\n },\n path: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n path: attributes.d,\n fillStrokeOrder: false\n };\n },\n arc: (attributes: Record<string, any>) => {\n return {\n ...commonAttributes(attributes),\n outerRadius: attributes.r ?? attributes.ry,\n x: parseFloat(attributes.cx),\n y: parseFloat(attributes.cy),\n startAngle: 0,\n endAngle: Math.PI * 2,\n scaleX: parseFloat(attributes.rx) / parseFloat(attributes.ry) || 1,\n fill: getFill(attributes, '#000')\n };\n },\n text: (attributes: Record<string, any>, value: string) => {\n return {\n ...commonAttributes(attributes),\n text: value,\n textAlign: attributes.textAlign ?? 'left',\n textBaseLine: attributes.textAnchor ?? 'middle',\n anchor: [0, 0],\n fill: getFill(attributes, '#000')\n };\n }\n};\n\nexport const pictogram = (data: DataView[]) => {\n if (!data || !data[0]) {\n return {};\n }\n const { elements } = data[0].latestData as SVGParserResult;\n\n // 处理最终属性\n if (elements && elements.length) {\n // TODO: type\n // elements.forEach((el: SVGParsedElementExtend, index: number) => {\n elements.forEach((el: any, index: number) => {\n el[DEFAULT_DATA_INDEX] = index;\n el._uniqueId = `${el.id}-${index}`;\n el.data = undefined;\n\n const { graphicType: type, transform } = el;\n\n let finalAttributes = {\n visible: el.attributes.visibility !== 'hidden' && el.attributes.visibility !== 'collapse'\n };\n\n if (el.graphicType === 'text') {\n merge(finalAttributes, el._inheritStyle, el.parent?._textGroupStyle, el.attributes);\n } else if (el.graphicType !== 'group') {\n merge(finalAttributes, el._inheritStyle, el.attributes);\n }\n\n if (graphicAttributeTransform[type]) {\n el._finalAttributes = graphicAttributeTransform[type](finalAttributes, el.value);\n } else {\n el._finalAttributes = finalAttributes;\n }\n\n if (transform) {\n el._finalAttributes.postMatrix = { ...transform };\n }\n });\n\n // 处理文字布局\n const texts = elements.filter(el => el.tagName === 'text');\n for (let i = 0; i < texts.length; i++) {\n const textId = texts[i]._uniqueId;\n const children = elements.filter(el => {\n let result = false;\n let parent = el.parent;\n while (parent) {\n if (parent._uniqueId === textId) {\n result = true;\n break;\n }\n parent = parent.parent;\n }\n return result;\n });\n\n if (children && children.length) {\n let startX = texts[i]._textGroupStyle?.x ?? 0;\n let curX = startX;\n\n for (let j = 0; j < children.length; j++) {\n const currentChild = children[j];\n if (currentChild.graphicType === 'group') {\n curX = startX;\n } else if (currentChild.value) {\n if (currentChild.parent._textGroupStyle.x === undefined) {\n const lastText = children\n .slice(0, j)\n .reverse()\n .find(c => c.graphicType === 'text' && c.value);\n if (lastText) {\n const width = measureText(lastText.value, lastText._finalAttributes).width;\n curX += width;\n }\n currentChild._finalAttributes.x = curX;\n }\n }\n }\n }\n }\n }\n\n return elements;\n};\n"]}
|
package/cjs/mark/group.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface IGroupMark extends IMarkRaw<IGroupMarkSpec> {
|
|
|
11
11
|
getMarks: () => IMark[];
|
|
12
12
|
getMarkInType: (type: MarkType) => IMark[];
|
|
13
13
|
getMarkInId: (id: number) => IMark | undefined;
|
|
14
|
-
getMarkInName: (name: string) => IMark
|
|
14
|
+
getMarkInName: (name: string) => IMark[];
|
|
15
15
|
}
|
|
16
16
|
export declare class GroupMark extends BaseMark<IGroupMarkSpec> implements IGroupMark {
|
|
17
17
|
static readonly type = MarkTypeEnum.group;
|
|
@@ -26,7 +26,8 @@ export declare class GroupMark extends BaseMark<IGroupMarkSpec> implements IGrou
|
|
|
26
26
|
removeMark(mark: IMark): boolean;
|
|
27
27
|
getMarkInType(type: MarkType): IMark[];
|
|
28
28
|
getMarkInId(id: number): IMark;
|
|
29
|
-
|
|
29
|
+
getMarkInUserId(id: string | number): IMark;
|
|
30
|
+
getMarkInName(name: string): IMark[];
|
|
30
31
|
protected _compileProduct(option?: IMarkCompileOption): void;
|
|
31
32
|
}
|
|
32
33
|
export declare const registerGroupMark: () => void;
|
package/cjs/mark/group.js
CHANGED
|
@@ -17,7 +17,7 @@ class GroupMark extends base_mark_1.BaseMark {
|
|
|
17
17
|
return Object.assign({}, super._getDefaultStyle());
|
|
18
18
|
}
|
|
19
19
|
isMarkExist(mark) {
|
|
20
|
-
return void 0 !== this._marks.find((m => m.id === mark.id
|
|
20
|
+
return void 0 !== this._marks.find((m => m.id === mark.id));
|
|
21
21
|
}
|
|
22
22
|
addMark(mark) {
|
|
23
23
|
return this.isMarkExist(mark) ? ((0, debug_1.warn)("Mark already exists, add mark failed."),
|
|
@@ -34,8 +34,18 @@ class GroupMark extends base_mark_1.BaseMark {
|
|
|
34
34
|
getMarkInId(id) {
|
|
35
35
|
return this._marks.find((m => m.id === id));
|
|
36
36
|
}
|
|
37
|
+
getMarkInUserId(id) {
|
|
38
|
+
let result;
|
|
39
|
+
if (this._marks.forEach((m => {
|
|
40
|
+
m.getUserId() === id && (result = m);
|
|
41
|
+
})), !result) for (let i = 0; i < this._marks.length; i++) {
|
|
42
|
+
const mark = this._marks[i];
|
|
43
|
+
if ("group" === mark.type && (result = mark.getMarkInUserId(id)), result) break;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
37
47
|
getMarkInName(name) {
|
|
38
|
-
return this._marks.
|
|
48
|
+
return this._marks.filter((m => m.name === name));
|
|
39
49
|
}
|
|
40
50
|
_compileProduct(option) {
|
|
41
51
|
super._compileProduct(option), this._product.configure({
|
package/cjs/mark/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mark/group.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAG5C,yCAAqC;AAErC,gDAA4C;AAM5C,2DAA+D;AAkB/D,MAAa,SAAU,SAAQ,oBAAwB;IAAvD;;QAEW,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QACrB,WAAM,GAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/mark/group.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAG5C,yCAAqC;AAErC,gDAA4C;AAM5C,2DAA+D;AAkB/D,MAAa,SAAU,SAAQ,oBAAwB;IAAvD;;QAEW,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QACrB,WAAM,GAAY,EAAE,CAAC;IA+FjC,CAAC;IA9FC,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAKS,gBAAgB;QACxB,MAAM,YAAY,qBACb,KAAK,CAAC,gBAAgB,EAAE,CAE5B,CAAC;QACF,OAAO,YAAY,CAAC;IACtB,CAAC;IAES,WAAW,CAAC,IAAW;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC;IAC/D,CAAC;IAED,OAAO,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EAAE,SAAS,CAAC,CAAC;AAClD,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B","file":"group.js","sourcesContent":["import { Factory } from './../core/factory';\nimport type { Maybe } from '../typings';\n// eslint-disable-next-line no-duplicate-imports\nimport { warn } from '../util/debug';\nimport type { IGroupMarkSpec } from '../typings/visual';\nimport { BaseMark } from './base/base-mark';\nimport type { IMark, IMarkRaw, IMarkStyle, MarkType } from './interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { MarkTypeEnum } from './interface/type';\nimport type { IGroupMark as IVGrammarGroupMark } from '@visactor/vgrammar-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { registerGroupGraphic } from '@visactor/vgrammar-core';\nimport type { IMarkCompileOption } from '../compile/mark';\n\nexport interface IGroupMark extends IMarkRaw<IGroupMarkSpec> {\n // groupMark的zIndex只能配在外层,encode里不生效,且无法写成signal\n // {type:'group', zIndex: 100} ✅\n // {type:'group', encode:{enter:{zIndex:{value:100}}}} ❌\n // {type:'group', zIndex: {signal: }} ❌\n\n addMark: (m: IMark) => boolean;\n removeMark: (m: IMark) => boolean;\n // TODO: 这里可能会出现mark嵌套的问题\n getMarks: () => IMark[];\n getMarkInType: (type: MarkType) => IMark[];\n getMarkInId: (id: number) => IMark | undefined;\n getMarkInName: (name: string) => IMark[];\n}\n\nexport class GroupMark extends BaseMark<IGroupMarkSpec> implements IGroupMark {\n static readonly type = MarkTypeEnum.group;\n readonly type = GroupMark.type;\n protected _marks: IMark[] = [];\n getMarks(): IMark[] {\n return this._marks;\n }\n\n protected declare _product: Maybe<IVGrammarGroupMark>;\n declare getProduct: () => Maybe<IVGrammarGroupMark>;\n\n protected _getDefaultStyle() {\n const defaultStyle: IMarkStyle<IGroupMarkSpec> = {\n ...super._getDefaultStyle()\n // clip: false\n };\n return defaultStyle;\n }\n\n protected isMarkExist(mark: IMark): boolean {\n return this._marks.find(m => m.id === mark.id) !== undefined;\n }\n\n addMark(mark: IMark): boolean {\n if (this.isMarkExist(mark)) {\n warn('Mark already exists, add mark failed.');\n return false;\n }\n\n this._marks.push(mark);\n return true;\n }\n\n removeMark(mark: IMark): boolean {\n const index = this._marks.findIndex(m => m.id === mark.id || m.name === mark.name);\n if (index === -1) {\n warn('Mark does not exists, removeMark failed.');\n return false;\n }\n this._marks.splice(index, 1);\n return true;\n }\n\n getMarkInType(type: MarkType) {\n return this._marks.filter(m => m.type === type);\n }\n\n getMarkInId(id: number) {\n return this._marks.find(m => m.id === id);\n }\n\n getMarkInUserId(id: string | number) {\n let result: IMark | undefined;\n this._marks.forEach(m => {\n if (m.getUserId() === id) {\n result = m;\n }\n });\n\n if (!result) {\n for (let i = 0; i < this._marks.length; i++) {\n const mark = this._marks[i];\n if (mark.type === 'group') {\n result = (mark as GroupMark).getMarkInUserId(id);\n }\n if (result) {\n break;\n }\n }\n }\n\n return result;\n }\n\n getMarkInName(name: string) {\n return this._marks.filter(m => m.name === name);\n }\n\n protected _compileProduct(option?: IMarkCompileOption): void {\n // 编译自身\n super._compileProduct(option);\n\n // 设置zIndex\n this._product.configure({\n zIndex: this._markConfig.zIndex\n });\n\n // 编译子元素\n if (!option?.ignoreChildren) {\n this.getMarks().forEach(mark => {\n // TODO: 如果语法元素已创建,先删除再重新指定父结点生成。vgrammar 是否可以动态指定 mark 父结点?\n if (mark.getProduct()) {\n mark.removeProduct();\n }\n mark.compile({ group: this._product });\n });\n }\n }\n}\n\nexport const registerGroupMark = () => {\n registerGroupGraphic();\n Factory.registerMark(GroupMark.type, GroupMark);\n};\n"]}
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
11
11
|
MarkTypeEnum.area = "area", MarkTypeEnum.arc = "arc", MarkTypeEnum.arc3d = "arc3d",
|
|
12
12
|
MarkTypeEnum.polygon = "polygon", MarkTypeEnum.pyramid3d = "pyramid3d", MarkTypeEnum.boxPlot = "boxPlot",
|
|
13
13
|
MarkTypeEnum.linkPath = "linkPath", MarkTypeEnum.cell = "cell", MarkTypeEnum.ripple = "ripple",
|
|
14
|
-
MarkTypeEnum.liquid = "liquid", MarkTypeEnum.component = "component", MarkTypeEnum.label = "label"
|
|
14
|
+
MarkTypeEnum.liquid = "liquid", MarkTypeEnum.component = "component", MarkTypeEnum.label = "label",
|
|
15
|
+
MarkTypeEnum.pictogram = "pictogram";
|
|
15
16
|
}(MarkTypeEnum = exports.MarkTypeEnum || (exports.MarkTypeEnum = {}));
|
|
16
17
|
//# sourceMappingURL=type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mark/interface/type.ts"],"names":[],"mappings":";;;AAEA,IAAkB,
|
|
1
|
+
{"version":3,"sources":["../src/mark/interface/type.ts"],"names":[],"mappings":";;;AAEA,IAAkB,YA0BjB;AA1BD,WAAkB,YAAY;IAC5B,+BAAe,CAAA;IAEf,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,2BAAW,CAAA;IACX,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IAEjB,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IAEf,uCAAuB,CAAA;AACzB,CAAC,EA1BiB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA0B7B","file":"type.js","sourcesContent":["export type MarkType = keyof typeof MarkTypeEnum | string;\n\nexport const enum MarkTypeEnum {\n group = 'group',\n\n symbol = 'symbol',\n rule = 'rule',\n line = 'line',\n text = 'text',\n rect = 'rect',\n rect3d = 'rect3d',\n image = 'image',\n path = 'path',\n area = 'area',\n arc = 'arc',\n arc3d = 'arc3d',\n polygon = 'polygon',\n pyramid3d = 'pyramid3d',\n boxPlot = 'boxPlot',\n linkPath = 'linkPath',\n cell = 'cell',\n ripple = 'ripple',\n liquid = 'liquid',\n\n component = 'component',\n label = 'label',\n\n pictogram = 'pictogram'\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Options } from './constants';
|
|
2
1
|
import type { Maybe, RenderMode } from '../../../typings';
|
|
3
2
|
import type { TooltipData, ITooltipActual, TooltipActiveType, ITooltipHandler, ITooltipPositionActual } from '../../../typings/tooltip';
|
|
4
3
|
import type { IGroup } from '@visactor/vrender-core';
|
|
@@ -9,7 +8,7 @@ import type { ITooltipSpec, Tooltip, TooltipHandlerParams } from '../../../compo
|
|
|
9
8
|
import { TooltipResult } from '../../../component/tooltip';
|
|
10
9
|
import type { IComponentPlugin, IComponentPluginService } from '../interface';
|
|
11
10
|
import { BasePlugin } from '../../base/base-plugin';
|
|
12
|
-
import type {
|
|
11
|
+
import type { ITooltipHandlerOptions } from './interface';
|
|
13
12
|
type ChangeTooltipFunc = (visible: boolean, params: TooltipHandlerParams, data?: TooltipData) => TooltipResult;
|
|
14
13
|
type ChangeTooltipPositionFunc = (params: TooltipHandlerParams, data: TooltipData) => TooltipResult;
|
|
15
14
|
export declare abstract class BaseTooltipHandler extends BasePlugin implements ITooltipHandler, IComponentPlugin {
|
|
@@ -17,12 +16,11 @@ export declare abstract class BaseTooltipHandler extends BasePlugin implements I
|
|
|
17
16
|
static readonly specKey = "tooltip";
|
|
18
17
|
readonly type: string;
|
|
19
18
|
protected _visible: boolean;
|
|
20
|
-
protected _option:
|
|
19
|
+
protected _option: ITooltipHandlerOptions;
|
|
21
20
|
protected _chartOption: IChartOption;
|
|
22
21
|
protected _env: RenderMode;
|
|
23
22
|
get env(): "desktop-browser" | "mobile-browser" | "node" | "worker" | "miniApp" | "wx" | "tt" | "harmony" | "desktop-miniApp" | "lynx";
|
|
24
23
|
protected _component: Tooltip;
|
|
25
|
-
protected _attributes?: ITooltipAttributes | null;
|
|
26
24
|
protected _chartContainer: Maybe<HTMLElement>;
|
|
27
25
|
protected _compiler: Compiler;
|
|
28
26
|
protected _container: Maybe<IGroup | HTMLElement>;
|
|
@@ -35,9 +33,9 @@ export declare abstract class BaseTooltipHandler extends BasePlugin implements I
|
|
|
35
33
|
release(): void;
|
|
36
34
|
protected abstract _updateTooltip(visible: boolean, params: TooltipHandlerParams): void;
|
|
37
35
|
protected abstract _removeTooltip(): void;
|
|
38
|
-
protected
|
|
36
|
+
protected abstract _getTooltipBoxSize(actualTooltip: ITooltipActual, changePositionOnly: boolean): IContainerSize | undefined;
|
|
37
|
+
protected _getDefaultOption(): ITooltipHandlerOptions;
|
|
39
38
|
protected _getActualTooltipPosition: (actualTooltip: ITooltipActual, params: TooltipHandlerParams, tooltipBoxSize: IContainerSize | undefined) => ITooltipPositionActual;
|
|
40
|
-
protected _getTooltipBoxSize(actualTooltip: ITooltipActual, changePositionOnly: boolean): IContainerSize | undefined;
|
|
41
39
|
protected _getParentElement(spec: ITooltipSpec): HTMLElement;
|
|
42
40
|
getTooltipContainer(): HTMLElement | IGroup;
|
|
43
41
|
protected _initFromSpec(): void;
|
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.BaseTooltipHandler = void 0;
|
|
6
6
|
|
|
7
|
-
const base_1 = require("../../../constant/base"), constants_1 = require("./constants"), env_1 = require("../../../util/env"), common_1 = require("./utils/common"), position_1 = require("./utils/position"), vutils_1 = require("@visactor/vutils"),
|
|
7
|
+
const base_1 = require("../../../constant/base"), constants_1 = require("./constants"), env_1 = require("../../../util/env"), common_1 = require("./utils/common"), position_1 = require("./utils/position"), vutils_1 = require("@visactor/vutils"), base_plugin_1 = require("../../base/base-plugin"), utils_1 = require("../../../component/tooltip/utils");
|
|
8
8
|
|
|
9
9
|
class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this._visible = !0, this.
|
|
12
|
-
this.showTooltip = (activeType, data, params) => {
|
|
11
|
+
super(...arguments), this._visible = !0, this._isReleased = !1, this.showTooltip = (activeType, data, params) => {
|
|
13
12
|
const {changePositionOnly: changePositionOnly} = params;
|
|
14
13
|
return changePositionOnly ? this.changeTooltipPosition(params, data) : this.changeTooltip(!0, params, data);
|
|
15
14
|
}, this.changeTooltip = (visible, params, data) => this._isReleased ? 1 : visible ? this.changeTooltipPosition(params, data) : (this._updateTooltip(!1, params),
|
|
@@ -165,24 +164,8 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
165
164
|
this._isReleased = !0);
|
|
166
165
|
}
|
|
167
166
|
_getDefaultOption() {
|
|
168
|
-
var _a, _b;
|
|
169
167
|
const {offset: offset} = this._component.getSpec();
|
|
170
|
-
return Object.assign(Object.assign({}, constants_1.DEFAULT_OPTIONS),
|
|
171
|
-
offsetX: null !== (_a = null == offset ? void 0 : offset.x) && void 0 !== _a ? _a : constants_1.DEFAULT_OPTIONS.offsetX,
|
|
172
|
-
offsetY: null !== (_b = null == offset ? void 0 : offset.y) && void 0 !== _b ? _b : constants_1.DEFAULT_OPTIONS.offsetY
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
_getTooltipBoxSize(actualTooltip, changePositionOnly) {
|
|
176
|
-
var _a, _b, _c;
|
|
177
|
-
if (!changePositionOnly || (0, vutils_1.isNil)(this._attributes)) {
|
|
178
|
-
const chartTheme = null !== (_b = null === (_a = this._chartOption) || void 0 === _a ? void 0 : _a.getTheme()) && void 0 !== _b ? _b : {};
|
|
179
|
-
this._attributes = (0, attribute_1.getTooltipAttributes)(actualTooltip, this._component.getSpec(), chartTheme);
|
|
180
|
-
}
|
|
181
|
-
const {panel: panel, panelDomHeight: panelDomHeight} = null !== (_c = this._attributes) && void 0 !== _c ? _c : {}, isCanvas = "canvas" === this._component.getSpec().renderMode;
|
|
182
|
-
return {
|
|
183
|
-
width: (null == panel ? void 0 : panel.width) + (isCanvas ? panel.lineWidth : 0),
|
|
184
|
-
height: (null != panelDomHeight ? panelDomHeight : null == panel ? void 0 : panel.height) + (isCanvas ? panel.lineWidth : 0)
|
|
185
|
-
};
|
|
168
|
+
return offset ? Object.assign(Object.assign({}, constants_1.DEFAULT_OPTIONS), offset) : constants_1.DEFAULT_OPTIONS;
|
|
186
169
|
}
|
|
187
170
|
_getParentElement(spec) {
|
|
188
171
|
return spec.parentElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin/components/tooltip-handler/base.ts"],"names":[],"mappings":";;;AAAA,iDAAmF;AAGnF,2CAA8C;AAK9C,2CAAkD;AAWlD,2CAA0C;AAC1C,+CAM0B;AAI1B,6CAA2G;AAK3G,iDAAyD;AAMzD,wDAAoD;AAEpD,4DAA0E;AAU1E,MAAsB,kBAAmB,SAAQ,wBAAU;IAA3D;;QAOY,aAAQ,GAAG,IAAI,CAAC;QAchB,gBAAW,GAA+B,IAAI,CAAC;QAQ/C,gBAAW,GAAY,KAAK,CAAC;QAavC,gBAAW,GAAG,CAAC,UAA6B,EAAE,IAAiB,EAAE,MAA4B,EAAE,EAAE;YAC/F,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;YAEtC,IAAI,kBAAkB,EAAE;gBACtB,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aACjD;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC,CAAC;QAGQ,kBAAa,GAAsB,CAAC,OAAgB,EAAE,MAA4B,EAAE,IAAkB,EAAE,EAAE;YAClH,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,SAA4B;aAC7B;YAED,IAAI,CAAC,OAAO,EAAE;gBAEZ,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACnC,SAA6B;aAC9B;YAED,OAAO,IAAI,CAAC,qBAAqB,CAAC,MA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,CAAC;QAGzD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,UAAU,KAAK,QAAQ,CAAC;QAEnE,OAAO;YACL,KAAK,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,IAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,EAAE,CAAC,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SAC7E,CAAC;IACJ,CAAC;IAES,iBAAiB,CAAC,IAAkB;QAC5C,OAAO,IAAI,CAAC,aAAoB,CAAC;IACnC,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;;AAxaH,gDAyaC;AAvaiB,0BAAO,GAAG,SAAS,CAAC","file":"base.js","sourcesContent":["import { DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT } from '../../../constant/base';\nimport type { Options } from './constants';\n// eslint-disable-next-line no-duplicate-imports\nimport { DEFAULT_OPTIONS } from './constants';\nimport type { Maybe, IPoint, RenderMode } from '../../../typings';\n// eslint-disable-next-line no-duplicate-imports\nimport type { ITooltipPositionFixedValue, TooltipPositionKeys } from '../../../typings/tooltip/position';\n// eslint-disable-next-line no-duplicate-imports\nimport { isTrueBrowser } from '../../../util/env';\nimport type {\n TooltipData,\n ITooltipActual,\n TooltipActiveType,\n ITooltipHandler,\n ITooltipPositionActual,\n IGlobalTooltipPositionPattern\n} from '../../../typings/tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TooltipFixedPosition } from '../../../typings/tooltip';\nimport { getScale } from './utils/common';\nimport {\n getActualTooltipPositionValue,\n getCartesianCrosshairRect,\n getPositionType,\n isFixedTooltipPositionPattern,\n isGlobalTooltipPositionPattern\n} from './utils/position';\nimport type { IGroup } from '@visactor/vrender-core';\nimport type { AABBBounds } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isNumber, isObject, isValidNumber, isValid, throttle, isNil, isFunction } from '@visactor/vutils';\nimport type { IElement } from '@visactor/vgrammar-core';\nimport type { ILayoutModel } from '../../../model/interface';\nimport type { Compiler } from '../../../compile/compiler';\nimport type { IContainerSize } from '@visactor/vrender-components';\nimport { getTooltipAttributes } from './utils/attribute';\nimport type { IChartOption } from '../../../chart/interface';\nimport type { ITooltipSpec, Tooltip, TooltipHandlerParams } from '../../../component/tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport { TooltipResult } from '../../../component/tooltip';\nimport type { IComponentPlugin, IComponentPluginService } from '../interface';\nimport { BasePlugin } from '../../base/base-plugin';\nimport type { ITooltipAttributes } from './interface';\nimport { getTooltipPatternValue } from '../../../component/tooltip/utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../event/events/dimension/interface';\n\ntype ChangeTooltipFunc = (visible: boolean, params: TooltipHandlerParams, data?: TooltipData) => TooltipResult;\n\ntype ChangeTooltipPositionFunc = (params: TooltipHandlerParams, data: TooltipData) => TooltipResult;\n\n/**\n * The tooltip handler class.\n */\nexport abstract class BaseTooltipHandler extends BasePlugin implements ITooltipHandler, IComponentPlugin {\n static readonly pluginType: 'component';\n static readonly specKey = 'tooltip';\n\n readonly type: string;\n\n /** 是否可见 */\n protected _visible = true;\n\n // protected _style: ITooltipStyle = {};\n\n protected _option: Options;\n\n protected _chartOption: IChartOption;\n\n protected _env: RenderMode;\n public get env() {\n return this._env;\n }\n\n protected _component: Tooltip;\n protected _attributes?: ITooltipAttributes | null = null;\n\n protected _chartContainer: Maybe<HTMLElement>;\n protected _compiler: Compiler;\n\n // tooltip 容器\n protected _container!: Maybe<IGroup | HTMLElement>;\n\n protected _isReleased: boolean = false;\n\n onAdd(service: IComponentPluginService<any>): void {\n super.onAdd(service);\n const component = service.component as Tooltip;\n this._component = component;\n this._chartOption = component.getOption() as any;\n this._env = this._chartOption.mode;\n this._chartContainer = this._chartOption.globalInstance.getContainer();\n this._compiler = component.getCompiler();\n this._initFromSpec();\n }\n\n showTooltip = (activeType: TooltipActiveType, data: TooltipData, params: TooltipHandlerParams) => {\n const { changePositionOnly } = params;\n\n if (changePositionOnly) {\n return this.changeTooltipPosition(params, data);\n }\n return this.changeTooltip(true, params, data);\n };\n\n /** 改变 tooltip 内容和位置(不带 throttle 版本),返回是否遇到异常 */\n protected changeTooltip: ChangeTooltipFunc = (visible: boolean, params: TooltipHandlerParams, data?: TooltipData) => {\n if (this._isReleased) {\n return TooltipResult.failed;\n }\n\n if (!visible) {\n /** 关闭 tooltip */\n this._updateTooltip(false, params);\n return TooltipResult.success;\n }\n\n return this.changeTooltipPosition(params, data);\n };\n\n /** 改变 tooltip 位置(不带 throttle 版本),返回是否遇到异常 */\n protected changeTooltipPosition: ChangeTooltipPositionFunc = (params: TooltipHandlerParams, data: TooltipData) => {\n if (this._isReleased) {\n return TooltipResult.failed;\n }\n\n const event = params.event as MouseEvent;\n const { tooltipSpec, activeTooltipSpec, changePositionOnly } = params;\n\n if (!activeTooltipSpec) {\n return TooltipResult.failed;\n }\n\n const activeType = activeTooltipSpec.activeType;\n\n /** 用户自定义逻辑 */\n if (activeTooltipSpec.handler) {\n return activeTooltipSpec.handler.showTooltip?.(activeType, data, params) ?? TooltipResult.success;\n }\n\n /** 默认逻辑 */\n const pattern = activeTooltipSpec;\n\n // 计算 tooltip 位置\n const position = this._getActualTooltipPosition(\n activeTooltipSpec,\n params,\n this._getTooltipBoxSize(activeTooltipSpec, changePositionOnly)\n );\n activeTooltipSpec.position = position;\n const updatePosition = activeTooltipSpec.updatePosition ?? tooltipSpec[activeType]?.updatePosition;\n\n if (updatePosition) {\n activeTooltipSpec.position = updatePosition(activeTooltipSpec.position, data, params);\n }\n\n // 判断 tooltip 可见性\n let tooltipVisible = pattern?.visible !== false;\n if (\n !data ||\n event.type === 'pointerout' ||\n !activeTooltipSpec.visible ||\n (!activeTooltipSpec.title && !activeTooltipSpec.content)\n ) {\n tooltipVisible = false;\n }\n\n this._updateTooltip(tooltipVisible, {\n ...params,\n changePositionOnly\n });\n return TooltipResult.success;\n };\n\n hideTooltip(params: TooltipHandlerParams): TooltipResult {\n return this.changeTooltip(false, params);\n }\n\n release(): void {\n const spec = this._component.getSpec() ?? {};\n /** 用户自定义逻辑 */\n if (spec.handler) {\n spec.handler.release?.();\n return;\n }\n /** 默认逻辑 */\n this._removeTooltip();\n\n this._isReleased = true;\n }\n\n /* -----需要子类继承的方法开始----- */\n\n protected abstract _updateTooltip(visible: boolean, params: TooltipHandlerParams): void;\n protected abstract _removeTooltip(): void;\n\n /* -----需要子类继承的方法结束----- */\n\n protected _getDefaultOption(): Options {\n const { offset } = this._component.getSpec();\n return {\n ...DEFAULT_OPTIONS,\n offsetX: offset?.x ?? DEFAULT_OPTIONS.offsetX,\n offsetY: offset?.y ?? DEFAULT_OPTIONS.offsetY\n };\n }\n\n /**\n * 计算实际的 tooltip 位置\n */\n protected _getActualTooltipPosition = (\n actualTooltip: ITooltipActual,\n params: TooltipHandlerParams,\n tooltipBoxSize: IContainerSize | undefined\n ): ITooltipPositionActual => {\n const { tooltipSpec } = params;\n const invalidPosition = {\n x: Infinity,\n y: Infinity\n };\n if (!tooltipSpec) {\n return invalidPosition;\n }\n const event = params.event as MouseEvent;\n const { activeType, data } = actualTooltip;\n const firstDim =\n activeType === 'dimension' ? (data as IDimensionInfo[])[0]?.data?.[0] : (data as IDimensionData[])?.[0];\n\n const { offsetX, offsetY } = this._option;\n\n const spec = tooltipSpec[activeType];\n const position = getTooltipPatternValue(spec?.position, data, params);\n const positionMode =\n getTooltipPatternValue(spec?.positionMode, data, params) ?? (activeType === 'mark' ? 'mark' : 'pointer');\n const { width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0 } = tooltipBoxSize ?? {};\n\n const isCanvas = tooltipSpec.renderMode === 'canvas';\n const canvasRect = params?.chart?.getCanvasRect();\n const canvasWidth = canvasRect?.width ?? DEFAULT_CHART_WIDTH;\n const canvasHeight = canvasRect?.height ?? DEFAULT_CHART_HEIGHT;\n let isFixedPosition = false;\n\n const containerSize = {\n width: 0,\n height: 0\n };\n let relativePosOffset = { x: 0, y: 0 };\n let tooltipParentElementRect: IPoint | DOMRect = { x: 0, y: 0 };\n let chartElementScale = 1;\n let tooltipParentElementScale = 1;\n\n if (isTrueBrowser(this._env) && !tooltipSpec.confine) {\n // 只有在 browser 模式下才可以获取到 window 对象\n containerSize.width = window.innerWidth;\n containerSize.height = window.innerHeight;\n\n if (!isCanvas) {\n const tooltipParentElement = this._getParentElement(tooltipSpec);\n tooltipParentElementRect = tooltipParentElement?.getBoundingClientRect?.() ?? invalidPosition;\n const chartElement = (this._compiler.getCanvas() ?? this._chartContainer) as HTMLElement;\n const chartElementRect = chartElement?.getBoundingClientRect();\n relativePosOffset = {\n x: chartElementRect.x - tooltipParentElementRect.x,\n y: chartElementRect.y - tooltipParentElementRect.y\n };\n chartElementScale = getScale(chartElement, chartElementRect);\n tooltipParentElementScale = getScale(tooltipParentElement, tooltipParentElementRect as DOMRect);\n }\n } else {\n containerSize.width = canvasWidth;\n containerSize.height = canvasHeight;\n }\n const tooltipSizeScale = tooltipParentElementScale / chartElementScale;\n\n /* 一、计算 left、top、right、bottom */\n\n const calcPos: { top?: number; bottom?: number; left?: number; right?: number } = {};\n const pointerFixedPosition: {\n x: TooltipFixedPosition;\n y: TooltipFixedPosition;\n } = { x: position as any, y: position as any };\n const dimToPos = { x: ['left', 'right'], y: ['top', 'bottom'] };\n\n const processCartesianFixedPosition = ({ orient, mode, offset }: ITooltipPositionFixedValue, dim: 'x' | 'y') => {\n let dim1: number;\n let dim2: number;\n const model = params.model as ILayoutModel;\n const startPoint = model?.getLayoutStartPoint();\n const dimOffset = offset ?? (dim === 'x' ? offsetX : offsetY);\n\n if (mode === 'mark') {\n isFixedPosition = true;\n const element = params.item as IElement;\n const bounds = element?.getBounds() as AABBBounds;\n if (bounds && startPoint) {\n dim1 = (dim === 'x' ? bounds.x1 : bounds.y1) + startPoint[dim];\n dim2 = (dim === 'x' ? bounds.x2 : bounds.y2) + startPoint[dim];\n }\n } else if (\n mode === 'crosshair' &&\n firstDim?.series?.coordinate === 'cartesian' &&\n firstDim.datum &&\n firstDim.datum.length\n ) {\n isFixedPosition = true;\n const rect = getCartesianCrosshairRect(firstDim, startPoint);\n if (rect) {\n dim1 = rect.start[dim];\n dim2 = rect.end[dim];\n }\n } else {\n pointerFixedPosition[dim] = orient;\n }\n\n if (isFixedPosition) {\n const posKey = dimToPos[dim][0] as TooltipPositionKeys;\n const boxSize = dim === 'x' ? tooltipBoxWidth : tooltipBoxHeight;\n switch (getPositionType(orient, dim)) {\n case -2:\n calcPos[posKey] = dim1 - boxSize * tooltipSizeScale - dimOffset;\n break;\n case 0:\n calcPos[posKey] = (dim1 + dim2) / 2 - (boxSize * tooltipSizeScale) / 2;\n break;\n case -1:\n calcPos[posKey] = (dim1 + dim2) / 2 - boxSize * tooltipSizeScale - dimOffset;\n break;\n case 1:\n calcPos[posKey] = (dim1 + dim2) / 2 + dimOffset;\n break;\n case 2:\n calcPos[posKey] = dim2 + dimOffset;\n break;\n }\n }\n };\n const dims = ['x', 'y'] as ('x' | 'y')[];\n if (isObject(position)) {\n if (isGlobalTooltipPositionPattern(position)) {\n const {\n left: posLeft,\n right: posRight,\n top: posTop,\n bottom: posBottom\n } = position as IGlobalTooltipPositionPattern;\n calcPos.left = getActualTooltipPositionValue(posLeft, event);\n calcPos.top = getActualTooltipPositionValue(posTop, event);\n calcPos.right = getActualTooltipPositionValue(posRight, event);\n calcPos.bottom = getActualTooltipPositionValue(posBottom, event);\n } else if (isFixedTooltipPositionPattern(position)) {\n dims.forEach(dim => {\n const dimValue = position[dim];\n if (isNumber(dimValue) || isFunction(dimValue)) {\n calcPos[dimToPos[dim][0] as TooltipPositionKeys] = getActualTooltipPositionValue(\n dimValue as number | ((event: MouseEvent) => number),\n event\n );\n } else {\n processCartesianFixedPosition(dimValue as ITooltipPositionFixedValue, dim);\n }\n });\n }\n } else if (isValid(position)) {\n processCartesianFixedPosition({ orient: position, mode: positionMode } as ITooltipPositionFixedValue, 'x');\n processCartesianFixedPosition({ orient: position, mode: positionMode } as ITooltipPositionFixedValue, 'y');\n }\n\n const result: ITooltipPositionActual = { x: null, y: null };\n const isBrowser = isTrueBrowser(this._env);\n\n dims.forEach(dim => {\n /* 二、换算成 x 和 y */\n const boxSize = dim === 'x' ? tooltipBoxWidth : tooltipBoxHeight;\n const canvasSize = dim === 'x' ? canvasWidth : canvasHeight;\n const offset = dim === 'x' ? offsetX : offsetY;\n const posType = getPositionType(pointerFixedPosition[dim], dim);\n if (isValidNumber(calcPos[dimToPos[dim][0] as TooltipPositionKeys])) {\n result[dim] = calcPos[dimToPos[dim][0] as TooltipPositionKeys];\n } else if (isValidNumber(calcPos[dimToPos[dim][1] as TooltipPositionKeys])) {\n result[dim] = canvasSize - boxSize * tooltipSizeScale - calcPos[dimToPos[dim][1] as TooltipPositionKeys];\n } else {\n const value0 = dim === 'x' ? (event as any).canvasX : (event as any).canvasY;\n\n if (posType > 0) {\n result[dim] = value0 + offset;\n } else if (posType === 0) {\n result[dim] = value0 - (boxSize * tooltipSizeScale) / 2;\n } else {\n result[dim] = value0 - boxSize * tooltipSizeScale - offset;\n }\n }\n result[dim] *= chartElementScale;\n\n if (isBrowser) {\n result[dim] += relativePosOffset[dim];\n }\n result[dim] /= tooltipParentElementScale;\n\n /* 三、确保tooltip在视区内 */\n const containerDimSize = dim === 'x' ? containerSize.width : containerSize.height;\n const leftOrTop = -tooltipParentElementRect[dim] / tooltipParentElementScale;\n const rightOrBottom = (containerDimSize - tooltipParentElementRect[dim]) / tooltipParentElementScale - boxSize;\n\n // 处理左右\n if (posType !== 2 && result[dim] < leftOrTop) {\n // 优先检测left\n if (isFixedPosition) {\n result[dim] = leftOrTop;\n } else {\n if (posType === 0) {\n // 从居中 挪至 右侧\n result[dim] += offset + boxSize / 2;\n } else {\n // 从居左/左侧 挪至 居右/右侧\n result[dim] += offset * 2 + boxSize;\n }\n\n if (result[dim] > rightOrBottom) {\n // 位置不超出视区右界\n result[dim] = rightOrBottom;\n }\n }\n } else if (posType !== -2 && result[dim] > rightOrBottom) {\n // 优先检测right\n // 位置不超出视区右界\n if (isFixedPosition) {\n result[dim] = rightOrBottom;\n } else {\n if (posType === 0) {\n // 从居中 挪至 左侧\n result[dim] -= offset + boxSize / 2;\n } else {\n // 从居右/右侧 挪至 居左/左侧\n result[dim] -= offset * 2 + boxSize;\n }\n\n if (result[dim] < leftOrTop) {\n // 位置不超出视区左界\n result[dim] = leftOrTop;\n }\n }\n }\n });\n\n return result;\n };\n\n // 计算 tooltip 内容区域的宽高,并缓存结果\n protected _getTooltipBoxSize(actualTooltip: ITooltipActual, changePositionOnly: boolean): IContainerSize | undefined {\n if (!changePositionOnly || isNil(this._attributes)) {\n const chartTheme = this._chartOption?.getTheme() ?? {};\n this._attributes = getTooltipAttributes(actualTooltip, this._component.getSpec(), chartTheme);\n }\n const { panel, panelDomHeight } = this._attributes ?? {};\n // canvas模式下, size需要考虑border size, 目的是为了精准判断边界是否超出画布,达到confine效果\n // html模式不提供confine, 所以不考虑精准计算size\n const isCanvas = this._component.getSpec().renderMode === 'canvas';\n\n return {\n width: panel?.width + (isCanvas ? panel.lineWidth : 0),\n height: (panelDomHeight ?? panel?.height) + (isCanvas ? panel.lineWidth : 0)\n };\n }\n\n protected _getParentElement(spec: ITooltipSpec): HTMLElement {\n return spec.parentElement as any;\n }\n\n getTooltipContainer() {\n return this._container;\n }\n\n protected _initFromSpec() {\n this._option = this._getDefa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,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,OAAO,kDAAI,CAAC;YACzB,OAAO;SACR;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAaS,iBAAiB;QACzB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE7C,OAAO,MAAM,CAAC,CAAC,iCAAM,2BAAe,GAAK,MAAM,EAAG,CAAC,CAAC,2BAAe,CAAC;IACtE,CAAC;IAkPS,iBAAiB,CAAC,IAAkB;QAC5C,OAAO,IAAI,CAAC,aAAoB,CAAC;IACnC,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;;AAvZH,gDAwZC;AAtZiB,0BAAO,GAAG,SAAS,CAAC","file":"base.js","sourcesContent":["import { DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT } from '../../../constant/base';\n// eslint-disable-next-line no-duplicate-imports\nimport { DEFAULT_OPTIONS } from './constants';\nimport type { Maybe, IPoint, RenderMode } from '../../../typings';\n// eslint-disable-next-line no-duplicate-imports\nimport type { ITooltipPositionFixedValue, TooltipPositionKeys } from '../../../typings/tooltip/position';\n// eslint-disable-next-line no-duplicate-imports\nimport { isTrueBrowser } from '../../../util/env';\nimport type {\n TooltipData,\n ITooltipActual,\n TooltipActiveType,\n ITooltipHandler,\n ITooltipPositionActual,\n IGlobalTooltipPositionPattern\n} from '../../../typings/tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TooltipFixedPosition } from '../../../typings/tooltip';\nimport { getScale } from './utils/common';\nimport {\n getActualTooltipPositionValue,\n getCartesianCrosshairRect,\n getPositionType,\n isFixedTooltipPositionPattern,\n isGlobalTooltipPositionPattern\n} from './utils/position';\nimport type { IGroup } from '@visactor/vrender-core';\nimport type { AABBBounds } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isNumber, isObject, isValidNumber, isValid, isFunction } from '@visactor/vutils';\nimport type { IElement } from '@visactor/vgrammar-core';\nimport type { ILayoutModel } from '../../../model/interface';\nimport type { Compiler } from '../../../compile/compiler';\nimport type { IContainerSize } from '@visactor/vrender-components';\nimport type { IChartOption } from '../../../chart/interface';\nimport type { ITooltipSpec, Tooltip, TooltipHandlerParams } from '../../../component/tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport { TooltipResult } from '../../../component/tooltip';\nimport type { IComponentPlugin, IComponentPluginService } from '../interface';\nimport { BasePlugin } from '../../base/base-plugin';\nimport { getTooltipPatternValue } from '../../../component/tooltip/utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../event/events/dimension/interface';\nimport type { ITooltipHandlerOptions } from './interface';\n\ntype ChangeTooltipFunc = (visible: boolean, params: TooltipHandlerParams, data?: TooltipData) => TooltipResult;\n\ntype ChangeTooltipPositionFunc = (params: TooltipHandlerParams, data: TooltipData) => TooltipResult;\n\n/**\n * The tooltip handler class.\n */\nexport abstract class BaseTooltipHandler extends BasePlugin implements ITooltipHandler, IComponentPlugin {\n static readonly pluginType: 'component';\n static readonly specKey = 'tooltip';\n\n readonly type: string;\n\n /** 是否可见 */\n protected _visible = true;\n\n // protected _style: ITooltipStyle = {};\n\n protected _option: ITooltipHandlerOptions;\n\n protected _chartOption: IChartOption;\n\n protected _env: RenderMode;\n public get env() {\n return this._env;\n }\n\n protected _component: Tooltip;\n\n protected _chartContainer: Maybe<HTMLElement>;\n protected _compiler: Compiler;\n\n // tooltip 容器\n protected _container!: Maybe<IGroup | HTMLElement>;\n\n protected _isReleased: boolean = false;\n\n onAdd(service: IComponentPluginService<any>): void {\n super.onAdd(service);\n const component = service.component as Tooltip;\n this._component = component;\n this._chartOption = component.getOption() as any;\n this._env = this._chartOption.mode;\n this._chartContainer = this._chartOption.globalInstance.getContainer();\n this._compiler = component.getCompiler();\n this._initFromSpec();\n }\n\n showTooltip = (activeType: TooltipActiveType, data: TooltipData, params: TooltipHandlerParams) => {\n const { changePositionOnly } = params;\n\n if (changePositionOnly) {\n return this.changeTooltipPosition(params, data);\n }\n return this.changeTooltip(true, params, data);\n };\n\n /** 改变 tooltip 内容和位置(不带 throttle 版本),返回是否遇到异常 */\n protected changeTooltip: ChangeTooltipFunc = (visible: boolean, params: TooltipHandlerParams, data?: TooltipData) => {\n if (this._isReleased) {\n return TooltipResult.failed;\n }\n\n if (!visible) {\n /** 关闭 tooltip */\n this._updateTooltip(false, params);\n return TooltipResult.success;\n }\n\n return this.changeTooltipPosition(params, data);\n };\n\n /** 改变 tooltip 位置(不带 throttle 版本),返回是否遇到异常 */\n protected changeTooltipPosition: ChangeTooltipPositionFunc = (params: TooltipHandlerParams, data: TooltipData) => {\n if (this._isReleased) {\n return TooltipResult.failed;\n }\n\n const event = params.event as MouseEvent;\n const { tooltipSpec, activeTooltipSpec, changePositionOnly } = params;\n\n if (!activeTooltipSpec) {\n return TooltipResult.failed;\n }\n\n const activeType = activeTooltipSpec.activeType;\n\n /** 用户自定义逻辑 */\n if (activeTooltipSpec.handler) {\n return activeTooltipSpec.handler.showTooltip?.(activeType, data, params) ?? TooltipResult.success;\n }\n\n /** 默认逻辑 */\n const pattern = activeTooltipSpec;\n\n // 计算 tooltip 位置\n const position = this._getActualTooltipPosition(\n activeTooltipSpec,\n params,\n this._getTooltipBoxSize(activeTooltipSpec, changePositionOnly)\n );\n activeTooltipSpec.position = position;\n const updatePosition = activeTooltipSpec.updatePosition ?? tooltipSpec[activeType]?.updatePosition;\n\n if (updatePosition) {\n activeTooltipSpec.position = updatePosition(activeTooltipSpec.position, data, params);\n }\n\n // 判断 tooltip 可见性\n let tooltipVisible = pattern?.visible !== false;\n if (\n !data ||\n event.type === 'pointerout' ||\n !activeTooltipSpec.visible ||\n (!activeTooltipSpec.title && !activeTooltipSpec.content)\n ) {\n tooltipVisible = false;\n }\n\n this._updateTooltip(tooltipVisible, {\n ...params,\n changePositionOnly\n });\n return TooltipResult.success;\n };\n\n hideTooltip(params: TooltipHandlerParams): TooltipResult {\n return this.changeTooltip(false, params);\n }\n\n release(): void {\n const spec = this._component.getSpec() ?? {};\n /** 用户自定义逻辑 */\n if (spec.handler) {\n spec.handler.release?.();\n return;\n }\n /** 默认逻辑 */\n this._removeTooltip();\n\n this._isReleased = true;\n }\n\n /* -----需要子类继承的方法开始----- */\n\n protected abstract _updateTooltip(visible: boolean, params: TooltipHandlerParams): void;\n protected abstract _removeTooltip(): void;\n protected abstract _getTooltipBoxSize(\n actualTooltip: ITooltipActual,\n changePositionOnly: boolean\n ): IContainerSize | undefined;\n\n /* -----需要子类继承的方法结束----- */\n\n protected _getDefaultOption(): ITooltipHandlerOptions {\n const { offset } = this._component.getSpec();\n\n return offset ? { ...DEFAULT_OPTIONS, ...offset } : DEFAULT_OPTIONS;\n }\n\n /**\n * 计算实际的 tooltip 位置\n */\n protected _getActualTooltipPosition = (\n actualTooltip: ITooltipActual,\n params: TooltipHandlerParams,\n tooltipBoxSize: IContainerSize | undefined\n ): ITooltipPositionActual => {\n const { tooltipSpec } = params;\n const invalidPosition = {\n x: Infinity,\n y: Infinity\n };\n if (!tooltipSpec) {\n return invalidPosition;\n }\n const event = params.event as MouseEvent;\n const { activeType, data } = actualTooltip;\n const firstDim =\n activeType === 'dimension' ? (data as IDimensionInfo[])[0]?.data?.[0] : (data as IDimensionData[])?.[0];\n\n const { offsetX, offsetY } = this._option;\n\n const spec = tooltipSpec[activeType];\n const position = getTooltipPatternValue(spec?.position, data, params);\n const positionMode =\n getTooltipPatternValue(spec?.positionMode, data, params) ?? (activeType === 'mark' ? 'mark' : 'pointer');\n const { width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0 } = tooltipBoxSize ?? {};\n\n const isCanvas = tooltipSpec.renderMode === 'canvas';\n const canvasRect = params?.chart?.getCanvasRect();\n const canvasWidth = canvasRect?.width ?? DEFAULT_CHART_WIDTH;\n const canvasHeight = canvasRect?.height ?? DEFAULT_CHART_HEIGHT;\n let isFixedPosition = false;\n\n const containerSize = {\n width: 0,\n height: 0\n };\n let relativePosOffset = { x: 0, y: 0 };\n let tooltipParentElementRect: IPoint | DOMRect = { x: 0, y: 0 };\n let chartElementScale = 1;\n let tooltipParentElementScale = 1;\n\n if (isTrueBrowser(this._env) && !tooltipSpec.confine) {\n // 只有在 browser 模式下才可以获取到 window 对象\n containerSize.width = window.innerWidth;\n containerSize.height = window.innerHeight;\n\n if (!isCanvas) {\n const tooltipParentElement = this._getParentElement(tooltipSpec);\n tooltipParentElementRect = tooltipParentElement?.getBoundingClientRect?.() ?? invalidPosition;\n const chartElement = (this._compiler.getCanvas() ?? this._chartContainer) as HTMLElement;\n const chartElementRect = chartElement?.getBoundingClientRect();\n relativePosOffset = {\n x: chartElementRect.x - tooltipParentElementRect.x,\n y: chartElementRect.y - tooltipParentElementRect.y\n };\n chartElementScale = getScale(chartElement, chartElementRect);\n tooltipParentElementScale = getScale(tooltipParentElement, tooltipParentElementRect as DOMRect);\n }\n } else {\n containerSize.width = canvasWidth;\n containerSize.height = canvasHeight;\n }\n const tooltipSizeScale = tooltipParentElementScale / chartElementScale;\n\n /* 一、计算 left、top、right、bottom */\n\n const calcPos: { top?: number; bottom?: number; left?: number; right?: number } = {};\n const pointerFixedPosition: {\n x: TooltipFixedPosition;\n y: TooltipFixedPosition;\n } = { x: position as any, y: position as any };\n const dimToPos = { x: ['left', 'right'], y: ['top', 'bottom'] };\n\n const processCartesianFixedPosition = ({ orient, mode, offset }: ITooltipPositionFixedValue, dim: 'x' | 'y') => {\n let dim1: number;\n let dim2: number;\n const model = params.model as ILayoutModel;\n const startPoint = model?.getLayoutStartPoint();\n const dimOffset = offset ?? (dim === 'x' ? offsetX : offsetY);\n\n if (mode === 'mark') {\n isFixedPosition = true;\n const element = params.item as IElement;\n const bounds = element?.getBounds() as AABBBounds;\n if (bounds && startPoint) {\n dim1 = (dim === 'x' ? bounds.x1 : bounds.y1) + startPoint[dim];\n dim2 = (dim === 'x' ? bounds.x2 : bounds.y2) + startPoint[dim];\n }\n } else if (\n mode === 'crosshair' &&\n firstDim?.series?.coordinate === 'cartesian' &&\n firstDim.datum &&\n firstDim.datum.length\n ) {\n isFixedPosition = true;\n const rect = getCartesianCrosshairRect(firstDim, startPoint);\n if (rect) {\n dim1 = rect.start[dim];\n dim2 = rect.end[dim];\n }\n } else {\n pointerFixedPosition[dim] = orient;\n }\n\n if (isFixedPosition) {\n const posKey = dimToPos[dim][0] as TooltipPositionKeys;\n const boxSize = dim === 'x' ? tooltipBoxWidth : tooltipBoxHeight;\n switch (getPositionType(orient, dim)) {\n case -2:\n calcPos[posKey] = dim1 - boxSize * tooltipSizeScale - dimOffset;\n break;\n case 0:\n calcPos[posKey] = (dim1 + dim2) / 2 - (boxSize * tooltipSizeScale) / 2;\n break;\n case -1:\n calcPos[posKey] = (dim1 + dim2) / 2 - boxSize * tooltipSizeScale - dimOffset;\n break;\n case 1:\n calcPos[posKey] = (dim1 + dim2) / 2 + dimOffset;\n break;\n case 2:\n calcPos[posKey] = dim2 + dimOffset;\n break;\n }\n }\n };\n const dims = ['x', 'y'] as ('x' | 'y')[];\n if (isObject(position)) {\n if (isGlobalTooltipPositionPattern(position)) {\n const {\n left: posLeft,\n right: posRight,\n top: posTop,\n bottom: posBottom\n } = position as IGlobalTooltipPositionPattern;\n calcPos.left = getActualTooltipPositionValue(posLeft, event);\n calcPos.top = getActualTooltipPositionValue(posTop, event);\n calcPos.right = getActualTooltipPositionValue(posRight, event);\n calcPos.bottom = getActualTooltipPositionValue(posBottom, event);\n } else if (isFixedTooltipPositionPattern(position)) {\n dims.forEach(dim => {\n const dimValue = position[dim];\n if (isNumber(dimValue) || isFunction(dimValue)) {\n calcPos[dimToPos[dim][0] as TooltipPositionKeys] = getActualTooltipPositionValue(\n dimValue as number | ((event: MouseEvent) => number),\n event\n );\n } else {\n processCartesianFixedPosition(dimValue as ITooltipPositionFixedValue, dim);\n }\n });\n }\n } else if (isValid(position)) {\n processCartesianFixedPosition({ orient: position, mode: positionMode } as ITooltipPositionFixedValue, 'x');\n processCartesianFixedPosition({ orient: position, mode: positionMode } as ITooltipPositionFixedValue, 'y');\n }\n\n const result: ITooltipPositionActual = { x: null, y: null };\n const isBrowser = isTrueBrowser(this._env);\n\n dims.forEach(dim => {\n /* 二、换算成 x 和 y */\n const boxSize = dim === 'x' ? tooltipBoxWidth : tooltipBoxHeight;\n const canvasSize = dim === 'x' ? canvasWidth : canvasHeight;\n const offset = dim === 'x' ? offsetX : offsetY;\n const posType = getPositionType(pointerFixedPosition[dim], dim);\n if (isValidNumber(calcPos[dimToPos[dim][0] as TooltipPositionKeys])) {\n result[dim] = calcPos[dimToPos[dim][0] as TooltipPositionKeys];\n } else if (isValidNumber(calcPos[dimToPos[dim][1] as TooltipPositionKeys])) {\n result[dim] = canvasSize - boxSize * tooltipSizeScale - calcPos[dimToPos[dim][1] as TooltipPositionKeys];\n } else {\n const value0 = dim === 'x' ? (event as any).canvasX : (event as any).canvasY;\n\n if (posType > 0) {\n result[dim] = value0 + offset;\n } else if (posType === 0) {\n result[dim] = value0 - (boxSize * tooltipSizeScale) / 2;\n } else {\n result[dim] = value0 - boxSize * tooltipSizeScale - offset;\n }\n }\n result[dim] *= chartElementScale;\n\n if (isBrowser) {\n result[dim] += relativePosOffset[dim];\n }\n result[dim] /= tooltipParentElementScale;\n\n /* 三、确保tooltip在视区内 */\n const containerDimSize = dim === 'x' ? containerSize.width : containerSize.height;\n const leftOrTop = -tooltipParentElementRect[dim] / tooltipParentElementScale;\n const rightOrBottom = (containerDimSize - tooltipParentElementRect[dim]) / tooltipParentElementScale - boxSize;\n\n // 处理左右\n if (posType !== 2 && result[dim] < leftOrTop) {\n // 优先检测left\n if (isFixedPosition) {\n result[dim] = leftOrTop;\n } else {\n if (posType === 0) {\n // 从居中 挪至 右侧\n result[dim] += offset + boxSize / 2;\n } else {\n // 从居左/左侧 挪至 居右/右侧\n result[dim] += offset * 2 + boxSize;\n }\n\n if (result[dim] > rightOrBottom) {\n // 位置不超出视区右界\n result[dim] = rightOrBottom;\n }\n }\n } else if (posType !== -2 && result[dim] > rightOrBottom) {\n // 优先检测right\n // 位置不超出视区右界\n if (isFixedPosition) {\n result[dim] = rightOrBottom;\n } else {\n if (posType === 0) {\n // 从居中 挪至 左侧\n result[dim] -= offset + boxSize / 2;\n } else {\n // 从居右/右侧 挪至 居左/左侧\n result[dim] -= offset * 2 + boxSize;\n }\n\n if (result[dim] < leftOrTop) {\n // 位置不超出视区左界\n result[dim] = leftOrTop;\n }\n }\n }\n });\n\n return result;\n };\n\n protected _getParentElement(spec: ITooltipSpec): HTMLElement {\n return spec.parentElement as any;\n }\n\n getTooltipContainer() {\n return this._container;\n }\n\n protected _initFromSpec() {\n this._option = this._getDefaultOption();\n }\n\n reInit() {\n this._initFromSpec();\n }\n}\n"]}
|