@visactor/vchart 1.3.0-beta.4 → 1.3.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/build/es5/index.js +1 -1
- package/build/index.js +400 -208
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/area/area.js +2 -1
- package/cjs/chart/area/area.js.map +1 -1
- package/cjs/chart/base-chart.d.ts +2 -1
- package/cjs/chart/base-chart.js +12 -0
- package/cjs/chart/base-chart.js.map +1 -1
- package/cjs/chart/interface/chart.d.ts +2 -1
- package/cjs/chart/interface/chart.js.map +1 -1
- package/cjs/chart/line/line.js +2 -1
- package/cjs/chart/line/line.js.map +1 -1
- package/cjs/chart/radar/radar.js +2 -1
- package/cjs/chart/radar/radar.js.map +1 -1
- package/cjs/chart/util.js +1 -2
- package/cjs/compile/compiler.d.ts +2 -1
- package/cjs/compile/compiler.js +4 -0
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/compile/mark/interface.d.ts +2 -0
- package/cjs/compile/mark/interface.js.map +1 -1
- package/cjs/component/index.js +2 -1
- package/cjs/component/title/title.js +1 -1
- package/cjs/component/title/title.js.map +1 -1
- package/cjs/component/tooltip/handler/base.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.d.ts +1 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/interface.d.ts +9 -12
- package/cjs/component/tooltip/handler/dom/interface.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/model/content-column-model.d.ts +4 -6
- package/cjs/component/tooltip/handler/dom/model/content-column-model.js +17 -15
- package/cjs/component/tooltip/handler/dom/model/content-column-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.js +18 -11
- package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/attribute.js +23 -23
- package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/compose.d.ts +2 -2
- package/cjs/component/tooltip/handler/utils/compose.js +13 -10
- package/cjs/component/tooltip/handler/utils/compose.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/get-spec.js +72 -54
- package/cjs/component/tooltip/handler/utils/get-spec.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/style.d.ts +1 -1
- package/cjs/component/tooltip/handler/utils/style.js +15 -10
- package/cjs/component/tooltip/handler/utils/style.js.map +1 -1
- package/cjs/component/tooltip/interface/theme.d.ts +1 -0
- package/cjs/component/tooltip/interface/theme.js.map +1 -1
- package/cjs/component/tooltip/tooltip.d.ts +1 -1
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/constant/marker.js +1 -2
- package/cjs/core/factory.js +2 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/vchart.d.ts +4 -1
- package/cjs/core/vchart.js +41 -11
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/initialize.js +9 -7
- package/cjs/data/initialize.js.map +1 -1
- package/cjs/series/area/interface.d.ts +1 -0
- package/cjs/series/area/interface.js.map +1 -1
- package/cjs/series/base/base-series.js +2 -1
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/base/tooltip-helper.js +1 -0
- package/cjs/series/base/tooltip-helper.js.map +1 -1
- package/cjs/series/line/interface.d.ts +1 -0
- package/cjs/series/line/interface.js.map +1 -1
- package/cjs/series/mixin/line-mixin.d.ts +10 -2
- package/cjs/series/mixin/line-mixin.js +53 -6
- package/cjs/series/mixin/line-mixin.js.map +1 -1
- package/cjs/series/polar/polar.js +2 -1
- package/cjs/series/polar/polar.js.map +1 -1
- package/cjs/series/radar/interface.d.ts +1 -0
- package/cjs/series/radar/interface.js.map +1 -1
- package/cjs/typings/tooltip/label.d.ts +10 -0
- package/cjs/typings/tooltip/label.js +6 -0
- package/cjs/typings/tooltip/label.js.map +1 -0
- package/cjs/typings/tooltip/line.d.ts +3 -3
- package/cjs/typings/tooltip/line.js.map +1 -1
- package/cjs/typings/tooltip/shape.d.ts +3 -0
- package/cjs/typings/tooltip/shape.js.map +1 -1
- package/esm/chart/area/area.js +2 -1
- package/esm/chart/area/area.js.map +1 -1
- package/esm/chart/base-chart.d.ts +2 -1
- package/esm/chart/base-chart.js +12 -0
- package/esm/chart/base-chart.js.map +1 -1
- package/esm/chart/interface/chart.d.ts +2 -1
- package/esm/chart/interface/chart.js.map +1 -1
- package/esm/chart/line/line.js +2 -1
- package/esm/chart/line/line.js.map +1 -1
- package/esm/chart/radar/radar.js +2 -1
- package/esm/chart/radar/radar.js.map +1 -1
- package/esm/chart/util.js +1 -2
- package/esm/compile/compiler.d.ts +2 -1
- package/esm/compile/compiler.js +4 -0
- package/esm/compile/compiler.js.map +1 -1
- package/esm/compile/mark/interface.d.ts +2 -0
- package/esm/compile/mark/interface.js.map +1 -1
- package/esm/component/index.js +2 -1
- package/esm/component/title/title.js +1 -1
- package/esm/component/title/title.js.map +1 -1
- package/esm/component/tooltip/handler/base.js.map +1 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.d.ts +1 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/dom/interface.d.ts +9 -12
- package/esm/component/tooltip/handler/dom/interface.js.map +1 -1
- package/esm/component/tooltip/handler/dom/model/content-column-model.d.ts +4 -6
- package/esm/component/tooltip/handler/dom/model/content-column-model.js +16 -14
- package/esm/component/tooltip/handler/dom/model/content-column-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.js +18 -11
- package/esm/component/tooltip/handler/dom/util.js.map +1 -1
- package/esm/component/tooltip/handler/utils/attribute.js +22 -23
- package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/esm/component/tooltip/handler/utils/compose.d.ts +2 -2
- package/esm/component/tooltip/handler/utils/compose.js +11 -10
- package/esm/component/tooltip/handler/utils/compose.js.map +1 -1
- package/esm/component/tooltip/handler/utils/get-spec.js +70 -50
- package/esm/component/tooltip/handler/utils/get-spec.js.map +1 -1
- package/esm/component/tooltip/handler/utils/style.d.ts +1 -1
- package/esm/component/tooltip/handler/utils/style.js +16 -9
- package/esm/component/tooltip/handler/utils/style.js.map +1 -1
- package/esm/component/tooltip/interface/theme.d.ts +1 -0
- package/esm/component/tooltip/interface/theme.js.map +1 -1
- package/esm/component/tooltip/tooltip.d.ts +1 -1
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/constant/marker.js +1 -2
- package/esm/core/factory.js +2 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/vchart.d.ts +4 -1
- package/esm/core/vchart.js +41 -11
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/initialize.js +10 -7
- package/esm/data/initialize.js.map +1 -1
- package/esm/series/area/interface.d.ts +1 -0
- package/esm/series/area/interface.js.map +1 -1
- package/esm/series/base/base-series.js +2 -1
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/base/tooltip-helper.js +1 -0
- package/esm/series/base/tooltip-helper.js.map +1 -1
- package/esm/series/line/interface.d.ts +1 -0
- package/esm/series/line/interface.js.map +1 -1
- package/esm/series/mixin/line-mixin.d.ts +10 -2
- package/esm/series/mixin/line-mixin.js +60 -5
- package/esm/series/mixin/line-mixin.js.map +1 -1
- package/esm/series/polar/polar.js +2 -1
- package/esm/series/polar/polar.js.map +1 -1
- package/esm/series/radar/interface.d.ts +1 -0
- package/esm/series/radar/interface.js.map +1 -1
- package/esm/typings/tooltip/label.d.ts +10 -0
- package/esm/typings/tooltip/label.js +2 -0
- package/esm/typings/tooltip/label.js.map +1 -0
- package/esm/typings/tooltip/line.d.ts +3 -3
- package/esm/typings/tooltip/line.js.map +1 -1
- package/esm/typings/tooltip/shape.d.ts +3 -0
- package/esm/typings/tooltip/shape.js.map +1 -1
- package/package.json +4 -4
|
@@ -44,20 +44,22 @@ export class ContentColumnModel extends BaseTooltipModel {
|
|
|
44
44
|
super.setStyle(merge({}, defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));
|
|
45
45
|
const renderContent = null !== (_b = null === (_a = this._option.getTooltipActual()) || void 0 === _a ? void 0 : _a.content) && void 0 !== _b ? _b : [], contentAttributes = null !== (_d = null === (_c = this._option.getTooltipAttributes()) || void 0 === _c ? void 0 : _c.content) && void 0 !== _d ? _d : [];
|
|
46
46
|
renderContent.forEach(((line, i) => {
|
|
47
|
-
var _a, _b;
|
|
47
|
+
var _a, _b, _c, _d, _e;
|
|
48
48
|
let childStyle = {};
|
|
49
49
|
if ("key-box" === this.className) {
|
|
50
50
|
const {key: key, isKeyAdaptive: isKeyAdaptive} = line;
|
|
51
|
-
childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, Object.assign({
|
|
51
|
+
childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, Object.assign(Object.assign({
|
|
52
52
|
height: getPixelPropertyStr(contentAttributes[i].height)
|
|
53
|
-
}, tooltipStyle.keyColumn.
|
|
54
|
-
isString(key) && "" !== (null === (
|
|
53
|
+
}, tooltipStyle.keyColumn.common), null === (_a = tooltipStyle.keyColumn.items) || void 0 === _a ? void 0 : _a[i]));
|
|
54
|
+
isString(key) && "" !== (null === (_b = null == key ? void 0 : key.trim) || void 0 === _b ? void 0 : _b.call(key)) || isNumber(key) || childStyle.visibility ? childStyle.visibility = "visible" : childStyle.visibility = "hidden",
|
|
55
55
|
this.children[i].setStyle(childStyle);
|
|
56
|
-
} else "value-box" === this.className ? (childStyle = merge({}, defaultValueStyle, Object.assign({
|
|
56
|
+
} else "value-box" === this.className ? (childStyle = merge({}, defaultValueStyle, Object.assign(Object.assign({
|
|
57
57
|
height: getPixelPropertyStr(contentAttributes[i].height)
|
|
58
|
-
}, tooltipStyle.valueColumn.
|
|
58
|
+
}, tooltipStyle.valueColumn.common), null === (_c = tooltipStyle.valueColumn.items) || void 0 === _c ? void 0 : _c[i])),
|
|
59
|
+
this.children[i].setStyle(childStyle)) : "shape-box" === this.className && (childStyle = merge({}, defaultShapeStyle, Object.assign(Object.assign({
|
|
59
60
|
height: getPixelPropertyStr(contentAttributes[i].height)
|
|
60
|
-
}, tooltipStyle.shapeColumn.
|
|
61
|
+
}, tooltipStyle.shapeColumn.common), null === (_d = tooltipStyle.shapeColumn.items) || void 0 === _d ? void 0 : _d[i])),
|
|
62
|
+
null === (_e = this.children[i]) || void 0 === _e || _e.setStyle(childStyle, this._getShapeSvgOption(line, i)));
|
|
61
63
|
}));
|
|
62
64
|
}
|
|
63
65
|
setContent() {
|
|
@@ -69,12 +71,12 @@ export class ContentColumnModel extends BaseTooltipModel {
|
|
|
69
71
|
if ("key-box" === this.className) {
|
|
70
72
|
const keyContent = line.key;
|
|
71
73
|
childContent = isString(keyContent) && "" !== (null === (_a = null == keyContent ? void 0 : keyContent.trim) || void 0 === _a ? void 0 : _a.call(keyContent)) || isNumber(keyContent) ? keyContent : TOOLTIP_EMPTY_STRING,
|
|
72
|
-
null === (_b = this.children[i]) || void 0 === _b || _b.setContent(childContent, null === (_c = contentAttributes[i].
|
|
74
|
+
null === (_b = this.children[i]) || void 0 === _b || _b.setContent(childContent, null === (_c = contentAttributes[i].key) || void 0 === _c ? void 0 : _c.multiLine);
|
|
73
75
|
} else if ("value-box" === this.className) {
|
|
74
76
|
const valueContent = line.value;
|
|
75
77
|
childContent = isString(valueContent) && "" !== (null === (_d = null == valueContent ? void 0 : valueContent.trim) || void 0 === _d ? void 0 : _d.call(valueContent)) || isNumber(valueContent) ? valueContent : TOOLTIP_EMPTY_STRING,
|
|
76
78
|
null === (_e = this.children[i]) || void 0 === _e || _e.setContent(childContent, null === (_f = contentAttributes[i].value) || void 0 === _f ? void 0 : _f.multiLine);
|
|
77
|
-
} else "shape-box" === this.className && (childContent = this._getShapeSvgOption(line),
|
|
79
|
+
} else "shape-box" === this.className && (childContent = this._getShapeSvgOption(line, i),
|
|
78
80
|
null === (_g = this.children[i]) || void 0 === _g || _g.setContent(childContent));
|
|
79
81
|
}));
|
|
80
82
|
}
|
|
@@ -95,16 +97,16 @@ export class ContentColumnModel extends BaseTooltipModel {
|
|
|
95
97
|
return tooltipStyle.valueColumn;
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
|
-
_getShapeSvgOption(line) {
|
|
99
|
-
var _a, _b, _c, _d, _e
|
|
100
|
-
const tooltipStyle = this._option.getTooltipStyle();
|
|
100
|
+
_getShapeSvgOption(line, index) {
|
|
101
|
+
var _a, _b, _c, _d, _e;
|
|
102
|
+
const tooltipStyle = this._option.getTooltipStyle(), shapeColumn = Object.assign(Object.assign({}, tooltipStyle.shapeColumn), null === (_a = tooltipStyle.shapeColumn.items) || void 0 === _a ? void 0 : _a[index]), keyColumn = Object.assign(Object.assign({}, tooltipStyle.keyColumn), null === (_b = tooltipStyle.keyColumn.items) || void 0 === _b ? void 0 : _b[index]);
|
|
101
103
|
return {
|
|
102
104
|
hasShape: line.hasShape,
|
|
103
105
|
shapeType: line.shapeType,
|
|
104
|
-
size:
|
|
106
|
+
size: shapeColumn.width,
|
|
105
107
|
color: line.shapeColor,
|
|
106
108
|
hollow: line.shapeHollow,
|
|
107
|
-
marginTop: `calc((${null !== (
|
|
109
|
+
marginTop: `calc((${null !== (_d = null !== (_c = keyColumn.lineHeight) && void 0 !== _c ? _c : keyColumn.fontSize) && void 0 !== _d ? _d : "18px"} - ${null !== (_e = shapeColumn.width) && void 0 !== _e ? _e : "8px"}) / 2)`
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|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AAA,MAAA,MAAA,YAAY,CAAC,SAAS,CAAC,IAAI,0CAAE,UAAU,mCAAI,MAAA,YAAY,CAAC,SAAS,CAAC,IAAI,0CAAE,QAAQ,mCAAI,MACtF,MAAM,MAAA,MAAA,YAAY,CAAC,WAAW,CAAC,IAAI,0CAAE,KAAK,mCAAI,KAAK,QAAQ;SACzC,CAAC;IACvB,CAAC;CACF","file":"content-column-model.js","sourcesContent":["import { isNumber, isString, merge, toNumber } from '@visactor/vutils';\nimport {\n defaultKeyStyle,\n defaultContentColumnStyle,\n defaultValueStyle,\n defaultAdaptiveKeyStyle,\n defaultShapeStyle\n} from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport type { ITooltipModelOption } from './interface';\nimport type { IShapeSvgOption } from './shape-model';\n// eslint-disable-next-line no-duplicate-imports\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\nimport { TOOLTIP_EMPTY_STRING } from '../../constants';\nimport { getPixelPropertyStr } from '../util';\nimport type { IToolTipLineActual } from '../../../../../typings';\n\nexport type ContentColumnType = 'shape-box' | 'key-box' | 'value-box';\n\nexport class ContentColumnModel extends BaseTooltipModel {\n readonly className: ContentColumnType;\n\n constructor(\n parent: BaseTooltipModel | HTMLElement,\n option: ITooltipModelOption,\n className: ContentColumnType,\n childIndex?: number\n ) {\n super(parent, option, childIndex);\n this.className = className;\n }\n\n init(): void {\n if (!this.product) {\n this.product = this.createElement('div', [this.className]);\n }\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n\n if (this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)) {\n // 当有一行配有形状的时候,其他行要对齐。如果没有一行配有形状,则删除所有的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n this.children[i].release();\n delete this.children[i];\n });\n } else {\n // 删除多余的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n if (i >= renderContent.length) {\n this.children[i].release();\n delete this.children[i];\n }\n });\n // 新增没有的行\n for (let i = 0; i < renderContent.length; i++) {\n if (!this.children[i]) {\n if (this.className === 'key-box' || this.className === 'value-box') {\n const text = new TextModel(this.product!, this._option, i);\n text.init([this.className.substring(0, this.className.indexOf('-'))], undefined, 'div');\n this.children[i] = text;\n } else if (this.className === 'shape-box') {\n const shape = new ShapeModel(this.product!, this._option, i);\n shape.init(['shape'], undefined, 'div');\n this.children[i] = shape;\n }\n }\n }\n }\n }\n\n setStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n super.setStyle(merge({}, defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));\n\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childStyle: any = {};\n if (this.className === 'key-box') {\n const { key, isKeyAdaptive } = line;\n childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.keyColumn.item\n });\n const hasContent = (isString(key) && key?.trim?.() !== '') || isNumber(key);\n if (!hasContent && !childStyle.visibility) {\n childStyle.visibility = 'hidden';\n } else {\n childStyle.visibility = 'visible';\n }\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'value-box') {\n childStyle = merge({}, defaultValueStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.valueColumn.item\n });\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'shape-box') {\n childStyle = merge({}, defaultShapeStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.shapeColumn.item\n });\n (this.children[i] as ShapeModel)?.setStyle(childStyle, this._getShapeSvgOption(line));\n }\n });\n }\n\n setContent(): void {\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childContent: any;\n if (this.className === 'key-box') {\n const keyContent = line.key;\n if ((isString(keyContent) && keyContent?.trim?.() !== '') || isNumber(keyContent)) {\n childContent = keyContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n (this.children[i] as TextModel)?.setContent(childContent, contentAttributes[i].value?.multiLine);\n } else if (this.className === 'value-box') {\n const valueContent = line.value;\n if ((isString(valueContent) && valueContent?.trim?.() !== '') || isNumber(valueContent)) {\n childContent = valueContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n (this.children[i] as TextModel)?.setContent(childContent, contentAttributes[i].value?.multiLine);\n } else if (this.className === 'shape-box') {\n childContent = this._getShapeSvgOption(line);\n this.children[i]?.setContent(childContent);\n }\n });\n }\n\n protected _getContentColumnStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n switch (this.className) {\n case 'shape-box':\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n return {\n ...tooltipStyle.shapeColumn,\n ...(this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)\n ? { display: 'none' }\n : {})\n };\n case 'key-box':\n return tooltipStyle.keyColumn;\n case 'value-box':\n return tooltipStyle.valueColumn;\n }\n }\n\n protected _getShapeSvgOption(line: IToolTipLineActual): IShapeSvgOption {\n const tooltipStyle = this._option.getTooltipStyle();\n return {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow,\n marginTop: `calc((${\n tooltipStyle.keyColumn.item?.lineHeight ?? tooltipStyle.keyColumn.item?.fontSize ?? '18px'\n } - ${tooltipStyle.shapeColumn.item?.width ?? '8px'}) / 2)`\n } as IShapeSvgOption;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/content-column-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB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zC,CAAC;QACF,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,WAAW,CAAC,KAAK;YACvB,KAAK,EAAE,IAAI,CAAC,UAAU;YACtB,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,SAAS,EAAE,SAAS,MAAA,MAAA,SAAS,CAAC,UAAU,mCAAI,SAAS,CAAC,QAAQ,mCAAI,MAAM,MAAM,MAAA,WAAW,CAAC,KAAK,mCAAI,KAAK,QAAQ;SAC9F,CAAC;IACvB,CAAC;CACF","file":"content-column-model.js","sourcesContent":["import { isNumber, isString, merge, toNumber } from '@visactor/vutils';\nimport {\n defaultKeyStyle,\n defaultContentColumnStyle,\n defaultValueStyle,\n defaultAdaptiveKeyStyle,\n defaultShapeStyle\n} from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport type { ITooltipModelOption } from './interface';\nimport type { IShapeSvgOption } from './shape-model';\n// eslint-disable-next-line no-duplicate-imports\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\nimport { TOOLTIP_EMPTY_STRING } from '../../constants';\nimport { getPixelPropertyStr } from '../util';\nimport type { IToolTipLineActual } from '../../../../../typings';\n\nexport type ContentColumnType = 'shape-box' | 'key-box' | 'value-box';\n\nexport class ContentColumnModel extends BaseTooltipModel {\n readonly className: ContentColumnType;\n\n constructor(\n parent: BaseTooltipModel | HTMLElement,\n option: ITooltipModelOption,\n className: ContentColumnType,\n childIndex?: number\n ) {\n super(parent, option, childIndex);\n this.className = className;\n }\n\n init(): void {\n if (!this.product) {\n this.product = this.createElement('div', [this.className]);\n }\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n\n if (this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)) {\n // 当有一行配有形状的时候,其他行要对齐。如果没有一行配有形状,则删除所有的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n this.children[i].release();\n delete this.children[i];\n });\n } else {\n // 删除多余的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n if (i >= renderContent.length) {\n this.children[i].release();\n delete this.children[i];\n }\n });\n // 新增没有的行\n for (let i = 0; i < renderContent.length; i++) {\n if (!this.children[i]) {\n if (this.className === 'key-box' || this.className === 'value-box') {\n const text = new TextModel(this.product!, this._option, i);\n text.init([this.className.substring(0, this.className.indexOf('-'))], undefined, 'div');\n this.children[i] = text;\n } else if (this.className === 'shape-box') {\n const shape = new ShapeModel(this.product!, this._option, i);\n shape.init(['shape'], undefined, 'div');\n this.children[i] = shape;\n }\n }\n }\n }\n }\n\n setStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n super.setStyle(merge({}, defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));\n\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childStyle: any = {};\n if (this.className === 'key-box') {\n const { key, isKeyAdaptive } = line;\n childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.keyColumn.common,\n ...tooltipStyle.keyColumn.items?.[i]\n });\n const hasContent = (isString(key) && key?.trim?.() !== '') || isNumber(key);\n if (!hasContent && !childStyle.visibility) {\n childStyle.visibility = 'hidden';\n } else {\n childStyle.visibility = 'visible';\n }\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'value-box') {\n childStyle = merge({}, defaultValueStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.valueColumn.common,\n ...tooltipStyle.valueColumn.items?.[i]\n });\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'shape-box') {\n childStyle = merge({}, defaultShapeStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.shapeColumn.common,\n ...tooltipStyle.shapeColumn.items?.[i]\n });\n (this.children[i] as ShapeModel)?.setStyle(childStyle, this._getShapeSvgOption(line, i));\n }\n });\n }\n\n setContent(): void {\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childContent: any;\n if (this.className === 'key-box') {\n const keyContent = line.key;\n if ((isString(keyContent) && keyContent?.trim?.() !== '') || isNumber(keyContent)) {\n childContent = keyContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n (this.children[i] as TextModel)?.setContent(childContent, contentAttributes[i].key?.multiLine);\n } else if (this.className === 'value-box') {\n const valueContent = line.value;\n if ((isString(valueContent) && valueContent?.trim?.() !== '') || isNumber(valueContent)) {\n childContent = valueContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n (this.children[i] as TextModel)?.setContent(childContent, contentAttributes[i].value?.multiLine);\n } else if (this.className === 'shape-box') {\n childContent = this._getShapeSvgOption(line, i);\n this.children[i]?.setContent(childContent);\n }\n });\n }\n\n protected _getContentColumnStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n switch (this.className) {\n case 'shape-box':\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n return {\n ...tooltipStyle.shapeColumn,\n ...(this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)\n ? { display: 'none' }\n : {})\n };\n case 'key-box':\n return tooltipStyle.keyColumn;\n case 'value-box':\n return tooltipStyle.valueColumn;\n }\n }\n\n protected _getShapeSvgOption(line: IToolTipLineActual, index: number): IShapeSvgOption {\n const tooltipStyle = this._option.getTooltipStyle();\n const shapeColumn = {\n ...tooltipStyle.shapeColumn,\n ...tooltipStyle.shapeColumn.items?.[index]\n };\n const keyColumn = {\n ...tooltipStyle.keyColumn,\n ...tooltipStyle.keyColumn.items?.[index]\n };\n return {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: shapeColumn.width,\n color: line.shapeColor,\n hollow: line.shapeHollow,\n marginTop: `calc((${keyColumn.lineHeight ?? keyColumn.fontSize ?? '18px'} - ${shapeColumn.width ?? '8px'}) / 2)`\n } as IShapeSvgOption;\n }\n}\n"]}
|
|
@@ -32,11 +32,11 @@ export class TitleModel extends BaseTooltipModel {
|
|
|
32
32
|
var _a, _b, _c;
|
|
33
33
|
const tooltipStyle = this._option.getTooltipStyle(), tooltipActual = this._option.getTooltipActual(), {title: title} = tooltipActual;
|
|
34
34
|
super.setStyle(merge({}, defaultH2Style, tooltipStyle.title, style)), null === (_a = this.shape) || void 0 === _a || _a.setStyle({
|
|
35
|
-
paddingRight: null === (_b = tooltipStyle.shapeColumn.
|
|
35
|
+
paddingRight: null === (_b = tooltipStyle.shapeColumn.common) || void 0 === _b ? void 0 : _b.marginRight
|
|
36
36
|
}, {
|
|
37
37
|
hasShape: null == title ? void 0 : title.hasShape,
|
|
38
38
|
shapeType: null == title ? void 0 : title.shapeType,
|
|
39
|
-
size: null === (_c = tooltipStyle.shapeColumn.
|
|
39
|
+
size: null === (_c = tooltipStyle.shapeColumn.common) || void 0 === _c ? void 0 : _c.width,
|
|
40
40
|
color: null == title ? void 0 : title.shapeColor,
|
|
41
41
|
hollow: null == title ? void 0 : title.shapeHollow
|
|
42
42
|
});
|
|
@@ -47,7 +47,7 @@ export class TitleModel extends BaseTooltipModel {
|
|
|
47
47
|
this.init(), null === (_a = this.shape) || void 0 === _a || _a.setStyle(void 0, {
|
|
48
48
|
hasShape: null == title ? void 0 : title.hasShape,
|
|
49
49
|
shapeType: null == title ? void 0 : title.shapeType,
|
|
50
|
-
size: null === (_b = tooltipStyle.shapeColumn.
|
|
50
|
+
size: null === (_b = tooltipStyle.shapeColumn.common) || void 0 === _b ? void 0 : _b.width,
|
|
51
51
|
color: null == title ? void 0 : title.shapeColor,
|
|
52
52
|
hollow: null == title ? void 0 : title.shapeHollow
|
|
53
53
|
}), null === (_c = this.textSpan) || void 0 === _c || _c.setContent(null == title ? void 0 : title.value, null === (_e = null === (_d = tooltipAttributes.title) || void 0 === _d ? void 0 : _d.value) || void 0 === _e ? void 0 : _e.multiLine);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/title-model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,OAAO,UAAW,SAAQ,gBAAgB;IAI9C,IAAI;QACF,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SACzC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAChC,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACf,IAAI,CAAC,UAAU,EAAE,CAAC;aACnB;SACF;aAAM,IAAI,IAAI,CAAC,KAAK,EAAE;YACrB,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;IACH,CAAC;IAEO,UAAU;QAChB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7D,KAAK,CAAC,IAAI,EAAE,C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E,WAAW;SAC3B,CACF,CAAC;IACJ,CAAC;IAED,UAAU;;QACR,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QACpD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;QAE9D,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,MAAA,IAAI,CAAC,KAAK,0CAAE,QAAQ,CAAC,SAAS,EAAE;YAC9B,QAAQ,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ;YACzB,SAAS,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS;YAC3B,IAAI,EAAE,MAAA,YAAY,CAAC,WAAW,CAAC,MAAM,0CAAE,KAAK;YAC5C,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU;YACxB,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW;SAC3B,CAAC,CAAC;QACH,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EAAE,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,KAAK,0CAAE,SAAS,CAAC,CAAC;IACrF,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF","file":"title-model.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { merge } from '@visactor/vutils';\nimport { defaultH2Style } from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\n\nexport class TitleModel extends BaseTooltipModel {\n shape: Maybe<ShapeModel>;\n textSpan: Maybe<TextModel>;\n\n init(): void {\n const tooltipActual = this._option.getTooltipActual();\n\n if (!this.product) {\n this.product = this.createElement('h2');\n }\n\n const { title } = tooltipActual;\n if (title?.hasShape && title?.shapeType) {\n if (!this.shape) {\n this._initShape();\n }\n } else if (this.shape) {\n this._releaseShape();\n }\n\n if (!this.textSpan) {\n this._initTextSpan();\n }\n }\n\n private _initShape() {\n const shape = new ShapeModel(this.product!, this._option, 0);\n shape.init();\n this.shape = shape;\n this.children[shape.childIndex] = shape;\n }\n\n private _releaseShape() {\n if (!this.shape) {\n return;\n }\n this.shape.release();\n delete this.children[this.shape.childIndex];\n this.shape = null;\n }\n\n private _initTextSpan() {\n const textSpan = new TextModel(this.product!, this._option, 1);\n textSpan.init();\n this.textSpan = textSpan;\n this.children[textSpan.childIndex] = textSpan;\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n\n const { title } = tooltipActual;\n super.setStyle(merge({}, defaultH2Style, tooltipStyle.title, style));\n\n this.shape?.setStyle(\n {\n paddingRight: tooltipStyle.shapeColumn.common?.marginRight\n },\n {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.common?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n }\n );\n }\n\n setContent(): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n const tooltipAttributes = this._option.getTooltipAttributes();\n\n const { title } = tooltipActual;\n this.init();\n this.shape?.setStyle(undefined, {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.common?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n });\n this.textSpan?.setContent(title?.value, tooltipAttributes.title?.value?.multiLine);\n }\n\n release(): void {\n super.release();\n this.shape = null;\n this.textSpan = null;\n }\n}\n"]}
|
|
@@ -5,8 +5,8 @@ const DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING
|
|
|
5
5
|
export const getPixelPropertyStr = (num, defaultStr) => isValid(num) ? isArray(num) ? num.map((n => `${n}px`)).join(" ") : `${num}px` : null != defaultStr ? defaultStr : "initial";
|
|
6
6
|
|
|
7
7
|
export function getDomStyles(style, attributeCache) {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
-
const {panel: {fill: fillColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth = 0}, padding: padding, key: key, value: value, title: title, shape: shape, enterable: enterable, spaceRow: spaceRow, transitionDuration: transitionDuration} = style, backgroundColor = fillColor, styles = {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9
|
+
const {panel: {fill: fillColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth = 0}, padding: padding, key: key, value: value, title: title, shape: shape, enterable: enterable, spaceRow: spaceRow, transitionDuration: transitionDuration} = style, backgroundColor = fillColor, shapeStyle = getShapeStyle(shape), keyStyle = getLabelStyle(key), valueStyle = getLabelStyle(value), styles = {
|
|
10
10
|
panel: {
|
|
11
11
|
width: getPixelPropertyStr((null !== (_b = null === (_a = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : 0) + 2 * lineWidth),
|
|
12
12
|
minHeight: getPixelPropertyStr((null !== (_d = null === (_c = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _c ? void 0 : _c.height) && void 0 !== _d ? _d : 0) + 2 * lineWidth),
|
|
@@ -24,31 +24,38 @@ export function getDomStyles(style, attributeCache) {
|
|
|
24
24
|
transitionProperty: transitionDuration ? "transform" : "initial",
|
|
25
25
|
transitionTimingFunction: transitionDuration ? "ease-out" : "initial"
|
|
26
26
|
},
|
|
27
|
-
title: getLabelStyle(title),
|
|
27
|
+
title: getLabelStyle(merge({}, title, null === (_e = null == attributeCache ? void 0 : attributeCache.title) || void 0 === _e ? void 0 : _e.value)),
|
|
28
28
|
content: {},
|
|
29
29
|
shapeColumn: {
|
|
30
|
-
|
|
30
|
+
common: shapeStyle,
|
|
31
|
+
items: [],
|
|
31
32
|
width: getPixelPropertyStr(shape.size),
|
|
32
|
-
marginRight: getPixelPropertyStr(null !== (
|
|
33
|
+
marginRight: getPixelPropertyStr(null !== (_f = shape.spacing) && void 0 !== _f ? _f : 8)
|
|
33
34
|
},
|
|
34
35
|
keyColumn: {
|
|
35
|
-
|
|
36
|
+
common: keyStyle,
|
|
37
|
+
items: null === (_g = null == attributeCache ? void 0 : attributeCache.content) || void 0 === _g ? void 0 : _g.map((({key: key}) => Object.assign(Object.assign(Object.assign({}, keyStyle), getLabelStyle(key)), (null == key ? void 0 : key.multiLine) ? {
|
|
38
|
+
width: getPixelPropertyStr(Math.ceil(key.width))
|
|
39
|
+
} : void 0))),
|
|
36
40
|
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.keyWidth),
|
|
37
|
-
marginRight: getPixelPropertyStr(null !== (
|
|
41
|
+
marginRight: getPixelPropertyStr(null !== (_h = key.spacing) && void 0 !== _h ? _h : 26)
|
|
38
42
|
},
|
|
39
43
|
valueColumn: {
|
|
40
|
-
|
|
44
|
+
common: valueStyle,
|
|
45
|
+
items: null === (_j = null == attributeCache ? void 0 : attributeCache.content) || void 0 === _j ? void 0 : _j.map((({value: value}) => Object.assign(Object.assign(Object.assign({}, valueStyle), getLabelStyle(value)), (null == value ? void 0 : value.multiLine) ? {
|
|
46
|
+
width: getPixelPropertyStr(Math.ceil(value.width))
|
|
47
|
+
} : void 0))),
|
|
41
48
|
width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.valueWidth),
|
|
42
|
-
marginRight: getPixelPropertyStr(null !== (
|
|
49
|
+
marginRight: getPixelPropertyStr(null !== (_k = value.spacing) && void 0 !== _k ? _k : 0)
|
|
43
50
|
},
|
|
44
51
|
spaceRow: getPixelPropertyStr(spaceRow)
|
|
45
52
|
};
|
|
46
53
|
if (isValid(spaceRow)) {
|
|
47
54
|
const gapUnit = spaceRow / 2;
|
|
48
|
-
[ styles.shapeColumn.
|
|
55
|
+
[ styles.shapeColumn.common, styles.keyColumn.common, styles.valueColumn.common ].forEach((obj => {
|
|
49
56
|
obj.marginTop = getPixelPropertyStr(gapUnit), obj.marginBottom = obj.marginTop;
|
|
50
57
|
})), styles.content.marginTop = getPixelPropertyStr(-gapUnit), styles.content.marginBottom = styles.content.marginTop;
|
|
51
|
-
} else [ styles.content, styles.shapeColumn.
|
|
58
|
+
} else [ styles.content, styles.shapeColumn.common, styles.keyColumn.common, styles.valueColumn.common ].forEach((obj => {
|
|
52
59
|
obj.marginTop = "initial", obj.marginBottom = "initial";
|
|
53
60
|
}));
|
|
54
61
|
return styles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YA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E,aAAa,EACvB,IAAI,EAAE,UAAU,EAChB,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACT,GAAG,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAsB,CAAC;IAC7D,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,QAAQ,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,GAAG,UAAoB,CAAC;IACtC,QAAQ,CAAC,SAAS,GAAG,SAAsB,CAAC;IAC5C,QAAQ,CAAC,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,GAAG,UAAwB,CAAC;IAC/C,QAAQ,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvD,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CACpB,UAAmC,EACnC,YAA8C;IAE9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"util.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport type { FontWeight, TextAlign } from '../../../../typings';\nimport { isValid, merge, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITooltipTextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, IMargin, IShapeStyle, IDomTooltipStyle } from './interface';\nimport type { TooltipAttributes } from '@visactor/vrender-components';\n\nconst DEFAULT_SHAPE_SPACING = 8;\nconst DEFAULT_KEY_SPACING = 26;\nconst DEFAULT_VALUE_SPACING = 0;\n\nexport const getPixelPropertyStr = (num?: number | number[], defaultStr?: string) => {\n if (isValid(num)) {\n if (isArray(num)) {\n return num.map(n => `${n}px`).join(' ');\n }\n return `${num}px`;\n }\n return defaultStr ?? 'initial';\n};\n\nexport function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel: {\n fill: fillColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth = 0\n },\n padding,\n key,\n value,\n title,\n shape,\n enterable,\n spaceRow,\n transitionDuration\n } = style;\n\n const backgroundColor = fillColor as string;\n\n const styles = {\n panel: {\n width: getPixelPropertyStr((attributeCache?.panel?.width ?? 0) + lineWidth * 2),\n minHeight: getPixelPropertyStr((attributeCache?.panel?.height ?? 0) + lineWidth * 2),\n paddingBottom: getPixelPropertyStr(padding.bottom),\n paddingLeft: getPixelPropertyStr(padding.left),\n paddingRight: getPixelPropertyStr(padding.right),\n paddingTop: getPixelPropertyStr(padding.top),\n borderColor: strokeColor,\n borderWidth: getPixelPropertyStr(lineWidth),\n borderRadius: getPixelPropertyStr(cornerRadius),\n backgroundColor: backgroundColor ? `${backgroundColor}` : 'transparent',\n boxShadow: shadow\n ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}`\n : 'initial',\n pointerEvents: enterable ? 'auto' : 'none',\n transitionDuration: transitionDuration ? `${transitionDuration}ms` : 'initial',\n transitionProperty: transitionDuration ? 'transform' : 'initial',\n transitionTimingFunction: transitionDuration ? 'ease-out' : 'initial'\n },\n title: getLabelStyle(title),\n content: {},\n shapeColumn: {\n item: getShapeStyle(shape),\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING)\n },\n keyColumn: {\n item: getLabelStyle(key),\n width: getPixelPropertyStr(attributeCache?.keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n item: getLabelStyle(value),\n width: getPixelPropertyStr(attributeCache?.valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\n },\n spaceRow: getPixelPropertyStr(spaceRow)\n } as IDomTooltipStyle;\n\n if (isValid(spaceRow)) {\n const gapUnit = spaceRow / 2;\n ([styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(obj => {\n obj.marginTop = getPixelPropertyStr(gapUnit);\n obj.marginBottom = obj.marginTop;\n });\n styles.content.marginTop = getPixelPropertyStr(-gapUnit);\n styles.content.marginBottom = styles.content.marginTop;\n } else {\n ([styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(\n obj => {\n obj.marginTop = 'initial';\n obj.marginBottom = 'initial';\n }\n );\n }\n return styles;\n}\n\nfunction getLabelStyle(\n labelStyle?: ITooltipTextStyle,\n defaultStyle?: Partial<ITooltipTextStyle>\n): ILabelStyle | undefined {\n if (!labelStyle) {\n return undefined;\n }\n const {\n fontFamily: labelFont,\n fontSize: labelFontSize,\n fill: labelColor,\n textAlign,\n lineHeight,\n fontWeight,\n multiLine,\n wordBreak,\n maxWidth\n } = merge({}, defaultStyle, labelStyle) as ITooltipTextStyle;\n const styleObj: ILabelStyle = {};\n\n styleObj.fontFamily = labelFont;\n styleObj.fontSize = getPixelPropertyStr(labelFontSize);\n styleObj.color = labelColor as string;\n styleObj.textAlign = textAlign as TextAlign;\n styleObj.lineHeight = getPixelPropertyStr(lineHeight);\n styleObj.fontWeight = fontWeight as FontWeight;\n styleObj.whiteSpace = multiLine ? 'initial' : 'nowrap';\n styleObj.wordBreak = wordBreak;\n styleObj.maxWidth = getPixelPropertyStr(maxWidth);\n return styleObj;\n}\n\nfunction getShapeStyle(\n shapeStyle?: ITooltipTheme['shape'],\n defaultStyle?: Partial<ITooltipTheme['shape']>\n): IShapeStyle | undefined {\n if (!shapeStyle) {\n return undefined;\n }\n const { size } = merge({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n return styleObj;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,GAAG,IAAI,CAAC;KACnB;IACD,OAAO,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,SAAS,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAoB,EAAE,cAAyC;;IAC1F,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,SAAS,EACf,MAAM,EACN,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,EAAE,WAAW,EACnB,SAAS,GAAG,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CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CACpB,UAAmC,EACnC,YAA8C;IAE9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"util.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport type { FontWeight, TextAlign } from '../../../../typings';\nimport { isValid, merge, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITooltipTextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, IMargin, IShapeStyle, IDomTooltipStyle } from './interface';\nimport type { TooltipAttributes } from '@visactor/vrender-components';\n\nconst DEFAULT_SHAPE_SPACING = 8;\nconst DEFAULT_KEY_SPACING = 26;\nconst DEFAULT_VALUE_SPACING = 0;\n\nexport const getPixelPropertyStr = (num?: number | number[], defaultStr?: string) => {\n if (isValid(num)) {\n if (isArray(num)) {\n return num.map(n => `${n}px`).join(' ');\n }\n return `${num}px`;\n }\n return defaultStr ?? 'initial';\n};\n\nexport function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel: {\n fill: fillColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth = 0\n },\n padding,\n key,\n value,\n title,\n shape,\n enterable,\n spaceRow,\n transitionDuration\n } = style;\n\n const backgroundColor = fillColor as string;\n\n const shapeStyle = getShapeStyle(shape);\n const keyStyle = getLabelStyle(key);\n const valueStyle = getLabelStyle(value);\n\n const styles = {\n panel: {\n width: getPixelPropertyStr((attributeCache?.panel?.width ?? 0) + lineWidth * 2),\n minHeight: getPixelPropertyStr((attributeCache?.panel?.height ?? 0) + lineWidth * 2),\n paddingBottom: getPixelPropertyStr(padding.bottom),\n paddingLeft: getPixelPropertyStr(padding.left),\n paddingRight: getPixelPropertyStr(padding.right),\n paddingTop: getPixelPropertyStr(padding.top),\n borderColor: strokeColor,\n borderWidth: getPixelPropertyStr(lineWidth),\n borderRadius: getPixelPropertyStr(cornerRadius),\n backgroundColor: backgroundColor ? `${backgroundColor}` : 'transparent',\n boxShadow: shadow\n ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}`\n : 'initial',\n pointerEvents: enterable ? 'auto' : 'none',\n transitionDuration: transitionDuration ? `${transitionDuration}ms` : 'initial',\n transitionProperty: transitionDuration ? 'transform' : 'initial',\n transitionTimingFunction: transitionDuration ? 'ease-out' : 'initial'\n },\n title: getLabelStyle(merge({}, title, attributeCache?.title?.value)),\n content: {},\n shapeColumn: {\n common: shapeStyle,\n items: [],\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING)\n },\n keyColumn: {\n common: keyStyle,\n items: attributeCache?.content?.map(({ key }) => ({\n ...keyStyle,\n ...getLabelStyle(key as ITooltipTextStyle),\n ...(key?.multiLine ? { width: getPixelPropertyStr(Math.ceil(key.width)) } : undefined) // 对多行文本使用定宽\n })),\n width: getPixelPropertyStr(attributeCache?.keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n common: valueStyle,\n items: attributeCache?.content?.map(({ value }) => ({\n ...valueStyle,\n ...getLabelStyle(value as ITooltipTextStyle),\n ...(value?.multiLine ? { width: getPixelPropertyStr(Math.ceil(value.width)) } : undefined) // 对多行文本使用定宽\n })),\n width: getPixelPropertyStr(attributeCache?.valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\n },\n spaceRow: getPixelPropertyStr(spaceRow)\n } as IDomTooltipStyle;\n\n if (isValid(spaceRow)) {\n const gapUnit = spaceRow / 2;\n ([styles.shapeColumn.common, styles.keyColumn.common, styles.valueColumn.common] as IMargin[]).forEach(obj => {\n obj.marginTop = getPixelPropertyStr(gapUnit);\n obj.marginBottom = obj.marginTop;\n });\n styles.content.marginTop = getPixelPropertyStr(-gapUnit);\n styles.content.marginBottom = styles.content.marginTop;\n } else {\n (\n [styles.content, styles.shapeColumn.common, styles.keyColumn.common, styles.valueColumn.common] as IMargin[]\n ).forEach(obj => {\n obj.marginTop = 'initial';\n obj.marginBottom = 'initial';\n });\n }\n return styles;\n}\n\nfunction getLabelStyle(\n labelStyle?: ITooltipTextStyle,\n defaultStyle?: Partial<ITooltipTextStyle>\n): ILabelStyle | undefined {\n if (!labelStyle) {\n return undefined;\n }\n const {\n fontFamily: labelFont,\n fontSize: labelFontSize,\n fill: labelColor,\n textAlign,\n lineHeight,\n fontWeight,\n multiLine,\n wordBreak,\n maxWidth\n } = merge({}, defaultStyle, labelStyle) as ITooltipTextStyle;\n const styleObj: ILabelStyle = {};\n\n styleObj.fontFamily = labelFont;\n styleObj.fontSize = getPixelPropertyStr(labelFontSize);\n styleObj.color = labelColor as string;\n styleObj.textAlign = textAlign as TextAlign;\n styleObj.lineHeight = getPixelPropertyStr(lineHeight);\n styleObj.fontWeight = fontWeight as FontWeight;\n styleObj.whiteSpace = multiLine ? 'initial' : 'nowrap';\n styleObj.wordBreak = wordBreak;\n styleObj.maxWidth = getPixelPropertyStr(maxWidth);\n return styleObj;\n}\n\nfunction getShapeStyle(\n shapeStyle?: ITooltipTheme['shape'],\n defaultStyle?: Partial<ITooltipTheme['shape']>\n): IShapeStyle | undefined {\n if (!shapeStyle) {\n return undefined;\n }\n const { size } = merge({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n return styleObj;\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { isValid } from "@visactor/vutils";
|
|
1
|
+
import { isValid, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { getRichTextBounds, initTextMeasure } from "../../../../util";
|
|
4
4
|
|
|
5
5
|
import { builtinSymbolsMap } from "@visactor/vrender";
|
|
6
6
|
|
|
7
|
+
import { getTextAttributes } from "./style";
|
|
8
|
+
|
|
7
9
|
export const getTooltipAttributes = (actualTooltip, style) => {
|
|
8
10
|
const {spaceRow: spaceRow, padding: padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle} = style, attribute = Object.assign(Object.assign({}, style), {
|
|
9
11
|
title: {},
|
|
@@ -27,16 +29,15 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
27
29
|
}));
|
|
28
30
|
const {title: title = {}, content: content = []} = actualTooltip;
|
|
29
31
|
let maxWidth = 0, containerHeight = padding.top + padding.bottom, titleMaxHeight = 0;
|
|
30
|
-
const {visible: titleVisible = !0, value: titleValue = "", hasShape: titleHasShape, shapeType: titleShapeType = "", shapeHollow: titleShapeHollow, shapeColor: titleShapeColor} = title;
|
|
32
|
+
const {visible: titleVisible = !0, value: titleValue = "", valueStyle: titleValueStyle, hasShape: titleHasShape, shapeType: titleShapeType = "", shapeHollow: titleShapeHollow, shapeColor: titleShapeColor} = title;
|
|
31
33
|
if (attribute.title.visible = titleVisible, titleVisible) {
|
|
32
|
-
const {text: text, width: width, height: height} = measureTooltipText(titleValue,
|
|
33
|
-
if (attribute.title.value = {
|
|
34
|
+
const lineTitleStyle = merge({}, titleStyle, getTextAttributes(titleValueStyle, void 0, {})), {text: text, width: width, height: height} = measureTooltipText(titleValue, lineTitleStyle);
|
|
35
|
+
if (attribute.title.value = Object.assign(Object.assign({
|
|
34
36
|
width: width,
|
|
35
|
-
height: height
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, maxWidth = width, titleMaxHeight = height, titleHasShape && builtinSymbolsMap[titleShapeType]) {
|
|
37
|
+
height: height
|
|
38
|
+
}, lineTitleStyle), {
|
|
39
|
+
text: text
|
|
40
|
+
}), maxWidth = width, titleMaxHeight = height, titleHasShape && builtinSymbolsMap[titleShapeType]) {
|
|
40
41
|
const titleShapeAttrs = {
|
|
41
42
|
symbolType: titleShapeType
|
|
42
43
|
};
|
|
@@ -60,24 +61,22 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
60
61
|
let itemHeight = 0;
|
|
61
62
|
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value, isKeyAdaptive: isKeyAdaptive} = item;
|
|
62
63
|
if (isValid(key)) {
|
|
63
|
-
const {width: width, height: height, text: text} = measureTooltipText(key,
|
|
64
|
-
itemAttrs.key = {
|
|
64
|
+
const lineKeyStyle = merge({}, keyStyle, getTextAttributes(item.keyStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(key, lineKeyStyle);
|
|
65
|
+
itemAttrs.key = Object.assign(Object.assign({
|
|
65
66
|
width: width,
|
|
66
|
-
height: height
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
67
|
+
height: height
|
|
68
|
+
}, lineKeyStyle), {
|
|
69
|
+
text: text
|
|
70
|
+
}), isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
71
71
|
}
|
|
72
72
|
if (isValid(value)) {
|
|
73
|
-
const {width: width, height: height, text: text} = measureTooltipText(value,
|
|
74
|
-
itemAttrs.value = {
|
|
73
|
+
const lineValueStyle = merge({}, valueStyle, getTextAttributes(item.valueStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(value, lineValueStyle);
|
|
74
|
+
itemAttrs.value = Object.assign(Object.assign({
|
|
75
75
|
width: width,
|
|
76
|
-
height: height
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
76
|
+
height: height
|
|
77
|
+
}, lineValueStyle), {
|
|
78
|
+
text: text
|
|
79
|
+
}), valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
81
80
|
}
|
|
82
81
|
if (hasShape && builtinSymbolsMap[shapeType]) {
|
|
83
82
|
hasContentShape = !0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,aAA6B,EAAE,KAAoB,EAAqB,EAAE;IAC7G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE5G,MAAM,SAAS,mCACV,KAAK,KAER,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAEX,UAAU,EAAE;YACV,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EACD,YAAY,EAAE;YACZ,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EAED,eAAe,EAAE,KAAK,EACtB,QAAQ,EAAE,CAAC,EACX,UAAU,EAAE,CAAC,GACd,CAAC;IACD,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACnE,O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,CAAC;YACT,UAAU,EAAE,SAAS,CAAC,GAAG,CACvB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CACV,CAAC,gCACI,KAAK,KACR,IAAI,EAAE,IAAI,GACgC,CAAA,CAC/C;SACF,CAAC,CAAC;QACH,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,SAAS;SAChB,CAAC;KACH;IAED,OAAO;QACL,KAAK;QACL,MAAM;QACN,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\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 attribute.title.value = {\n width,\n height,\n text,\n multiLine: titleStyle.multiLine,\n wordBreak: titleStyle.wordBreak\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 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 itemAttrs.key = {\n width,\n height,\n text,\n multiLine: keyStyle.multiLine,\n wordBreak: titleStyle.wordBreak\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, text } = measureTooltipText(value, valueStyle);\n itemAttrs.value = {\n width,\n height,\n text,\n multiLine: valueStyle.multiLine,\n wordBreak: titleStyle.wordBreak\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\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
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,aAA6B,EAAE,KAAoB,EAAqB,EAAE;IAC7G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE5G,MAAM,SAAS,mCACV,KAAK,KAER,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAEX,UAAU,EAAE;YACV,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EACD,YAAY,EAAE;YACZ,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,UAAU;YACjB,QAAQ;SACT,EAED,eAAe,EAAE,KAAK,EACtB,QAAQ,EAAE,CAAC,EACX,UAAU,EAAE,C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M,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAEzD,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,EAAE;QAE7C,MAAM,KAAK,GAAG,iBAAiB,CAAC;YAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,UAAU,EAAE,SAAS,CAAC,GAAG,CACvB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CACV,CAAC,gCACI,KAAK,KACR,IAAI,EAAE,IAAI,GACgC,CAAA,CAC/C;SACF,CAAC,CAAC;QACH,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,SAAS;SAChB,CAAC;KACH;IAED,OAAO;QACL,KAAK;QACL,MAAM;QACN,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\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, merge } 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';\nimport { getTextAttributes } from './style';\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 valueStyle: titleValueStyle,\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor\n } = title;\n attribute.title.visible = titleVisible;\n if (titleVisible) {\n const lineTitleStyle = merge({}, titleStyle, getTextAttributes(titleValueStyle, undefined, {}));\n const { text, width, height } = measureTooltipText(titleValue, lineTitleStyle);\n attribute.title.value = {\n width,\n height,\n ...lineTitleStyle,\n text\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 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 lineKeyStyle = merge({}, keyStyle, getTextAttributes(item.keyStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(key, lineKeyStyle);\n itemAttrs.key = {\n width,\n height,\n ...lineKeyStyle,\n text\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 lineValueStyle = merge({}, valueStyle, getTextAttributes(item.valueStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(value, lineValueStyle);\n itemAttrs.value = {\n width,\n height,\n ...lineValueStyle,\n text\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\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,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TooltipActualTitleContent } from '../../tooltip';
|
|
2
2
|
import type { IToolTipLinePattern, ITooltipPattern, TooltipData, IToolTipLineActual } from '../../../../typings/tooltip';
|
|
3
3
|
import type { TooltipHandlerParams } from '../../interface';
|
|
4
|
-
export declare const getShowContent: (pattern: ITooltipPattern, data: TooltipData, params: TooltipHandlerParams) =>
|
|
4
|
+
export declare const getShowContent: (pattern: ITooltipPattern, data: TooltipData, params: TooltipHandlerParams) => TooltipActualTitleContent | null;
|
|
5
5
|
export declare const getOneLineData: (datum: any, config: IToolTipLinePattern, params: TooltipHandlerParams) => IToolTipLineActual;
|
|
@@ -19,14 +19,13 @@ export const getShowContent = (pattern, data, params) => {
|
|
|
19
19
|
content: []
|
|
20
20
|
}, {maxLineCount: maxLineCount = TOOLTIP_MAX_LINE_COUNT} = pattern, patternTitleVisible = !1 !== getTooltipContentValue(null == patternTitle ? void 0 : patternTitle.visible, data, params);
|
|
21
21
|
if (patternTitle && patternTitleVisible) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
const datum = getFirstDatumFromTooltipData(data);
|
|
23
|
+
tooltipContent.title = {
|
|
24
|
+
value: getTooltipContentValue(null == patternTitle ? void 0 : patternTitle.value, datum, params),
|
|
25
|
+
valueStyle: getTooltipContentValue(null == patternTitle ? void 0 : patternTitle.valueStyle, datum, params),
|
|
26
|
+
hasShape: patternTitle.hasShape,
|
|
27
|
+
shapeHollow: patternTitle.shapeHollow
|
|
28
|
+
};
|
|
30
29
|
} else tooltipContent.title = {
|
|
31
30
|
hasShape: !1,
|
|
32
31
|
visible: !1
|
|
@@ -69,7 +68,7 @@ export const getShowContent = (pattern, data, params) => {
|
|
|
69
68
|
};
|
|
70
69
|
|
|
71
70
|
export const getOneLineData = (datum, config, params) => {
|
|
72
|
-
const key = getTooltipContentValue(config.key, datum, params), value = getTooltipContentValue(config.value, datum, params), visible = !1 !== getTooltipContentValue(config.visible, datum, params) && (isValid(key) || isValid(value)), isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params), shapeType = getTooltipContentValue(config.shapeType, datum, params), shapeColor = getTooltipContentValue(config.shapeColor, datum, params);
|
|
71
|
+
const key = getTooltipContentValue(config.key, datum, params), value = getTooltipContentValue(config.value, datum, params), visible = !1 !== getTooltipContentValue(config.visible, datum, params) && (isValid(key) || isValid(value)), isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params), shapeType = getTooltipContentValue(config.shapeType, datum, params), shapeColor = getTooltipContentValue(config.shapeColor, datum, params), keyStyle = getTooltipContentValue(config.keyStyle, datum, params), valueStyle = getTooltipContentValue(config.valueStyle, datum, params);
|
|
73
72
|
return {
|
|
74
73
|
key: key,
|
|
75
74
|
value: value,
|
|
@@ -78,7 +77,9 @@ export const getOneLineData = (datum, config, params) => {
|
|
|
78
77
|
hasShape: config.hasShape,
|
|
79
78
|
shapeType: shapeType,
|
|
80
79
|
shapeHollow: config.shapeHollow,
|
|
81
|
-
shapeColor: shapeColor
|
|
80
|
+
shapeColor: shapeColor,
|
|
81
|
+
keyStyle: keyStyle,
|
|
82
|
+
valueStyle: valueStyle
|
|
82
83
|
};
|
|
83
84
|
};
|
|
84
85
|
//# sourceMappingURL=compose.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQzD,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACxG,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAS3E,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAwB,EACxB,IAAiB,EACjB,MAA4B,EACL,EAAE;;IACzB,IACE,CAAC,IAAI;QAEL,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,IAAI,MAAK,UAAU,EAClC;QACA,OAAO,IAAI,CAAC;KACb;IAED,MAAM,YAAY,GAAG,sBAAsB,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI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CAAC,MAAM,cAAc,GAAG,CAC5B,KAAU,EACV,MAA2B,EAC3B,MAA4B,EACR,EAAE;IACtB,MAAM,GAAG,GAAG,sBAAsB,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClE,MAAM,OAAO,GACX,sBAAsB,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACtG,MAAM,aAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,sBAAsB,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5E,OAAO;QACL,GAAG;QACH,KAAK;QACL,OAAO;QACP,aAAa;QACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,SAAgB;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC,CAAC","file":"compose.js","sourcesContent":["import { isValid, isNil, array } from '../../../../util';\nimport type { TooltipContent } from '../../tooltip';\nimport type {\n IToolTipLinePattern,\n ITooltipPattern,\n TooltipData,\n IToolTipLineActual\n} from '../../../../typings/tooltip';\nimport { getFirstDatumFromTooltipData, getTooltipContentValue, getTooltipPatternValue } from './common';\nimport { getTooltipActualActiveType } from '../../utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension/interface';\nimport type { TooltipHandlerParams } from '../../interface';\nimport { TOOLTIP_MAX_LINE_COUNT, TOOLTIP_OTHERS_LINE } from '../constants';\n\n/**\n * 获得tooltip的实际显示内容\n * @param pattern\n * @param data\n * @param event\n * @returns\n */\nexport const getShowContent = (\n pattern: ITooltipPattern,\n data: TooltipData,\n params: TooltipHandlerParams\n): TooltipContent | null => {\n if (\n !data ||\n // data.key === undefined ||\n params?.event?.type === 'mouseout'\n ) {\n return null;\n }\n\n const patternTitle = getTooltipPatternValue(pattern.title, data, params);\n const patternContent = array(getTooltipPatternValue(pattern.content, data, params));\n\n const tooltipContent: Required<TooltipContent> = {\n title: {\n value: patternTitle?.value?.toString(),\n hasShape: false,\n shapeType: undefined,\n shapeHollow: undefined\n },\n content: []\n };\n\n const { maxLineCount = TOOLTIP_MAX_LINE_COUNT } = pattern;\n\n /** title */\n const patternTitleVisible = getTooltipContentValue(patternTitle?.visible, data, params) !== false;\n if (!patternTitle || !patternTitleVisible) {\n tooltipContent.title = {\n hasShape: false,\n visible: false\n };\n } else {\n tooltipContent.title.hasShape = patternTitle.hasShape;\n if (isValid(patternTitle.value)) {\n tooltipContent.title = {\n hasShape: patternTitle.hasShape,\n shapeHollow: patternTitle.shapeHollow\n };\n // 找到第一个可用的datum\n const datum = getFirstDatumFromTooltipData(data);\n tooltipContent.title.value = getTooltipContentValue(patternTitle?.value, datum, params);\n }\n }\n\n /** content */\n if (pattern.activeType === 'mark') {\n for (const content of patternContent ?? []) {\n const oneLineData = getOneLineData((data as IDimensionData[])[0]?.datum[0], content, params);\n if (oneLineData.visible !== false) {\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n }\n } else if (pattern.activeType === 'dimension') {\n for (const { data: d } of data as IDimensionInfo[]) {\n for (const { datum, series } of d) {\n if (!getTooltipActualActiveType(series.tooltipHelper?.spec).includes('dimension')) {\n continue;\n }\n const contentPatterns =\n patternContent?.filter(\n c => isNil(c.seriesId) || c.seriesId === series.id // 匹配对应series\n ) ?? [];\n for (const datumItem of datum) {\n for (const linePattern of contentPatterns) {\n const oneLineData = getOneLineData(datumItem, linePattern, params);\n if (oneLineData.visible === false) {\n continue;\n }\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n }\n\n if (tooltipContent.title) {\n // TODO:对 title shape 的支持目前还不完整,尚没有相关需求\n if (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType) {\n if (isNil(tooltipContent.title.shapeType)) {\n tooltipContent.title.shapeType = tooltipContent.content[0].shapeType;\n }\n if (isNil(tooltipContent.title.shapeColor)) {\n tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor;\n }\n } else {\n tooltipContent.title.hasShape = false;\n }\n }\n\n return tooltipContent;\n};\n\n/**\n * 获得tooltip的单行实际显示内容\n * @param datum\n * @param config\n * @returns\n */\nexport const getOneLineData = (\n datum: any,\n config: IToolTipLinePattern,\n params: TooltipHandlerParams\n): IToolTipLineActual => {\n const key = getTooltipContentValue(config.key, datum, params);\n const value = getTooltipContentValue(config.value, datum, params);\n const visible: boolean =\n getTooltipContentValue(config.visible, datum, params) !== false && (isValid(key) || isValid(value));\n const isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params);\n\n const shapeType = getTooltipContentValue(config.shapeType, datum, params);\n const shapeColor = getTooltipContentValue(config.shapeColor, datum, params);\n\n return {\n key,\n value,\n visible,\n isKeyAdaptive,\n hasShape: config.hasShape,\n shapeType: shapeType as any,\n shapeH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,EAAE,MAAM,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,sBAAsB,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5E,OAAO;QACL,GAAG;QACH,KAAK;QACL,OAAO;QACP,aAAa;QACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,SAAgB;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU;QACV,QAAQ;QACR,UAAU;KACX,CAAC;AACJ,CAAC,CAAC","file":"compose.js","sourcesContent":["import { isValid, isNil, array } from '../../../../util';\nimport type { TooltipActualTitleContent } from '../../tooltip';\nimport type {\n IToolTipLinePattern,\n ITooltipPattern,\n TooltipData,\n IToolTipLineActual\n} from '../../../../typings/tooltip';\nimport { getFirstDatumFromTooltipData, getTooltipContentValue, getTooltipPatternValue } from './common';\nimport { getTooltipActualActiveType } from '../../utils';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension/interface';\nimport type { TooltipHandlerParams } from '../../interface';\nimport { TOOLTIP_MAX_LINE_COUNT, TOOLTIP_OTHERS_LINE } from '../constants';\n\n/**\n * 获得tooltip的实际显示内容\n * @param pattern\n * @param data\n * @param event\n * @returns\n */\nexport const getShowContent = (\n pattern: ITooltipPattern,\n data: TooltipData,\n params: TooltipHandlerParams\n): TooltipActualTitleContent | null => {\n if (\n !data ||\n // data.key === undefined ||\n params?.event?.type === 'mouseout'\n ) {\n return null;\n }\n\n const patternTitle = getTooltipPatternValue(pattern.title, data, params);\n const patternContent = array(getTooltipPatternValue(pattern.content, data, params));\n\n const tooltipContent: Required<TooltipActualTitleContent> = {\n title: {\n value: patternTitle?.value?.toString(),\n hasShape: false,\n shapeType: undefined,\n shapeHollow: undefined\n },\n content: []\n };\n\n const { maxLineCount = TOOLTIP_MAX_LINE_COUNT } = pattern;\n\n /** title */\n const patternTitleVisible = getTooltipContentValue(patternTitle?.visible, data, params) !== false;\n if (!patternTitle || !patternTitleVisible) {\n tooltipContent.title = {\n hasShape: false,\n visible: false\n };\n } else {\n // 找到第一个可用的datum\n const datum = getFirstDatumFromTooltipData(data);\n tooltipContent.title = {\n value: getTooltipContentValue(patternTitle?.value, datum, params),\n valueStyle: getTooltipContentValue(patternTitle?.valueStyle, datum, params),\n hasShape: patternTitle.hasShape,\n shapeHollow: patternTitle.shapeHollow\n };\n }\n\n /** content */\n if (pattern.activeType === 'mark') {\n for (const content of patternContent ?? []) {\n const oneLineData = getOneLineData((data as IDimensionData[])[0]?.datum[0], content, params);\n if (oneLineData.visible !== false) {\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n }\n } else if (pattern.activeType === 'dimension') {\n for (const { data: d } of data as IDimensionInfo[]) {\n for (const { datum, series } of d) {\n if (!getTooltipActualActiveType(series.tooltipHelper?.spec).includes('dimension')) {\n continue;\n }\n const contentPatterns =\n patternContent?.filter(\n c => isNil(c.seriesId) || c.seriesId === series.id // 匹配对应series\n ) ?? [];\n for (const datumItem of datum) {\n for (const linePattern of contentPatterns) {\n const oneLineData = getOneLineData(datumItem, linePattern, params);\n if (oneLineData.visible === false) {\n continue;\n }\n if (tooltipContent.content.length === maxLineCount - 1) {\n tooltipContent.content.push({\n ...oneLineData,\n ...TOOLTIP_OTHERS_LINE\n });\n break;\n } else if (tooltipContent.content.length < maxLineCount) {\n tooltipContent.content.push(oneLineData);\n } else {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n if (tooltipContent.content.length >= maxLineCount) {\n break;\n }\n }\n }\n\n if (tooltipContent.title) {\n // TODO:对 title shape 的支持目前还不完整,尚没有相关需求\n if (tooltipContent.content.length > 0 && tooltipContent.content[0].shapeType) {\n if (isNil(tooltipContent.title.shapeType)) {\n tooltipContent.title.shapeType = tooltipContent.content[0].shapeType;\n }\n if (isNil(tooltipContent.title.shapeColor)) {\n tooltipContent.title.shapeColor = tooltipContent.content[0].shapeColor;\n }\n } else {\n tooltipContent.title.hasShape = false;\n }\n }\n\n return tooltipContent;\n};\n\n/**\n * 获得tooltip的单行实际显示内容\n * @param datum\n * @param config\n * @returns\n */\nexport const getOneLineData = (\n datum: any,\n config: IToolTipLinePattern,\n params: TooltipHandlerParams\n): IToolTipLineActual => {\n const key = getTooltipContentValue(config.key, datum, params);\n const value = getTooltipContentValue(config.value, datum, params);\n const visible: boolean =\n getTooltipContentValue(config.visible, datum, params) !== false && (isValid(key) || isValid(value));\n const isKeyAdaptive = getTooltipContentValue(config.isKeyAdaptive, datum, params);\n\n const shapeType = getTooltipContentValue(config.shapeType, datum, params);\n const shapeColor = getTooltipContentValue(config.shapeColor, datum, params);\n const keyStyle = getTooltipContentValue(config.keyStyle, datum, params);\n const valueStyle = getTooltipContentValue(config.valueStyle, datum, params);\n\n return {\n key,\n value,\n visible,\n isKeyAdaptive,\n hasShape: config.hasShape,\n shapeType: shapeType as any,\n shapeHollow: config.shapeHollow,\n shapeColor,\n keyStyle,\n valueStyle\n };\n};\n"]}
|