@visactor/vchart 1.1.0-beta.4 → 1.1.0-beta.6
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/README.md +8 -8
- package/build/index.js +230 -92
- package/build/index.min.js +2 -2
- package/cjs/chart/box-plot/box-plot.js +3 -8
- package/cjs/chart/box-plot/box-plot.js.map +1 -1
- package/cjs/component/brush/brush.d.ts +8 -0
- package/cjs/component/brush/brush.js +19 -3
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/brush/interface.d.ts +8 -0
- package/cjs/component/brush/interface.js +7 -1
- package/cjs/component/brush/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/base.js +1 -3
- package/cjs/component/tooltip/handler/base.js.map +1 -1
- package/cjs/component/tooltip/handler/constants.d.ts +1 -1
- package/cjs/component/tooltip/handler/constants.js +2 -2
- package/cjs/component/tooltip/handler/constants.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/interface.d.ts +3 -2
- package/cjs/component/tooltip/handler/dom/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/content-column-model.d.ts +3 -0
- package/cjs/component/tooltip/handler/dom/model/content-column-model.js +34 -33
- package/cjs/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/interface.d.ts +2 -0
- package/cjs/component/tooltip/handler/dom/model/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/shape-model.d.ts +1 -0
- package/cjs/component/tooltip/handler/dom/model/shape-model.js +3 -3
- package/cjs/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/text-model.d.ts +1 -1
- package/cjs/component/tooltip/handler/dom/model/text-model.js +3 -2
- package/cjs/component/tooltip/handler/dom/model/text-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/title-model.js +3 -3
- package/cjs/component/tooltip/handler/dom/model/title-model.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/util.d.ts +1 -0
- package/cjs/component/tooltip/handler/dom/util.js +27 -28
- package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
- package/cjs/component/tooltip/handler/interface/style.d.ts +10 -9
- package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -2
- package/cjs/component/tooltip/handler/utils/attribute.js +58 -9
- package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/style.d.ts +2 -2
- package/cjs/component/tooltip/handler/utils/style.js +5 -2
- package/cjs/component/tooltip/handler/utils/style.js.map +1 -1
- package/cjs/component/tooltip/interface/spec.d.ts +1 -3
- package/cjs/component/tooltip/interface/spec.js.map +1 -1
- package/cjs/component/tooltip/interface/theme.d.ts +4 -2
- package/cjs/component/tooltip/interface/theme.js.map +1 -1
- package/cjs/component/tooltip/tooltip.js +4 -2
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/component/tooltip/utils/show-tooltip.js +9 -4
- package/cjs/component/tooltip/utils/show-tooltip.js.map +1 -1
- package/cjs/constant/event.d.ts +2 -0
- package/cjs/constant/event.js +4 -3
- package/cjs/constant/event.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/instance-manager.d.ts +2 -1
- package/cjs/core/instance-manager.js +7 -2
- package/cjs/core/instance-manager.js.map +1 -1
- package/cjs/core/interface.d.ts +3 -0
- package/cjs/core/interface.js.map +1 -1
- package/cjs/core/vchart.d.ts +3 -2
- package/cjs/core/vchart.js +5 -3
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/series/range-column/rangeColumn.js +5 -5
- package/cjs/series/range-column/rangeColumn.js.map +1 -1
- package/cjs/util/text.d.ts +4 -0
- package/cjs/util/text.js +9 -1
- package/cjs/util/text.js.map +1 -1
- package/esm/chart/box-plot/box-plot.js +2 -9
- package/esm/chart/box-plot/box-plot.js.map +1 -1
- package/esm/component/brush/brush.d.ts +8 -0
- package/esm/component/brush/brush.js +19 -3
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/brush/interface.d.ts +8 -0
- package/esm/component/brush/interface.js +7 -1
- package/esm/component/brush/interface.js.map +1 -1
- package/esm/component/tooltip/handler/base.js +1 -3
- package/esm/component/tooltip/handler/base.js.map +1 -1
- package/esm/component/tooltip/handler/constants.d.ts +1 -1
- package/esm/component/tooltip/handler/constants.js +1 -1
- package/esm/component/tooltip/handler/constants.js.map +1 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/dom/interface.d.ts +3 -2
- package/esm/component/tooltip/handler/dom/interface.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/content-column-model.d.ts +3 -0
- package/esm/component/tooltip/handler/dom/model/content-column-model.js +33 -31
- package/esm/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/interface.d.ts +2 -0
- package/esm/component/tooltip/handler/dom/model/interface.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/shape-model.d.ts +1 -0
- package/esm/component/tooltip/handler/dom/model/shape-model.js +3 -3
- package/esm/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/text-model.d.ts +1 -1
- package/esm/component/tooltip/handler/dom/model/text-model.js +3 -2
- package/esm/component/tooltip/handler/dom/model/text-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/title-model.js +3 -3
- package/esm/component/tooltip/handler/dom/model/title-model.js.map +1 -1
- package/esm/component/tooltip/handler/dom/util.d.ts +1 -0
- package/esm/component/tooltip/handler/dom/util.js +9 -8
- package/esm/component/tooltip/handler/dom/util.js.map +1 -1
- package/esm/component/tooltip/handler/interface/style.d.ts +10 -9
- package/esm/component/tooltip/handler/interface/style.js.map +1 -1
- package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -2
- package/esm/component/tooltip/handler/utils/attribute.js +56 -8
- package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/esm/component/tooltip/handler/utils/common.js.map +1 -1
- package/esm/component/tooltip/handler/utils/style.d.ts +2 -2
- package/esm/component/tooltip/handler/utils/style.js +5 -2
- package/esm/component/tooltip/handler/utils/style.js.map +1 -1
- package/esm/component/tooltip/interface/spec.d.ts +1 -3
- package/esm/component/tooltip/interface/spec.js.map +1 -1
- package/esm/component/tooltip/interface/theme.d.ts +4 -2
- package/esm/component/tooltip/interface/theme.js.map +1 -1
- package/esm/component/tooltip/tooltip.js +5 -1
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/component/tooltip/utils/show-tooltip.js +9 -4
- package/esm/component/tooltip/utils/show-tooltip.js.map +1 -1
- package/esm/constant/event.d.ts +2 -0
- package/esm/constant/event.js +4 -3
- package/esm/constant/event.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/instance-manager.d.ts +2 -1
- package/esm/core/instance-manager.js +7 -2
- package/esm/core/instance-manager.js.map +1 -1
- package/esm/core/interface.d.ts +3 -0
- package/esm/core/interface.js.map +1 -1
- package/esm/core/vchart.d.ts +3 -2
- package/esm/core/vchart.js +5 -3
- package/esm/core/vchart.js.map +1 -1
- package/esm/series/range-column/rangeColumn.js +5 -5
- package/esm/series/range-column/rangeColumn.js.map +1 -1
- package/esm/util/text.d.ts +4 -0
- package/esm/util/text.js +7 -1
- package/esm/util/text.js.map +1 -1
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.getTooltipAttributes = void 0;
|
|
5
|
+
}), exports.measureTooltipText = exports.getTooltipAttributes = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util"), vrender_1 = require("@visactor/vrender"), getTooltipAttributes = (actualTooltip, style) => {
|
|
8
8
|
const {spaceRow: spaceRow, padding: padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle} = style, attribute = Object.assign(Object.assign({}, style), {
|
|
@@ -29,9 +29,13 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
29
29
|
let maxWidth = 0, containerHeight = padding.top + padding.bottom, titleMaxHeight = 0;
|
|
30
30
|
const {visible: titleVisible = !0, value: titleValue = "", hasShape: titleHasShape, shapeType: titleShapeType = "", shapeHollow: titleShapeHollow, shapeColor: titleShapeColor} = title;
|
|
31
31
|
if (attribute.title.visible = titleVisible, titleVisible) {
|
|
32
|
-
const {width: width, height: height} = (0,
|
|
32
|
+
const {text: text, width: width, height: height} = (0, exports.measureTooltipText)(titleValue, titleStyle);
|
|
33
33
|
if (attribute.title.value = {
|
|
34
|
-
|
|
34
|
+
width: width,
|
|
35
|
+
height: height,
|
|
36
|
+
text: text,
|
|
37
|
+
multiLine: titleStyle.multiLine,
|
|
38
|
+
wordBreak: titleStyle.wordBreak
|
|
35
39
|
}, maxWidth = width, titleMaxHeight = height, titleHasShape && vrender_1.builtinSymbolsMap[titleShapeType]) {
|
|
36
40
|
const titleShapeAttrs = {
|
|
37
41
|
symbolType: titleShapeType
|
|
@@ -47,8 +51,7 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
47
51
|
if (filteredContent.length) {
|
|
48
52
|
titleVisible && (containerHeight += spaceRow);
|
|
49
53
|
let hasContentShape = !1;
|
|
50
|
-
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = []
|
|
51
|
-
util_1.initTextMeasure)(keyStyle), valueTextMeasure = (0, util_1.initTextMeasure)(valueStyle);
|
|
54
|
+
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [];
|
|
52
55
|
attribute.content = filteredContent.map(((item, i) => {
|
|
53
56
|
const itemAttrs = {
|
|
54
57
|
height: 0,
|
|
@@ -57,15 +60,23 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
57
60
|
let itemHeight = 0;
|
|
58
61
|
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value, isKeyAdaptive: isKeyAdaptive} = item;
|
|
59
62
|
if ((0, vutils_1.isValid)(key)) {
|
|
60
|
-
const {width: width, height: height} =
|
|
63
|
+
const {width: width, height: height, text: text} = (0, exports.measureTooltipText)(key, keyStyle);
|
|
61
64
|
itemAttrs.key = {
|
|
62
|
-
|
|
65
|
+
width: width,
|
|
66
|
+
height: height,
|
|
67
|
+
text: text,
|
|
68
|
+
multiLine: keyStyle.multiLine,
|
|
69
|
+
wordBreak: titleStyle.wordBreak
|
|
63
70
|
}, isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
64
71
|
}
|
|
65
72
|
if ((0, vutils_1.isValid)(value)) {
|
|
66
|
-
const {width: width, height: height} =
|
|
73
|
+
const {width: width, height: height, text: text} = (0, exports.measureTooltipText)(value, valueStyle);
|
|
67
74
|
itemAttrs.value = {
|
|
68
|
-
|
|
75
|
+
width: width,
|
|
76
|
+
height: height,
|
|
77
|
+
text: text,
|
|
78
|
+
multiLine: valueStyle.multiLine,
|
|
79
|
+
wordBreak: titleStyle.wordBreak
|
|
69
80
|
}, valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
70
81
|
}
|
|
71
82
|
if (hasShape && vrender_1.builtinSymbolsMap[shapeType]) {
|
|
@@ -96,4 +107,42 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
96
107
|
};
|
|
97
108
|
|
|
98
109
|
exports.getTooltipAttributes = getTooltipAttributes;
|
|
110
|
+
|
|
111
|
+
const measureTooltipText = (text, style) => {
|
|
112
|
+
const measure = (0, util_1.initTextMeasure)(style);
|
|
113
|
+
if (!style.multiLine) {
|
|
114
|
+
const {width: width, height: height} = measure.fullMeasure(text);
|
|
115
|
+
return {
|
|
116
|
+
width: width,
|
|
117
|
+
height: height,
|
|
118
|
+
text: text
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
let textLines = text.split("\n");
|
|
122
|
+
textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line));
|
|
123
|
+
const {width: width, height: height} = measure.fullMeasure(textLines);
|
|
124
|
+
if (style.maxWidth && style.maxWidth <= width) {
|
|
125
|
+
const bound = (0, util_1.getRichTextBounds)({
|
|
126
|
+
wordBreak: style.wordBreak,
|
|
127
|
+
maxWidth: style.maxWidth,
|
|
128
|
+
width: 0,
|
|
129
|
+
height: 0,
|
|
130
|
+
textConfig: textLines.map(((line, i) => Object.assign(Object.assign({}, style), {
|
|
131
|
+
text: line
|
|
132
|
+
})))
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
width: bound.width(),
|
|
136
|
+
height: bound.height(),
|
|
137
|
+
text: textLines
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
width: width,
|
|
142
|
+
height: height,
|
|
143
|
+
text: textLines
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
exports.measureTooltipText = measureTooltipText;
|
|
99
148
|
//# sourceMappingURL=attribute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":";;;AAQA,6CAA2C;AAC3C,2CAAmD;AACnD,+CAAsD;AAE/C,MAAM,oBAAoB,GAAG,CAAC,aAA6B,EAAE,KAAoB,EAAqB,EAAE;IAC7G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,E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AC,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,QAAQ,GAAG,IAAI,CAAC,GAAG,CACjB,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,GAAG,UAAU,EAChF,mBAAmB,GAAG,UAAU,EAChC,QAAQ,CACT,CAAC;YACF,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;YAC5C,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC;YACjC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC;SACtC;KACF;IAED,MAAM,aAAa,GAAmB;QACpC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK;QAC9C,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IAC5C,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AArKW,QAAA,oBAAoB,wBAqK/B","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual } from '../../../../typings';\nimport type { ITooltipStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { initTextMeasure } from '../../../../util';\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nexport const getTooltipAttributes = (actualTooltip: IToolTipActual, style: ITooltipStyle): TooltipAttributes => {\n const { spaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor\n } = title;\n attribute.title.visible = titleVisible;\n if (titleVisible) {\n const { width, height } = initTextMeasure(titleStyle as any).quickMeasure(titleValue);\n attribute.title.value = {\n // width, height,\n text: titleValue\n };\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n if (titleVisible) {\n containerHeight += spaceRow; // title 与 content 之前的间隔\n }\n\n let hasContentShape = false;\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n\n const keyTextMeasure = initTextMeasure(keyStyle as any);\n const valueTextMeasure = initTextMeasure(valueStyle as any);\n\n attribute.content = filteredContent.map((item, i) => {\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow };\n let itemHeight = 0;\n const { hasShape, key, shapeColor, shapeHollow, shapeType = '', value, isKeyAdaptive } = item;\n if (isValid(key)) {\n const { width, height } = keyTextMeasure.quickMeasure(key);\n itemAttrs.key = {\n text: key as any\n };\n if (!isKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const { width, height } = valueTextMeasure.quickMeasure(value);\n itemAttrs.value = {\n text: value as any\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape && builtinSymbolsMap[shapeType]) {\n hasContentShape = true;\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: shapeType\n };\n if (shapeHollow) {\n shape.stroke = shapeColor;\n } else {\n shape.fill = shapeColor;\n }\n itemHeight = Math.max(shapeStyle.size, itemHeight);\n itemAttrs.shape = shape;\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n const shapeWidth = hasContentShape ? shapeStyle.size + shapeStyle.spacing : 0; // shape 列宽度\n maxWidth = Math.max(\n maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth,\n maxAdaptiveKeyWidth + shapeWidth,\n maxWidth\n );\n attribute.hasContentShape = hasContentShape;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils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ize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual, MaybeArray } from '../../../../typings';\nimport type { ITooltipStyle, ITooltipTextStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { getRichTextBounds, initTextMeasure } from '../../../../util';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nexport const getTooltipAttributes = (actualTooltip: IToolTipActual, style: ITooltipStyle): TooltipAttributes => {\n const { spaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor\n } = title;\n attribute.title.visible = titleVisible;\n if (titleVisible) {\n const { text, width, height } = measureTooltipText(titleValue, titleStyle);\n // FIXME: vrender 发版后去掉 any\n attribute.title.value = {\n width,\n height,\n text,\n multiLine: titleStyle.multiLine,\n wordBreak: titleStyle.wordBreak\n } as any;\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n if (titleVisible) {\n containerHeight += spaceRow; // title 与 content 之前的间隔\n }\n\n let hasContentShape = false;\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n\n attribute.content = filteredContent.map((item, i) => {\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow };\n let itemHeight = 0;\n const { hasShape, key, shapeColor, shapeHollow, shapeType = '', value, isKeyAdaptive } = item;\n if (isValid(key)) {\n const { width, height, text } = measureTooltipText(key, keyStyle);\n // FIXME: vrender 发版后去掉 any\n itemAttrs.key = {\n width,\n height,\n text,\n multiLine: keyStyle.multiLine,\n wordBreak: titleStyle.wordBreak\n } as any;\n if (!isKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const { width, height, text } = measureTooltipText(value, valueStyle);\n // FIXME: vrender 发版后去掉 any\n itemAttrs.value = {\n width,\n height,\n text,\n multiLine: valueStyle.multiLine,\n wordBreak: titleStyle.wordBreak\n } as any;\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape && builtinSymbolsMap[shapeType]) {\n hasContentShape = true;\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: shapeType\n };\n if (shapeHollow) {\n shape.stroke = shapeColor;\n } else {\n shape.fill = shapeColor;\n }\n itemHeight = Math.max(shapeStyle.size, itemHeight);\n itemAttrs.shape = shape;\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n const shapeWidth = hasContentShape ? shapeStyle.size + shapeStyle.spacing : 0; // shape 列宽度\n maxWidth = Math.max(\n maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth,\n maxAdaptiveKeyWidth + shapeWidth,\n maxWidth\n );\n attribute.hasContentShape = hasContentShape;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string>;\n}\n\nexport const measureTooltipText = (text: string, style: ITooltipTextStyle): ITooltipTextInfo => {\n const measure = initTextMeasure(style as any);\n if (!style.multiLine) {\n // 单行文本\n const { width, height } = measure.fullMeasure(text);\n return {\n width,\n height,\n text\n };\n }\n // 多行文本\n let textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\\n' : line));\n const { width, height } = measure.fullMeasure(textLines);\n\n if (style.maxWidth && style.maxWidth <= width) {\n // 允许自动换行的情况,改用 richText 测量\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak,\n maxWidth: style.maxWidth,\n width: 0,\n height: 0,\n textConfig: textLines.map(\n (line, i) =>\n ({\n ...style,\n text: line\n } as unknown as IRichTextParagraphCharacter)\n )\n });\n return {\n width: bound.width(),\n height: bound.height(),\n text: textLines\n };\n }\n\n return {\n width,\n height,\n text: textLines\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,2CAA2F;AAiB3F,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClH,CAAC;AAFD,gCAEC;AAEM,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,iBAAU,EAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC;AAEK,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6B,EAC4D,EAAE;IAC3F,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,EAAE;QAClB,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACnB,IAAI,IAAA,iBAAU,EAAC,IAAI,CAAC,EAAE;gBACpB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC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I,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IACD,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,IAAK,KAAwB,CAAC,KAAK,IAAK,KAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAC5F,OAAQ,KAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC;KACjE;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAbD,oDAaC","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar';\nimport type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';\nimport { isFunction, isObject, isString, isNil, isArray, isValid } from '../../../../util';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\n\ninterface IGradientColor {\n [key: string]: any;\n stops: {\n offset: number;\n color: string;\n }[];\n}\n\n/**\n * Escape special HTML characters.\n *\n * @param value A value to convert to string and HTML-escape.\n */\nexport function escapeHTML(value: any): string {\n return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\\(/g, '(');\n}\n\nexport const getTooltipContentValue = <T>(\n field?: TooltipContentProperty<T>,\n datum?: any,\n params?: TooltipHandlerParams\n): T | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isFunction(field)) {\n return field(datum, params);\n }\n return field;\n};\n\nexport const getTooltipPatternValue = <T>(\n field?: MaybeArray<TooltipPatternProperty<T>>,\n data?: TooltipData,\n params?: TooltipHandlerParams\n): (typeof field extends Array<TooltipPatternProperty<T>> ? MaybeArray<T> : T) | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isArray(field)) {\n const result: T[] = [];\n field.forEach(item => {\n if (isFunction(item)) {\n const value = item(data, params);\n if (isValid(value)) {\n result.push(value);\n }\n } else {\n result.push(item);\n }\n });\n return result as any;\n }\n if (isFunction(field)) {\n return field(data, params);\n }\n return field;\n};\n\nexport function getFirstDatumFromTooltipData(data: TooltipData): Datum {\n // 找到第一个可用的datum\n const dimInfoList: IDimensionInfo[] = (data as IDimensionData[])[0]?.series\n ? [{ data: data as IDimensionData[], value: '' }]\n : (data as IDimensionInfo[]);\n for (const { data: dataList } of dimInfoList) {\n for (const { datum: datumList } of dataList) {\n for (const datumItem of datumList ?? []) {\n if (datumItem) {\n return datumItem;\n }\n }\n }\n }\n}\n\nexport function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined {\n for (const ele of elements) {\n if (isValid(ele)) {\n return ele;\n }\n }\n return undefined;\n}\n\n// 针对渐变色,受底层渲染引擎影响,不一定都能绘制正确,所以这里取 colorStop 的第一个颜色作为 color\nexport function convertToColorString(color: any, defaultColor: string = '#000') {\n if (!color) {\n return defaultColor;\n }\n if (isString(color)) {\n return color;\n }\n\n if (isObject(color) && (color as IGradientColor).stops && (color as IGradientColor).stops[0]) {\n return (color as IGradientColor).stops[0].color || defaultColor;\n }\n\n return defaultColor;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ITheme } from '../../../../theme';
|
|
2
2
|
import type { ITooltipTextTheme } from '../../interface';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function getTextAttributes(style?: ITooltipTextTheme, globalTheme?: ITheme):
|
|
3
|
+
import type { ITooltipTextStyle } from '../interface';
|
|
4
|
+
export declare function getTextAttributes(style?: ITooltipTextTheme, globalTheme?: ITheme): ITooltipTextStyle;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
const theme_1 = require("../../../../theme");
|
|
8
8
|
|
|
9
9
|
function getTextAttributes(style = {}, globalTheme) {
|
|
10
|
-
var _a, _b, _c;
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
11
|
return {
|
|
12
12
|
fill: style.fontColor,
|
|
13
13
|
textAlign: style.textAlign,
|
|
@@ -16,7 +16,10 @@ function getTextAttributes(style = {}, globalTheme) {
|
|
|
16
16
|
fontSize: style.fontSize,
|
|
17
17
|
fontWeight: style.fontWeight,
|
|
18
18
|
lineHeight: style.lineHeight,
|
|
19
|
-
spacing: null !== (_c = style.spacing) && void 0 !== _c ? _c : 10
|
|
19
|
+
spacing: null !== (_c = style.spacing) && void 0 !== _c ? _c : 10,
|
|
20
|
+
multiLine: null !== (_d = style.multiLine) && void 0 !== _d && _d,
|
|
21
|
+
maxWidth: style.maxWidth,
|
|
22
|
+
wordBreak: null !== (_e = style.wordBreak) && void 0 !== _e ? _e : "break-word"
|
|
20
23
|
};
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/style.ts"],"names":[],"mappings":";;;AAEA,6CAA6D;AAI7D,SAAgB,iBAAiB,CAAC,QAA2B,EAAE,EAAE,WAAoB;;IACnF,MAAM,KAAK,
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/style.ts"],"names":[],"mappings":";;;AAEA,6CAA6D;AAI7D,SAAgB,iBAAiB,CAAC,QAA2B,EAAE,EAAE,WAAoB;;IACnF,MAAM,KAAK,GAAsB;QAC/B,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,MAAA,MAAA,KAAK,CAAC,UAAU,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,mCAAI,gCAAwB;QACnF,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE;QAC5B,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,KAAK;QACnC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,YAAY;KAC3C,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAfD,8CAeC","file":"style.js","sourcesContent":["import type { ITheme } from '../../../../theme';\n// eslint-disable-next-line no-duplicate-imports\nimport { DEFAULT_TEXT_FONT_FAMILY } from '../../../../theme';\nimport type { ITooltipTextTheme } from '../../interface';\nimport type { ITooltipTextStyle } from '../interface';\n\nexport function getTextAttributes(style: ITooltipTextTheme = {}, globalTheme?: ITheme) {\n const attrs: ITooltipTextStyle = {\n fill: style.fontColor,\n textAlign: style.textAlign,\n textBaseline: style.textBaseline,\n fontFamily: style.fontFamily ?? globalTheme?.fontFamily ?? DEFAULT_TEXT_FONT_FAMILY,\n fontSize: style.fontSize,\n fontWeight: style.fontWeight,\n lineHeight: style.lineHeight,\n spacing: style.spacing ?? 10,\n multiLine: style.multiLine ?? false,\n maxWidth: style.maxWidth,\n wordBreak: style.wordBreak ?? 'break-word'\n };\n return attrs;\n}\n"]}
|
|
@@ -6,7 +6,7 @@ export interface ITooltipSpec extends Partial<ITooltipActiveTypeAsKeys<ITooltipP
|
|
|
6
6
|
activeType?: TooltipActiveType | TooltipActiveType[];
|
|
7
7
|
trigger?: 'hover' | 'click' | 'none';
|
|
8
8
|
triggerOff?: 'hover' | 'click' | 'none';
|
|
9
|
-
style?: Omit<ITooltipTheme, '
|
|
9
|
+
style?: Omit<ITooltipTheme, 'offset'>;
|
|
10
10
|
handler?: Partial<ITooltipHandlerSpec>;
|
|
11
11
|
renderMode?: 'html' | 'canvas';
|
|
12
12
|
confine?: boolean;
|
|
@@ -15,8 +15,6 @@ export interface ITooltipSpec extends Partial<ITooltipActiveTypeAsKeys<ITooltipP
|
|
|
15
15
|
enterable?: boolean;
|
|
16
16
|
transitionDuration?: number;
|
|
17
17
|
throttleInterval?: number;
|
|
18
|
-
maxWidth?: number;
|
|
19
|
-
minWidth?: number;
|
|
20
18
|
offset?: {
|
|
21
19
|
x?: number;
|
|
22
20
|
y?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { ITooltipPattern, Maybe, TooltipActiveType, TooltipData } from '../../../typings';\nimport type { ITooltipActiveTypeAsKeys, TooltipHandlerParams, TooltipResult } from './common';\nimport type { ITooltipTheme } from './theme';\n\nexport interface ITooltipSpec\n extends Partial<\n /* mark tooltip pattern(*支持在series上设置)\n * & dimension tooltip pattern\n */\n ITooltipActiveTypeAsKeys<ITooltipPattern, ITooltipPattern>\n > {\n /** 是否显示(*支持在series上设置)(*会影响自定义handler) */\n visible?: boolean;\n /** 受支持的激活类型(*支持在series上设置)(*会影响自定义handler) */\n activeType?: TooltipActiveType | TooltipActiveType[];\n /** tooltip触发方式(*会影响自定义handler) */\n trigger?: 'hover' | 'click' | 'none';\n /** 隐藏tooltip的触发方式(目前仅支持和trigger一致的设置以及none)(*会影响自定义handler) */\n triggerOff?: 'hover' | 'click' | 'none';\n\n /** tooltip样式 */\n style?: Omit<ITooltipTheme, '
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { ITooltipPattern, Maybe, TooltipActiveType, TooltipData } from '../../../typings';\nimport type { ITooltipActiveTypeAsKeys, TooltipHandlerParams, TooltipResult } from './common';\nimport type { ITooltipTheme } from './theme';\n\nexport interface ITooltipSpec\n extends Partial<\n /* mark tooltip pattern(*支持在series上设置)\n * & dimension tooltip pattern\n */\n ITooltipActiveTypeAsKeys<ITooltipPattern, ITooltipPattern>\n > {\n /** 是否显示(*支持在series上设置)(*会影响自定义handler) */\n visible?: boolean;\n /** 受支持的激活类型(*支持在series上设置)(*会影响自定义handler) */\n activeType?: TooltipActiveType | TooltipActiveType[];\n /** tooltip触发方式(*会影响自定义handler) */\n trigger?: 'hover' | 'click' | 'none';\n /** 隐藏tooltip的触发方式(目前仅支持和trigger一致的设置以及none)(*会影响自定义handler) */\n triggerOff?: 'hover' | 'click' | 'none';\n\n /** tooltip样式 */\n style?: Omit<ITooltipTheme, 'offset'>;\n\n /** 自定义handler方法 */\n handler?: Partial<ITooltipHandlerSpec>;\n\n /** tooltip 渲染方式,默认为 html */\n renderMode?: 'html' | 'canvas';\n /**\n * 是否将 tooltip 框限制在画布区域内,renderMode 为 canvas 时,默认开启。\n */\n confine?: boolean;\n\n /**\n * tooltip dom元素的 className,仅当 renderMode: 'html' 时生效\n */\n className?: string;\n /**\n * tooltip dom 元素的挂载点\n */\n parentElement?: HTMLElement | HTMLCanvasElement;\n /**\n * 鼠标是否可进入提示框浮层中,默认为false,如需详情内交互,如添加链接,按钮,可设置为 true。\n * 该属性目前只对 renderMode 为 html 时生效\n * TODO: 支持 renderMode: canvas\n */\n enterable?: boolean;\n\n /**\n * 浮层移动动画过渡时间,单位是 ms,设置为 0 的时候会紧跟着鼠标移动(目前仅影响 dom tooltip)\n */\n transitionDuration?: number;\n\n /** 更新 tooltip 的防抖动时间间隔,单位是 ms */\n throttleInterval?: number;\n\n offset?: {\n x?: number;\n y?: number;\n };\n}\n\nexport interface ITooltipHandlerSpec {\n /** 显示 tooltip,可以选择返回是否遇到异常 */\n showTooltip: (activeType: TooltipActiveType, data: TooltipData, params: TooltipHandlerParams) => Maybe<TooltipResult>;\n /** 隐藏 tooltip */\n hideTooltip: (params: TooltipHandlerParams) => void;\n /** 释放 tooltip */\n release: () => void;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RichTextWordBreak } from '@visactor/vrender';
|
|
1
2
|
import type { IPadding, StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';
|
|
2
3
|
export interface ITooltipTextTheme {
|
|
3
4
|
fontFamily?: string;
|
|
@@ -8,6 +9,9 @@ export interface ITooltipTextTheme {
|
|
|
8
9
|
textBaseline?: TextBaseLine;
|
|
9
10
|
lineHeight?: number;
|
|
10
11
|
spacing?: number;
|
|
12
|
+
multiLine?: boolean;
|
|
13
|
+
maxWidth?: number;
|
|
14
|
+
wordBreak?: RichTextWordBreak;
|
|
11
15
|
}
|
|
12
16
|
export interface ITooltipTheme {
|
|
13
17
|
panel?: {
|
|
@@ -34,8 +38,6 @@ export interface ITooltipTheme {
|
|
|
34
38
|
keyLabel?: ITooltipTextTheme;
|
|
35
39
|
valueLabel?: ITooltipTextTheme;
|
|
36
40
|
spaceRow?: number;
|
|
37
|
-
maxWidth?: number;
|
|
38
|
-
minWidth?: number;
|
|
39
41
|
offset?: {
|
|
40
42
|
x?: number;
|
|
41
43
|
y?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IPadding, StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';\n\nexport interface ITooltipTextTheme {\n /** 字体 */\n fontFamily?: string;\n /** 字体大小 */\n fontSize?: number;\n /** 字体颜色 */\n fontColor?: string;\n /** 字重 */\n fontWeight?: StringOrNumber;\n /** 对齐方式 */\n textAlign?: TextAlign;\n /** 字体基线 */\n textBaseline?: TextBaseLine;\n /** 行高 */\n lineHeight?: number;\n /** 与相邻元素的水平间距 */\n spacing?: number;\n}\n\nexport interface ITooltipTheme {\n /** 容器样式配置 */\n panel?: {\n /** tooltip 容器内边距 */\n padding?: IPadding;\n /** 背景色 */\n backgroundColor?: string;\n /** tooltip边框 */\n border?: {\n color?: string;\n width?: number;\n /** 圆角 */\n radius?: number;\n };\n /** tooltip阴影 */\n shadow?: {\n x: number;\n y: number;\n blur: number;\n spread: number;\n color: string;\n };\n };\n shape?: {\n /** 标记大小 */\n size?: number;\n /** shape 与相邻元素的水平间距 */\n spacing?: number;\n };\n /** tooltip标题 */\n titleLabel?: ITooltipTextTheme;\n /** tooltip内容,key字段 */\n keyLabel?: ITooltipTextTheme;\n /** tooltip内容,value字段 */\n valueLabel?: ITooltipTextTheme;\n /** 内容项行间距 */\n spaceRow?: number;\n /**
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { RichTextWordBreak } from '@visactor/vrender';\nimport type { IPadding, StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';\n\nexport interface ITooltipTextTheme {\n /** 字体 */\n fontFamily?: string;\n /** 字体大小 */\n fontSize?: number;\n /** 字体颜色 */\n fontColor?: string;\n /** 字重 */\n fontWeight?: StringOrNumber;\n /** 对齐方式 */\n textAlign?: TextAlign;\n /** 字体基线 */\n textBaseline?: TextBaseLine;\n /** 行高 */\n lineHeight?: number;\n /** 与相邻元素的水平间距 */\n spacing?: number;\n /** 是否支持换行 */\n multiLine?: boolean;\n /** 最大宽度 */\n maxWidth?: number;\n /** 换行模式,默认为'break-word' */\n wordBreak?: RichTextWordBreak;\n}\n\nexport interface ITooltipTheme {\n /** 容器样式配置 */\n panel?: {\n /** tooltip 容器内边距 */\n padding?: IPadding;\n /** 背景色 */\n backgroundColor?: string;\n /** tooltip边框 */\n border?: {\n color?: string;\n width?: number;\n /** 圆角 */\n radius?: number;\n };\n /** tooltip阴影 */\n shadow?: {\n x: number;\n y: number;\n blur: number;\n spread: number;\n color: string;\n };\n };\n shape?: {\n /** 标记大小 */\n size?: number;\n /** shape 与相邻元素的水平间距 */\n spacing?: number;\n };\n /** tooltip标题 */\n titleLabel?: ITooltipTextTheme;\n /** tooltip内容,key字段 */\n keyLabel?: ITooltipTextTheme;\n /** tooltip内容,value字段 */\n valueLabel?: ITooltipTextTheme;\n /** 内容项行间距 */\n spaceRow?: number;\n /** 偏移量 */\n offset?: {\n x?: number;\n y?: number;\n };\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Tooltip = void 0;
|
|
6
6
|
|
|
7
|
-
const interface_1 = require("../interface"), base_1 = require("../base"), handler_1 = require("./handler"), util_1 = require("../../util"), constants_1 = require("./handler/constants"), utils_1 = require("./utils"), util_2 = require("../../event/events/dimension/util"), constant_1 = require("../../constant"), processor_1 = require("./processor"), vutils_1 = require("@visactor/vutils");
|
|
7
|
+
const interface_1 = require("../interface"), base_1 = require("../base"), handler_1 = require("./handler"), util_1 = require("../../util"), constants_1 = require("./handler/constants"), utils_1 = require("./utils"), util_2 = require("../../event/events/dimension/util"), constant_1 = require("../../constant"), processor_1 = require("./processor"), vutils_1 = require("@visactor/vutils"), vchart_1 = require("../../core/vchart");
|
|
8
8
|
|
|
9
9
|
class Tooltip extends base_1.BaseComponent {
|
|
10
10
|
constructor() {
|
|
@@ -47,7 +47,9 @@ class Tooltip extends base_1.BaseComponent {
|
|
|
47
47
|
const tooltipInfo = mouseEventData.tooltipInfo[activeType], isSameAsCache = this._isSameAsCacheInfo(tooltipInfo);
|
|
48
48
|
success = !processor.showTooltip(tooltipInfo, params, isSameAsCache), success && (this._cacheInfo = tooltipInfo);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const vchart = this._option.globalInstance;
|
|
51
|
+
return success && vchart_1.VChart.globalConfig.uniqueTooltip && vchart_1.VChart.hideTooltip(vchart.id),
|
|
52
|
+
success;
|
|
51
53
|
}, this._getMouseEventData = params => {
|
|
52
54
|
const result = {
|
|
53
55
|
tooltipInfo: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/tooltip.ts"],"names":[],"mappings":";;;AAEA,4CAAiD;AAGjD,kCAAwC;AAGxC,uCAAoE;AAEpE,qCAUoB;AASpB,mDAA4D;AAE5D,mCAA8E;AAC9E,4DAAwE;AACxE,6CAAuE;AAGvE,2CAA2G;AAC3G,6CAAgH;AAYhH,MAAa,OAAQ,SAAQ,oBAAa;IAA1C;;QAEE,SAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC;QACjC,SAAI,GAAW,6BAA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xC;aACF;iBAAM;gBACL,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;aACvB;YAED,MAAM,SAAS,GAAG,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,mBAAmB,kDAAI,CAAC;YAC/D,IAAI,IAAA,cAAO,EAAC,SAAS,CAAC,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,IAAI,IAAA,yBAAgB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE;gBAChF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC;;AAraH,0BAsaC;AAraQ,YAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC","file":"tooltip.js","sourcesContent":["import type { IComponentOption } from '../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface';\nimport type { IModelLayoutOption, IModelRenderOption, ILayoutItem } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport { BaseComponent } from '../base';\nimport type { BaseEventParams, EventCallback, EventQuery, EventType } from '../../event/interface';\nimport type { ITooltipHandler, IToolTipLineActual, TooltipActiveType } from '../../typings/tooltip';\nimport { DomTooltipHandler, CanvasTooltipHandler } from './handler';\nimport type { Datum, IPoint, IShowTooltipOption } from '../../typings';\nimport {\n cloneDeep,\n isArray,\n isValid,\n merge,\n isMobileLikeMode,\n isTrueBrowser,\n isNil,\n isMiniAppLikeMode,\n domDocument\n} from '../../util';\nimport type {\n ITooltip,\n ITooltipActiveTypeAsKeys,\n ITooltipSpec,\n ITooltipTheme,\n TooltipHandlerParams,\n TotalMouseEventData\n} from './interface';\nimport { TOOLTIP_EL_CLASS_NAME } from './handler/constants';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTooltipActualActiveType, showTooltip, isEmptyPos } from './utils';\nimport { isSameDimensionInfo } from '../../event/events/dimension/util';\nimport { Event_Bubble_Level, Event_Source_Type } from '../../constant';\nimport type { DimensionTooltipInfo, MarkTooltipInfo, TooltipInfo } from './processor';\n// eslint-disable-next-line no-duplicate-imports\nimport { isDimensionInfo, isMarkInfo, MarkTooltipProcessor, DimensionTooltipProcessor } from './processor';\nimport { getElementAbsolutePosition, getElementAbsoluteScrollOffset, hasParentElement } from '@visactor/vutils';\n\nexport type TooltipContent = {\n title?: IToolTipLineActual;\n content?: IToolTipLineActual[];\n};\n\ntype EventHandlerList = {\n eventType: EventType;\n handler: any;\n}[];\n\nexport class Tooltip extends BaseComponent implements ITooltip {\n static type = ComponentTypeEnum.tooltip;\n type = ComponentTypeEnum.tooltip;\n name: string = ComponentTypeEnum.tooltip;\n\n layoutType: ILayoutItem['layoutType'] = 'absolute';\n\n static createComponent(spec: any, options: IComponentOption) {\n const tooltipSpec = spec.tooltip;\n if (!tooltipSpec) {\n return null;\n }\n if (!isArray(tooltipSpec)) {\n return new Tooltip(tooltipSpec, { ...options, specKey: 'tooltip' });\n }\n const tooltips: Tooltip[] = [];\n tooltipSpec.forEach((s: any, i: number) => {\n tooltips.push(new Tooltip(s, { ...options, specIndex: i, specKey: 'tooltip' }));\n });\n return tooltips;\n }\n\n tooltipHandler?: ITooltipHandler;\n\n private _alwaysShow: boolean = false;\n\n private _cacheInfo: TooltipInfo | undefined;\n\n private _eventList: EventHandlerList = [];\n\n protected declare _spec: ITooltipSpec;\n\n protected declare _theme: ITooltipTheme;\n\n protected _processor: ITooltipActiveTypeAsKeys<MarkTooltipProcessor, DimensionTooltipProcessor>;\n\n changeRegions(regions: IRegion[]) {\n /* do nothing */\n }\n protected _registerEvent() {\n /* do nothing */\n }\n protected _releaseEvent() {\n /* do nothing */\n }\n onLayout(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onLayoutEnd(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onRender(ctx: IModelRenderOption) {\n /* do nothing */\n }\n\n created() {\n super.created();\n this._regions = this._option.getAllRegions();\n // handler\n this._initHandler();\n // processor\n this._initProcessor();\n // event\n this._initEvent();\n }\n\n release() {\n super.release();\n\n this._eventList.forEach(({ eventType, handler }) => {\n this.event.off(eventType, handler);\n });\n this._eventList = [];\n this.tooltipHandler?.release?.();\n }\n\n protected _initHandler() {\n const renderMode = this._spec.renderMode ?? 'html';\n\n const userTooltipHandler = this._option.globalInstance.getTooltipHandlerByUser();\n if (userTooltipHandler) {\n this.tooltipHandler = userTooltipHandler;\n } else {\n // 构造内部默认 handler\n const Handler = renderMode === 'canvas' ? CanvasTooltipHandler : DomTooltipHandler;\n const id = `${this._spec.className}-${this._option.globalInstance.id ?? 0}-${this._option.specIndex ?? 0}`;\n this.tooltipHandler = new Handler(id, this);\n }\n }\n\n protected _initProcessor() {\n // 初始化 tooltip 类型\n this._processor = {\n mark: new MarkTooltipProcessor(this),\n dimension: new DimensionTooltipProcessor(this)\n };\n }\n\n protected _initEvent() {\n const trigger = this._spec.trigger ?? 'hover';\n // TODO: triggerOff完整支持\n // const triggerOff = this._spec.triggerOff ?? trigger;\n const mode = this._option.mode;\n\n if (trigger === 'hover') {\n this._mountEvent('pointermove', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n // 移动端的点按 + 滑动触发\n if (isMobileLikeMode(mode) || isMiniAppLikeMode(mode)) {\n this._mountEvent('pointerdown', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._handleMouseOut);\n }\n this._mountEvent('pointermove', { source: 'window' }, this._handleMouseOut);\n } else if (trigger === 'click') {\n this._mountEvent('pointertap', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._handleMouseOut);\n }\n }\n\n protected _mountEvent = (eType: EventType, query: EventQuery, callback: EventCallback<any>) => {\n this.event.on(eType, query, callback);\n this._eventList.push({\n eventType: eType,\n handler: callback\n });\n };\n\n protected _handleMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n // 当 enterable 为 true,同时鼠标移入 tooltip 时 pointerleave 事件也会触发,所以这里做一个判断\n const { clientX, clientY } = params.event as MouseEvent;\n if (\n isTrueBrowser(this._option.mode) &&\n (this._isPointerInChart({ x: clientX, y: clientY }) || this._isPointerOnTooltip(params))\n ) {\n return;\n }\n\n this._handleChartMouseOut(params);\n };\n\n protected _handleChartMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (this._spec.triggerOff !== 'none') {\n this._hideTooltipByHandler({\n ...params\n });\n this._cacheInfo = undefined;\n }\n };\n\n protected _handleMouseMove = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n if (this._isPointerOnTooltip(params)) {\n return;\n }\n\n /* 获取 tooltip 原始数据 */\n const mouseEventData = this._getMouseEventData(params);\n const {\n tooltipInfo: { dimension: dimensionInfo },\n ignore: { mark: ignoreMark, dimension: ignoreDimension }\n } = mouseEventData;\n\n let markTooltipSuccess: boolean = false;\n let dimensionTooltipSuccess: boolean = false;\n\n /* 显示常规tooltip */\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params);\n if (!markTooltipSuccess) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n\n /* 如果不是常规情况,进行一些特殊情况tooltip处理 */\n if (!markTooltipSuccess && !dimensionTooltipSuccess && !isEmptyPos(params)) {\n // 用户手动配置ignore,则继续显示缓存tooltip\n if (ignoreMark && isMarkInfo(this._cacheInfo)) {\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params, true);\n } else if (ignoreDimension && isDimensionInfo(this._cacheInfo)) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params, true);\n } else if (isValid(dimensionInfo)) {\n // 用户没有手动配置ignore的话,默认显示dimension tooltip\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n }\n\n /* 如果还是不应该显示tooltip,则隐藏上一次tooltip */\n if (!markTooltipSuccess && (!dimensionTooltipSuccess || isNil(dimensionInfo))) {\n this._handleChartMouseOut(params);\n }\n };\n\n /**\n * 通过鼠标事件触发 tooltip,返回是否成功\n * @param activeType tooltip 类型\n * @param mouseEventData tooltip 相关数据\n * @param params 事件参数\n * @param useCache 是否直接显示缓存 tooltip\n * @returns 是否成功执行\n */\n protected _showTooltipByMouseEvent = (\n activeType: TooltipActiveType,\n mouseEventData: TotalMouseEventData,\n params: BaseEventParams,\n useCache?: boolean\n ): boolean => {\n const processor = this._processor[activeType];\n // 判断是否应该触发 tooltip\n if (\n !processor.shouldHandleTooltip(params, {\n tooltipInfo: mouseEventData.tooltipInfo[activeType],\n ignore: mouseEventData.ignore[activeType]\n })\n ) {\n return false;\n }\n\n let success: boolean;\n if (useCache) {\n // 直接显示缓存 tooltip\n success = !processor.showTooltip(this._cacheInfo as any, params, true);\n } else {\n const tooltipInfo = mouseEventData.tooltipInfo[activeType];\n const isSameAsCache = this._isSameAsCacheInfo(tooltipInfo);\n success = !processor.showTooltip(tooltipInfo as any, params, isSameAsCache);\n if (success) {\n // 成功显示 tooltip,则更新缓存\n this._cacheInfo = tooltipInfo;\n }\n }\n return success;\n };\n\n protected _getMouseEventData = (params: BaseEventParams): TotalMouseEventData => {\n const result: TotalMouseEventData = {\n tooltipInfo: {},\n ignore: {}\n };\n Object.keys(this._processor).forEach(activeType => {\n const { tooltipInfo, ignore } = this._processor[activeType].getMouseEventData(params);\n result.tooltipInfo[activeType] = tooltipInfo;\n result.ignore[activeType] = ignore;\n });\n return result;\n };\n\n protected _hideTooltipByHandler = (params: TooltipHandlerParams) => {\n if (this.tooltipHandler?.hideTooltip) {\n this.tooltipHandler.hideTooltip(params);\n }\n };\n\n protected _initTheme(theme?: any) {\n super._initTheme(theme);\n this._spec.style = merge({}, this._theme, this._originalSpec.style);\n }\n\n reInit(theme?: any) {\n super.reInit(theme);\n this.tooltipHandler?.reInit?.();\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n const userSpec = this._spec as ITooltipSpec;\n this._spec = {\n ...userSpec,\n visible: isValid(userSpec.visible) ? userSpec.visible : true,\n activeType: getTooltipActualActiveType(userSpec),\n renderMode: 'html',\n trigger: isValid(userSpec.trigger) ? userSpec.trigger : 'hover',\n className: isValid(userSpec.className) ? userSpec.className : TOOLTIP_EL_CLASS_NAME,\n enterable: isValid(userSpec.enterable) ? userSpec.enterable : false,\n transitionDuration: isValid(userSpec.transitionDuration) ? userSpec.transitionDuration : 150\n } as ITooltipSpec;\n this._spec.triggerOff = isValid(userSpec.triggerOff) ? userSpec.triggerOff : this._spec.trigger;\n\n if (isValid(userSpec.renderMode)) {\n this._spec.renderMode = userSpec.renderMode;\n } else if (isMiniAppLikeMode(this._option.mode)) {\n // 小程序环境下,默认使用canvas渲染\n this._spec.renderMode = 'canvas';\n }\n\n if (isValid(userSpec.mark)) {\n this._spec.mark = {\n ...cloneDeep(userSpec.mark),\n activeType: 'mark'\n };\n }\n if (isValid(userSpec.dimension)) {\n this._spec.dimension = {\n ...cloneDeep(userSpec.dimension),\n activeType: 'dimension'\n };\n }\n\n if (isValid(userSpec.parentElement)) {\n this._spec.parentElement = userSpec.parentElement;\n } else if (isTrueBrowser(this._option.mode)) {\n this._spec.parentElement = domDocument?.body;\n }\n\n if (isValid(userSpec.confine)) {\n this._spec.confine = userSpec.confine;\n } else {\n this._spec.confine = this._spec.renderMode === 'canvas';\n }\n }\n\n showTooltip(datum: Datum, options: IShowTooltipOption) {\n if (!this.tooltipHandler?.showTooltip) {\n return false;\n }\n const result = showTooltip(datum, options, this.tooltipHandler, this._option);\n if (result !== 'none') {\n this._alwaysShow = !!options?.alwaysShow;\n }\n return result;\n }\n\n hideTooltip() {\n if (!this.tooltipHandler?.hideTooltip) {\n return false;\n }\n this._alwaysShow = false;\n this.tooltipHandler.hideTooltip({\n changePositionOnly: false,\n item: undefined,\n datum: undefined,\n source: Event_Source_Type.chart\n } as any);\n return true;\n }\n\n private _isSameAsCacheInfo(nextInfo?: TooltipInfo): boolean {\n if (nextInfo === this._cacheInfo) {\n return true;\n }\n if (isNil(this._cacheInfo) || isNil(nextInfo)) {\n return false;\n }\n\n if (isDimensionInfo(nextInfo)) {\n if (isMarkInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as DimensionTooltipInfo;\n return prevInfo.length === nextInfo.length && nextInfo.every((info, i) => isSameDimensionInfo(info, prevInfo[i]));\n }\n if (isDimensionInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as MarkTooltipInfo;\n return (\n nextInfo?.datum === prevInfo.datum && nextInfo?.mark === prevInfo.mark && nextInfo?.series === prevInfo.series\n );\n }\n\n private _isPointerInChart(point: IPoint): boolean {\n const globalInstance = this._option.globalInstance;\n const chart = globalInstance.getChart();\n if (!chart) {\n return false;\n }\n const { x, y } = point;\n const container = globalInstance.getContainer();\n const { x: chartX, y: chartY } = getElementAbsolutePosition(container);\n const { x: scrollOffsetX, y: scrollOffsetY } = getElementAbsoluteScrollOffset(container);\n const canvasRect = chart.getCanvasRect();\n const chartWidth = canvasRect?.width;\n const chartHeight = canvasRect?.height;\n // 鼠标仍在图表范围内,则不处理\n if (\n x >= chartX - scrollOffsetX &&\n x <= chartX + chartWidth - scrollOffsetX &&\n y >= chartY - scrollOffsetY &&\n y <= chartY + chartHeight - scrollOffsetY\n ) {\n return true;\n }\n\n return false;\n }\n\n private _isPointerOnTooltip(params: BaseEventParams): boolean {\n // TODO:后续支持 renderMode === 'canvas' 场景\n if (this._spec.enterable && this._spec.renderMode === 'html') {\n const { event } = params;\n let target: any;\n if (isValid(event.nativeEvent)) {\n // get native event object\n const nativeEvent = event.nativeEvent as Event;\n target = nativeEvent.target;\n // if in shadow DOM use composedPath to access target\n if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {\n target = nativeEvent.composedPath()[0];\n }\n } else {\n target = event.target;\n }\n\n const container = this.tooltipHandler?.getTooltipContainer?.();\n if (isValid(container) && isValid(target) && hasParentElement(target, container)) {\n return true;\n }\n }\n return false;\n }\n\n getVisible() {\n return this._spec.visible === true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/tooltip.ts"],"names":[],"mappings":";;;AAEA,4CAAiD;AAGjD,kCAAwC;AAGxC,uCAAoE;AAEpE,qCAUoB;AASpB,mDAA4D;AAE5D,mCAA8E;AAC9E,4DAAwE;AACxE,6CAAuE;AAGvE,2CAA2G;AAC3G,6CAAgH;AAChH,8CAA2C;AAY3C,MAAa,OAAQ,SAAQ,oBAAa;IAA1C;;QAEE,SAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC;QACjC,SAAI,GAAW,6BAAiB,CAAC,OAAO,CAAC;QAEzC,eAAU,GAA8B,UAAU,CAAC;QAmB3C,gBAAW,GAAY,KAAK,CAAC;QAI7B,eAAU,GAAqB,EAAE,CAAC;QA0FhC,gBAAW,GAAG,CAAC,KAAgB,EAAE,KAAiB,EAAE,QAA4B,EAAE,EAAE;YAC5F,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACnB,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,CAAC,CAAC;QAEQ,oBAAe,GAAG,CAAC,MAAuB,EAAE,EAAE;YACtD,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO;aACR;YAGD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,KAAmB,CAAC;YACxD,IACE,IAAA,oBAAa,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAChC,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,EACxF;gBACA,OAAO;a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,GAAG,aAAa,EACzC;YACA,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,mBAAmB,CAAC,MAAuB;;QAEjD,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,MAAM,EAAE;YAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YACzB,IAAI,MAAW,CAAC;YAChB,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBAE9B,MAAM,WAAW,GAAG,KAAK,CAAC,WAAoB,CAAC;gBAC/C,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;gBAE5B,IAAI,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrE,MAAM,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;iBACxC;aACF;iBAAM;gBACL,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;aACvB;YAED,MAAM,SAAS,GAAG,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,mBAAmB,kDAAI,CAAC;YAC/D,IAAI,IAAA,cAAO,EAAC,SAAS,CAAC,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,IAAI,IAAA,yBAAgB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE;gBAChF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC;;AA1aH,0BA2aC;AA1aQ,YAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC","file":"tooltip.js","sourcesContent":["import type { IComponentOption } from '../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface';\nimport type { IModelLayoutOption, IModelRenderOption, ILayoutItem } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport { BaseComponent } from '../base';\nimport type { BaseEventParams, EventCallback, EventQuery, EventType } from '../../event/interface';\nimport type { ITooltipHandler, IToolTipLineActual, TooltipActiveType } from '../../typings/tooltip';\nimport { DomTooltipHandler, CanvasTooltipHandler } from './handler';\nimport type { Datum, IPoint, IShowTooltipOption } from '../../typings';\nimport {\n cloneDeep,\n isArray,\n isValid,\n merge,\n isMobileLikeMode,\n isTrueBrowser,\n isNil,\n isMiniAppLikeMode,\n domDocument\n} from '../../util';\nimport type {\n ITooltip,\n ITooltipActiveTypeAsKeys,\n ITooltipSpec,\n ITooltipTheme,\n TooltipHandlerParams,\n TotalMouseEventData\n} from './interface';\nimport { TOOLTIP_EL_CLASS_NAME } from './handler/constants';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTooltipActualActiveType, showTooltip, isEmptyPos } from './utils';\nimport { isSameDimensionInfo } from '../../event/events/dimension/util';\nimport { Event_Bubble_Level, Event_Source_Type } from '../../constant';\nimport type { DimensionTooltipInfo, MarkTooltipInfo, TooltipInfo } from './processor';\n// eslint-disable-next-line no-duplicate-imports\nimport { isDimensionInfo, isMarkInfo, MarkTooltipProcessor, DimensionTooltipProcessor } from './processor';\nimport { getElementAbsolutePosition, getElementAbsoluteScrollOffset, hasParentElement } from '@visactor/vutils';\nimport { VChart } from '../../core/vchart';\n\nexport type TooltipContent = {\n title?: IToolTipLineActual;\n content?: IToolTipLineActual[];\n};\n\ntype EventHandlerList = {\n eventType: EventType;\n handler: any;\n}[];\n\nexport class Tooltip extends BaseComponent implements ITooltip {\n static type = ComponentTypeEnum.tooltip;\n type = ComponentTypeEnum.tooltip;\n name: string = ComponentTypeEnum.tooltip;\n\n layoutType: ILayoutItem['layoutType'] = 'absolute';\n\n static createComponent(spec: any, options: IComponentOption) {\n const tooltipSpec = spec.tooltip;\n if (!tooltipSpec) {\n return null;\n }\n if (!isArray(tooltipSpec)) {\n return new Tooltip(tooltipSpec, { ...options, specKey: 'tooltip' });\n }\n const tooltips: Tooltip[] = [];\n tooltipSpec.forEach((s: any, i: number) => {\n tooltips.push(new Tooltip(s, { ...options, specIndex: i, specKey: 'tooltip' }));\n });\n return tooltips;\n }\n\n tooltipHandler?: ITooltipHandler;\n\n private _alwaysShow: boolean = false;\n\n private _cacheInfo: TooltipInfo | undefined;\n\n private _eventList: EventHandlerList = [];\n\n protected declare _spec: ITooltipSpec;\n\n protected declare _theme: ITooltipTheme;\n\n protected _processor: ITooltipActiveTypeAsKeys<MarkTooltipProcessor, DimensionTooltipProcessor>;\n\n changeRegions(regions: IRegion[]) {\n /* do nothing */\n }\n protected _registerEvent() {\n /* do nothing */\n }\n protected _releaseEvent() {\n /* do nothing */\n }\n onLayout(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onLayoutEnd(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onRender(ctx: IModelRenderOption) {\n /* do nothing */\n }\n\n created() {\n super.created();\n this._regions = this._option.getAllRegions();\n // handler\n this._initHandler();\n // processor\n this._initProcessor();\n // event\n this._initEvent();\n }\n\n release() {\n super.release();\n\n this._eventList.forEach(({ eventType, handler }) => {\n this.event.off(eventType, handler);\n });\n this._eventList = [];\n this.tooltipHandler?.release?.();\n }\n\n protected _initHandler() {\n const renderMode = this._spec.renderMode ?? 'html';\n\n const userTooltipHandler = this._option.globalInstance.getTooltipHandlerByUser();\n if (userTooltipHandler) {\n this.tooltipHandler = userTooltipHandler;\n } else {\n // 构造内部默认 handler\n const Handler = renderMode === 'canvas' ? CanvasTooltipHandler : DomTooltipHandler;\n const id = `${this._spec.className}-${this._option.globalInstance.id ?? 0}-${this._option.specIndex ?? 0}`;\n this.tooltipHandler = new Handler(id, this);\n }\n }\n\n protected _initProcessor() {\n // 初始化 tooltip 类型\n this._processor = {\n mark: new MarkTooltipProcessor(this),\n dimension: new DimensionTooltipProcessor(this)\n };\n }\n\n protected _initEvent() {\n const trigger = this._spec.trigger ?? 'hover';\n // TODO: triggerOff完整支持\n // const triggerOff = this._spec.triggerOff ?? trigger;\n const mode = this._option.mode;\n\n if (trigger === 'hover') {\n this._mountEvent('pointermove', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n // 移动端的点按 + 滑动触发\n if (isMobileLikeMode(mode) || isMiniAppLikeMode(mode)) {\n this._mountEvent('pointerdown', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._handleMouseOut);\n }\n this._mountEvent('pointermove', { source: 'window' }, this._handleMouseOut);\n } else if (trigger === 'click') {\n this._mountEvent('pointertap', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._handleMouseOut);\n }\n }\n\n protected _mountEvent = (eType: EventType, query: EventQuery, callback: EventCallback<any>) => {\n this.event.on(eType, query, callback);\n this._eventList.push({\n eventType: eType,\n handler: callback\n });\n };\n\n protected _handleMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n // 当 enterable 为 true,同时鼠标移入 tooltip 时 pointerleave 事件也会触发,所以这里做一个判断\n const { clientX, clientY } = params.event as MouseEvent;\n if (\n isTrueBrowser(this._option.mode) &&\n (this._isPointerInChart({ x: clientX, y: clientY }) || this._isPointerOnTooltip(params))\n ) {\n return;\n }\n\n this._handleChartMouseOut(params);\n };\n\n protected _handleChartMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (this._spec.triggerOff !== 'none') {\n this._hideTooltipByHandler({\n ...params\n });\n this._cacheInfo = undefined;\n }\n };\n\n protected _handleMouseMove = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n if (this._isPointerOnTooltip(params)) {\n return;\n }\n\n /* 获取 tooltip 原始数据 */\n const mouseEventData = this._getMouseEventData(params);\n const {\n tooltipInfo: { dimension: dimensionInfo },\n ignore: { mark: ignoreMark, dimension: ignoreDimension }\n } = mouseEventData;\n\n let markTooltipSuccess: boolean = false;\n let dimensionTooltipSuccess: boolean = false;\n\n /* 显示常规tooltip */\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params);\n if (!markTooltipSuccess) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n\n /* 如果不是常规情况,进行一些特殊情况tooltip处理 */\n if (!markTooltipSuccess && !dimensionTooltipSuccess && !isEmptyPos(params)) {\n // 用户手动配置ignore,则继续显示缓存tooltip\n if (ignoreMark && isMarkInfo(this._cacheInfo)) {\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params, true);\n } else if (ignoreDimension && isDimensionInfo(this._cacheInfo)) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params, true);\n } else if (isValid(dimensionInfo)) {\n // 用户没有手动配置ignore的话,默认显示dimension tooltip\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n }\n\n /* 如果还是不应该显示tooltip,则隐藏上一次tooltip */\n if (!markTooltipSuccess && (!dimensionTooltipSuccess || isNil(dimensionInfo))) {\n this._handleChartMouseOut(params);\n }\n };\n\n /**\n * 通过鼠标事件触发 tooltip,返回是否成功\n * @param activeType tooltip 类型\n * @param mouseEventData tooltip 相关数据\n * @param params 事件参数\n * @param useCache 是否直接显示缓存 tooltip\n * @returns 是否成功执行\n */\n protected _showTooltipByMouseEvent = (\n activeType: TooltipActiveType,\n mouseEventData: TotalMouseEventData,\n params: BaseEventParams,\n useCache?: boolean\n ): boolean => {\n const processor = this._processor[activeType];\n // 判断是否应该触发 tooltip\n if (\n !processor.shouldHandleTooltip(params, {\n tooltipInfo: mouseEventData.tooltipInfo[activeType],\n ignore: mouseEventData.ignore[activeType]\n })\n ) {\n return false;\n }\n\n let success: boolean;\n if (useCache) {\n // 直接显示缓存 tooltip\n success = !processor.showTooltip(this._cacheInfo as any, params, true);\n } else {\n const tooltipInfo = mouseEventData.tooltipInfo[activeType];\n const isSameAsCache = this._isSameAsCacheInfo(tooltipInfo);\n success = !processor.showTooltip(tooltipInfo as any, params, isSameAsCache);\n if (success) {\n // 成功显示 tooltip,则更新缓存\n this._cacheInfo = tooltipInfo;\n }\n }\n // 全局唯一 tooltip\n const vchart = this._option.globalInstance;\n if (success && VChart.globalConfig.uniqueTooltip) {\n VChart.hideTooltip(vchart.id);\n }\n return success;\n };\n\n protected _getMouseEventData = (params: BaseEventParams): TotalMouseEventData => {\n const result: TotalMouseEventData = {\n tooltipInfo: {},\n ignore: {}\n };\n Object.keys(this._processor).forEach(activeType => {\n const { tooltipInfo, ignore } = this._processor[activeType].getMouseEventData(params);\n result.tooltipInfo[activeType] = tooltipInfo;\n result.ignore[activeType] = ignore;\n });\n return result;\n };\n\n protected _hideTooltipByHandler = (params: TooltipHandlerParams) => {\n if (this.tooltipHandler?.hideTooltip) {\n this.tooltipHandler.hideTooltip(params);\n }\n };\n\n protected _initTheme(theme?: any) {\n super._initTheme(theme);\n this._spec.style = merge({}, this._theme, this._originalSpec.style);\n }\n\n reInit(theme?: any) {\n super.reInit(theme);\n this.tooltipHandler?.reInit?.();\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n const userSpec = this._spec as ITooltipSpec;\n this._spec = {\n ...userSpec,\n visible: isValid(userSpec.visible) ? userSpec.visible : true,\n activeType: getTooltipActualActiveType(userSpec),\n renderMode: 'html',\n trigger: isValid(userSpec.trigger) ? userSpec.trigger : 'hover',\n className: isValid(userSpec.className) ? userSpec.className : TOOLTIP_EL_CLASS_NAME,\n enterable: isValid(userSpec.enterable) ? userSpec.enterable : false,\n transitionDuration: isValid(userSpec.transitionDuration) ? userSpec.transitionDuration : 150\n } as ITooltipSpec;\n this._spec.triggerOff = isValid(userSpec.triggerOff) ? userSpec.triggerOff : this._spec.trigger;\n\n if (isValid(userSpec.renderMode)) {\n this._spec.renderMode = userSpec.renderMode;\n } else if (isMiniAppLikeMode(this._option.mode)) {\n // 小程序环境下,默认使用canvas渲染\n this._spec.renderMode = 'canvas';\n }\n\n if (isValid(userSpec.mark)) {\n this._spec.mark = {\n ...cloneDeep(userSpec.mark),\n activeType: 'mark'\n };\n }\n if (isValid(userSpec.dimension)) {\n this._spec.dimension = {\n ...cloneDeep(userSpec.dimension),\n activeType: 'dimension'\n };\n }\n\n if (isValid(userSpec.parentElement)) {\n this._spec.parentElement = userSpec.parentElement;\n } else if (isTrueBrowser(this._option.mode)) {\n this._spec.parentElement = domDocument?.body;\n }\n\n if (isValid(userSpec.confine)) {\n this._spec.confine = userSpec.confine;\n } else {\n this._spec.confine = this._spec.renderMode === 'canvas';\n }\n }\n\n showTooltip(datum: Datum, options: IShowTooltipOption) {\n if (!this.tooltipHandler?.showTooltip) {\n return false;\n }\n const result = showTooltip(datum, options, this.tooltipHandler, this._option);\n if (result !== 'none') {\n this._alwaysShow = !!options?.alwaysShow;\n }\n return result;\n }\n\n hideTooltip() {\n if (!this.tooltipHandler?.hideTooltip) {\n return false;\n }\n this._alwaysShow = false;\n this.tooltipHandler.hideTooltip({\n changePositionOnly: false,\n item: undefined,\n datum: undefined,\n source: Event_Source_Type.chart\n } as any);\n return true;\n }\n\n private _isSameAsCacheInfo(nextInfo?: TooltipInfo): boolean {\n if (nextInfo === this._cacheInfo) {\n return true;\n }\n if (isNil(this._cacheInfo) || isNil(nextInfo)) {\n return false;\n }\n\n if (isDimensionInfo(nextInfo)) {\n if (isMarkInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as DimensionTooltipInfo;\n return prevInfo.length === nextInfo.length && nextInfo.every((info, i) => isSameDimensionInfo(info, prevInfo[i]));\n }\n if (isDimensionInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as MarkTooltipInfo;\n return (\n nextInfo?.datum === prevInfo.datum && nextInfo?.mark === prevInfo.mark && nextInfo?.series === prevInfo.series\n );\n }\n\n private _isPointerInChart(point: IPoint): boolean {\n const globalInstance = this._option.globalInstance;\n const chart = globalInstance.getChart();\n if (!chart) {\n return false;\n }\n const { x, y } = point;\n const container = globalInstance.getContainer();\n const { x: chartX, y: chartY } = getElementAbsolutePosition(container);\n const { x: scrollOffsetX, y: scrollOffsetY } = getElementAbsoluteScrollOffset(container);\n const canvasRect = chart.getCanvasRect();\n const chartWidth = canvasRect?.width;\n const chartHeight = canvasRect?.height;\n // 鼠标仍在图表范围内,则不处理\n if (\n x >= chartX - scrollOffsetX &&\n x <= chartX + chartWidth - scrollOffsetX &&\n y >= chartY - scrollOffsetY &&\n y <= chartY + chartHeight - scrollOffsetY\n ) {\n return true;\n }\n\n return false;\n }\n\n private _isPointerOnTooltip(params: BaseEventParams): boolean {\n // TODO:后续支持 renderMode === 'canvas' 场景\n if (this._spec.enterable && this._spec.renderMode === 'html') {\n const { event } = params;\n let target: any;\n if (isValid(event.nativeEvent)) {\n // get native event object\n const nativeEvent = event.nativeEvent as Event;\n target = nativeEvent.target;\n // if in shadow DOM use composedPath to access target\n if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {\n target = nativeEvent.composedPath()[0];\n }\n } else {\n target = event.target;\n }\n\n const container = this.tooltipHandler?.getTooltipContainer?.();\n if (isValid(container) && isValid(target) && hasParentElement(target, container)) {\n return true;\n }\n }\n return false;\n }\n\n getVisible() {\n return this._spec.visible === true;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.showTooltip = void 0;
|
|
6
6
|
|
|
7
|
-
const util_1 = require("../../../util"), type_1 = require("../../../series/interface/type"), constant_1 = require("../../../constant"), vutils_1 = require("@visactor/vutils"), getDataArrayFromFieldArray = (fields, datum) => (0,
|
|
7
|
+
const util_1 = require("../../../util"), type_1 = require("../../../series/interface/type"), constant_1 = require("../../../constant"), vutils_1 = require("@visactor/vutils"), vchart_1 = require("../../../core/vchart"), getDataArrayFromFieldArray = (fields, datum) => (0,
|
|
8
8
|
util_1.isValid)(datum) ? fields.map((f => datum[f])) : void 0, datumContainsArray = (fields, data) => datum => fields.every(((key, i) => datum[key] === (null == data ? void 0 : data[i]))), hasData = data => !(0,
|
|
9
9
|
util_1.isNil)(data) && ((0, util_1.isArray)(data) ? data.length > 0 && data.every(util_1.isValid) : Object.keys(data).length > 0);
|
|
10
10
|
|
|
@@ -212,7 +212,9 @@ function showTooltip(datum, options, tooltipHandler, componentOptions) {
|
|
|
212
212
|
item: void 0,
|
|
213
213
|
itemMap: new Map
|
|
214
214
|
};
|
|
215
|
-
|
|
215
|
+
null === (_c = null == tooltipHandler ? void 0 : tooltipHandler.showTooltip) || void 0 === _c || _c.call(tooltipHandler, activeType, mockDimensionInfo, mockParams);
|
|
216
|
+
const vchart = componentOptions.globalInstance;
|
|
217
|
+
return vchart_1.VChart.globalConfig.uniqueTooltip && vchart_1.VChart.hideTooltip(vchart.id),
|
|
216
218
|
activeType;
|
|
217
219
|
}
|
|
218
220
|
if ("mark" === activeType) {
|
|
@@ -228,10 +230,13 @@ function showTooltip(datum, options, tooltipHandler, componentOptions) {
|
|
|
228
230
|
item: void 0,
|
|
229
231
|
itemMap: new Map
|
|
230
232
|
};
|
|
231
|
-
|
|
233
|
+
null === (_e = null == tooltipHandler ? void 0 : tooltipHandler.showTooltip) || void 0 === _e || _e.call(tooltipHandler, activeType, [ {
|
|
232
234
|
datum: [ mockDatum ],
|
|
233
235
|
series: info.series
|
|
234
|
-
} ], mockParams)
|
|
236
|
+
} ], mockParams);
|
|
237
|
+
const vchart = componentOptions.globalInstance;
|
|
238
|
+
return vchart_1.VChart.globalConfig.uniqueTooltip && vchart_1.VChart.hideTooltip(vchart.id),
|
|
239
|
+
activeType;
|
|
235
240
|
}
|
|
236
241
|
return "none";
|
|
237
242
|
}
|