@visactor/vchart 1.4.2-beta.1 → 1.4.2

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.
Files changed (141) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +328 -263
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/chart/base-chart.js +3 -1
  6. package/cjs/chart/base-chart.js.map +1 -1
  7. package/cjs/component/brush/brush.d.ts +0 -1
  8. package/cjs/component/brush/brush.js +10 -7
  9. package/cjs/component/brush/brush.js.map +1 -1
  10. package/cjs/component/custom-mark/custom-mark.js +2 -1
  11. package/cjs/component/custom-mark/custom-mark.js.map +1 -1
  12. package/cjs/component/data-zoom/data-filter-base-component.js +6 -4
  13. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  14. package/cjs/component/marker/mark-area/mark-area.js +3 -3
  15. package/cjs/component/marker/mark-area/mark-area.js.map +1 -1
  16. package/cjs/component/marker/mark-line/mark-line.js +2 -2
  17. package/cjs/component/marker/mark-line/mark-line.js.map +1 -1
  18. package/cjs/component/marker/mark-point/mark-point.js +3 -3
  19. package/cjs/component/marker/mark-point/mark-point.js.map +1 -1
  20. package/cjs/component/tooltip/handler/base.d.ts +2 -4
  21. package/cjs/component/tooltip/handler/base.js +15 -38
  22. package/cjs/component/tooltip/handler/base.js.map +1 -1
  23. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  24. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  25. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  26. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  27. package/cjs/component/tooltip/handler/dom/util.d.ts +1 -2
  28. package/cjs/component/tooltip/handler/dom/util.js +14 -13
  29. package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
  30. package/cjs/component/tooltip/handler/interface/style.d.ts +4 -23
  31. package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
  32. package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -11
  33. package/cjs/component/tooltip/handler/utils/attribute.js +136 -126
  34. package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
  35. package/cjs/component/tooltip/handler/utils/common.d.ts +8 -0
  36. package/cjs/component/tooltip/handler/utils/common.js +42 -2
  37. package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
  38. package/cjs/component/tooltip/handler/utils/index.d.ts +0 -1
  39. package/cjs/component/tooltip/handler/utils/index.js +1 -2
  40. package/cjs/component/tooltip/handler/utils/index.js.map +1 -1
  41. package/cjs/component/tooltip/interface/common.d.ts +2 -2
  42. package/cjs/component/tooltip/interface/common.js.map +1 -1
  43. package/cjs/component/tooltip/interface/theme.d.ts +5 -3
  44. package/cjs/component/tooltip/interface/theme.js.map +1 -1
  45. package/cjs/component/tooltip/tooltip.d.ts +1 -0
  46. package/cjs/component/tooltip/tooltip.js +7 -4
  47. package/cjs/component/tooltip/tooltip.js.map +1 -1
  48. package/cjs/core/index.d.ts +1 -1
  49. package/cjs/core/index.js +1 -1
  50. package/cjs/core/index.js.map +1 -1
  51. package/cjs/core/util.d.ts +3 -0
  52. package/cjs/core/util.js +12 -0
  53. package/cjs/core/util.js.map +1 -0
  54. package/cjs/core/vchart.d.ts +3 -0
  55. package/cjs/core/vchart.js +2 -2
  56. package/cjs/core/vchart.js.map +1 -1
  57. package/cjs/interaction/trigger.js +1 -2
  58. package/cjs/layout/base-layout.js +2 -1
  59. package/cjs/mark/box-plot.js +1 -1
  60. package/cjs/model/base-model.d.ts +1 -0
  61. package/cjs/model/base-model.js +1 -0
  62. package/cjs/model/base-model.js.map +1 -1
  63. package/cjs/model/interface.d.ts +2 -1
  64. package/cjs/model/interface.js.map +1 -1
  65. package/cjs/series/polar/polar.js +1 -1
  66. package/cjs/series/polar/polar.js.map +1 -1
  67. package/cjs/util/text.d.ts +3 -3
  68. package/cjs/util/text.js +5 -1
  69. package/cjs/util/text.js.map +1 -1
  70. package/esm/chart/base-chart.js +3 -1
  71. package/esm/chart/base-chart.js.map +1 -1
  72. package/esm/component/brush/brush.d.ts +0 -1
  73. package/esm/component/brush/brush.js +10 -6
  74. package/esm/component/brush/brush.js.map +1 -1
  75. package/esm/component/custom-mark/custom-mark.js +2 -1
  76. package/esm/component/custom-mark/custom-mark.js.map +1 -1
  77. package/esm/component/data-zoom/data-filter-base-component.js +6 -4
  78. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  79. package/esm/component/marker/mark-area/mark-area.js +5 -5
  80. package/esm/component/marker/mark-area/mark-area.js.map +1 -1
  81. package/esm/component/marker/mark-line/mark-line.js +4 -4
  82. package/esm/component/marker/mark-line/mark-line.js.map +1 -1
  83. package/esm/component/marker/mark-point/mark-point.js +5 -5
  84. package/esm/component/marker/mark-point/mark-point.js.map +1 -1
  85. package/esm/component/tooltip/handler/base.d.ts +2 -4
  86. package/esm/component/tooltip/handler/base.js +14 -39
  87. package/esm/component/tooltip/handler/base.js.map +1 -1
  88. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  89. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  90. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  91. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  92. package/esm/component/tooltip/handler/dom/util.d.ts +1 -2
  93. package/esm/component/tooltip/handler/dom/util.js +14 -14
  94. package/esm/component/tooltip/handler/dom/util.js.map +1 -1
  95. package/esm/component/tooltip/handler/interface/style.d.ts +4 -23
  96. package/esm/component/tooltip/handler/interface/style.js.map +1 -1
  97. package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -11
  98. package/esm/component/tooltip/handler/utils/attribute.js +131 -123
  99. package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
  100. package/esm/component/tooltip/handler/utils/common.d.ts +8 -0
  101. package/esm/component/tooltip/handler/utils/common.js +41 -1
  102. package/esm/component/tooltip/handler/utils/common.js.map +1 -1
  103. package/esm/component/tooltip/handler/utils/index.d.ts +0 -1
  104. package/esm/component/tooltip/handler/utils/index.js +0 -2
  105. package/esm/component/tooltip/handler/utils/index.js.map +1 -1
  106. package/esm/component/tooltip/interface/common.d.ts +2 -2
  107. package/esm/component/tooltip/interface/common.js.map +1 -1
  108. package/esm/component/tooltip/interface/theme.d.ts +5 -3
  109. package/esm/component/tooltip/interface/theme.js.map +1 -1
  110. package/esm/component/tooltip/tooltip.d.ts +1 -0
  111. package/esm/component/tooltip/tooltip.js +7 -4
  112. package/esm/component/tooltip/tooltip.js.map +1 -1
  113. package/esm/core/index.d.ts +1 -1
  114. package/esm/core/index.js +1 -1
  115. package/esm/core/index.js.map +1 -1
  116. package/esm/core/util.d.ts +3 -0
  117. package/esm/core/util.js +6 -0
  118. package/esm/core/util.js.map +1 -0
  119. package/esm/core/vchart.d.ts +3 -0
  120. package/esm/core/vchart.js +3 -1
  121. package/esm/core/vchart.js.map +1 -1
  122. package/esm/interaction/trigger.js +1 -2
  123. package/esm/layout/base-layout.js +2 -1
  124. package/esm/mark/box-plot.js +1 -1
  125. package/esm/model/base-model.d.ts +1 -0
  126. package/esm/model/base-model.js +1 -0
  127. package/esm/model/base-model.js.map +1 -1
  128. package/esm/model/interface.d.ts +2 -1
  129. package/esm/model/interface.js.map +1 -1
  130. package/esm/series/polar/polar.js +1 -1
  131. package/esm/series/polar/polar.js.map +1 -1
  132. package/esm/util/text.d.ts +3 -3
  133. package/esm/util/text.js +2 -0
  134. package/esm/util/text.js.map +1 -1
  135. package/package.json +4 -4
  136. package/cjs/component/tooltip/handler/utils/style.d.ts +0 -4
  137. package/cjs/component/tooltip/handler/utils/style.js +0 -32
  138. package/cjs/component/tooltip/handler/utils/style.js.map +0 -1
  139. package/esm/component/tooltip/handler/utils/style.d.ts +0 -4
  140. package/esm/component/tooltip/handler/utils/style.js +0 -26
  141. package/esm/component/tooltip/handler/utils/style.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import type { Datum } from '@visactor/vgrammar-core';
2
2
  import type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';
3
3
  import type { TooltipHandlerParams } from '../../interface';
4
+ import type { ITooltipTextStyle } from '../interface/style';
4
5
  export declare function escapeHTML(value: any): string;
5
6
  export declare const getTooltipContentValue: <T>(field?: TooltipContentProperty<T>, datum?: any, params?: TooltipHandlerParams) => T;
6
7
  export declare const getTooltipPatternValue: <T>(field?: MaybeArray<TooltipPatternProperty<T>>, data?: TooltipData, params?: TooltipHandlerParams) => MaybeArray<TooltipPatternProperty<T>> extends TooltipPatternProperty<T>[] ? MaybeArray<T> : T;
@@ -8,3 +9,10 @@ export declare function getFirstDatumFromTooltipData(data: TooltipData): Datum;
8
9
  export declare function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined;
9
10
  export declare function convertToColorString(color: any, defaultColor?: string): string;
10
11
  export declare const getScale: (element: HTMLElement, boundingClientRect?: DOMRect) => number;
