@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/content-column-model.ts"],"names":[],"mappings":"A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AM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QAEpD,QAAQ,IAAI,CAAC,SAAS,EAAE;YACtB,KAAK,WAAW;gBACd,MAAM,aAAa,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,0CAAE,OAAO,mCAAI,EAAE,CAAC;gBACrE,uCACK,YAAY,CAAC,WAAW,GACxB,CAAC,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC;oBACvF,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;oBACrB,CAAC,CAAC,EAAE,CAAC,EACP;YACJ,KAAK,SAAS;gBACZ,OAAO,YAAY,CAAC,SAAS,CAAC;YAChC,KAAK,WAAW;gBACd,OAAO,YAAY,CAAC,WAAW,CAAC;SACnC;IACH,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';\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 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: `${100 / renderContent.length}%`,\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: `${100 / renderContent.length}%`,\n ...tooltipStyle.valueColumn.item\n });\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'shape-box') {\n childStyle = merge({}, defaultShapeStyle, tooltipStyle.shapeColumn.item);\n const childContent = {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow\n } as IShapeSvgOption;\n (this.children[i] as ShapeModel)?.setStyle(childStyle, childContent);\n }\n });\n }\n\n setContent(): void {\n const tooltipStyle = this._option.getTooltipStyle();\n\n const renderContent = this._option.getTooltipActual()?.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 } 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 } else if (this.className === 'shape-box') {\n childContent = {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow\n } as IShapeSvgOption;\n }\n this.children[i]?.setContent(childContent);\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"]}
|
|
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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CAAI,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 // FIXME: vrender 发版后去掉 any\n (this.children[i] as TextModel)?.setContent(childContent, (contentAttributes[i].value as any)?.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 // FIXME: vrender 发版后去掉 any\n (this.children[i] as TextModel)?.setContent(childContent, (contentAttributes[i].value as any)?.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,7 +1,9 @@
|
|
|
1
|
+
import type { TooltipAttributes } from '@visactor/vrender-components';
|
|
1
2
|
import type { IToolTipActual } from '../../../../../typings';
|
|
2
3
|
import type { IDomTooltipStyle } from '../interface';
|
|
3
4
|
export interface ITooltipModelOption {
|
|
4
5
|
valueToHtml: (value: any) => string;
|
|
5
6
|
getTooltipStyle: () => IDomTooltipStyle;
|
|
6
7
|
getTooltipActual: () => IToolTipActual;
|
|
8
|
+
getTooltipAttributes: () => TooltipAttributes;
|
|
7
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IToolTipActual } from '../../../../../typings';\nimport type { IDomTooltipStyle } from '../interface';\n\nexport interface ITooltipModelOption {\n valueToHtml: (value: any) => string;\n getTooltipStyle: () => IDomTooltipStyle;\n getTooltipActual: () => IToolTipActual;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { TooltipAttributes } from '@visactor/vrender-components';\nimport type { IToolTipActual } from '../../../../../typings';\nimport type { IDomTooltipStyle } from '../interface';\n\nexport interface ITooltipModelOption {\n valueToHtml: (value: any) => string;\n getTooltipStyle: () => IDomTooltipStyle;\n getTooltipActual: () => IToolTipActual;\n getTooltipAttributes: () => TooltipAttributes;\n}\n"]}
|
|
@@ -29,15 +29,15 @@ export class ShapeModel extends BaseTooltipModel {
|
|
|
29
29
|
function getSvgHtml(option) {
|
|
30
30
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
31
31
|
if (!(null == option ? void 0 : option.hasShape) || !option.shapeType || !builtinSymbolsMap[option.shapeType]) return "";
|
|
32
|
-
const {shapeType: shapeType, size: size, color: color, hollow: hollow = !1} = option, path = builtinSymbolsMap[shapeType].pathStr;
|
|
32
|
+
const {shapeType: shapeType, size: size, color: color, hollow: hollow = !1, marginTop: marginTop = "0px"} = option, path = builtinSymbolsMap[shapeType].pathStr;
|
|
33
33
|
let fill = "currentColor";
|
|
34
34
|
if (!color || isString(color) || hollow) return fill = hollow ? "none" : null !== (_a = color) && void 0 !== _a ? _a : "currentColor",
|
|
35
|
-
`\n <svg width="${size}"
|
|
35
|
+
`\n <svg width="${size}" height="${size}" viewBox="-0.5 -0.5 1 1"\n style="display: inline-block; vertical-align: middle; margin-top: ${marginTop};">\n <path fill="${fill}" d="${path}" style="fill: ${fill};">\n </path>\n </svg>`;
|
|
36
36
|
if (isObject(color)) {
|
|
37
37
|
fill = "gradientColor";
|
|
38
38
|
let gradient = "";
|
|
39
39
|
return "radial" === color.gradient ? gradient = `\n <radialGradient id="${fill}" cx="50%" cy="50%" r="50%" fx="0%" fy="0%">\n ${(null !== (_b = color.stops) && void 0 !== _b ? _b : []).map((s => `<stop offset="${s.offset}" stop-color="${s.color}"/>`))}\n \t</radialGradient>\n ` : "linear" === color.gradient && (gradient = `\n <linearGradient id="${fill}" x1="${100 * (null !== (_c = color.x0) && void 0 !== _c ? _c : 0)}%" y1="${100 * (null !== (_d = color.y0) && void 0 !== _d ? _d : 0)}%" x2="${100 * (null !== (_e = color.x1) && void 0 !== _e ? _e : 0)}%" y2="${100 * (null !== (_f = color.y1) && void 0 !== _f ? _f : 0)}%">\n ${(null !== (_g = color.stops) && void 0 !== _g ? _g : []).map((s => `<stop offset="${s.offset}" stop-color="${s.color}"/>`))}\n </linearGradient>\n `),
|
|
40
|
-
`\n <svg width="${size}" height="${size}"
|
|
40
|
+
`\n <svg width="${size}" height="${size}" viewBox="-0.5 -0.5 1 1"\n style="display: inline-block; vertical-align: middle; margin-top: ${marginTop};">\n ${gradient}\n <path fill="url(#${fill})" d="${path}" style="fill: url(#${fill});">\n </path>\n </svg>`;
|
|
41
41
|
}
|
|
42
42
|
return "";
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/shape-model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/shape-model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,O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CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GAAG,UAC9D,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GACrD;UACI,CAAC,MAAC,KAAyB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,MAAM,iBAAiB,CAAC,CAAC,KAAK,KAAK,CAAC;;OAE5G,CAAC;SACH;QACD,OAAO;kBACO,IAAI,aAAa,IAAI;0EACmC,SAAS;QAC3E,QAAQ;yBACS,IAAI,SAAS,IAAI,uBAAuB,IAAI;;WAE1D,CAAC;KACT;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","file":"shape-model.js","sourcesContent":["import type { IGradientColor, ILinearGradient } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nimport { isObject, isString } from '../../../../../util';\nimport type { ShapeType } from '../../../../../typings';\nimport { BaseTooltipModel } from './base-tooltip-model';\n\nexport interface IShapeSvgOption {\n hasShape?: boolean;\n shapeType?: ShapeType;\n size?: string;\n color?: string | IGradientColor;\n hollow?: boolean;\n marginTop?: string;\n}\n\nexport class ShapeModel extends BaseTooltipModel {\n svg: SVGElement;\n\n private _svgHtmlCache: string;\n\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n const container = this.createElement(tag ?? 'div', [...(classList ?? []), 'shape'], undefined, id);\n this.product = container;\n }\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>, option?: IShapeSvgOption): void {\n super.setStyle(style);\n this.setSvg(option);\n }\n\n setContent(option: IShapeSvgOption) {\n this.setSvg(option);\n }\n\n setSvg(option?: IShapeSvgOption) {\n const html = getSvgHtml(option);\n if (this.product && html !== this._svgHtmlCache) {\n this._svgHtmlCache = html;\n this.product.innerHTML = html;\n }\n }\n\n release(): void {\n super.release();\n this._svgHtmlCache = '';\n }\n}\n\nfunction getSvgHtml(option?: IShapeSvgOption) {\n if (!option?.hasShape || !option.shapeType || !builtinSymbolsMap[option.shapeType]) {\n return '';\n }\n\n const { shapeType, size, color, hollow = false, marginTop = '0px' } = option;\n\n // FIXME 通过 VRender 获取symbol path\n const path = builtinSymbolsMap[shapeType].pathStr;\n let fill: string = 'currentColor';\n if (!color || isString(color) || hollow) {\n fill = hollow ? 'none' : (color as string) ?? 'currentColor';\n return `\n <svg width=\"${size}\" height=\"${size}\" viewBox=\"-0.5 -0.5 1 1\"\n style=\"display: inline-block; vertical-align: middle; margin-top: ${marginTop};\">\n <path fill=\"${fill}\" d=\"${path}\" style=\"fill: ${fill};\">\n </path>\n </svg>`;\n }\n if (isObject(color)) {\n fill = 'gradientColor';\n let gradient = '';\n if ((color as IGradientColor).gradient === 'radial') {\n gradient = `\n <radialGradient id=\"${fill}\" cx=\"50%\" cy=\"50%\" r=\"50%\" fx=\"0%\" fy=\"0%\">\n ${(((color as IGradientColor).stops as any[]) ?? []).map(\n s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`\n )}\n \t</radialGradient>\n `;\n } else if ((color as IGradientColor).gradient === 'linear') {\n gradient = `\n <linearGradient id=\"${fill}\" x1=\"${(((color as ILinearGradient).x0 as number) ?? 0) * 100}%\" y1=\"${\n (((color as ILinearGradient).y0 as number) ?? 0) * 100\n }%\" x2=\"${(((color as ILinearGradient).x1 as number) ?? 0) * 100}%\" y2=\"${\n (((color as ILinearGradient).y1 as number) ?? 0) * 100\n }%\">\n ${((color as ILinearGradient).stops ?? []).map(s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`)}\n </linearGradient>\n `;\n }\n return `\n <svg width=\"${size}\" height=\"${size}\" viewBox=\"-0.5 -0.5 1 1\"\n style=\"display: inline-block; vertical-align: middle; margin-top: ${marginTop};\">\n ${gradient}\n <path fill=\"url(#${fill})\" d=\"${path}\" style=\"fill: url(#${fill});\">\n </path>\n </svg>`;\n }\n\n return '';\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseTooltipModel } from './base-tooltip-model';
|
|
2
2
|
export declare class TextModel extends BaseTooltipModel {
|
|
3
3
|
init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void;
|
|
4
|
-
setContent(content?: any): void;
|
|
4
|
+
setContent(content?: any, multiLine?: boolean): void;
|
|
5
5
|
}
|
|
@@ -4,9 +4,10 @@ export class TextModel extends BaseTooltipModel {
|
|
|
4
4
|
init(classList, id, tag) {
|
|
5
5
|
this.product || (this.product = this.createElement(null != tag ? tag : "span", classList, void 0, id));
|
|
6
6
|
}
|
|
7
|
-
setContent(content) {
|
|
7
|
+
setContent(content, multiLine) {
|
|
8
8
|
if (!this.product) return;
|
|
9
|
-
|
|
9
|
+
let html = this._option.valueToHtml(content);
|
|
10
|
+
multiLine && (html = html.replaceAll("\n", "<br>")), html !== this.product.innerHTML && (this.product.innerHTML = html);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=text-model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/text-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;SAC5E;IACH,CAAC;IAED,UAAU,CAAC,OAAa;
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/dom/model/text-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,OAAO,SAAU,SAAQ,gBAAgB;IAC7C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;SAC5E;IACH,CAAC;IAED,UAAU,CAAC,OAAa,EAAE,SAAmB;QAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO;SACR;QACD,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,SAAS,EAAE;YACb,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SACtC;QACD,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;SAC/B;IACH,CAAC;CACF","file":"text-model.js","sourcesContent":["import { BaseTooltipModel } from './base-tooltip-model';\n\nexport class TextModel extends BaseTooltipModel {\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n this.product = this.createElement(tag ?? 'span', classList, undefined, id);\n }\n }\n\n setContent(content?: any, multiLine?: boolean): void {\n if (!this.product) {\n return;\n }\n let html = this._option.valueToHtml(content);\n if (multiLine) {\n html = html.replaceAll('\\n', '<br>');\n }\n if (html !== this.product.innerHTML) {\n this.product.innerHTML = html;\n }\n }\n}\n"]}
|
|
@@ -42,15 +42,15 @@ export class TitleModel extends BaseTooltipModel {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
setContent() {
|
|
45
|
-
var _a, _b, _c;
|
|
46
|
-
const tooltipStyle = this._option.getTooltipStyle(), tooltipActual = this._option.getTooltipActual(), {title: title} = tooltipActual;
|
|
45
|
+
var _a, _b, _c, _d, _e;
|
|
46
|
+
const tooltipStyle = this._option.getTooltipStyle(), tooltipActual = this._option.getTooltipActual(), tooltipAttributes = this._option.getTooltipAttributes(), {title: title} = tooltipActual;
|
|
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
50
|
size: null === (_b = tooltipStyle.shapeColumn.item) || 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
|
-
}), null === (_c = this.textSpan) || void 0 === _c || _c.setContent(null == title ? void 0 : title.value);
|
|
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);
|
|
54
54
|
}
|
|
55
55
|
release() {
|
|
56
56
|
super.release(), this.shape = null, this.textSpan = null;
|
|
@@ -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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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,IAAI,0CAAE,KAAK;YAC1C,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU;YACxB,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW;SAC3B,CAAC,CAAC;QAEH,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EAAE,MAAC,MAAA,iBAAiB,CAAC,KAAK,0CAAE,KAAa,0CAAE,SAAS,CAAC,CAAC;IAC9F,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.item?.marginRight\n },\n {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.item?.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.item?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n });\n // FIXME: vrender 发版后去掉 any\n this.textSpan?.setContent(title?.value, (tooltipAttributes.title?.value as any)?.multiLine);\n }\n\n release(): void {\n super.release();\n this.shape = null;\n this.textSpan = null;\n }\n}\n"]}
|
|
@@ -2,4 +2,5 @@ import type { Maybe } from '@visactor/vutils';
|
|
|
2
2
|
import type { ITooltipStyle } from '../interface';
|
|
3
3
|
import type { IDomTooltipStyle } from './interface';
|
|
4
4
|
import type { TooltipAttributes } from '@visactor/vrender-components';
|
|
5
|
+
export declare const getPixelPropertyStr: (num?: number | number[], defaultStr?: string) => string;
|
|
5
6
|
export declare function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isValid, merge, isArray } from "../../../../util";
|
|
2
2
|
|
|
3
|
-
const DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0
|
|
3
|
+
const DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0;
|
|
4
|
+
|
|
5
|
+
export const getPixelPropertyStr = (num, defaultStr) => isValid(num) ? isArray(num) ? num.map((n => `${n}px`)).join(" ") : `${num}px` : null != defaultStr ? defaultStr : "initial";
|
|
4
6
|
|
|
5
7
|
export function getDomStyles(style, attributeCache) {
|
|
6
8
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7
|
-
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,
|
|
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
10
|
panel: {
|
|
9
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),
|
|
10
12
|
height: 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),
|
|
@@ -17,8 +19,6 @@ export function getDomStyles(style, attributeCache) {
|
|
|
17
19
|
borderRadius: getPixelPropertyStr(cornerRadius),
|
|
18
20
|
backgroundColor: backgroundColor ? `${backgroundColor}` : "transparent",
|
|
19
21
|
boxShadow: shadow ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}` : "initial",
|
|
20
|
-
maxWidth: getPixelPropertyStr(maxWidth),
|
|
21
|
-
minWidth: getPixelPropertyStr(minWidth),
|
|
22
22
|
pointerEvents: enterable ? "auto" : "none",
|
|
23
23
|
transitionDuration: transitionDuration ? `${transitionDuration}ms` : "initial",
|
|
24
24
|
transitionProperty: transitionDuration ? "transform" : "initial",
|
|
@@ -56,16 +56,17 @@ export function getDomStyles(style, attributeCache) {
|
|
|
56
56
|
|
|
57
57
|
function getLabelStyle(labelStyle, defaultStyle) {
|
|
58
58
|
if (!labelStyle) return;
|
|
59
|
-
const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight} = merge({}, defaultStyle, labelStyle), styleObj = {};
|
|
59
|
+
const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight, multiLine: multiLine, wordBreak: wordBreak, maxWidth: maxWidth} = merge({}, defaultStyle, labelStyle), styleObj = {};
|
|
60
60
|
return styleObj.fontFamily = labelFont, styleObj.fontSize = getPixelPropertyStr(labelFontSize),
|
|
61
61
|
styleObj.color = labelColor, styleObj.textAlign = textAlign, styleObj.lineHeight = getPixelPropertyStr(lineHeight),
|
|
62
|
-
styleObj.fontWeight = fontWeight, styleObj
|
|
62
|
+
styleObj.fontWeight = fontWeight, styleObj.whiteSpace = multiLine ? "initial" : "nowrap",
|
|
63
|
+
styleObj.wordBreak = wordBreak, styleObj.maxWidth = getPixelPropertyStr(maxWidth),
|
|
64
|
+
styleObj;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
function getShapeStyle(shapeStyle, defaultStyle) {
|
|
66
68
|
if (!shapeStyle) return;
|
|
67
69
|
const {size: size} = merge({}, defaultStyle, shapeStyle), styleObj = {};
|
|
68
|
-
return styleObj.width = getPixelPropertyStr(size), styleObj
|
|
69
|
-
styleObj;
|
|
70
|
+
return styleObj.width = getPixelPropertyStr(size), styleObj;
|
|
70
71
|
}
|
|
71
72
|
//# sourceMappingURL=util.js.map
|
|
@@ -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,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;
|
|
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,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3C,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 height: 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,25 +1,26 @@
|
|
|
1
|
-
import type { ITextAttribute, IFillStyle, IRectGraphicAttribute } from '@visactor/vrender';
|
|
1
|
+
import type { ITextAttribute, IFillStyle, IRectGraphicAttribute, RichTextWordBreak } from '@visactor/vrender';
|
|
2
2
|
import type { IPadding } from '../../../../typings';
|
|
3
|
-
export interface
|
|
3
|
+
export interface ITooltipTextStyle extends Partial<ITextAttribute & IFillStyle> {
|
|
4
4
|
spacing: number;
|
|
5
|
+
multiLine: boolean;
|
|
6
|
+
maxWidth?: number;
|
|
7
|
+
wordBreak?: RichTextWordBreak;
|
|
5
8
|
}
|
|
6
|
-
export interface
|
|
9
|
+
export interface ITooltipPanelStyle extends Partial<IRectGraphicAttribute> {
|
|
7
10
|
shadow: boolean;
|
|
8
11
|
shadowSpread?: number;
|
|
9
12
|
}
|
|
10
13
|
export interface ITooltipStyle {
|
|
11
|
-
panel:
|
|
12
|
-
title:
|
|
14
|
+
panel: ITooltipPanelStyle;
|
|
15
|
+
title: ITooltipTextStyle;
|
|
13
16
|
shape: {
|
|
14
17
|
fill: boolean;
|
|
15
18
|
size: number;
|
|
16
19
|
spacing: number;
|
|
17
20
|
};
|
|
18
|
-
key:
|
|
19
|
-
value:
|
|
21
|
+
key: ITooltipTextStyle;
|
|
22
|
+
value: ITooltipTextStyle;
|
|
20
23
|
padding: IPadding;
|
|
21
|
-
minWidth: number;
|
|
22
|
-
maxWidth: number;
|
|
23
24
|
spaceRow: number;
|
|
24
25
|
enterable: boolean;
|
|
25
26
|
transitionDuration: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/interface/style.ts"],"names":[],"mappings":"","file":"style.js","sourcesContent":["import type { ITextAttribute, IFillStyle, IRectGraphicAttribute } from '@visactor/vrender';\nimport type { IPadding } from '../../../../typings';\n\nexport interface
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/interface/style.ts"],"names":[],"mappings":"","file":"style.js","sourcesContent":["import type { ITextAttribute, IFillStyle, IRectGraphicAttribute, RichTextWordBreak } from '@visactor/vrender';\nimport type { IPadding } from '../../../../typings';\n\nexport interface ITooltipTextStyle extends Partial<ITextAttribute & IFillStyle> {\n /** 和相邻元素的水平间距 */\n spacing: number;\n /** 是否支持换行 */\n multiLine: boolean;\n /** 文本元素的最大宽度 */\n maxWidth?: number;\n /** 换行模式 */\n wordBreak?: RichTextWordBreak;\n}\n\nexport interface ITooltipPanelStyle extends Partial<IRectGraphicAttribute> {\n shadow: boolean;\n shadowSpread?: number;\n}\n\nexport interface ITooltipStyle {\n panel: ITooltipPanelStyle;\n title: ITooltipTextStyle;\n shape: {\n fill: boolean;\n size: number;\n spacing: number;\n };\n key: ITooltipTextStyle;\n value: ITooltipTextStyle;\n padding: IPadding;\n spaceRow: number;\n enterable: boolean;\n transitionDuration: number;\n}\n"]}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { TooltipAttributes } from '@visactor/vrender-components';
|
|
2
|
-
import type { IToolTipActual } from '../../../../typings';
|
|
3
|
-
import type { ITooltipStyle } from '../interface';
|
|
2
|
+
import type { IToolTipActual, MaybeArray } from '../../../../typings';
|
|
3
|
+
import type { ITooltipStyle, ITooltipTextStyle } from '../interface';
|
|
4
4
|
export declare const getTooltipAttributes: (actualTooltip: IToolTipActual, style: ITooltipStyle) => TooltipAttributes;
|
|
5
|
+
interface ITooltipTextInfo {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
text: MaybeArray<number> | MaybeArray<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isValid } from "@visactor/vutils";
|
|
2
2
|
|
|
3
|
-
import { initTextMeasure } from "../../../../util";
|
|
3
|
+
import { getRichTextBounds, initTextMeasure } from "../../../../util";
|
|
4
4
|
|
|
5
5
|
import { builtinSymbolsMap } from "@visactor/vrender";
|
|
6
6
|
|
|
@@ -29,9 +29,13 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
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} =
|
|
32
|
+
const {text: text, width: width, height: height} = 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 && builtinSymbolsMap[titleShapeType]) {
|
|
36
40
|
const titleShapeAttrs = {
|
|
37
41
|
symbolType: titleShapeType
|
|
@@ -47,7 +51,7 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
47
51
|
if (filteredContent.length) {
|
|
48
52
|
titleVisible && (containerHeight += spaceRow);
|
|
49
53
|
let hasContentShape = !1;
|
|
50
|
-
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = []
|
|
54
|
+
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [];
|
|
51
55
|
attribute.content = filteredContent.map(((item, i) => {
|
|
52
56
|
const itemAttrs = {
|
|
53
57
|
height: 0,
|
|
@@ -56,15 +60,23 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
56
60
|
let itemHeight = 0;
|
|
57
61
|
const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", value: value, isKeyAdaptive: isKeyAdaptive} = item;
|
|
58
62
|
if (isValid(key)) {
|
|
59
|
-
const {width: width, height: height} =
|
|
63
|
+
const {width: width, height: height, text: text} = measureTooltipText(key, keyStyle);
|
|
60
64
|
itemAttrs.key = {
|
|
61
|
-
|
|
65
|
+
width: width,
|
|
66
|
+
height: height,
|
|
67
|
+
text: text,
|
|
68
|
+
multiLine: keyStyle.multiLine,
|
|
69
|
+
wordBreak: titleStyle.wordBreak
|
|
62
70
|
}, isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
63
71
|
}
|
|
64
72
|
if (isValid(value)) {
|
|
65
|
-
const {width: width, height: height} =
|
|
73
|
+
const {width: width, height: height, text: text} = measureTooltipText(value, valueStyle);
|
|
66
74
|
itemAttrs.value = {
|
|
67
|
-
|
|
75
|
+
width: width,
|
|
76
|
+
height: height,
|
|
77
|
+
text: text,
|
|
78
|
+
multiLine: valueStyle.multiLine,
|
|
79
|
+
wordBreak: titleStyle.wordBreak
|
|
68
80
|
}, valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
69
81
|
}
|
|
70
82
|
if (hasShape && builtinSymbolsMap[shapeType]) {
|
|
@@ -93,4 +105,40 @@ export const getTooltipAttributes = (actualTooltip, style) => {
|
|
|
93
105
|
return attribute.panel.width = containerSize.width, attribute.panel.height = containerSize.height,
|
|
94
106
|
attribute;
|
|
95
107
|
};
|
|
108
|
+
|
|
109
|
+
export const measureTooltipText = (text, style) => {
|
|
110
|
+
const measure = initTextMeasure(style);
|
|
111
|
+
if (!style.multiLine) {
|
|
112
|
+
const {width: width, height: height} = measure.fullMeasure(text);
|
|
113
|
+
return {
|
|
114
|
+
width: width,
|
|
115
|
+
height: height,
|
|
116
|
+
text: text
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
let textLines = text.split("\n");
|
|
120
|
+
textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line));
|
|
121
|
+
const {width: width, height: height} = measure.fullMeasure(textLines);
|
|
122
|
+
if (style.maxWidth && style.maxWidth <= width) {
|
|
123
|
+
const bound = getRichTextBounds({
|
|
124
|
+
wordBreak: style.wordBreak,
|
|
125
|
+
maxWidth: style.maxWidth,
|
|
126
|
+
width: 0,
|
|
127
|
+
height: 0,
|
|
128
|
+
textConfig: textLines.map(((line, i) => Object.assign(Object.assign({}, style), {
|
|
129
|
+
text: line
|
|
130
|
+
})))
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
width: bound.width(),
|
|
134
|
+
height: bound.height(),
|
|
135
|
+
text: textLines
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
width: width,
|
|
140
|
+
height: height,
|
|
141
|
+
text: textLines
|
|
142
|
+
};
|
|
143
|
+
};
|
|
96
144
|
//# sourceMappingURL=attribute.js.map
|
|
@@ -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,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,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G,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxE,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,QAAQ,GAAG,IAAI,CAAC,GAAG,CACjB,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,GAAG,UAAU,EAChF,mBAAmB,GAAG,UAAU,EAChC,QAAQ,CACT,CAAC;YACF,SAAS,CAAC,eAAe,GAAG,eAAe,CAAC;YAC5C,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC;YACjC,SAAS,CAAC,UAAU,GAAG,aAAa,CAAC;SACtC;KACF;IAED,MAAM,aAAa,GAAmB;QACpC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK;QAC9C,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IAC5C,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","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 =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O;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 // 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,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAiB3F,MAAM,UAAU,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;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6B,EAC4D,EAAE;IAC3F,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KAC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AC1B,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC;SACZ;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAGD,MAAM,UAAU,oBAAoB,CAAC,KAAU,EAAE,eAAuB,MAAM;IAC5E,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IACD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,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","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;
|