@visactor/vchart 1.12.7 → 1.12.8
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 +1117 -1665
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base/base-chart.js.map +1 -1
- package/cjs/chart/gauge/interface.d.ts +1 -1
- package/cjs/chart/gauge/interface.js.map +1 -1
- package/cjs/chart/treemap/interface.d.ts +1 -1
- package/cjs/chart/treemap/interface.js.map +1 -1
- package/cjs/chart/venn/interface.d.ts +2 -2
- package/cjs/chart/venn/interface.js.map +1 -1
- package/cjs/compile/compilable-base.js +1 -2
- package/cjs/compile/util.js +2 -1
- package/cjs/component/axis/base-axis.js +1 -1
- package/cjs/component/axis/base-axis.js.map +1 -1
- package/cjs/component/axis/cartesian/axis.js +5 -4
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/axis/cartesian/interface/common.d.ts +1 -0
- package/cjs/component/axis/cartesian/interface/common.js.map +1 -1
- package/cjs/component/axis/polar/axis.js.map +1 -1
- package/cjs/component/geo/geo-coordinate.js +5 -2
- package/cjs/component/geo/geo-coordinate.js.map +1 -1
- package/cjs/component/interface/index.d.ts +0 -1
- package/cjs/component/interface/index.js +1 -1
- package/cjs/component/interface/index.js.map +1 -1
- package/cjs/component/label/util.js +1 -1
- package/cjs/component/label/util.js.map +1 -1
- package/cjs/component/title/interface/spec.d.ts +3 -3
- package/cjs/component/title/interface/spec.js.map +1 -1
- package/cjs/component/tooltip/constant.d.ts +5 -4
- package/cjs/component/tooltip/constant.js +7 -7
- package/cjs/component/tooltip/constant.js.map +1 -1
- package/cjs/component/tooltip/interface/common.d.ts +1 -1
- package/cjs/component/tooltip/interface/common.js.map +1 -1
- package/cjs/component/tooltip/interface/spec.d.ts +8 -0
- package/cjs/component/tooltip/interface/spec.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/processor/base.d.ts +3 -5
- package/cjs/component/tooltip/processor/base.js +24 -27
- package/cjs/component/tooltip/processor/base.js.map +1 -1
- package/cjs/component/tooltip/processor/group-tooltip.js +1 -1
- package/cjs/component/tooltip/processor/group-tooltip.js.map +1 -1
- package/cjs/component/tooltip/processor/mark-tooltip.js +2 -2
- package/cjs/component/tooltip/processor/mark-tooltip.js.map +1 -1
- package/cjs/component/tooltip/tooltip-transformer.js +0 -1
- package/cjs/component/tooltip/tooltip-transformer.js.map +1 -1
- package/cjs/component/tooltip/tooltip.d.ts +9 -4
- package/cjs/component/tooltip/tooltip.js +64 -53
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/component/tooltip/utils/common.d.ts +6 -4
- package/cjs/component/tooltip/utils/common.js +52 -7
- package/cjs/component/tooltip/utils/common.js.map +1 -1
- package/cjs/component/tooltip/utils/get-spec.d.ts +4 -4
- package/cjs/component/tooltip/utils/get-spec.js +20 -82
- package/cjs/component/tooltip/utils/get-spec.js.map +1 -1
- package/cjs/component/tooltip/utils/get-value.d.ts +1 -2
- package/cjs/component/tooltip/utils/get-value.js +2 -12
- package/cjs/component/tooltip/utils/get-value.js.map +1 -1
- package/cjs/component/tooltip/utils/index.d.ts +0 -1
- package/cjs/component/tooltip/utils/index.js +1 -2
- package/cjs/component/tooltip/utils/index.js.map +1 -1
- package/cjs/constant/correlation.js +2 -1
- package/cjs/constant/layout.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/vchart.js +14 -11
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/transforms/pie.d.ts +3 -0
- package/cjs/data/transforms/pie.js +8 -3
- package/cjs/data/transforms/pie.js.map +1 -1
- package/cjs/model/interface.d.ts +14 -0
- package/cjs/model/interface.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/base.d.ts +1 -13
- package/cjs/plugin/components/tooltip-handler/base.js +83 -220
- package/cjs/plugin/components/tooltip-handler/base.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js +1 -1
- package/cjs/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/dom/dom-tooltip-handler.d.ts +0 -1
- package/cjs/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js +7 -19
- package/cjs/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/content-column-model.js +16 -14
- package/cjs/plugin/components/tooltip-handler/dom/model/content-column-model.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/dom/model/title-model.js +2 -2
- package/cjs/plugin/components/tooltip-handler/dom/model/title-model.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/interface/style.d.ts +1 -2
- package/cjs/plugin/components/tooltip-handler/interface/style.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/attribute.js +7 -7
- package/cjs/plugin/components/tooltip-handler/utils/attribute.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/common.js.map +1 -1
- package/cjs/plugin/components/tooltip-handler/utils/position.d.ts +3 -5
- package/cjs/plugin/components/tooltip-handler/utils/position.js +22 -29
- package/cjs/plugin/components/tooltip-handler/utils/position.js.map +1 -1
- package/cjs/region/interface.d.ts +3 -1
- package/cjs/region/interface.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 +30 -6
- package/cjs/series/base/tooltip-helper.js +80 -73
- package/cjs/series/base/tooltip-helper.js.map +1 -1
- package/cjs/series/box-plot/tooltip-helper.d.ts +2 -2
- package/cjs/series/box-plot/tooltip-helper.js +26 -67
- package/cjs/series/box-plot/tooltip-helper.js.map +1 -1
- package/cjs/series/cartesian/cartesian.d.ts +1 -1
- package/cjs/series/circle-packing/circle-packing.js +1 -2
- package/cjs/series/circle-packing/circle-packing.js.map +1 -1
- package/cjs/series/dot/tooltip-helper.d.ts +8 -2
- package/cjs/series/dot/tooltip-helper.js +42 -41
- package/cjs/series/dot/tooltip-helper.js.map +1 -1
- package/cjs/series/gauge/pointer-tooltip-helper.d.ts +2 -1
- package/cjs/series/gauge/pointer-tooltip-helper.js +3 -8
- package/cjs/series/gauge/pointer-tooltip-helper.js.map +1 -1
- package/cjs/series/heatmap/tooltip-helper.d.ts +2 -3
- package/cjs/series/heatmap/tooltip-helper.js +3 -5
- package/cjs/series/heatmap/tooltip-helper.js.map +1 -1
- package/cjs/series/interface/tooltip-helper.d.ts +5 -4
- package/cjs/series/interface/tooltip-helper.js.map +1 -1
- package/cjs/series/link/tooltip-helper.d.ts +5 -2
- package/cjs/series/link/tooltip-helper.js +26 -27
- package/cjs/series/link/tooltip-helper.js.map +1 -1
- package/cjs/series/liquid/tooltip-helper.d.ts +4 -5
- package/cjs/series/liquid/tooltip-helper.js +2 -22
- package/cjs/series/liquid/tooltip-helper.js.map +1 -1
- package/cjs/series/pie/pie.js +6 -2
- package/cjs/series/pie/pie.js.map +1 -1
- package/cjs/series/progress/linear/tooltip-helper.d.ts +2 -3
- package/cjs/series/progress/linear/tooltip-helper.js +2 -11
- package/cjs/series/progress/linear/tooltip-helper.js.map +1 -1
- package/cjs/series/range-area/tooltip-helper.d.ts +1 -3
- package/cjs/series/range-area/tooltip-helper.js +2 -50
- package/cjs/series/range-area/tooltip-helper.js.map +1 -1
- package/cjs/series/range-column/tooltip-helper.d.ts +1 -2
- package/cjs/series/range-column/tooltip-helper.js +2 -19
- package/cjs/series/range-column/tooltip-helper.js.map +1 -1
- package/cjs/series/sankey/sankey.d.ts +1 -1
- package/cjs/series/sankey/tooltip-helper.d.ts +3 -3
- package/cjs/series/sankey/tooltip-helper.js +10 -57
- package/cjs/series/sankey/tooltip-helper.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +3 -3
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/typings/tooltip/position.d.ts +1 -0
- package/cjs/typings/tooltip/position.js.map +1 -1
- package/cjs/typings/tooltip/shape.d.ts +0 -1
- package/cjs/typings/tooltip/shape.js.map +1 -1
- package/cjs/typings/tooltip/tooltip.d.ts +7 -0
- package/cjs/typings/tooltip/tooltip.js.map +1 -1
- package/esm/chart/base/base-chart.js.map +1 -1
- package/esm/chart/gauge/interface.d.ts +1 -1
- package/esm/chart/gauge/interface.js.map +1 -1
- package/esm/chart/treemap/interface.d.ts +1 -1
- package/esm/chart/treemap/interface.js.map +1 -1
- package/esm/chart/venn/interface.d.ts +2 -2
- package/esm/chart/venn/interface.js.map +1 -1
- package/esm/compile/compilable-base.js +1 -2
- package/esm/compile/util.js +2 -1
- package/esm/component/axis/base-axis.js +1 -1
- package/esm/component/axis/base-axis.js.map +1 -1
- package/esm/component/axis/cartesian/axis.js +5 -4
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/axis/cartesian/interface/common.d.ts +1 -0
- package/esm/component/axis/cartesian/interface/common.js.map +1 -1
- package/esm/component/axis/polar/axis.js.map +1 -1
- package/esm/component/geo/geo-coordinate.js +5 -2
- package/esm/component/geo/geo-coordinate.js.map +1 -1
- package/esm/component/interface/index.d.ts +0 -1
- package/esm/component/interface/index.js +0 -2
- package/esm/component/interface/index.js.map +1 -1
- package/esm/component/label/util.js +1 -1
- package/esm/component/label/util.js.map +1 -1
- package/esm/component/title/interface/spec.d.ts +3 -3
- package/esm/component/title/interface/spec.js.map +1 -1
- package/esm/component/tooltip/constant.d.ts +5 -4
- package/esm/component/tooltip/constant.js +6 -3
- package/esm/component/tooltip/constant.js.map +1 -1
- package/esm/component/tooltip/interface/common.d.ts +1 -1
- package/esm/component/tooltip/interface/common.js.map +1 -1
- package/esm/component/tooltip/interface/spec.d.ts +8 -0
- package/esm/component/tooltip/interface/spec.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/processor/base.d.ts +3 -5
- package/esm/component/tooltip/processor/base.js +24 -28
- package/esm/component/tooltip/processor/base.js.map +1 -1
- package/esm/component/tooltip/processor/group-tooltip.js +1 -1
- package/esm/component/tooltip/processor/group-tooltip.js.map +1 -1
- package/esm/component/tooltip/processor/mark-tooltip.js +2 -2
- package/esm/component/tooltip/processor/mark-tooltip.js.map +1 -1
- package/esm/component/tooltip/tooltip-transformer.js +0 -1
- package/esm/component/tooltip/tooltip-transformer.js.map +1 -1
- package/esm/component/tooltip/tooltip.d.ts +9 -4
- package/esm/component/tooltip/tooltip.js +66 -54
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/component/tooltip/utils/common.d.ts +6 -4
- package/esm/component/tooltip/utils/common.js +46 -5
- package/esm/component/tooltip/utils/common.js.map +1 -1
- package/esm/component/tooltip/utils/get-spec.d.ts +4 -4
- package/esm/component/tooltip/utils/get-spec.js +24 -80
- package/esm/component/tooltip/utils/get-spec.js.map +1 -1
- package/esm/component/tooltip/utils/get-value.d.ts +1 -2
- package/esm/component/tooltip/utils/get-value.js +1 -9
- package/esm/component/tooltip/utils/get-value.js.map +1 -1
- package/esm/component/tooltip/utils/index.d.ts +0 -1
- package/esm/component/tooltip/utils/index.js +0 -2
- package/esm/component/tooltip/utils/index.js.map +1 -1
- package/esm/constant/correlation.js +2 -1
- package/esm/constant/layout.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/vchart.js +14 -10
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/transforms/pie.d.ts +3 -0
- package/esm/data/transforms/pie.js +6 -3
- package/esm/data/transforms/pie.js.map +1 -1
- package/esm/model/interface.d.ts +14 -0
- package/esm/model/interface.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/base.d.ts +1 -13
- package/esm/plugin/components/tooltip-handler/base.js +79 -212
- package/esm/plugin/components/tooltip-handler/base.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js +1 -1
- package/esm/plugin/components/tooltip-handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/dom/dom-tooltip-handler.d.ts +0 -1
- package/esm/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js +6 -19
- package/esm/plugin/components/tooltip-handler/dom/dom-tooltip-handler.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/dom/model/content-column-model.js +16 -14
- package/esm/plugin/components/tooltip-handler/dom/model/content-column-model.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/dom/model/title-model.js +2 -2
- package/esm/plugin/components/tooltip-handler/dom/model/title-model.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/interface/style.d.ts +1 -2
- package/esm/plugin/components/tooltip-handler/interface/style.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/attribute.js +7 -7
- package/esm/plugin/components/tooltip-handler/utils/attribute.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/common.js.map +1 -1
- package/esm/plugin/components/tooltip-handler/utils/position.d.ts +3 -5
- package/esm/plugin/components/tooltip-handler/utils/position.js +20 -25
- package/esm/plugin/components/tooltip-handler/utils/position.js.map +1 -1
- package/esm/region/interface.d.ts +3 -1
- package/esm/region/interface.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 +30 -6
- package/esm/series/base/tooltip-helper.js +85 -74
- package/esm/series/base/tooltip-helper.js.map +1 -1
- package/esm/series/box-plot/tooltip-helper.d.ts +2 -2
- package/esm/series/box-plot/tooltip-helper.js +26 -67
- package/esm/series/box-plot/tooltip-helper.js.map +1 -1
- package/esm/series/cartesian/cartesian.d.ts +1 -1
- package/esm/series/circle-packing/circle-packing.js +1 -2
- package/esm/series/circle-packing/circle-packing.js.map +1 -1
- package/esm/series/dot/tooltip-helper.d.ts +8 -2
- package/esm/series/dot/tooltip-helper.js +42 -41
- package/esm/series/dot/tooltip-helper.js.map +1 -1
- package/esm/series/gauge/pointer-tooltip-helper.d.ts +2 -1
- package/esm/series/gauge/pointer-tooltip-helper.js +2 -9
- package/esm/series/gauge/pointer-tooltip-helper.js.map +1 -1
- package/esm/series/heatmap/tooltip-helper.d.ts +2 -3
- package/esm/series/heatmap/tooltip-helper.js +2 -6
- package/esm/series/heatmap/tooltip-helper.js.map +1 -1
- package/esm/series/interface/tooltip-helper.d.ts +5 -4
- package/esm/series/interface/tooltip-helper.js.map +1 -1
- package/esm/series/link/tooltip-helper.d.ts +5 -2
- package/esm/series/link/tooltip-helper.js +26 -27
- package/esm/series/link/tooltip-helper.js.map +1 -1
- package/esm/series/liquid/tooltip-helper.d.ts +4 -5
- package/esm/series/liquid/tooltip-helper.js +2 -22
- package/esm/series/liquid/tooltip-helper.js.map +1 -1
- package/esm/series/pie/pie.js +7 -3
- package/esm/series/pie/pie.js.map +1 -1
- package/esm/series/progress/linear/tooltip-helper.d.ts +2 -3
- package/esm/series/progress/linear/tooltip-helper.js +2 -11
- package/esm/series/progress/linear/tooltip-helper.js.map +1 -1
- package/esm/series/range-area/tooltip-helper.d.ts +1 -3
- package/esm/series/range-area/tooltip-helper.js +2 -50
- package/esm/series/range-area/tooltip-helper.js.map +1 -1
- package/esm/series/range-column/tooltip-helper.d.ts +1 -2
- package/esm/series/range-column/tooltip-helper.js +2 -19
- package/esm/series/range-column/tooltip-helper.js.map +1 -1
- package/esm/series/sankey/sankey.d.ts +1 -1
- package/esm/series/sankey/tooltip-helper.d.ts +3 -3
- package/esm/series/sankey/tooltip-helper.js +10 -57
- package/esm/series/sankey/tooltip-helper.js.map +1 -1
- package/esm/typings/spec/common.d.ts +3 -3
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/typings/tooltip/position.d.ts +1 -0
- package/esm/typings/tooltip/position.js.map +1 -1
- package/esm/typings/tooltip/shape.d.ts +0 -1
- package/esm/typings/tooltip/shape.js.map +1 -1
- package/esm/typings/tooltip/tooltip.d.ts +7 -0
- package/esm/typings/tooltip/tooltip.js.map +1 -1
- package/package.json +13 -13
- package/cjs/component/interface/tooltip-helper.d.ts +0 -5
- package/cjs/component/interface/tooltip-helper.js +0 -6
- package/cjs/component/interface/tooltip-helper.js.map +0 -1
- package/cjs/component/tooltip/utils/compose.d.ts +0 -4
- package/cjs/component/tooltip/utils/compose.js +0 -120
- package/cjs/component/tooltip/utils/compose.js.map +0 -1
- package/cjs/model/tooltip-helper.d.ts +0 -29
- package/cjs/model/tooltip-helper.js +0 -19
- package/cjs/model/tooltip-helper.js.map +0 -1
- package/esm/component/interface/tooltip-helper.d.ts +0 -5
- package/esm/component/interface/tooltip-helper.js +0 -2
- package/esm/component/interface/tooltip-helper.js.map +0 -1
- package/esm/component/tooltip/utils/compose.d.ts +0 -4
- package/esm/component/tooltip/utils/compose.js +0 -105
- package/esm/component/tooltip/utils/compose.js.map +0 -1
- package/esm/model/tooltip-helper.d.ts +0 -29
- package/esm/model/tooltip-helper.js +0 -11
- package/esm/model/tooltip-helper.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/transforms/pie.ts"],"names":[],"mappings":";;;AAEA,0CAAqD;AACrD,0CAAkD;AAClD,gDAA2D;AAC3D,
|
|
1
|
+
{"version":3,"sources":["../src/data/transforms/pie.ts"],"names":[],"mappings":"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","file":"pie.js","sourcesContent":["import type { DataView } from '@visactor/vdataset';\nimport type { Datum } from '../../typings';\nimport { couldBeValidNumber } from '../../util/type';\nimport { getPercentValue } from '../../util/math';\nimport { ARC_TRANSFORM_VALUE } from '../../constant/polar';\nimport { computeQuadrant, isNil } from '@visactor/vutils';\n\nexport interface IPieOpt {\n angleField: () => string;\n startAngle: () => number;\n endAngle: () => number;\n minAngle: () => number;\n\n asStartAngle: string;\n asEndAngle: string;\n asMiddleAngle: string;\n asRadian: string;\n asRatio: string;\n asQuadrant: string;\n asK: string;\n showAllZero: boolean;\n supportNegative: boolean;\n showEmptyCircle: boolean;\n}\n\nfunction transformInvalidValue(value: any) {\n if (!couldBeValidNumber(value)) {\n return 0;\n }\n return Number.parseFloat(value);\n}\n\nexport const pie = (originData: Array<DataView>, op: IPieOpt) => {\n const {\n asStartAngle,\n asEndAngle,\n asMiddleAngle,\n asRadian,\n asRatio,\n asQuadrant,\n asK,\n showAllZero,\n supportNegative,\n showEmptyCircle\n } = op;\n\n const angleField = op.angleField();\n const startAngle = op.startAngle();\n const endAngle = op.endAngle();\n const minAngle = op.minAngle();\n\n const data = originData.map((datum: Datum) => ({ ...datum }));\n if (!data || data.length === 0) {\n return data;\n }\n\n if (!showAllZero && showEmptyCircle && isDataEmpty(data, angleField, supportNegative)) {\n return data;\n }\n\n const appendArcInfo = (data: Datum, startAngle: number, angle: number) => {\n data[asStartAngle] = startAngle;\n data[asEndAngle] = startAngle + angle;\n data[asMiddleAngle] = startAngle + angle / 2;\n data[asRadian] = angle;\n data[asQuadrant] = computeQuadrant(startAngle + angle / 2);\n };\n\n let total = 0;\n let max = -Infinity;\n let isAllZero = true;\n for (let index = 0; index < data.length; index++) {\n const angleFieldValue = supportNegative\n ? Math.abs(transformInvalidValue(data[index][angleField]))\n : transformInvalidValue(data[index][angleField]);\n total += angleFieldValue;\n max = Math.max(angleFieldValue, max);\n if (isAllZero && angleFieldValue !== 0) {\n isAllZero = false;\n }\n\n data[index][ARC_TRANSFORM_VALUE] = angleFieldValue;\n }\n\n const valueList = data.map(d => Number(d[angleField]));\n const angleRange = endAngle - startAngle;\n let lastAngle = startAngle;\n let restAngle = angleRange;\n let largeThanMinAngleTotal = 0;\n const percents = getPercentValue(valueList);\n\n data.forEach((d, i) => {\n const angleFieldValue = d[ARC_TRANSFORM_VALUE];\n const ratio = total ? angleFieldValue / total : 0;\n let radian = ratio * angleRange;\n\n if (radian < minAngle) {\n radian = minAngle;\n restAngle -= minAngle;\n } else {\n largeThanMinAngleTotal += angleFieldValue;\n }\n\n const dStartAngle = lastAngle;\n const dEndAngle = lastAngle + radian;\n\n d[asRatio] = ratio;\n d[asK] = max ? angleFieldValue / max : 0;\n d._percent_ = (percents as number[])[i];\n appendArcInfo(d, dStartAngle, radian);\n\n lastAngle = dEndAngle;\n });\n\n if (restAngle < angleRange) {\n if (restAngle <= 1e-3) {\n const angle = angleRange / data.length;\n data.forEach((d, index) => {\n appendArcInfo(d, startAngle + index * angle, angle);\n });\n } else {\n const unitRadian = restAngle / largeThanMinAngleTotal;\n lastAngle = startAngle;\n data.forEach(d => {\n const angle = d[asRadian] === minAngle ? minAngle : d[ARC_TRANSFORM_VALUE] * unitRadian;\n appendArcInfo(d, lastAngle, angle);\n\n lastAngle += angle;\n });\n }\n }\n\n if (total !== 0) {\n // 数据都为 0 时,起始角和结束角相同,不应该强制赋值\n // 防止一个扇区的角度会因为浮点数精度问题和传入的 endAngle 不相等\n data[data.length - 1][asEndAngle] = endAngle;\n }\n\n if (isAllZero && showAllZero) {\n const angle = angleRange / data.length;\n data.forEach((d, index) => {\n appendArcInfo(d, startAngle + index * angle, angle);\n });\n }\n return data;\n};\n\nexport const isDataEmpty = (data: Datum[], angleField: string, supportNegative: boolean) => {\n if (isNil(data)) {\n return true;\n }\n if (data.length === 0) {\n return true;\n }\n if (data.every(datum => transformInvalidValue(datum[angleField]) === 0)) {\n return true;\n }\n // 未支持负数, 并且和为0, 则也认为是空数据\n if (!supportNegative && data.reduce((sum, datum) => sum + transformInvalidValue(datum[angleField]), 0) === 0) {\n return true;\n }\n\n return false;\n};\n"]}
|
package/cjs/model/interface.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ import type { ILayoutItem, ILayoutItemSpec } from '../layout/interface';
|
|
|
20
20
|
import type { ILayoutPoint, ILayoutRect } from '../typings/layout';
|
|
21
21
|
import type { ComponentTypeEnum } from '../component/interface';
|
|
22
22
|
import type { SeriesTypeEnum } from '../series';
|
|
23
|
+
import type { ITooltipSpec } from '../component/tooltip/interface';
|
|
24
|
+
import type { TooltipActiveType } from '../typings';
|
|
23
25
|
export interface IModelInitOption {
|
|
24
26
|
}
|
|
25
27
|
export interface IModelLayoutOption {
|
|
@@ -152,3 +154,15 @@ export interface IBaseModelSpecTransformer {
|
|
|
152
154
|
getTheme: (spec: any, chartSpec: any) => any;
|
|
153
155
|
transformSpec: (spec: any, chartSpec: any, chartSpecInfo?: IChartSpecInfo) => IBaseModelSpecTransformerResult<any, any>;
|
|
154
156
|
}
|
|
157
|
+
export interface ITooltipHelper {
|
|
158
|
+
spec: ITooltipSpec | undefined;
|
|
159
|
+
activeType: TooltipActiveType[];
|
|
160
|
+
activeTriggerSet: {
|
|
161
|
+
mark?: Set<IMark>;
|
|
162
|
+
group?: Set<IMark>;
|
|
163
|
+
};
|
|
164
|
+
ignoreTriggerSet: {
|
|
165
|
+
mark?: Set<IMark>;
|
|
166
|
+
};
|
|
167
|
+
updateTooltipSpec: () => void;
|
|
168
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { DataSet, DataView } from '@visactor/vdataset';\nimport type { IEvent, IEventDispatcher } from '../event/interface';\nimport type { IMark, IMarkRaw, IMarkStyle, MarkTypeEnum } from '../mark/interface';\nimport type { RenderMode } from '../typings/spec/common';\nimport type { VChart } from '../vchart-all';\nimport type { IData } from '@visactor/vgrammar-core';\nimport type { StringOrNumber } from '../typings/common';\nimport type { IGroupMarkSpec, ConvertToMarkStyleSpec, ICommonSpec } from '../typings/visual';\nimport type { IRect } from '../typings/space';\nimport type { IPoint, CoordinateType } from '../typings/coordinate';\nimport type { ITheme } from '../theme';\nimport type { StateValueType } from '../typings/spec';\nimport type { ICompilable, ICompilableInitOption } from '../compile/interface';\nimport type { ICompilableData } from '../compile/data';\nimport type { IGlobalScale } from '../scale/interface';\nimport type { IChart, IChartSpecInfo, IChartSpecTransformerOption } from '../chart/interface';\nimport type { IThemeColorScheme } from '../theme/color-scheme/interface';\nimport type { ILayoutItem, ILayoutItemSpec } from '../layout/interface';\nimport type { ILayoutPoint, ILayoutRect } from '../typings/layout';\nimport type { ComponentTypeEnum } from '../component/interface';\nimport type { SeriesTypeEnum } from '../series';\n\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelInitOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelLayoutOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelEvaluateOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelRenderOption {}\n\nexport interface IEffect {\n [key: string]: (e?: any) => any;\n}\n\nexport interface IMarkTreeGroup extends Partial<IMarkStyle<IGroupMarkSpec>> {\n // 必须要有名字\n type: 'group';\n name: string;\n marks: (IMarkTreeGroup | IMark)[];\n // TODO: 这里要不要支持复杂场景,有图形组合的场景,用自定义mark?\n // from?: IData;\n}\n\nexport type IMarkTree = IMarkTreeGroup | IMark | (IMarkTreeGroup | IMark)[];\n\nexport interface IUpdateSpecResult {\n change: boolean;\n reMake: boolean;\n reRender?: boolean;\n reSize?: boolean;\n // TODO: compile 的判断应不应该出现在这里?\n reCompile?: boolean;\n reTransformSpec?: boolean;\n reAnimate?: boolean;\n changeTheme?: boolean;\n changeBackground?: boolean;\n}\n\nexport interface IUpdateDataResult {\n reAnimate?: boolean;\n}\n\nexport interface IModelProduct {\n srData: IData;\n}\n\nexport interface IModel extends ICompilable {\n readonly modelType: string;\n readonly type: string;\n readonly specKey: string;\n readonly transformerConstructor: new (option: IBaseModelSpecTransformerOption) => IBaseModelSpecTransformer;\n\n readonly id: number;\n\n readonly userId?: StringOrNumber;\n\n // 事件\n readonly event: IEvent;\n\n // 副作用\n readonly effect: IEffect;\n\n coordinate?: CoordinateType;\n\n // 布局\n layout?: ILayoutItem;\n\n /** 是否可见 */\n getVisible: () => boolean;\n\n // 初始化参数\n getOption: () => IModelOption;\n\n getMarks: () => IMark[];\n getMarkNameMap: () => Record<string, IMark>;\n\n getData: () => ICompilableData;\n\n getChart: () => IChart;\n\n //生命周期\n // 创建模块自身内容,设置自身属性\n created: () => void;\n // 用来处理与其他图表模块的联系\n init: (option: IModelInitOption) => void;\n /** updateSpec 或者切换主题后,根据新 spec 执行的初始化过程 */\n reInit: (spec?: any) => void;\n beforeRelease: () => void;\n\n onEvaluateEnd: (ctx: IModelEvaluateOption) => void;\n onRender: (ctx: IModelRenderOption) => void;\n onDataUpdate: () => void;\n\n updateSpec: (spec: any, totalSpec?: any) => IUpdateSpecResult;\n getSpec?: () => any;\n getSpecIndex: () => number;\n getSpecPath: () => Array<string | number>;\n\n //布局周期\n onLayoutStart: (layoutRect: IRect, viewRect: ILayoutRect, ctx: IModelLayoutOption) => void;\n onLayoutEnd: (ctx: IModelLayoutOption) => void;\n\n getColorScheme: () => IThemeColorScheme | undefined;\n\n setMarkStyle: <T extends ICommonSpec>(\n mark?: IMarkRaw<T>,\n style?: Partial<IMarkStyle<T> | ConvertToMarkStyleSpec<T>>,\n state?: StateValueType,\n level?: number\n ) => void;\n\n initMarkStyleWithSpec: (mark?: IMark, spec?: any, key?: string) => void;\n\n getSpecInfo: () => IModelSpecInfo;\n}\n\nexport interface ILayoutModel extends IModel {\n // 布局相关\n getLayoutStartPoint: () => IPoint;\n setLayoutStartPosition: (pos: Partial<IPoint>) => void;\n getLayoutRect: () => ILayoutRect;\n setLayoutRect: (rect: Partial<ILayoutRect>, levelMap?: Partial<ILayoutRect>) => void;\n\n getLastComputeOutBounds: () => IBoundsLike;\n\n getBoundsInRect: (rect: ILayoutRect, fullRect: ILayoutRect) => IBoundsLike;\n\n //布局周期\n afterSetLayoutStartPoint: (pos: ILayoutPoint) => void;\n}\n\nexport interface IModelOption extends ICompilableInitOption {\n type: string;\n eventDispatcher: IEventDispatcher;\n dataSet: DataSet;\n map: Map<StringOrNumber, IModel | IMark>;\n mode: RenderMode;\n globalInstance: VChart;\n regionIndexes?: Array<number>;\n specKey?: string;\n specPath?: Array<string | number>;\n specInfoPath?: Array<string | number>;\n\n getTheme?: () => ITheme;\n getSpecInfo?: () => IChartSpecInfo;\n getChartLayoutRect: () => IRect;\n getChartViewRect: () => ILayoutRect;\n\n getChart: () => IChart;\n getSeriesData: (id: StringOrNumber | undefined, index: number | undefined) => DataView | undefined;\n\n globalScale: IGlobalScale;\n animation: boolean;\n /**\n * 错误消息回调函数\n */\n onError: (...args: any[]) => void;\n\n /**\n * 是否关闭交互效果\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface IModelSpecInfo<T extends Record<string, unknown> = any> {\n /** model 具体类型 */\n type: string | ComponentTypeEnum | SeriesTypeEnum;\n /** model spec */\n spec: T;\n /** 该 spec 在图表 spec 上的路径 */\n specPath?: Array<string | number>;\n /** 该 spec 在图表 spec info 上的路径 */\n specInfoPath?: Array<string | number>;\n /** model 当前主题 */\n theme?: any;\n /** model 对应的 region 索引 */\n regionIndexes?: number[];\n /** model 对应的 series 索引 */\n seriesIndexes?: number[];\n}\n\nexport interface IModelConstructor {\n readonly transformerConstructor: new (option: IBaseModelSpecTransformerOption) => IBaseModelSpecTransformer;\n}\n\nexport type ILayoutModelState = {\n layoutUpdateRank: number;\n [key: string]: unknown;\n};\n\n// TODO: 补充model共有配置\nexport type IModelSpec = ILayoutItemSpec & { id?: StringOrNumber };\n\nexport interface IModelMarkInfo {\n /** mark 类型 */\n type: MarkTypeEnum | string | (MarkTypeEnum | string)[];\n /** mark 名称 */\n name: string;\n}\n\nexport type IBaseModelSpecTransformerOption = IChartSpecTransformerOption;\n\nexport interface IBaseModelSpecTransformerResult<T, K> {\n spec: T;\n theme: K;\n}\n\nexport interface IBaseModelSpecTransformer {\n getTheme: (spec: any, chartSpec: any) => any;\n transformSpec: (\n spec: any,\n chartSpec: any,\n chartSpecInfo?: IChartSpecInfo\n ) => IBaseModelSpecTransformerResult<any, any>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { DataSet, DataView } from '@visactor/vdataset';\nimport type { IEvent, IEventDispatcher } from '../event/interface';\nimport type { IMark, IMarkRaw, IMarkStyle, MarkTypeEnum } from '../mark/interface';\nimport type { RenderMode } from '../typings/spec/common';\nimport type { VChart } from '../vchart-all';\nimport type { IData } from '@visactor/vgrammar-core';\nimport type { StringOrNumber } from '../typings/common';\nimport type { IGroupMarkSpec, ConvertToMarkStyleSpec, ICommonSpec } from '../typings/visual';\nimport type { IRect } from '../typings/space';\nimport type { IPoint, CoordinateType } from '../typings/coordinate';\nimport type { ITheme } from '../theme';\nimport type { StateValueType } from '../typings/spec';\nimport type { ICompilable, ICompilableInitOption } from '../compile/interface';\nimport type { ICompilableData } from '../compile/data';\nimport type { IGlobalScale } from '../scale/interface';\nimport type { IChart, IChartSpecInfo, IChartSpecTransformerOption } from '../chart/interface';\nimport type { IThemeColorScheme } from '../theme/color-scheme/interface';\nimport type { ILayoutItem, ILayoutItemSpec } from '../layout/interface';\nimport type { ILayoutPoint, ILayoutRect } from '../typings/layout';\nimport type { ComponentTypeEnum } from '../component/interface';\nimport type { SeriesTypeEnum } from '../series';\nimport type { ITooltipSpec } from '../component/tooltip/interface';\nimport type { TooltipActiveType } from '../typings';\n\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelInitOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelLayoutOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelEvaluateOption {}\n// TODO:\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IModelRenderOption {}\n\nexport interface IEffect {\n [key: string]: (e?: any) => any;\n}\n\nexport interface IMarkTreeGroup extends Partial<IMarkStyle<IGroupMarkSpec>> {\n // 必须要有名字\n type: 'group';\n name: string;\n marks: (IMarkTreeGroup | IMark)[];\n // TODO: 这里要不要支持复杂场景,有图形组合的场景,用自定义mark?\n // from?: IData;\n}\n\nexport type IMarkTree = IMarkTreeGroup | IMark | (IMarkTreeGroup | IMark)[];\n\nexport interface IUpdateSpecResult {\n change: boolean;\n reMake: boolean;\n reRender?: boolean;\n reSize?: boolean;\n // TODO: compile 的判断应不应该出现在这里?\n reCompile?: boolean;\n reTransformSpec?: boolean;\n reAnimate?: boolean;\n changeTheme?: boolean;\n changeBackground?: boolean;\n}\n\nexport interface IUpdateDataResult {\n reAnimate?: boolean;\n}\n\nexport interface IModelProduct {\n srData: IData;\n}\n\nexport interface IModel extends ICompilable {\n readonly modelType: string;\n readonly type: string;\n readonly specKey: string;\n readonly transformerConstructor: new (option: IBaseModelSpecTransformerOption) => IBaseModelSpecTransformer;\n\n readonly id: number;\n\n readonly userId?: StringOrNumber;\n\n // 事件\n readonly event: IEvent;\n\n // 副作用\n readonly effect: IEffect;\n\n coordinate?: CoordinateType;\n\n // 布局\n layout?: ILayoutItem;\n\n /** 是否可见 */\n getVisible: () => boolean;\n\n // 初始化参数\n getOption: () => IModelOption;\n\n getMarks: () => IMark[];\n getMarkNameMap: () => Record<string, IMark>;\n\n getData: () => ICompilableData;\n\n getChart: () => IChart;\n\n //生命周期\n // 创建模块自身内容,设置自身属性\n created: () => void;\n // 用来处理与其他图表模块的联系\n init: (option: IModelInitOption) => void;\n /** updateSpec 或者切换主题后,根据新 spec 执行的初始化过程 */\n reInit: (spec?: any) => void;\n beforeRelease: () => void;\n\n onEvaluateEnd: (ctx: IModelEvaluateOption) => void;\n onRender: (ctx: IModelRenderOption) => void;\n onDataUpdate: () => void;\n\n updateSpec: (spec: any, totalSpec?: any) => IUpdateSpecResult;\n getSpec?: () => any;\n getSpecIndex: () => number;\n getSpecPath: () => Array<string | number>;\n\n //布局周期\n onLayoutStart: (layoutRect: IRect, viewRect: ILayoutRect, ctx: IModelLayoutOption) => void;\n onLayoutEnd: (ctx: IModelLayoutOption) => void;\n\n getColorScheme: () => IThemeColorScheme | undefined;\n\n setMarkStyle: <T extends ICommonSpec>(\n mark?: IMarkRaw<T>,\n style?: Partial<IMarkStyle<T> | ConvertToMarkStyleSpec<T>>,\n state?: StateValueType,\n level?: number\n ) => void;\n\n initMarkStyleWithSpec: (mark?: IMark, spec?: any, key?: string) => void;\n\n getSpecInfo: () => IModelSpecInfo;\n}\n\nexport interface ILayoutModel extends IModel {\n // 布局相关\n getLayoutStartPoint: () => IPoint;\n setLayoutStartPosition: (pos: Partial<IPoint>) => void;\n getLayoutRect: () => ILayoutRect;\n setLayoutRect: (rect: Partial<ILayoutRect>, levelMap?: Partial<ILayoutRect>) => void;\n\n getLastComputeOutBounds: () => IBoundsLike;\n\n getBoundsInRect: (rect: ILayoutRect, fullRect: ILayoutRect) => IBoundsLike;\n\n //布局周期\n afterSetLayoutStartPoint: (pos: ILayoutPoint) => void;\n}\n\nexport interface IModelOption extends ICompilableInitOption {\n type: string;\n eventDispatcher: IEventDispatcher;\n dataSet: DataSet;\n map: Map<StringOrNumber, IModel | IMark>;\n mode: RenderMode;\n globalInstance: VChart;\n regionIndexes?: Array<number>;\n specKey?: string;\n specPath?: Array<string | number>;\n specInfoPath?: Array<string | number>;\n\n getTheme?: () => ITheme;\n getSpecInfo?: () => IChartSpecInfo;\n getChartLayoutRect: () => IRect;\n getChartViewRect: () => ILayoutRect;\n\n getChart: () => IChart;\n getSeriesData: (id: StringOrNumber | undefined, index: number | undefined) => DataView | undefined;\n\n globalScale: IGlobalScale;\n animation: boolean;\n /**\n * 错误消息回调函数\n */\n onError: (...args: any[]) => void;\n\n /**\n * 是否关闭交互效果\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface IModelSpecInfo<T extends Record<string, unknown> = any> {\n /** model 具体类型 */\n type: string | ComponentTypeEnum | SeriesTypeEnum;\n /** model spec */\n spec: T;\n /** 该 spec 在图表 spec 上的路径 */\n specPath?: Array<string | number>;\n /** 该 spec 在图表 spec info 上的路径 */\n specInfoPath?: Array<string | number>;\n /** model 当前主题 */\n theme?: any;\n /** model 对应的 region 索引 */\n regionIndexes?: number[];\n /** model 对应的 series 索引 */\n seriesIndexes?: number[];\n}\n\nexport interface IModelConstructor {\n readonly transformerConstructor: new (option: IBaseModelSpecTransformerOption) => IBaseModelSpecTransformer;\n}\n\nexport type ILayoutModelState = {\n layoutUpdateRank: number;\n [key: string]: unknown;\n};\n\n// TODO: 补充model共有配置\nexport type IModelSpec = ILayoutItemSpec & { id?: StringOrNumber };\n\nexport interface IModelMarkInfo {\n /** mark 类型 */\n type: MarkTypeEnum | string | (MarkTypeEnum | string)[];\n /** mark 名称 */\n name: string;\n}\n\nexport type IBaseModelSpecTransformerOption = IChartSpecTransformerOption;\n\nexport interface IBaseModelSpecTransformerResult<T, K> {\n spec: T;\n theme: K;\n}\n\nexport interface IBaseModelSpecTransformer {\n getTheme: (spec: any, chartSpec: any) => any;\n transformSpec: (\n spec: any,\n chartSpec: any,\n chartSpecInfo?: IChartSpecInfo\n ) => IBaseModelSpecTransformerResult<any, any>;\n}\n\nexport interface ITooltipHelper {\n /** tooltip对应spec */\n spec: ITooltipSpec | undefined;\n\n /** 实际生效的tooltip activeType */\n activeType: TooltipActiveType[];\n\n /** 可以响应mark tooltip或者dimension tooltip的对象 */\n activeTriggerSet: {\n mark?: Set<IMark>;\n group?: Set<IMark>;\n };\n /** 不响应tooltip且不会影响已有tooltip的对象 */\n ignoreTriggerSet: {\n mark?: Set<IMark>;\n };\n\n /** 更新spec */\n updateTooltipSpec: () => void;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options } from './constants';
|
|
2
|
-
import type { Maybe,
|
|
2
|
+
import type { Maybe, RenderMode } from '../../../typings';
|
|
3
3
|
import type { TooltipData, ITooltipActual, TooltipActiveType, ITooltipHandler, ITooltipPositionActual } from '../../../typings/tooltip';
|
|
4
4
|
import type { IGroup } from '@visactor/vrender-core';
|
|
5
5
|
import type { Compiler } from '../../../compile/compiler';
|
|
@@ -25,12 +25,6 @@ export declare abstract class BaseTooltipHandler extends BasePlugin implements I
|
|
|
25
25
|
protected _attributes?: ITooltipAttributes | null;
|
|
26
26
|
protected _chartContainer: Maybe<HTMLElement>;
|
|
27
27
|
protected _compiler: Compiler;
|
|
28
|
-
protected _isTooltipPaused: boolean;
|
|
29
|
-
protected _isPointerEscaped: boolean;
|
|
30
|
-
protected _cachePointerTimer: number;
|
|
31
|
-
protected _cachePointerPosition: ILayoutPoint;
|
|
32
|
-
protected _cacheTooltipPosition: ILayoutPoint;
|
|
33
|
-
protected _cacheTooltipSize: IContainerSize;
|
|
34
28
|
protected _container: Maybe<IGroup | HTMLElement>;
|
|
35
29
|
protected _isReleased: boolean;
|
|
36
30
|
onAdd(service: IComponentPluginService<any>): void;
|
|
@@ -41,18 +35,12 @@ export declare abstract class BaseTooltipHandler extends BasePlugin implements I
|
|
|
41
35
|
protected _changeTooltipPosition: ChangeTooltipPositionFunc;
|
|
42
36
|
hideTooltip(params: TooltipHandlerParams): TooltipResult;
|
|
43
37
|
release(): void;
|
|
44
|
-
protected _clearAllCache(): void;
|
|
45
38
|
protected abstract _updateTooltip(visible: boolean, params: TooltipHandlerParams): void;
|
|
46
39
|
protected abstract _removeTooltip(): void;
|
|
47
40
|
protected _throttle(callback: any): (...args: unknown[]) => unknown;
|
|
48
41
|
protected _getDefaultOption(): Options;
|
|
49
42
|
protected _getActualTooltipPosition: (actualTooltip: ITooltipActual, params: TooltipHandlerParams, tooltipBoxSize: IContainerSize | undefined) => ITooltipPositionActual;
|
|
50
43
|
protected _getTooltipBoxSize(actualTooltip: ITooltipActual, changePositionOnly: boolean): IContainerSize | undefined;
|
|
51
|
-
protected _getPointerPositionRelativeToTooltipParent(params: TooltipHandlerParams): {
|
|
52
|
-
x: any;
|
|
53
|
-
y: any;
|
|
54
|
-
};
|
|
55
|
-
protected _isPointerMovingToTooltip(params: TooltipHandlerParams): boolean;
|
|
56
44
|
protected _getParentElement(spec: ITooltipSpec): HTMLElement;
|
|
57
45
|
getTooltipContainer(): HTMLElement | IGroup;
|
|
58
46
|
protected _initFromSpec(): void;
|
|
@@ -12,27 +12,20 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
12
12
|
this.showTooltip = (activeType, data, params) => {
|
|
13
13
|
const {changePositionOnly: changePositionOnly} = params;
|
|
14
14
|
return changePositionOnly ? this.changeTooltipPosition(params, data) : this.changeTooltip(!0, params, data);
|
|
15
|
-
}, this._changeTooltip = (visible, params, data) => this._isReleased ? 1 : visible ? this._changeTooltipPosition(params, data) : (this.
|
|
16
|
-
|
|
17
|
-
var _a, _b, _c;
|
|
15
|
+
}, this._changeTooltip = (visible, params, data) => this._isReleased ? 1 : visible ? this._changeTooltipPosition(params, data) : (this._updateTooltip(!1, params),
|
|
16
|
+
0), this._changeTooltipPosition = (params, data) => {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
18
|
if (this._isReleased) return 1;
|
|
19
|
-
const event = params.event, {tooltipSpec: tooltipSpec,
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
const activeType = tooltipActual.activeType;
|
|
29
|
-
if (tooltipSpec.handler) return null !== (_c = null === (_b = (_a = tooltipSpec.handler).showTooltip) || void 0 === _b ? void 0 : _b.call(_a, activeType, data, params)) && void 0 !== _c ? _c : 0;
|
|
30
|
-
const pattern = tooltipSpec[activeType];
|
|
31
|
-
if (!pattern) return 1;
|
|
32
|
-
const position = this._getActualTooltipPosition(tooltipActual, params, this._getTooltipBoxSize(tooltipActual, changePositionOnly));
|
|
33
|
-
tooltipActual.position = position, pattern.updatePosition && (tooltipActual.position = pattern.updatePosition(tooltipActual.position, data, params));
|
|
19
|
+
const event = params.event, {tooltipSpec: tooltipSpec, activeTooltipSpec: activeTooltipSpec, changePositionOnly: changePositionOnly} = params;
|
|
20
|
+
if (!activeTooltipSpec) return 1;
|
|
21
|
+
const activeType = activeTooltipSpec.activeType;
|
|
22
|
+
if (activeTooltipSpec.handler) return null !== (_c = null === (_b = (_a = activeTooltipSpec.handler).showTooltip) || void 0 === _b ? void 0 : _b.call(_a, activeType, data, params)) && void 0 !== _c ? _c : 0;
|
|
23
|
+
const pattern = activeTooltipSpec, position = this._getActualTooltipPosition(activeTooltipSpec, params, this._getTooltipBoxSize(activeTooltipSpec, changePositionOnly));
|
|
24
|
+
activeTooltipSpec.position = position;
|
|
25
|
+
const updatePosition = null !== (_d = activeTooltipSpec.updatePosition) && void 0 !== _d ? _d : null === (_e = tooltipSpec[activeType]) || void 0 === _e ? void 0 : _e.updatePosition;
|
|
26
|
+
updatePosition && (activeTooltipSpec.position = updatePosition(activeTooltipSpec.position, data, params));
|
|
34
27
|
let tooltipVisible = !1 !== (null == pattern ? void 0 : pattern.visible);
|
|
35
|
-
return data && "pointerout" !== event.type &&
|
|
28
|
+
return data && "pointerout" !== event.type && activeTooltipSpec.visible && (activeTooltipSpec.title || activeTooltipSpec.content) || (tooltipVisible = !1),
|
|
36
29
|
this._updateTooltip(tooltipVisible, Object.assign(Object.assign({}, params), {
|
|
37
30
|
changePositionOnly: changePositionOnly
|
|
38
31
|
})), 0;
|
|
@@ -42,11 +35,10 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
42
35
|
x: 1 / 0,
|
|
43
36
|
y: 1 / 0
|
|
44
37
|
};
|
|
45
|
-
if (!tooltipSpec) return
|
|
46
|
-
const event = params.event, {activeType: activeType, data: data} = actualTooltip, firstDim = "dimension" === activeType ? null === (_b = null === (_a = data[0]) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0] : null == data ? void 0 : data[0]
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
utils_1.getTooltipPatternValue)(spec.positionMode, data, params)) && void 0 !== _c ? _c : "mark" === activeType ? "mark" : "pointer", {width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0} = null != tooltipBoxSize ? tooltipBoxSize : {}, isCanvas = "canvas" === tooltipSpec.renderMode, canvasRect = null === (_d = null == params ? void 0 : params.chart) || void 0 === _d ? void 0 : _d.getCanvasRect(), canvasWidth = null !== (_e = null == canvasRect ? void 0 : canvasRect.width) && void 0 !== _e ? _e : base_1.DEFAULT_CHART_WIDTH, canvasHeight = null !== (_f = null == canvasRect ? void 0 : canvasRect.height) && void 0 !== _f ? _f : base_1.DEFAULT_CHART_HEIGHT;
|
|
38
|
+
if (!tooltipSpec) return invalidPosition;
|
|
39
|
+
const event = params.event, {activeType: activeType, data: data} = actualTooltip, firstDim = "dimension" === activeType ? null === (_b = null === (_a = data[0]) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0] : null == data ? void 0 : data[0], {offsetX: offsetX, offsetY: offsetY} = this._option, spec = tooltipSpec[activeType], position = (0,
|
|
40
|
+
utils_1.getTooltipPatternValue)(null == spec ? void 0 : spec.position, data, params), positionMode = null !== (_c = (0,
|
|
41
|
+
utils_1.getTooltipPatternValue)(null == spec ? void 0 : spec.positionMode, data, params)) && void 0 !== _c ? _c : "mark" === activeType ? "mark" : "pointer", {width: tooltipBoxWidth = 0, height: tooltipBoxHeight = 0} = null != tooltipBoxSize ? tooltipBoxSize : {}, isCanvas = "canvas" === tooltipSpec.renderMode, canvasRect = null === (_d = null == params ? void 0 : params.chart) || void 0 === _d ? void 0 : _d.getCanvasRect(), canvasWidth = null !== (_e = null == canvasRect ? void 0 : canvasRect.width) && void 0 !== _e ? _e : base_1.DEFAULT_CHART_WIDTH, canvasHeight = null !== (_f = null == canvasRect ? void 0 : canvasRect.height) && void 0 !== _f ? _f : base_1.DEFAULT_CHART_HEIGHT;
|
|
50
42
|
let isFixedPosition = !1;
|
|
51
43
|
const containerSize = {
|
|
52
44
|
width: 0,
|
|
@@ -72,152 +64,85 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
72
64
|
common_1.getScale)(tooltipParentElement, tooltipParentElementRect);
|
|
73
65
|
}
|
|
74
66
|
} else containerSize.width = canvasWidth, containerSize.height = canvasHeight;
|
|
75
|
-
const tooltipSizeScale = tooltipParentElementScale / chartElementScale
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const tooltipSizeScale = tooltipParentElementScale / chartElementScale, calcPos = {}, pointerFixedPosition = {
|
|
68
|
+
x: position,
|
|
69
|
+
y: position
|
|
70
|
+
}, dimToPos = {
|
|
71
|
+
x: [ "left", "right" ],
|
|
72
|
+
y: [ "top", "bottom" ]
|
|
73
|
+
}, processCartesianFixedPosition = ({orient: orient, mode: mode, offset: offset}, dim) => {
|
|
78
74
|
var _a;
|
|
79
|
-
let
|
|
80
|
-
const model = params.model, startPoint = null == model ? void 0 : model.getLayoutStartPoint();
|
|
81
|
-
if (
|
|
75
|
+
let dim1, dim2;
|
|
76
|
+
const model = params.model, startPoint = null == model ? void 0 : model.getLayoutStartPoint(), dimOffset = null != offset ? offset : "x" === dim ? offsetX : offsetY;
|
|
77
|
+
if ("mark" === mode) {
|
|
82
78
|
isFixedPosition = !0;
|
|
83
79
|
const element = params.item, bounds = null == element ? void 0 : element.getBounds();
|
|
84
|
-
bounds && startPoint && (
|
|
80
|
+
bounds && startPoint && (dim1 = ("x" === dim ? bounds.x1 : bounds.y1) + startPoint[dim],
|
|
81
|
+
dim2 = ("x" === dim ? bounds.x2 : bounds.y2) + startPoint[dim]);
|
|
85
82
|
} else if ("crosshair" === mode && "cartesian" === (null === (_a = null == firstDim ? void 0 : firstDim.series) || void 0 === _a ? void 0 : _a.coordinate) && firstDim.datum && firstDim.datum.length) {
|
|
86
83
|
isFixedPosition = !0;
|
|
87
84
|
const rect = (0, position_1.getCartesianCrosshairRect)(firstDim, startPoint);
|
|
88
|
-
rect && (
|
|
89
|
-
} else
|
|
90
|
-
if (isFixedPosition)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let y1, y2;
|
|
113
|
-
const model = params.model, startPoint = null == model ? void 0 : model.getLayoutStartPoint();
|
|
114
|
-
if (offsetY = null != offset ? offset : offsetY, "mark" === mode) {
|
|
115
|
-
isFixedPosition = !0;
|
|
116
|
-
const element = params.item, bounds = null == element ? void 0 : element.getBounds();
|
|
117
|
-
bounds && startPoint && (y1 = bounds.y1 + startPoint.y, y2 = bounds.y2 + startPoint.y);
|
|
118
|
-
} else if ("crosshair" === mode && "cartesian" === (null === (_a = null == firstDim ? void 0 : firstDim.series) || void 0 === _a ? void 0 : _a.coordinate) && firstDim.datum && firstDim.datum.length) {
|
|
119
|
-
isFixedPosition = !0;
|
|
120
|
-
const rect = (0, position_1.getCartesianCrosshairRect)(firstDim, startPoint);
|
|
121
|
-
rect && (y1 = rect.start.y, y2 = rect.end.y);
|
|
122
|
-
} else pointerFixedPositionY = orient;
|
|
123
|
-
if (isFixedPosition) switch ((0, position_1.getVerticalPositionType)(orient)) {
|
|
124
|
-
case "top":
|
|
125
|
-
top = y1 - tooltipBoxHeight * tooltipSizeScale - offsetY;
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case "bottom":
|
|
129
|
-
top = y2 + offsetY;
|
|
130
|
-
break;
|
|
131
|
-
|
|
132
|
-
case "center":
|
|
133
|
-
top = (y1 + y2) / 2 - tooltipBoxHeight * tooltipSizeScale / 2;
|
|
134
|
-
break;
|
|
135
|
-
|
|
136
|
-
case "centerTop":
|
|
137
|
-
top = (y1 + y2) / 2 - tooltipBoxHeight * tooltipSizeScale - offsetY;
|
|
138
|
-
break;
|
|
139
|
-
|
|
140
|
-
case "centerBottom":
|
|
141
|
-
top = (y1 + y2) / 2 + offsetY;
|
|
85
|
+
rect && (dim1 = rect.start[dim], dim2 = rect.end[dim]);
|
|
86
|
+
} else pointerFixedPosition[dim] = orient;
|
|
87
|
+
if (isFixedPosition) {
|
|
88
|
+
const posKey = dimToPos[dim][0], boxSize = "x" === dim ? tooltipBoxWidth : tooltipBoxHeight;
|
|
89
|
+
switch ((0, position_1.getPositionType)(orient, dim)) {
|
|
90
|
+
case -2:
|
|
91
|
+
calcPos[posKey] = dim1 - boxSize * tooltipSizeScale - dimOffset;
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 0:
|
|
95
|
+
calcPos[posKey] = (dim1 + dim2) / 2 - boxSize * tooltipSizeScale / 2;
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case -1:
|
|
99
|
+
calcPos[posKey] = (dim1 + dim2) / 2 - boxSize * tooltipSizeScale - dimOffset;
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 1:
|
|
103
|
+
calcPos[posKey] = (dim1 + dim2) / 2 + dimOffset;
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 2:
|
|
107
|
+
calcPos[posKey] = dim2 + dimOffset;
|
|
108
|
+
}
|
|
142
109
|
}
|
|
143
|
-
};
|
|
144
|
-
if ((0, vutils_1.isObject)(position)) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
} else (0, vutils_1.isValid)(position) && (processCartesianFixedPositionX({
|
|
110
|
+
}, dims = [ "x", "y" ];
|
|
111
|
+
if ((0, vutils_1.isObject)(position)) if ((0, position_1.isGlobalTooltipPositionPattern)(position)) {
|
|
112
|
+
const {left: posLeft, right: posRight, top: posTop, bottom: posBottom} = position;
|
|
113
|
+
calcPos.left = (0, position_1.getActualTooltipPositionValue)(posLeft, event), calcPos.top = (0,
|
|
114
|
+
position_1.getActualTooltipPositionValue)(posTop, event), calcPos.right = (0, position_1.getActualTooltipPositionValue)(posRight, event),
|
|
115
|
+
calcPos.bottom = (0, position_1.getActualTooltipPositionValue)(posBottom, event);
|
|
116
|
+
} else (0, position_1.isFixedTooltipPositionPattern)(position) && dims.forEach((dim => {
|
|
117
|
+
const dimValue = position[dim];
|
|
118
|
+
(0, vutils_1.isNumber)(dimValue) || (0, vutils_1.isFunction)(dimValue) ? calcPos[dimToPos[dim][0]] = (0,
|
|
119
|
+
position_1.getActualTooltipPositionValue)(dimValue, event) : processCartesianFixedPosition(dimValue, dim);
|
|
120
|
+
})); else (0, vutils_1.isValid)(position) && (processCartesianFixedPosition({
|
|
156
121
|
orient: position,
|
|
157
122
|
mode: positionMode
|
|
158
|
-
}),
|
|
123
|
+
}, "x"), processCartesianFixedPosition({
|
|
159
124
|
orient: position,
|
|
160
125
|
mode: positionMode
|
|
161
|
-
}));
|
|
162
|
-
let x, y;
|
|
163
|
-
const {canvasX: canvasX, canvasY: canvasY} = event;
|
|
164
|
-
if ((0, vutils_1.isValidNumber)(left)) x = left; else if ((0, vutils_1.isValidNumber)(right)) x = canvasWidth - tooltipBoxWidth * tooltipSizeScale - right; else {
|
|
165
|
-
const x0 = canvasX;
|
|
166
|
-
switch ((0, position_1.getHorizontalPositionType)(pointerFixedPositionX, "right")) {
|
|
167
|
-
case "center":
|
|
168
|
-
x = x0 - tooltipBoxWidth * tooltipSizeScale / 2;
|
|
169
|
-
break;
|
|
170
|
-
|
|
171
|
-
case "left":
|
|
172
|
-
case "centerLeft":
|
|
173
|
-
x = x0 - tooltipBoxWidth * tooltipSizeScale - offsetX;
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case "right":
|
|
177
|
-
case "centerRight":
|
|
178
|
-
x = x0 + offsetX;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if ((0, vutils_1.isValidNumber)(top)) y = top; else if ((0, vutils_1.isValidNumber)(bottom)) y = canvasHeight - tooltipBoxHeight * tooltipSizeScale - bottom; else {
|
|
182
|
-
const y0 = canvasY;
|
|
183
|
-
switch ((0, position_1.getVerticalPositionType)(pointerFixedPositionY, "bottom")) {
|
|
184
|
-
case "center":
|
|
185
|
-
y = y0 - tooltipBoxHeight * tooltipSizeScale / 2;
|
|
186
|
-
break;
|
|
187
|
-
|
|
188
|
-
case "top":
|
|
189
|
-
case "centerTop":
|
|
190
|
-
y = y0 - tooltipBoxHeight * tooltipSizeScale - offsetY;
|
|
191
|
-
break;
|
|
192
|
-
|
|
193
|
-
case "bottom":
|
|
194
|
-
case "centerBottom":
|
|
195
|
-
y = y0 + offsetY;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
x *= chartElementScale, y *= chartElementScale, (0, env_1.isTrueBrowser)(this._env) && (x += relativePosOffset.x,
|
|
199
|
-
y += relativePosOffset.y), x /= tooltipParentElementScale, y /= tooltipParentElementScale;
|
|
200
|
-
const {width: containerWidth, height: containerHeight} = containerSize, isLeftOut = () => x * tooltipParentElementScale + tooltipParentElementRect.x < 0, isRightOut = () => (x + tooltipBoxWidth) * tooltipParentElementScale + tooltipParentElementRect.x > containerWidth, isTopOut = () => y * tooltipParentElementScale + tooltipParentElementRect.y < 0, isBottomOut = () => (y + tooltipBoxHeight) * tooltipParentElementScale + tooltipParentElementRect.y > containerHeight, horizontalType = (0,
|
|
201
|
-
position_1.getHorizontalPositionType)(position, "right");
|
|
202
|
-
"left" === horizontalType || horizontalType.includes("center") && isLeftOut() ? (isLeftOut() && (isFixedPosition ? x = -tooltipParentElementRect.x / tooltipParentElementScale : "center" === (0,
|
|
203
|
-
position_1.getHorizontalPositionType)(position, "right") ? x += offsetX + tooltipBoxWidth / 2 : x += 2 * offsetX + tooltipBoxWidth),
|
|
204
|
-
isRightOut() && (x = (containerWidth - tooltipParentElementRect.x) / tooltipParentElementScale - tooltipBoxWidth)) : (isRightOut() && (isFixedPosition ? x = (containerWidth - tooltipParentElementRect.x) / tooltipParentElementScale - tooltipBoxWidth : "center" === (0,
|
|
205
|
-
position_1.getHorizontalPositionType)(position, "right") ? x -= offsetX + tooltipBoxWidth / 2 : x -= 2 * offsetX + tooltipBoxWidth),
|
|
206
|
-
isLeftOut() && (x = -tooltipParentElementRect.x / tooltipParentElementScale));
|
|
207
|
-
const verticalType = (0, position_1.getVerticalPositionType)(position, "bottom");
|
|
208
|
-
"top" === verticalType || verticalType.includes("center") && isTopOut() ? (isTopOut() && (isFixedPosition ? y = -tooltipParentElementRect.y / tooltipParentElementScale : "center" === (0,
|
|
209
|
-
position_1.getVerticalPositionType)(position, "bottom") ? y += offsetY + tooltipBoxHeight / 2 : y += 2 * offsetY + tooltipBoxHeight),
|
|
210
|
-
isBottomOut() && (y = (containerHeight - tooltipParentElementRect.y) / tooltipParentElementScale - tooltipBoxHeight)) : (isBottomOut() && (isFixedPosition ? y = (containerHeight - tooltipParentElementRect.y) / tooltipParentElementScale - tooltipBoxHeight : "center" === (0,
|
|
211
|
-
position_1.getVerticalPositionType)(position, "bottom") ? y -= offsetY + tooltipBoxHeight / 2 : y -= 2 * offsetY + tooltipBoxHeight),
|
|
212
|
-
isTopOut() && (y = 0 - tooltipParentElementRect.y / tooltipParentElementScale));
|
|
126
|
+
}, "y"));
|
|
213
127
|
const result = {
|
|
214
|
-
x:
|
|
215
|
-
y:
|
|
216
|
-
};
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
128
|
+
x: null,
|
|
129
|
+
y: null
|
|
130
|
+
}, isBrowser = (0, env_1.isTrueBrowser)(this._env);
|
|
131
|
+
return dims.forEach((dim => {
|
|
132
|
+
const boxSize = "x" === dim ? tooltipBoxWidth : tooltipBoxHeight, canvasSize = "x" === dim ? canvasWidth : canvasHeight, offset = "x" === dim ? offsetX : offsetY, posType = (0,
|
|
133
|
+
position_1.getPositionType)(pointerFixedPosition[dim], dim);
|
|
134
|
+
if ((0, vutils_1.isValidNumber)(calcPos[dimToPos[dim][0]])) result[dim] = calcPos[dimToPos[dim][0]]; else if ((0,
|
|
135
|
+
vutils_1.isValidNumber)(calcPos[dimToPos[dim][1]])) result[dim] = canvasSize - boxSize * tooltipSizeScale - calcPos[dimToPos[dim][1]]; else {
|
|
136
|
+
const value0 = "x" === dim ? event.canvasX : event.canvasY;
|
|
137
|
+
result[dim] = posType > 0 ? value0 + offset : value0 - boxSize * tooltipSizeScale / 2 + (posType < 0 ? -1 : 0) * offset;
|
|
138
|
+
}
|
|
139
|
+
result[dim] *= chartElementScale, isBrowser && (result[dim] += relativePosOffset[dim]),
|
|
140
|
+
result[dim] /= tooltipParentElementScale;
|
|
141
|
+
const containerDimSize = "x" === dim ? containerSize.width : containerSize.height, leftOrTop = -tooltipParentElementRect[dim] / tooltipParentElementScale, rightOrBottom = (containerDimSize - tooltipParentElementRect[dim]) / tooltipParentElementScale - boxSize;
|
|
142
|
+
2 !== posType && result[dim] < leftOrTop ? isFixedPosition ? result[dim] = leftOrTop : (result[dim] += 0 === posType ? offset + boxSize / 2 : 2 * offset + boxSize,
|
|
143
|
+
result[dim] > rightOrBottom && (result[dim] = rightOrBottom)) : -2 !== posType && result[dim] > rightOrBottom && (isFixedPosition ? result[dim] = rightOrBottom : (result[dim] -= 0 === posType ? offset + boxSize / 2 : 2 * offset + boxSize,
|
|
144
|
+
result[dim] < leftOrTop && (result[dim] = leftOrTop)));
|
|
145
|
+
})), result;
|
|
221
146
|
};
|
|
222
147
|
}
|
|
223
148
|
get env() {
|
|
@@ -235,16 +160,10 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
235
160
|
}
|
|
236
161
|
release() {
|
|
237
162
|
var _a, _b, _c;
|
|
238
|
-
this._clearAllCache();
|
|
239
163
|
const spec = null !== (_a = this._component.getSpec()) && void 0 !== _a ? _a : {};
|
|
240
164
|
spec.handler ? null === (_c = (_b = spec.handler).release) || void 0 === _c || _c.call(_b) : (this._removeTooltip(),
|
|
241
165
|
this._isReleased = !0);
|
|
242
166
|
}
|
|
243
|
-
_clearAllCache() {
|
|
244
|
-
this._isTooltipPaused = !1, this._isPointerEscaped = !1, clearTimeout(this._cachePointerTimer),
|
|
245
|
-
this._cachePointerTimer = -1, this._cachePointerPosition = void 0, this._cacheTooltipPosition = void 0,
|
|
246
|
-
this._cacheTooltipSize = void 0;
|
|
247
|
-
}
|
|
248
167
|
_throttle(callback) {
|
|
249
168
|
const tooltipSpec = this._component.getSpec();
|
|
250
169
|
let wait;
|
|
@@ -271,62 +190,6 @@ class BaseTooltipHandler extends base_plugin_1.BasePlugin {
|
|
|
271
190
|
height: (null != panelDomHeight ? panelDomHeight : null == panel ? void 0 : panel.height) + (isCanvas ? panel.lineWidth : 0)
|
|
272
191
|
};
|
|
273
192
|
}
|
|
274
|
-
_getPointerPositionRelativeToTooltipParent(params) {
|
|
275
|
-
var _a, _b;
|
|
276
|
-
let {canvasX: x, canvasY: y} = params.event;
|
|
277
|
-
const {tooltipSpec: tooltipSpec} = params, invalidPosition = {
|
|
278
|
-
x: 1 / 0,
|
|
279
|
-
y: 1 / 0
|
|
280
|
-
}, isCanvas = "canvas" === tooltipSpec.renderMode, tooltipParentElement = this._getParentElement(tooltipSpec);
|
|
281
|
-
let relativePosOffset = {
|
|
282
|
-
x: 0,
|
|
283
|
-
y: 0
|
|
284
|
-
}, tooltipParentElementRect = {
|
|
285
|
-
x: 0,
|
|
286
|
-
y: 0
|
|
287
|
-
}, chartElementScale = 1, tooltipParentElementScale = 1;
|
|
288
|
-
if ((0, env_1.isTrueBrowser)(this._env) && !tooltipSpec.confine && !isCanvas) {
|
|
289
|
-
tooltipParentElementRect = null !== (_a = null == tooltipParentElement ? void 0 : tooltipParentElement.getBoundingClientRect()) && void 0 !== _a ? _a : invalidPosition;
|
|
290
|
-
const chartElement = null !== (_b = this._compiler.getCanvas()) && void 0 !== _b ? _b : this._chartContainer, chartElementRect = null == chartElement ? void 0 : chartElement.getBoundingClientRect();
|
|
291
|
-
relativePosOffset = {
|
|
292
|
-
x: chartElementRect.x - tooltipParentElementRect.x,
|
|
293
|
-
y: chartElementRect.y - tooltipParentElementRect.y
|
|
294
|
-
}, chartElementScale = (0, common_1.getScale)(chartElement, chartElementRect), tooltipParentElementScale = (0,
|
|
295
|
-
common_1.getScale)(tooltipParentElement, tooltipParentElementRect);
|
|
296
|
-
}
|
|
297
|
-
return x *= chartElementScale, y *= chartElementScale, (0, env_1.isTrueBrowser)(this._env) && (x += relativePosOffset.x,
|
|
298
|
-
y += relativePosOffset.y), x /= tooltipParentElementScale, y /= tooltipParentElementScale,
|
|
299
|
-
{
|
|
300
|
-
x: x,
|
|
301
|
-
y: y
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
_isPointerMovingToTooltip(params) {
|
|
305
|
-
if (!this._cacheTooltipPosition || !this._cacheTooltipSize || !this._cachePointerPosition) return !1;
|
|
306
|
-
const {width: tooltipWidth, height: tooltipHeight} = this._cacheTooltipSize, {x: tooltipX = 0, y: tooltipY} = this._cacheTooltipPosition, pos = this._getPointerPositionRelativeToTooltipParent(params);
|
|
307
|
-
if ((0, vutils_1.pointInRect)(pos, {
|
|
308
|
-
x1: tooltipX,
|
|
309
|
-
y1: tooltipY,
|
|
310
|
-
x2: tooltipX + tooltipWidth,
|
|
311
|
-
y2: tooltipY + tooltipHeight
|
|
312
|
-
}, !1)) return !0;
|
|
313
|
-
const a = {
|
|
314
|
-
x: tooltipX,
|
|
315
|
-
y: tooltipY
|
|
316
|
-
}, b = {
|
|
317
|
-
x: a.x + tooltipWidth,
|
|
318
|
-
y: a.y
|
|
319
|
-
}, c = {
|
|
320
|
-
x: a.x,
|
|
321
|
-
y: a.y + tooltipHeight
|
|
322
|
-
}, d = {
|
|
323
|
-
x: b.x,
|
|
324
|
-
y: c.y
|
|
325
|
-
}, oldPos = this._cachePointerPosition;
|
|
326
|
-
return (0, vutils_1.polygonContainPoint)([ oldPos, a, b ], pos.x, pos.y) || (0,
|
|
327
|
-
vutils_1.polygonContainPoint)([ oldPos, c, d ], pos.x, pos.y) || (0, vutils_1.polygonContainPoint)([ oldPos, a, d ], pos.x, pos.y) || (0,
|
|
328
|
-
vutils_1.polygonContainPoint)([ oldPos, b, c ], pos.x, pos.y);
|
|
329
|
-
}
|
|
330
193
|
_getParentElement(spec) {
|
|
331
194
|
return spec.parentElement;
|
|
332
195
|
}
|