12
+ interface ITooltipTextInfo {
13
+ width: number;
14
+ height: number;
15
+ text: MaybeArray<number> | MaybeArray<string>;
16
+ }
17
+ export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
18
+ export {};
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.getScale = exports.convertToColorString = exports.pickFirstValidValue = exports.getFirstDatumFromTooltipData = exports.getTooltipPatternValue = exports.getTooltipContentValue = exports.escapeHTML = void 0;
5
+ }), exports.measureTooltipText = exports.getScale = exports.convertToColorString = exports.pickFirstValidValue = exports.getFirstDatumFromTooltipData = exports.getTooltipPatternValue = exports.getTooltipContentValue = exports.escapeHTML = void 0;
6
6
 
7
- const util_1 = require("../../../../util");
7
+ const util_1 = require("../../../../util"), vrender_1 = require("@visactor/vrender");
8
8
 
9
9
  function escapeHTML(value) {
10
10
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\(/g, "&#40;").replace(/ /g, " &nbsp;");
@@ -55,4 +55,44 @@ const getScale = (element, boundingClientRect) => element ? (boundingClientRect
55
55
  element.offsetWidth > 0 ? boundingClientRect.width / element.offsetWidth : boundingClientRect.height / element.offsetHeight) : 1;
56
56
 
57
57
  exports.getScale = getScale;
58
+
59
+ const measureTooltipText = (text, style) => {
60
+ var _a;
61
+ text = (null != text ? text : "").toString();
62
+ const measure = (0, util_1.initTextMeasure)(style);
63
+ if (!style.multiLine) {
64
+ const {width: width, height: height} = measure.fullMeasure(text);
65
+ return {
66
+ width: width,
67
+ height: height,
68
+ text: text
69
+ };
70
+ }
71
+ let textLines = text.split("\n");
72
+ textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line));
73
+ const {width: width, height: height} = measure.fullMeasure(textLines);
74
+ if (style.maxWidth && style.maxWidth <= width) {
75
+ const bound = (0, vrender_1.getRichTextBounds)({
76
+ wordBreak: null !== (_a = style.wordBreak) && void 0 !== _a ? _a : "break-word",
77
+ maxWidth: style.maxWidth,
78
+ width: 0,
79
+ height: 0,
80
+ textConfig: textLines.map(((line, i) => Object.assign(Object.assign({}, style), {
81
+ text: line
82
+ })))
83
+ });
84
+ return {
85
+ width: bound.width(),
86
+ height: bound.height(),
87
+ text: textLines
88
+ };
89
+ }
90
+ return {
91
+ width: width,
92
+ height: height,
93
+ text: textLines
94
+ };
95
+ };
96
+
97
+ exports.measureTooltipText = measureTooltipText;
58
98
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,2CAA2F;AAiB3F,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;SACjB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,O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AY,CAAC;AACtB,CAAC;AAbD,oDAaC;AAGM,MAAM,QAAQ,GAAG,CAAC,OAAoB,EAAE,kBAA4B,EAAE,EAAE;IAC7E,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,CAAC,CAAC;KACV;IACD,IAAI,CAAC,kBAAkB,EAAE;QACvB,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;KACtD;IACD,IAAI,OAAO,CAAC,WAAW,GAAG,CAAC,EAAE;QAC3B,OAAO,kBAAkB,CAAC,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC;KACvD;IACD,OAAO,kBAAkB,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;AAC1D,CAAC,CAAC;AAXW,QAAA,QAAQ,YAWnB","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar-core';\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)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\\(/g, '&#40;')\n .replace(/ /g, ' &nbsp;'); // 转义符和真空格夹杂,在转义和正常换行之间取得平衡\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\n/** 获取元素的绝对缩放因数(支持外部传入 boundingClientRect 提升性能) */\nexport const getScale = (element: HTMLElement, boundingClientRect?: DOMRect) => {\n if (!element) {\n return 1;\n }\n if (!boundingClientRect) {\n boundingClientRect = element.getBoundingClientRect();\n }\n if (element.offsetWidth > 0) {\n return boundingClientRect.width / element.offsetWidth;\n }\n return boundingClientRect.height / element.offsetHeight;\n};\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,2CAA4G;AAI5G,+CAAsD;AAgBtD,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AM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACxF,MAAM,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,IAAA,2BAAiB,EAAC;YAC9B,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,YAAY;YAC1C,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;AA5CW,QAAA,kBAAkB,sBA4C7B","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar-core';\nimport type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';\nimport { isFunction, isObject, isString, isNil, isArray, isValid, initTextMeasure } from '../../../../util';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender';\nimport { getRichTextBounds } from '@visactor/vrender';\nimport type { ITooltipTextStyle } from '../interface/style';\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)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\\(/g, '&#40;')\n .replace(/ /g, ' &nbsp;'); // 转义符和真空格夹杂,在转义和正常换行之间取得平衡\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\n/** 获取元素的绝对缩放因数(支持外部传入 boundingClientRect 提升性能) */\nexport const getScale = (element: HTMLElement, boundingClientRect?: DOMRect) => {\n if (!element) {\n return 1;\n }\n if (!boundingClientRect) {\n boundingClientRect = element.getBoundingClientRect();\n }\n if (element.offsetWidth > 0) {\n return boundingClientRect.width / element.offsetWidth;\n }\n return boundingClientRect.height / element.offsetHeight;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string>;\n}\n\n/** 测量 tooltip 标签文本 */\nexport const measureTooltipText = (text: string, style: ITooltipTextStyle): ITooltipTextInfo => {\n text = (text ?? '').toString();\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 ?? 'break-word',\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"]}
@@ -4,4 +4,3 @@ export * from './pattern';
4
4
  export * from './get-spec';
5
5
  export * from './position';
6
6
  export * from './attribute';
7
- export * from './style';
@@ -19,6 +19,5 @@ Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), __exportStar(require("./common"), exports), __exportStar(require("./compose"), exports),
21
21
  __exportStar(require("./pattern"), exports), __exportStar(require("./get-spec"), exports),
22
- __exportStar(require("./position"), exports), __exportStar(require("./attribute"), exports),
23
- __exportStar(require("./style"), exports);
22
+ __exportStar(require("./position"), exports), __exportStar(require("./attribute"), exports);
24
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B;AAC5B,0CAAwB","file":"index.js","sourcesContent":["export * from './common';\nexport * from './compose';\nexport * from './pattern';\nexport * from './get-spec';\nexport * from './position';\nexport * from './attribute';\nexport * from './style';\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B","file":"index.js","sourcesContent":["export * from './common';\nexport * from './compose';\nexport * from './pattern';\nexport * from './get-spec';\nexport * from './position';\nexport * from './attribute';\n"]}
@@ -1,8 +1,8 @@
1
- import type { IModel } from '../../../model/interface';
2
1
  import type { DimensionEventParams } from '../../../event/events/dimension/interface';
3
2
  import type { BaseEventParams } from '../../../event/interface';
4
3
  import type { DimensionTooltipInfo, MarkTooltipInfo } from '../processor/interface';
5
4
  import type { Datum, IShowTooltipOption } from '../../../typings';
5
+ import type { IComponent } from '../../interface';
6
6
  export type TooltipHandlerParams = (BaseEventParams | DimensionEventParams) & {
7
7
  changePositionOnly?: boolean;
8
8
  };
@@ -18,7 +18,7 @@ export declare enum TooltipResult {
18
18
  success = 0,
19
19
  failed = 1
20
20
  }
21
- export interface ITooltip extends IModel {
21
+ export interface ITooltip extends IComponent {
22
22
  getVisible: () => boolean;
23
23
  showTooltip: (datum: Datum, options: IShowTooltipOption) => void;
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/interface/common.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAKX;AALD,WAAY,aAAa;IAEvB,uDAAW,CAAA;IAEX,qDAAU,CAAA;AACZ,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB","file":"common.js","sourcesContent":["import type { IModel } from '../../../model/interface';\nimport type { DimensionEventParams } from '../../../event/events/dimension/interface';\nimport type { BaseEventParams } from '../../../event/interface';\nimport type { DimensionTooltipInfo, MarkTooltipInfo } from '../processor/interface';\nimport type { Datum, IShowTooltipOption } from '../../../typings';\n\nexport type TooltipHandlerParams = (BaseEventParams | DimensionEventParams) & {\n changePositionOnly?: boolean;\n};\n\nexport interface ITooltipActiveTypeAsKeys<T, K> {\n mark: T;\n dimension: K;\n}\n\nexport type TotalMouseEventData = {\n tooltipInfo: Partial<ITooltipActiveTypeAsKeys<MarkTooltipInfo, DimensionTooltipInfo>>;\n ignore: Partial<ITooltipActiveTypeAsKeys<boolean, boolean>>;\n};\n\nexport enum TooltipResult {\n /** tooltip 显示成功 */\n success = 0,\n /** tooltip 未成功显示 */\n failed = 1\n}\n\nexport interface ITooltip extends IModel {\n getVisible: () => boolean;\n showTooltip: (datum: Datum, options: IShowTooltipOption) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/interface/common.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAKX;AALD,WAAY,aAAa;IAEvB,uDAAW,CAAA;IAEX,qDAAU,CAAA;AACZ,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB","file":"common.js","sourcesContent":["import type { DimensionEventParams } from '../../../event/events/dimension/interface';\nimport type { BaseEventParams } from '../../../event/interface';\nimport type { DimensionTooltipInfo, MarkTooltipInfo } from '../processor/interface';\nimport type { Datum, IShowTooltipOption } from '../../../typings';\nimport type { IComponent } from '../../interface';\n\nexport type TooltipHandlerParams = (BaseEventParams | DimensionEventParams) & {\n changePositionOnly?: boolean;\n};\n\nexport interface ITooltipActiveTypeAsKeys<T, K> {\n mark: T;\n dimension: K;\n}\n\nexport type TotalMouseEventData = {\n tooltipInfo: Partial<ITooltipActiveTypeAsKeys<MarkTooltipInfo, DimensionTooltipInfo>>;\n ignore: Partial<ITooltipActiveTypeAsKeys<boolean, boolean>>;\n};\n\nexport enum TooltipResult {\n /** tooltip 显示成功 */\n success = 0,\n /** tooltip 未成功显示 */\n failed = 1\n}\n\nexport interface ITooltip extends IComponent {\n getVisible: () => boolean;\n showTooltip: (datum: Datum, options: IShowTooltipOption) => void;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { RichTextWordBreak } from '@visactor/vrender';
2
- import type { IPadding, StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';
2
+ import type { StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';
3
3
  import type { IColorKey } from '../../../theme/color-scheme/interface';
4
+ import type { Padding } from '@visactor/vrender-components/es/core/type';
4
5
  export interface ITooltipTextTheme {
5
6
  fontFamily?: string;
6
7
  fontSize?: number;
@@ -14,10 +15,11 @@ export interface ITooltipTextTheme {
14
15
  multiLine?: boolean;
15
16
  maxWidth?: number;
16
17
  wordBreak?: RichTextWordBreak;
18
+ autoWidth?: boolean;
17
19
  }
18
20
  export interface ITooltipTheme {
19
21
  panel?: {
20
- padding?: IPadding;
22
+ padding?: Padding;
21
23
  backgroundColor?: string | IColorKey;
22
24
  border?: {
23
25
  color?: string | IColorKey;
@@ -37,7 +39,7 @@ export interface ITooltipTheme {
37
39
  spacing?: number;
38
40
  };
39
41
  titleLabel?: ITooltipTextTheme;
40
- keyLabel?: ITooltipTextTheme;
42
+ keyLabel?: Omit<ITooltipTextTheme, 'autoWidth'>;
41
43
  valueLabel?: ITooltipTextTheme;
42
44
  spaceRow?: number;
43
45
  offset?: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { RichTextWordBreak } from '@visactor/vrender';\nimport type { IPadding, StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';\nimport type { IColorKey } from '../../../theme/color-scheme/interface';\n\nexport interface ITooltipTextTheme {\n /** 字体 */\n fontFamily?: string;\n /** 字体大小 */\n fontSize?: number;\n /** 字体颜色 */\n fill?: string | IColorKey;\n /** @deprecated 字体颜色(兼容旧版本) */\n fontColor?: string | IColorKey;\n /** 字重 */\n fontWeight?: StringOrNumber;\n /** 对齐方式 */\n textAlign?: TextAlign;\n /** 字体基线 */\n textBaseline?: TextBaseLine;\n /** 行高 */\n lineHeight?: number | string;\n /** 与相邻元素的水平间距 */\n spacing?: number;\n /** 是否支持换行 */\n multiLine?: boolean;\n /** 最大宽度 */\n maxWidth?: number;\n /** 换行模式,默认为'break-word' */\n wordBreak?: RichTextWordBreak;\n}\n\nexport interface ITooltipTheme {\n /** 容器样式配置 */\n panel?: {\n /** tooltip 容器内边距 */\n padding?: IPadding;\n /** 背景色 */\n backgroundColor?: string | IColorKey;\n /** tooltip边框 */\n border?: {\n color?: string | IColorKey;\n width?: number;\n /** 圆角 */\n radius?: number;\n };\n /** tooltip阴影 */\n shadow?: {\n x: number;\n y: number;\n blur: number;\n spread: number;\n color: string | IColorKey;\n };\n };\n shape?: {\n /** 标记大小 */\n size?: number;\n /** shape 与相邻元素的水平间距 */\n spacing?: number;\n };\n /** tooltip标题 */\n titleLabel?: ITooltipTextTheme;\n /** tooltip内容,key字段 */\n keyLabel?: ITooltipTextTheme;\n /** tooltip内容,value字段 */\n valueLabel?: ITooltipTextTheme;\n /** 内容项行间距 */\n spaceRow?: number;\n /** 偏移量 */\n offset?: {\n x?: number;\n y?: number;\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { RichTextWordBreak } from '@visactor/vrender';\nimport type { StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';\nimport type { IColorKey } from '../../../theme/color-scheme/interface';\nimport type { Padding } from '@visactor/vrender-components/es/core/type';\n\nexport interface ITooltipTextTheme {\n /** 字体 */\n fontFamily?: string;\n /** 字体大小 */\n fontSize?: number;\n /** 字体颜色 */\n fill?: string | IColorKey;\n /** @deprecated 字体颜色(兼容旧版本) */\n fontColor?: string | IColorKey;\n /** 字重 */\n fontWeight?: StringOrNumber;\n /** 对齐方式 */\n textAlign?: TextAlign;\n /** 字体基线 */\n textBaseline?: TextBaseLine;\n /** 行高 */\n lineHeight?: number | string;\n /** 与相邻元素的水平间距 */\n spacing?: number;\n /** 是否支持换行 */\n multiLine?: boolean;\n /** 最大宽度 */\n maxWidth?: number;\n /** 换行模式,默认为'break-word' */\n wordBreak?: RichTextWordBreak;\n /**\n * 是否开启自动宽度。效果分为以下几种情况:\n * - tooltip 标题:`autoWidth` 默认为 `false`。如果配置为 `true`,则 tooltip 标题会保持和 tooltip 内容一致的宽度\n * - tooltip key 标签:`autoWidth` 不适用\n * - tooltip value 标签:`autoWidth` 默认为 `true`。如果配置为 `true`,则 tooltip value 标签会自动占满 tooltip 整体宽度的剩余部分\n * @since 1.4.2\n */\n autoWidth?: boolean;\n}\n\nexport interface ITooltipTheme {\n /** 容器样式配置 */\n panel?: {\n /** tooltip 容器内边距 */\n padding?: Padding;\n /** 背景色 */\n backgroundColor?: string | IColorKey;\n /** tooltip边框 */\n border?: {\n color?: string | IColorKey;\n width?: number;\n /** 圆角 */\n radius?: number;\n };\n /** tooltip阴影 */\n shadow?: {\n x: number;\n y: number;\n blur: number;\n spread: number;\n color: string | IColorKey;\n };\n };\n shape?: {\n /** 标记大小 */\n size?: number;\n /** shape 与相邻元素的水平间距 */\n spacing?: number;\n };\n /** tooltip标题 */\n titleLabel?: ITooltipTextTheme;\n /** tooltip内容,key字段 */\n keyLabel?: Omit<ITooltipTextTheme, 'autoWidth'>;\n /** tooltip内容,value字段 */\n valueLabel?: ITooltipTextTheme;\n /** 内容项行间距 */\n spaceRow?: number;\n /** 偏移量 */\n offset?: {\n x?: number;\n y?: number;\n };\n}\n"]}
@@ -37,6 +37,7 @@ export declare class Tooltip extends BaseComponent<any> implements ITooltip {
37
37
  onRender(ctx: IModelRenderOption): void;
38
38
  created(): void;
39
39
  release(): void;
40
+ beforeRelease(): void;
40
41
  protected _initHandler(): void;
41
42
  protected _initProcessor(): void;
42
43
  protected _initEvent(): void;
@@ -108,14 +108,17 @@ class Tooltip extends base_1.BaseComponent {
108
108
  }
109
109
  release() {
110
110
  var _a, _b;
111
+ super.release(), this._eventList.forEach((({eventType: eventType, handler: handler}) => {
112
+ this.event.off(eventType, handler);
113
+ })), this._eventList = [], null === (_b = null === (_a = this.tooltipHandler) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
114
+ this._isTooltipShown = !1;
115
+ }
116
+ beforeRelease() {
111
117
  this.event.emit(constant_1.ChartEvent.tooltipHide, {
112
118
  tooltip: this
113
119
  }), this.event.emit(constant_1.ChartEvent.tooltipRelease, {
114
120
  tooltip: this
115
- }), super.release(), this._eventList.forEach((({eventType: eventType, handler: handler}) => {
116
- this.event.off(eventType, handler);
117
- })), this._eventList = [], null === (_b = null === (_a = this.tooltipHandler) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
118
- this._isTooltipShown = !1;
121
+ });
119
122
  }
120
123
  _initHandler() {
121
124
  var _a, _b, _c;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/tooltip.ts"],"names":[],"mappings":";;;AAEA,4CAAiD;AAGjD,kCAAwC;AAGxC,uCAAoE;AAEpE,qCAUoB;AACpB,2CAQqB;AACrB,mDAA4D;AAE5D,mCAA8E;AAC9E,4DAAwE;AACxE,6CAAmF;AAGnF,2CAA2G;AAC3G,6CAA8D;AAC9D,8CAA2C;AAc3C,MAAa,OAAQ,SAAQ,oBAAkB;IAA/C;;QAEE,SAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC;QACjC,SAAI,GAA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SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,MAAM,EAAE;YAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YACzB,IAAI,MAAW,CAAC;YAChB,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,WAAW,CAAC,EAAE;gBAE9B,MAAM,WAAW,GAAG,KAAK,CAAC,WAAoB,CAAC;gBAC/C,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;gBAE5B,IAAI,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrE,MAAM,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;iBACxC;aACF;iBAAM;gBACL,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;aACvB;YAED,MAAM,SAAS,GAAG,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,mBAAmB,kDAAI,CAAC;YAC/D,IAAI,IAAA,cAAO,EAAC,SAAS,CAAC,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,IAAI,IAAA,yBAAgB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE;gBAChF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC;;AAneH,0BAoeC;AAneQ,YAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC","file":"tooltip.js","sourcesContent":["import type { IComponentOption } from '../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface';\nimport type { IModelLayoutOption, IModelRenderOption, ILayoutItem } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport { BaseComponent } from '../base';\nimport type { BaseEventParams, EventCallback, EventQuery, EventType } from '../../event/interface';\nimport type { ITooltipHandler, IToolTipLineActual, TooltipActiveType } from '../../typings/tooltip';\nimport { DomTooltipHandler, CanvasTooltipHandler } from './handler';\nimport type { Datum, IPoint, IShowTooltipOption } from '../../typings';\nimport {\n cloneDeep,\n isArray,\n isValid,\n mergeSpec,\n isMobileLikeMode,\n isTrueBrowser,\n isNil,\n isMiniAppLikeMode,\n domDocument\n} from '../../util';\nimport {\n TooltipResult,\n type ITooltip,\n type ITooltipActiveTypeAsKeys,\n type ITooltipSpec,\n type ITooltipTheme,\n type TooltipHandlerParams,\n type TotalMouseEventData\n} from './interface';\nimport { TOOLTIP_EL_CLASS_NAME } from './handler/constants';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTooltipActualActiveType, showTooltip, isEmptyPos } from './utils';\nimport { isSameDimensionInfo } from '../../event/events/dimension/util';\nimport { ChartEvent, Event_Bubble_Level, Event_Source_Type } from '../../constant';\nimport type { DimensionTooltipInfo, MarkTooltipInfo, TooltipInfo } from './processor';\n// eslint-disable-next-line no-duplicate-imports\nimport { isDimensionInfo, isMarkInfo, MarkTooltipProcessor, DimensionTooltipProcessor } from './processor';\nimport { hasParentElement, isString } from '@visactor/vutils';\nimport { VChart } from '../../core/vchart';\nimport type { TooltipEventParams } from './interface/event';\nimport type { IGroup } from '@visactor/vrender';\n\nexport type TooltipActualTitleContent = {\n title?: IToolTipLineActual;\n content?: IToolTipLineActual[];\n};\n\ntype EventHandlerList = {\n eventType: EventType;\n handler: any;\n}[];\n\nexport class Tooltip extends BaseComponent<any> implements ITooltip {\n static type = ComponentTypeEnum.tooltip;\n type = ComponentTypeEnum.tooltip;\n name: string = ComponentTypeEnum.tooltip;\n\n layoutType: ILayoutItem['layoutType'] = 'absolute';\n\n protected declare _spec: ITooltipSpec;\n\n static createComponent(spec: any, options: IComponentOption) {\n const tooltipSpec = spec.tooltip;\n if (!tooltipSpec) {\n return null;\n }\n if (!isArray(tooltipSpec)) {\n return new Tooltip(tooltipSpec, { ...options, specKey: 'tooltip' });\n }\n const tooltips: Tooltip[] = [];\n tooltipSpec.forEach((s: any, i: number) => {\n tooltips.push(new Tooltip(s, { ...options, specIndex: i, specKey: 'tooltip' }));\n });\n return tooltips;\n }\n\n tooltipHandler?: ITooltipHandler;\n\n private _alwaysShow: boolean = false;\n\n private _cacheInfo: TooltipInfo | undefined;\n\n private _eventList: EventHandlerList = [];\n\n protected declare _theme: ITooltipTheme;\n\n protected _processor: ITooltipActiveTypeAsKeys<MarkTooltipProcessor, DimensionTooltipProcessor>;\n\n protected _isTooltipShown: boolean = false;\n /** 当前是否正在显示 tooltip */\n isTooltipShown() {\n return this._isTooltipShown;\n }\n\n changeRegions(regions: IRegion[]) {\n /* do nothing */\n }\n getVRenderComponents(): IGroup[] {\n return [];\n }\n protected _registerEvent() {\n /* do nothing */\n }\n protected _releaseEvent() {\n /* do nothing */\n }\n onLayout(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onLayoutEnd(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onRender(ctx: IModelRenderOption) {\n /* do nothing */\n }\n\n created() {\n super.created();\n this._regions = this._option.getAllRegions();\n // event\n this._initEvent();\n }\n\n release() {\n this.event.emit(ChartEvent.tooltipHide, {\n tooltip: this\n } as unknown as TooltipEventParams);\n this.event.emit(ChartEvent.tooltipRelease, {\n tooltip: this\n } as unknown as TooltipEventParams);\n\n super.release();\n\n this._eventList.forEach(({ eventType, handler }) => {\n this.event.off(eventType, handler);\n });\n this._eventList = [];\n this.tooltipHandler?.release?.();\n this._isTooltipShown = false;\n }\n\n protected _initHandler() {\n const renderMode = this._spec.renderMode ?? 'html';\n\n const userTooltipHandler = this._option.globalInstance.getTooltipHandlerByUser();\n if (userTooltipHandler) {\n this.tooltipHandler = userTooltipHandler;\n } else {\n // 构造内部默认 handler\n const Handler = renderMode === 'canvas' ? CanvasTooltipHandler : DomTooltipHandler;\n const id = `${this._spec.className}-${this._option.globalInstance.id ?? 0}-${this._option.specIndex ?? 0}`;\n this.tooltipHandler = new Handler(id, this);\n }\n }\n\n protected _initProcessor() {\n // 初始化 tooltip 类型\n this._processor = {\n mark: new MarkTooltipProcessor(this),\n dimension: new DimensionTooltipProcessor(this)\n };\n }\n\n protected _initEvent() {\n const trigger = this._spec.trigger ?? 'hover';\n // TODO: triggerOff完整支持\n // const triggerOff = this._spec.triggerOff ?? trigger;\n const mode = this._option.mode;\n\n if (trigger === 'hover') {\n this._mountEvent('pointermove', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n // 移动端的点按 + 滑动触发\n if (isMobileLikeMode(mode) || isMiniAppLikeMode(mode)) {\n this._mountEvent('pointerdown', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._getMouseOutHandler(true));\n }\n this._mountEvent('pointerout', { source: 'canvas' }, this._getMouseOutHandler(false));\n } else if (trigger === 'click') {\n this._mountEvent('pointertap', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._getMouseOutHandler(true));\n }\n }\n\n protected _mountEvent = (eType: EventType, query: EventQuery, callback: EventCallback<any>) => {\n this.event.on(eType, query, callback);\n this._eventList.push({\n eventType: eType,\n handler: callback\n });\n };\n\n protected _getMouseOutHandler = (needPointerDetection?: boolean) => (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (!this._isTooltipShown && !this.tooltipHandler?.isTooltipShown?.()) {\n return;\n }\n\n const browserEnv = isTrueBrowser(this._option.mode);\n const { clientX, clientY } = params.event as MouseEvent;\n\n // 当 enterable 为 true,同时鼠标移入 tooltip 时 pointerleave 事件也会触发,所以这里做一个判断\n if (browserEnv && this._isPointerOnTooltip(params)) {\n return;\n }\n\n // 判断鼠标是否在图表范围内\n if (browserEnv && needPointerDetection && this._isPointerInChart({ x: clientX, y: clientY })) {\n return;\n }\n\n this._handleChartMouseOut(params);\n };\n\n protected _handleChartMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (this._spec.triggerOff !== 'none') {\n this._hideTooltipByHandler({\n ...params\n });\n this._cacheInfo = undefined;\n }\n };\n\n protected _handleMouseMove = (params: BaseEventParams) => {\n if (!this.tooltipHandler) {\n this._initHandler();\n }\n\n if (!this._processor) {\n this._initProcessor();\n }\n\n if (this._alwaysShow) {\n return;\n }\n if (this._isPointerOnTooltip(params)) {\n return;\n }\n\n /* 获取 tooltip 原始数据 */\n const mouseEventData = this._getMouseEventData(params);\n const {\n tooltipInfo: { dimension: dimensionInfo },\n ignore: { mark: ignoreMark, dimension: ignoreDimension }\n } = mouseEventData;\n\n let markTooltipSuccess: boolean = false;\n let dimensionTooltipSuccess: boolean = false;\n\n /* 显示常规tooltip */\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params);\n if (!markTooltipSuccess) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n\n /* 如果不是常规情况,进行一些特殊情况tooltip处理 */\n if (!markTooltipSuccess && !dimensionTooltipSuccess && !isEmptyPos(params)) {\n // 用户手动配置ignore,则继续显示缓存tooltip\n if (ignoreMark && isMarkInfo(this._cacheInfo)) {\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params, true);\n } else if (ignoreDimension && isDimensionInfo(this._cacheInfo)) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params, true);\n } else if (isValid(dimensionInfo)) {\n // 用户没有手动配置ignore的话,默认显示dimension tooltip\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n }\n\n /* 如果还是不应该显示tooltip,则隐藏上一次tooltip */\n if (!markTooltipSuccess && (!dimensionTooltipSuccess || isNil(dimensionInfo))) {\n this._handleChartMouseOut(params);\n }\n };\n\n /**\n * 通过鼠标事件触发 tooltip,返回是否成功\n * @param activeType tooltip 类型\n * @param mouseEventData tooltip 相关数据\n * @param params 事件参数\n * @param useCache 是否直接显示缓存 tooltip\n * @returns 是否成功执行\n */\n protected _showTooltipByMouseEvent = (\n activeType: TooltipActiveType,\n mouseEventData: TotalMouseEventData,\n params: BaseEventParams,\n useCache?: boolean\n ): boolean => {\n const processor = this._processor[activeType];\n // 判断是否应该触发 tooltip\n if (\n !processor.shouldHandleTooltip(params, {\n tooltipInfo: mouseEventData.tooltipInfo[activeType],\n ignore: mouseEventData.ignore[activeType]\n })\n ) {\n return false;\n }\n\n let success: boolean;\n if (useCache) {\n // 直接显示缓存 tooltip\n success = !processor.showTooltip(this._cacheInfo as any, params, true);\n } else {\n const tooltipInfo = mouseEventData.tooltipInfo[activeType];\n const isSameAsCache = this._isSameAsCacheInfo(tooltipInfo);\n success = !processor.showTooltip(tooltipInfo as any, params, isSameAsCache);\n if (success) {\n // 成功显示 tooltip,则更新缓存\n this._cacheInfo = tooltipInfo;\n }\n }\n if (success) {\n this._isTooltipShown = true;\n }\n // 全局唯一 tooltip\n const vchart = this._option.globalInstance;\n if (success && VChart.globalConfig.uniqueTooltip) {\n VChart.hideTooltip(vchart.id);\n }\n return success;\n };\n\n protected _getMouseEventData = (params: BaseEventParams): TotalMouseEventData => {\n const result: TotalMouseEventData = {\n tooltipInfo: {},\n ignore: {}\n };\n Object.keys(this._processor).forEach(activeType => {\n const { tooltipInfo, ignore } = this._processor[activeType].getMouseEventData(params);\n result.tooltipInfo[activeType] = tooltipInfo;\n result.ignore[activeType] = ignore;\n });\n return result;\n };\n\n protected _hideTooltipByHandler = (params: TooltipHandlerParams): TooltipResult => {\n if (!this._isTooltipShown && !this.tooltipHandler?.isTooltipShown?.()) {\n // 如果当前 tooltip 未显示,则提前退出\n return TooltipResult.success;\n }\n this.event.emit(ChartEvent.tooltipHide, {\n ...params,\n source: Event_Source_Type.chart, // 统一 event 的来源\n tooltip: this\n });\n if (this.tooltipHandler?.hideTooltip) {\n const result = this.tooltipHandler.hideTooltip(params);\n if (!result) {\n this._isTooltipShown = false;\n }\n return result;\n }\n return TooltipResult.failed;\n };\n\n protected _initTheme(theme?: any) {\n super._initTheme(theme);\n this._spec.style = this._prepareSpecAfterMergingTheme(mergeSpec({}, this._theme, this._originalSpec.style));\n }\n\n protected _shouldMergeThemeToSpec() {\n return false;\n }\n\n reInit(theme?: any) {\n super.reInit(theme);\n\n if (this.tooltipHandler) {\n this.tooltipHandler.reInit?.();\n } else {\n this._initHandler();\n }\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n const userSpec = this._spec as ITooltipSpec;\n this._spec = {\n ...userSpec,\n visible: isValid(userSpec.visible) ? userSpec.visible : true,\n activeType: getTooltipActualActiveType(userSpec),\n renderMode: 'html',\n trigger: isValid(userSpec.trigger) ? userSpec.trigger : 'hover',\n className: isValid(userSpec.className) ? userSpec.className : TOOLTIP_EL_CLASS_NAME,\n enterable: isValid(userSpec.enterable) ? userSpec.enterable : false,\n transitionDuration: isValid(userSpec.transitionDuration) ? userSpec.transitionDuration : 150\n } as ITooltipSpec;\n this._spec.triggerOff = isValid(userSpec.triggerOff) ? userSpec.triggerOff : this._spec.trigger;\n\n if (isValid(userSpec.renderMode)) {\n this._spec.renderMode = userSpec.renderMode;\n } else if (isMiniAppLikeMode(this._option.mode)) {\n // 小程序环境下,默认使用canvas渲染\n this._spec.renderMode = 'canvas';\n }\n\n if (isValid(userSpec.mark)) {\n this._spec.mark = {\n ...cloneDeep(userSpec.mark),\n activeType: 'mark'\n };\n }\n if (isValid(userSpec.dimension)) {\n this._spec.dimension = {\n ...cloneDeep(userSpec.dimension),\n activeType: 'dimension'\n };\n }\n\n if (isValid(userSpec.parentElement)) {\n if (isString(userSpec.parentElement)) {\n this._spec.parentElement = globalThis.document?.getElementById(userSpec.parentElement);\n } else {\n this._spec.parentElement = userSpec.parentElement;\n }\n } else if (isTrueBrowser(this._option.mode)) {\n this._spec.parentElement = domDocument?.body;\n }\n\n if (isValid(userSpec.confine)) {\n this._spec.confine = userSpec.confine;\n } else {\n this._spec.confine = this._spec.renderMode === 'canvas';\n }\n }\n\n showTooltip(datum: Datum, options: IShowTooltipOption) {\n if (!this.tooltipHandler) {\n this._initHandler();\n }\n\n if (!this._processor) {\n this._initProcessor();\n }\n\n if (!this.tooltipHandler?.showTooltip) {\n return false;\n }\n const result = showTooltip(datum, options, this.tooltipHandler, this._option);\n if (result !== 'none') {\n this._alwaysShow = !!options?.alwaysShow;\n }\n return result;\n }\n\n /** 手动隐藏 tooltip,返回是否成功 */\n hideTooltip(): boolean {\n const params: TooltipHandlerParams = {\n changePositionOnly: false,\n item: undefined,\n datum: undefined,\n source: Event_Source_Type.chart\n } as any;\n\n this._alwaysShow = false;\n return !this._hideTooltipByHandler(params);\n }\n\n private _isSameAsCacheInfo(nextInfo?: TooltipInfo): boolean {\n if (nextInfo === this._cacheInfo) {\n return true;\n }\n if (isNil(this._cacheInfo) || isNil(nextInfo)) {\n return false;\n }\n\n if (isDimensionInfo(nextInfo)) {\n if (isMarkInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as DimensionTooltipInfo;\n return prevInfo.length === nextInfo.length && nextInfo.every((info, i) => isSameDimensionInfo(info, prevInfo[i]));\n }\n if (isDimensionInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as MarkTooltipInfo;\n return (\n nextInfo?.datum === prevInfo.datum && nextInfo?.mark === prevInfo.mark && nextInfo?.series === prevInfo.series\n );\n }\n\n private _isPointerInChart(point: IPoint): boolean {\n const globalInstance = this._option.globalInstance;\n const chart = globalInstance.getChart();\n if (!chart) {\n return false;\n }\n const { x, y } = point;\n const canvas = globalInstance.getCanvas();\n const { x: chartX, y: chartY, width: chartWidth, height: chartHeight } = canvas.getBoundingClientRect();\n // 鼠标仍在图表范围内,则不处理\n if (x >= chartX && x <= chartX + chartWidth && y >= chartY && y <= chartY + chartHeight) {\n return true;\n }\n\n return false;\n }\n\n private _isPointerOnTooltip(params: BaseEventParams): boolean {\n // TODO:后续支持 renderMode === 'canvas' 场景\n if (this._spec.enterable && this._spec.renderMode === 'html') {\n const { event } = params;\n let target: any;\n if (isValid(event.nativeEvent)) {\n // get native event object\n const nativeEvent = event.nativeEvent as Event;\n target = nativeEvent.target;\n // if in shadow DOM use composedPath to access target\n if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {\n target = nativeEvent.composedPath()[0];\n }\n } else {\n target = event.target;\n }\n\n const container = this.tooltipHandler?.getTooltipContainer?.();\n if (isValid(container) && isValid(target) && hasParentElement(target, container)) {\n return true;\n }\n }\n return false;\n }\n\n getVisible() {\n return this._spec.visible === true;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/tooltip.ts"],"names":[],"mappings":";;;AAEA,4CAAiD;AAGjD,kCAAwC;AAGxC,uCAAoE;AAEpE,qCAUoB;AACpB,2CAQqB;AACrB,mDAA4D;AAE5D,mCAA8E;AAC9E,4DAAwE;AACxE,6CAAmF;AAGnF,2CAA2G;AAC3G,6CAA8D;AAC9D,8CAA2C;AAc3C,MAAa,OAAQ,SAAQ,oBAAkB;IAA/C;;QAEE,SAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC;QACjC,SAAI,GAAW,6BAAiB,CAAC,OAAO,CAAC;QAEzC,eAAU,GAA8B,UAAU,CAAC;QAqB3C,gBAAW,GAAY,KAAK,CAAC;QAI7B,eAAU,GAAqB,EAAE,CAAC;QAMhC,oBAAe,GAAY,KAAK,CAAC;QAkGjC,gBAAW,GAAG,CAAC,KAAgB,EAAE,KAAiB,EAAE,QAA4B,EAAE,EAAE;YAC5F,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACnB,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,CAAC,CAAC;QAEQ,wBAAmB,GAAG,CAAC,oBAA8B,EAAE,EAAE,CAAC,CAAC,MAAuB,EAAE,EAAE;;YAC9F,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO;aACR;YAED,IAAI,CAAC,IAAI,C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DAAI,CAAC;YAC/D,IAAI,IAAA,cAAO,EAAC,SAAS,CAAC,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,IAAI,IAAA,yBAAgB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE;gBAChF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACrC,CAAC;;AAteH,0BAueC;AAteQ,YAAI,GAAG,6BAAiB,CAAC,OAAO,CAAC","file":"tooltip.js","sourcesContent":["import type { IComponentOption } from '../interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { ComponentTypeEnum } from '../interface';\nimport type { IModelLayoutOption, IModelRenderOption, ILayoutItem } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport { BaseComponent } from '../base';\nimport type { BaseEventParams, EventCallback, EventQuery, EventType } from '../../event/interface';\nimport type { ITooltipHandler, IToolTipLineActual, TooltipActiveType } from '../../typings/tooltip';\nimport { DomTooltipHandler, CanvasTooltipHandler } from './handler';\nimport type { Datum, IPoint, IShowTooltipOption } from '../../typings';\nimport {\n cloneDeep,\n isArray,\n isValid,\n mergeSpec,\n isMobileLikeMode,\n isTrueBrowser,\n isNil,\n isMiniAppLikeMode,\n domDocument\n} from '../../util';\nimport {\n TooltipResult,\n type ITooltip,\n type ITooltipActiveTypeAsKeys,\n type ITooltipSpec,\n type ITooltipTheme,\n type TooltipHandlerParams,\n type TotalMouseEventData\n} from './interface';\nimport { TOOLTIP_EL_CLASS_NAME } from './handler/constants';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTooltipActualActiveType, showTooltip, isEmptyPos } from './utils';\nimport { isSameDimensionInfo } from '../../event/events/dimension/util';\nimport { ChartEvent, Event_Bubble_Level, Event_Source_Type } from '../../constant';\nimport type { DimensionTooltipInfo, MarkTooltipInfo, TooltipInfo } from './processor';\n// eslint-disable-next-line no-duplicate-imports\nimport { isDimensionInfo, isMarkInfo, MarkTooltipProcessor, DimensionTooltipProcessor } from './processor';\nimport { hasParentElement, isString } from '@visactor/vutils';\nimport { VChart } from '../../core/vchart';\nimport type { TooltipEventParams } from './interface/event';\nimport type { IGroup } from '@visactor/vrender';\n\nexport type TooltipActualTitleContent = {\n title?: IToolTipLineActual;\n content?: IToolTipLineActual[];\n};\n\ntype EventHandlerList = {\n eventType: EventType;\n handler: any;\n}[];\n\nexport class Tooltip extends BaseComponent<any> implements ITooltip {\n static type = ComponentTypeEnum.tooltip;\n type = ComponentTypeEnum.tooltip;\n name: string = ComponentTypeEnum.tooltip;\n\n layoutType: ILayoutItem['layoutType'] = 'absolute';\n\n protected declare _spec: ITooltipSpec;\n\n static createComponent(spec: any, options: IComponentOption) {\n const tooltipSpec = spec.tooltip;\n if (!tooltipSpec) {\n return null;\n }\n if (!isArray(tooltipSpec)) {\n return new Tooltip(tooltipSpec, { ...options, specKey: 'tooltip' });\n }\n const tooltips: Tooltip[] = [];\n tooltipSpec.forEach((s: any, i: number) => {\n tooltips.push(new Tooltip(s, { ...options, specIndex: i, specKey: 'tooltip' }));\n });\n return tooltips;\n }\n\n tooltipHandler?: ITooltipHandler;\n\n private _alwaysShow: boolean = false;\n\n private _cacheInfo: TooltipInfo | undefined;\n\n private _eventList: EventHandlerList = [];\n\n protected declare _theme: ITooltipTheme;\n\n protected _processor: ITooltipActiveTypeAsKeys<MarkTooltipProcessor, DimensionTooltipProcessor>;\n\n protected _isTooltipShown: boolean = false;\n /** 当前是否正在显示 tooltip */\n isTooltipShown() {\n return this._isTooltipShown;\n }\n\n changeRegions(regions: IRegion[]) {\n /* do nothing */\n }\n getVRenderComponents(): IGroup[] {\n return [];\n }\n protected _registerEvent() {\n /* do nothing */\n }\n protected _releaseEvent() {\n /* do nothing */\n }\n onLayout(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onLayoutEnd(ctx: IModelLayoutOption) {\n /* do nothing */\n }\n onRender(ctx: IModelRenderOption) {\n /* do nothing */\n }\n\n created() {\n super.created();\n this._regions = this._option.getAllRegions();\n // event\n this._initEvent();\n }\n\n release() {\n super.release();\n\n this._eventList.forEach(({ eventType, handler }) => {\n this.event.off(eventType, handler);\n });\n this._eventList = [];\n this.tooltipHandler?.release?.();\n this._isTooltipShown = false;\n }\n\n beforeRelease() {\n // 触发事件\n this.event.emit(ChartEvent.tooltipHide, {\n tooltip: this\n } as unknown as TooltipEventParams);\n this.event.emit(ChartEvent.tooltipRelease, {\n tooltip: this\n } as unknown as TooltipEventParams);\n }\n\n protected _initHandler() {\n const renderMode = this._spec.renderMode ?? 'html';\n\n const userTooltipHandler = this._option.globalInstance.getTooltipHandlerByUser();\n if (userTooltipHandler) {\n this.tooltipHandler = userTooltipHandler;\n } else {\n // 构造内部默认 handler\n const Handler = renderMode === 'canvas' ? CanvasTooltipHandler : DomTooltipHandler;\n const id = `${this._spec.className}-${this._option.globalInstance.id ?? 0}-${this._option.specIndex ?? 0}`;\n this.tooltipHandler = new Handler(id, this);\n }\n }\n\n protected _initProcessor() {\n // 初始化 tooltip 类型\n this._processor = {\n mark: new MarkTooltipProcessor(this),\n dimension: new DimensionTooltipProcessor(this)\n };\n }\n\n protected _initEvent() {\n const trigger = this._spec.trigger ?? 'hover';\n // TODO: triggerOff完整支持\n // const triggerOff = this._spec.triggerOff ?? trigger;\n const mode = this._option.mode;\n\n if (trigger === 'hover') {\n this._mountEvent('pointermove', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n // 移动端的点按 + 滑动触发\n if (isMobileLikeMode(mode) || isMiniAppLikeMode(mode)) {\n this._mountEvent('pointerdown', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._getMouseOutHandler(true));\n }\n this._mountEvent('pointerout', { source: 'canvas' }, this._getMouseOutHandler(false));\n } else if (trigger === 'click') {\n this._mountEvent('pointertap', { level: Event_Bubble_Level.chart }, this._handleMouseMove);\n this._mountEvent('pointerup', { source: 'window' }, this._getMouseOutHandler(true));\n }\n }\n\n protected _mountEvent = (eType: EventType, query: EventQuery, callback: EventCallback<any>) => {\n this.event.on(eType, query, callback);\n this._eventList.push({\n eventType: eType,\n handler: callback\n });\n };\n\n protected _getMouseOutHandler = (needPointerDetection?: boolean) => (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (!this._isTooltipShown && !this.tooltipHandler?.isTooltipShown?.()) {\n return;\n }\n\n const browserEnv = isTrueBrowser(this._option.mode);\n const { clientX, clientY } = params.event as MouseEvent;\n\n // 当 enterable 为 true,同时鼠标移入 tooltip 时 pointerleave 事件也会触发,所以这里做一个判断\n if (browserEnv && this._isPointerOnTooltip(params)) {\n return;\n }\n\n // 判断鼠标是否在图表范围内\n if (browserEnv && needPointerDetection && this._isPointerInChart({ x: clientX, y: clientY })) {\n return;\n }\n\n this._handleChartMouseOut(params);\n };\n\n protected _handleChartMouseOut = (params: BaseEventParams) => {\n if (this._alwaysShow) {\n return;\n }\n\n if (this._spec.triggerOff !== 'none') {\n this._hideTooltipByHandler({\n ...params\n });\n this._cacheInfo = undefined;\n }\n };\n\n protected _handleMouseMove = (params: BaseEventParams) => {\n if (!this.tooltipHandler) {\n this._initHandler();\n }\n\n if (!this._processor) {\n this._initProcessor();\n }\n\n if (this._alwaysShow) {\n return;\n }\n if (this._isPointerOnTooltip(params)) {\n return;\n }\n\n /* 获取 tooltip 原始数据 */\n const mouseEventData = this._getMouseEventData(params);\n const {\n tooltipInfo: { dimension: dimensionInfo },\n ignore: { mark: ignoreMark, dimension: ignoreDimension }\n } = mouseEventData;\n\n let markTooltipSuccess: boolean = false;\n let dimensionTooltipSuccess: boolean = false;\n\n /* 显示常规tooltip */\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params);\n if (!markTooltipSuccess) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n\n /* 如果不是常规情况,进行一些特殊情况tooltip处理 */\n if (!markTooltipSuccess && !dimensionTooltipSuccess && !isEmptyPos(params)) {\n // 用户手动配置ignore,则继续显示缓存tooltip\n if (ignoreMark && isMarkInfo(this._cacheInfo)) {\n markTooltipSuccess = this._showTooltipByMouseEvent('mark', mouseEventData, params, true);\n } else if (ignoreDimension && isDimensionInfo(this._cacheInfo)) {\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params, true);\n } else if (isValid(dimensionInfo)) {\n // 用户没有手动配置ignore的话,默认显示dimension tooltip\n dimensionTooltipSuccess = this._showTooltipByMouseEvent('dimension', mouseEventData, params);\n }\n }\n\n /* 如果还是不应该显示tooltip,则隐藏上一次tooltip */\n if (!markTooltipSuccess && (!dimensionTooltipSuccess || isNil(dimensionInfo))) {\n this._handleChartMouseOut(params);\n }\n };\n\n /**\n * 通过鼠标事件触发 tooltip,返回是否成功\n * @param activeType tooltip 类型\n * @param mouseEventData tooltip 相关数据\n * @param params 事件参数\n * @param useCache 是否直接显示缓存 tooltip\n * @returns 是否成功执行\n */\n protected _showTooltipByMouseEvent = (\n activeType: TooltipActiveType,\n mouseEventData: TotalMouseEventData,\n params: BaseEventParams,\n useCache?: boolean\n ): boolean => {\n const processor = this._processor[activeType];\n // 判断是否应该触发 tooltip\n if (\n !processor.shouldHandleTooltip(params, {\n tooltipInfo: mouseEventData.tooltipInfo[activeType],\n ignore: mouseEventData.ignore[activeType]\n })\n ) {\n return false;\n }\n\n let success: boolean;\n if (useCache) {\n // 直接显示缓存 tooltip\n success = !processor.showTooltip(this._cacheInfo as any, params, true);\n } else {\n const tooltipInfo = mouseEventData.tooltipInfo[activeType];\n const isSameAsCache = this._isSameAsCacheInfo(tooltipInfo);\n success = !processor.showTooltip(tooltipInfo as any, params, isSameAsCache);\n if (success) {\n // 成功显示 tooltip,则更新缓存\n this._cacheInfo = tooltipInfo;\n }\n }\n if (success) {\n this._isTooltipShown = true;\n }\n // 全局唯一 tooltip\n const vchart = this._option.globalInstance;\n if (success && VChart.globalConfig.uniqueTooltip) {\n VChart.hideTooltip(vchart.id);\n }\n return success;\n };\n\n protected _getMouseEventData = (params: BaseEventParams): TotalMouseEventData => {\n const result: TotalMouseEventData = {\n tooltipInfo: {},\n ignore: {}\n };\n Object.keys(this._processor).forEach(activeType => {\n const { tooltipInfo, ignore } = this._processor[activeType].getMouseEventData(params);\n result.tooltipInfo[activeType] = tooltipInfo;\n result.ignore[activeType] = ignore;\n });\n return result;\n };\n\n protected _hideTooltipByHandler = (params: TooltipHandlerParams): TooltipResult => {\n if (!this._isTooltipShown && !this.tooltipHandler?.isTooltipShown?.()) {\n // 如果当前 tooltip 未显示,则提前退出\n return TooltipResult.success;\n }\n this.event.emit(ChartEvent.tooltipHide, {\n ...params,\n source: Event_Source_Type.chart, // 统一 event 的来源\n tooltip: this\n });\n if (this.tooltipHandler?.hideTooltip) {\n const result = this.tooltipHandler.hideTooltip(params);\n if (!result) {\n this._isTooltipShown = false;\n }\n return result;\n }\n return TooltipResult.failed;\n };\n\n protected _initTheme(theme?: any) {\n super._initTheme(theme);\n this._spec.style = this._prepareSpecAfterMergingTheme(mergeSpec({}, this._theme, this._originalSpec.style));\n }\n\n protected _shouldMergeThemeToSpec() {\n return false;\n }\n\n reInit(theme?: any) {\n super.reInit(theme);\n\n if (this.tooltipHandler) {\n this.tooltipHandler.reInit?.();\n } else {\n this._initHandler();\n }\n }\n\n setAttrFromSpec() {\n super.setAttrFromSpec();\n const userSpec = this._spec as ITooltipSpec;\n this._spec = {\n ...userSpec,\n visible: isValid(userSpec.visible) ? userSpec.visible : true,\n activeType: getTooltipActualActiveType(userSpec),\n renderMode: 'html',\n trigger: isValid(userSpec.trigger) ? userSpec.trigger : 'hover',\n className: isValid(userSpec.className) ? userSpec.className : TOOLTIP_EL_CLASS_NAME,\n enterable: isValid(userSpec.enterable) ? userSpec.enterable : false,\n transitionDuration: isValid(userSpec.transitionDuration) ? userSpec.transitionDuration : 150\n } as ITooltipSpec;\n this._spec.triggerOff = isValid(userSpec.triggerOff) ? userSpec.triggerOff : this._spec.trigger;\n\n if (isValid(userSpec.renderMode)) {\n this._spec.renderMode = userSpec.renderMode;\n } else if (isMiniAppLikeMode(this._option.mode)) {\n // 小程序环境下,默认使用canvas渲染\n this._spec.renderMode = 'canvas';\n }\n\n if (isValid(userSpec.mark)) {\n this._spec.mark = {\n ...cloneDeep(userSpec.mark),\n activeType: 'mark'\n };\n }\n if (isValid(userSpec.dimension)) {\n this._spec.dimension = {\n ...cloneDeep(userSpec.dimension),\n activeType: 'dimension'\n };\n }\n\n if (isValid(userSpec.parentElement)) {\n if (isString(userSpec.parentElement)) {\n this._spec.parentElement = globalThis.document?.getElementById(userSpec.parentElement);\n } else {\n this._spec.parentElement = userSpec.parentElement;\n }\n } else if (isTrueBrowser(this._option.mode)) {\n this._spec.parentElement = domDocument?.body;\n }\n\n if (isValid(userSpec.confine)) {\n this._spec.confine = userSpec.confine;\n } else {\n this._spec.confine = this._spec.renderMode === 'canvas';\n }\n }\n\n showTooltip(datum: Datum, options: IShowTooltipOption) {\n if (!this.tooltipHandler) {\n this._initHandler();\n }\n\n if (!this._processor) {\n this._initProcessor();\n }\n\n if (!this.tooltipHandler?.showTooltip) {\n return false;\n }\n const result = showTooltip(datum, options, this.tooltipHandler, this._option);\n if (result !== 'none') {\n this._alwaysShow = !!options?.alwaysShow;\n }\n return result;\n }\n\n /** 手动隐藏 tooltip,返回是否成功 */\n hideTooltip(): boolean {\n const params: TooltipHandlerParams = {\n changePositionOnly: false,\n item: undefined,\n datum: undefined,\n source: Event_Source_Type.chart\n } as any;\n\n this._alwaysShow = false;\n return !this._hideTooltipByHandler(params);\n }\n\n private _isSameAsCacheInfo(nextInfo?: TooltipInfo): boolean {\n if (nextInfo === this._cacheInfo) {\n return true;\n }\n if (isNil(this._cacheInfo) || isNil(nextInfo)) {\n return false;\n }\n\n if (isDimensionInfo(nextInfo)) {\n if (isMarkInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as DimensionTooltipInfo;\n return prevInfo.length === nextInfo.length && nextInfo.every((info, i) => isSameDimensionInfo(info, prevInfo[i]));\n }\n if (isDimensionInfo(this._cacheInfo)) {\n return false;\n }\n\n const prevInfo = this._cacheInfo as MarkTooltipInfo;\n return (\n nextInfo?.datum === prevInfo.datum && nextInfo?.mark === prevInfo.mark && nextInfo?.series === prevInfo.series\n );\n }\n\n private _isPointerInChart(point: IPoint): boolean {\n const globalInstance = this._option.globalInstance;\n const chart = globalInstance.getChart();\n if (!chart) {\n return false;\n }\n const { x, y } = point;\n const canvas = globalInstance.getCanvas();\n const { x: chartX, y: chartY, width: chartWidth, height: chartHeight } = canvas.getBoundingClientRect();\n // 鼠标仍在图表范围内,则不处理\n if (x >= chartX && x <= chartX + chartWidth && y >= chartY && y <= chartY + chartHeight) {\n return true;\n }\n\n return false;\n }\n\n private _isPointerOnTooltip(params: BaseEventParams): boolean {\n // TODO:后续支持 renderMode === 'canvas' 场景\n if (this._spec.enterable && this._spec.renderMode === 'html') {\n const { event } = params;\n let target: any;\n if (isValid(event.nativeEvent)) {\n // get native event object\n const nativeEvent = event.nativeEvent as Event;\n target = nativeEvent.target;\n // if in shadow DOM use composedPath to access target\n if (nativeEvent.composedPath && nativeEvent.composedPath().length > 0) {\n target = nativeEvent.composedPath()[0];\n }\n } else {\n target = event.target;\n }\n\n const container = this.tooltipHandler?.getTooltipContainer?.();\n if (isValid(container) && isValid(target) && hasParentElement(target, container)) {\n return true;\n }\n }\n return false;\n }\n\n getVisible() {\n return this._spec.visible === true;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { VChart } from './vchart';
2
2
  import { Factory } from './factory';
3
3
  export { VChart, Factory };
4
- export declare const version = "1.4.2-beta.1";
4
+ export declare const version = "1.4.2";
5
5
  export type { IVChart } from './interface';
6
6
  export * from '../event/interface';
7
7
  export * from '../typings/spec/common';
package/cjs/core/index.js CHANGED
@@ -41,7 +41,7 @@ const region_1 = require("../region/region"), base_layout_1 = require("../layout
41
41
 
42
42
  vchart_1.VChart.useMark([ component_1.ComponentMark, group_1.GroupMark, image_1.ImageMark ]),
43
43
  factory_1.Factory.registerRegion("region", region_1.Region), factory_1.Factory.registerLayout("base", base_layout_1.Layout),
44
- exports.version = "1.4.2-beta.1", __exportStar(require("../event/interface"), exports),
44
+ exports.version = "1.4.2", __exportStar(require("../event/interface"), exports),
45
45
  __exportStar(require("../typings/spec/common"), exports), __exportStar(require("../theme/interface"), exports),
46
46
  vutils_1.Logger.getInstance(vutils_1.LoggerLevel.Error);
47
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAAuD;AAKvD,qCAAkC;AAiBzB,uFAjBA,eAAM,OAiBA;AAhBf,uCAAoC;AAgBnB,wFAhBR,iBAAO,OAgBQ;AAfxB,6CAA0C;AAC1C,uDAA+C;AAC/C,yCAA0C;AAC1C,iDAAkD;AAClD,yCAA0C;AAG1C,eAAM,CAAC,OAAO,CAAC,CAAC,yBAAa,EAAE,iBAAS,EAAE,iBAAS,CAAC,CAAC,CAAC;AAGtD,iBAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAa,CAAC,CAAC;AAGhD,iBAAO,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAa,CAAC,CAAC;AAKjC,QAAA,OAAO,GAAG,cAAc,CAAC;AAKtC,qDAAmC;AACnC,yDAAuC;AAEvC,qDAAmC;AAGnC,eAAM,CAAC,WAAW,CAAC,oBAAW,CAAC,KAAK,CAAC,CAAC","file":"index.js","sourcesContent":["import { Logger, LoggerLevel } from '@visactor/vutils';\n/**\n * @description The core module of VChart, containing the necessary interfaces for using VChart.\n */\n\nimport { VChart } from './vchart';\nimport { Factory } from './factory';\nimport { Region } from '../region/region';\nimport { Layout } from '../layout/base-layout';\nimport { GroupMark } from '../mark/group';\nimport { ComponentMark } from '../mark/component';\nimport { ImageMark } from '../mark/image';\n\n// register groupMark and componentMark\nVChart.useMark([ComponentMark, GroupMark, ImageMark]);\n\n// install region module\nFactory.registerRegion('region', Region as any);\n\n// install layout module\nFactory.registerLayout('base', Layout as any);\n\nexport { VChart, Factory };\n\n// export the version\nexport const version = \"1.4.2-beta.1\";\n\n// export necessary types\nexport type { IVChart } from './interface';\n// the event types\nexport * from '../event/interface';\nexport * from '../typings/spec/common';\nexport type { IStateSpec, StateValueType } from '../compile/mark';\nexport * from '../theme/interface';\n\n// set default logger level to Level.error\nLogger.getInstance(LoggerLevel.Error);\n"]}
1
+ {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAAuD;AAKvD,qCAAkC;AAiBzB,uFAjBA,eAAM,OAiBA;AAhBf,uCAAoC;AAgBnB,wFAhBR,iBAAO,OAgBQ;AAfxB,6CAA0C;AAC1C,uDAA+C;AAC/C,yCAA0C;AAC1C,iDAAkD;AAClD,yCAA0C;AAG1C,eAAM,CAAC,OAAO,CAAC,CAAC,yBAAa,EAAE,iBAAS,EAAE,iBAAS,CAAC,CAAC,CAAC;AAGtD,iBAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAa,CAAC,CAAC;AAGhD,iBAAO,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAa,CAAC,CAAC;AAKjC,QAAA,OAAO,GAAG,OAAO,CAAC;AAK/B,qDAAmC;AACnC,yDAAuC;AAEvC,qDAAmC;AAGnC,eAAM,CAAC,WAAW,CAAC,oBAAW,CAAC,KAAK,CAAC,CAAC","file":"index.js","sourcesContent":["import { Logger, LoggerLevel } from '@visactor/vutils';\n/**\n * @description The core module of VChart, containing the necessary interfaces for using VChart.\n */\n\nimport { VChart } from './vchart';\nimport { Factory } from './factory';\nimport { Region } from '../region/region';\nimport { Layout } from '../layout/base-layout';\nimport { GroupMark } from '../mark/group';\nimport { ComponentMark } from '../mark/component';\nimport { ImageMark } from '../mark/image';\n\n// register groupMark and componentMark\nVChart.useMark([ComponentMark, GroupMark, ImageMark]);\n\n// install region module\nFactory.registerRegion('region', Region as any);\n\n// install layout module\nFactory.registerLayout('base', Layout as any);\n\nexport { VChart, Factory };\n\n// export the version\nexport const version = \"1.4.2\";\n\n// export necessary types\nexport type { IVChart } from './interface';\n// the event types\nexport * from '../event/interface';\nexport * from '../typings/spec/common';\nexport type { IStateSpec, StateValueType } from '../compile/mark';\nexport * from '../theme/interface';\n\n// set default logger level to Level.error\nLogger.getInstance(LoggerLevel.Error);\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const VCHART_UTILS: {
2
+ measureText: (text: string, textSpec?: Partial<import("@visactor/vrender").ITextGraphicAttribute>, option?: Partial<import("@visactor/vutils").ITextMeasureOption>, useNaiveCanvas?: boolean) => import("@visactor/vutils").ITextSize;
3
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.VCHART_UTILS = void 0;
6
+
7
+ const util_1 = require("../util");
8
+
9
+ exports.VCHART_UTILS = {
10
+ measureText: util_1.measureText
11
+ };
12
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/util.ts"],"names":[],"mappings":";;;AAAA,kCAAsC;AAGzB,QAAA,YAAY,GAAG;IAC1B,WAAW,EAAX,kBAAW;CACZ,CAAC","file":"util.js","sourcesContent":["import { measureText } from '../util';\n\n/** 存放一些业务方可能会在扩展功能里用到的工具方法 */\nexport const VCHART_UTILS = {\n measureText\n};\n"]}
@@ -38,6 +38,9 @@ export declare class VChart implements IVChart {
38
38
  static readonly InstanceManager: typeof InstanceManager;
39
39
  static readonly ThemeManager: typeof ThemeManager;
40
40
  static globalConfig: IGlobalConfig;
41
+ static readonly Utils: {
42
+ measureText: (text: string, textSpec?: Partial<import("@visactor/vrender").ITextGraphicAttribute>, option?: Partial<import("@visactor/vutils").ITextMeasureOption>, useNaiveCanvas?: boolean) => import("@visactor/vutils").ITextSize;
43
+ };
41
44
  protected _spec: any;
42
45
  private _viewBox;
43
46
  private _chart;
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", {
38
38
  value: !0
39
39
  }), exports.VChart = void 0;
40
40
 
41
- const array_1 = require("../data/parser/array"), common_1 = require("../typings/spec/common"), interface_1 = require("../component/interface"), vdataset_1 = require("@visactor/vdataset"), util_1 = require("../util"), factory_1 = require("./factory"), event_1 = require("../event/event"), event_dispatcher_1 = require("../event/event-dispatcher"), geo_source_1 = require("../series/map/geo-source"), register_1 = require("../data/register"), initialize_1 = require("../data/initialize"), stack_split_1 = require("../data/transforms/stack-split"), copy_data_view_1 = require("../data/transforms/copy-data-view"), interface_2 = require("../animation/interface"), theme_manager_1 = require("../theme/theme-manager"), compiler_1 = require("../compile/compiler"), image_1 = require("../util/image"), constant_1 = require("../constant"), vutils_1 = require("@visactor/vutils"), instance_manager_1 = require("./instance-manager"), vrender_components_1 = require("@visactor/vrender-components"), util_2 = require("../chart/util");
41
+ const array_1 = require("../data/parser/array"), common_1 = require("../typings/spec/common"), interface_1 = require("../component/interface"), vdataset_1 = require("@visactor/vdataset"), util_1 = require("../util"), factory_1 = require("./factory"), event_1 = require("../event/event"), event_dispatcher_1 = require("../event/event-dispatcher"), geo_source_1 = require("../series/map/geo-source"), register_1 = require("../data/register"), initialize_1 = require("../data/initialize"), stack_split_1 = require("../data/transforms/stack-split"), copy_data_view_1 = require("../data/transforms/copy-data-view"), interface_2 = require("../animation/interface"), theme_manager_1 = require("../theme/theme-manager"), compiler_1 = require("../compile/compiler"), image_1 = require("../util/image"), constant_1 = require("../constant"), vutils_1 = require("@visactor/vutils"), instance_manager_1 = require("./instance-manager"), vrender_components_1 = require("@visactor/vrender-components"), util_2 = require("../chart/util"), util_3 = require("./util");
42
42
 
43
43
  class VChart {
44
44
  static useChart(charts) {
@@ -713,5 +713,5 @@ class VChart {
713
713
  exports.VChart = VChart, VChart.InstanceManager = instance_manager_1.InstanceManager,
714
714
  VChart.ThemeManager = theme_manager_1.ThemeManager, VChart.globalConfig = {
715
715
  uniqueTooltip: !0
716
- };
716
+ }, VChart.Utils = util_3.VCHART_UTILS;
717
717
  //# sourceMappingURL=vchart.js.map