@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
package/build/index.js CHANGED
@@ -14723,10 +14723,10 @@
14723
14723
  lineEnd() {
14724
14724
  switch (this._point) {
14725
14725
  case 2:
14726
- this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined2, this.lastPoint1);
14726
+ this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
14727
14727
  break;
14728
14728
  case 3:
14729
- point$2(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined2, this.lastPoint1);
14729
+ point$2(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
14730
14730
  }
14731
14731
  (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line = 1 - this._line;
14732
14732
  }
@@ -57268,6 +57268,9 @@
57268
57268
  fontSize: THEME_CONSTANTS.defaultFontSize
57269
57269
  });
57270
57270
  };
57271
+ const measureText = (text, textSpec, option, useNaiveCanvas) => {
57272
+ return initTextMeasure(textSpec, option, useNaiveCanvas).measure(text);
57273
+ };
57271
57274
 
57272
57275
  function mergeFields(targetFields, mergeFields) {
57273
57276
  for (let i = 0; i < mergeFields.length; i++) {
@@ -59329,6 +59332,10 @@
59329
59332
  return resultA;
59330
59333
  }
59331
59334
 
59335
+ const VCHART_UTILS = {
59336
+ measureText
59337
+ };
59338
+
59332
59339
  class VChart {
59333
59340
  static useChart(charts) {
59334
59341
  charts.forEach(c => Factory.registerChart(c.type, c));
@@ -60318,6 +60325,7 @@
60318
60325
  VChart.globalConfig = {
60319
60326
  uniqueTooltip: true
60320
60327
  };
60328
+ VChart.Utils = VCHART_UTILS;
60321
60329
 
60322
60330
  var STATE_VALUE_ENUM;
60323
60331
  (function (STATE_VALUE_ENUM) {
@@ -61114,6 +61122,8 @@
61114
61122
  }
61115
61123
  onDataUpdate() {
61116
61124
  }
61125
+ beforeRelease() {
61126
+ }
61117
61127
  release() {
61118
61128
  var _a;
61119
61129
  this._releaseEvent();
@@ -63462,7 +63472,7 @@
63462
63472
  VChart.useMark([ComponentMark, GroupMark, ImageMark]);
63463
63473
  Factory.registerRegion('region', Region);
63464
63474
  Factory.registerLayout('base', Layout);
63465
- const version = "1.4.2-beta.1";
63475
+ const version = "1.4.2";
63466
63476
  Logger.getInstance(LoggerLevel.Error);
63467
63477
 
63468
63478
  const WordCloud3dAnimation = (params) => {
@@ -68423,6 +68433,9 @@
68423
68433
  (_d = (_c = this._option.performanceHook) === null || _c === void 0 ? void 0 : _c.afterComponentCompile) === null || _d === void 0 ? void 0 : _d.call(_c);
68424
68434
  }
68425
68435
  release() {
68436
+ [...this._components, ...this._regions, ...this._series].forEach(m => {
68437
+ m.beforeRelease();
68438
+ });
68426
68439
  super.release();
68427
68440
  this.clear();
68428
68441
  [...this._components, ...this._regions, ...this._series].forEach(m => {
@@ -71963,9 +71976,8 @@
71963
71976
  _buildMarkAttributeContext() {
71964
71977
  super._buildMarkAttributeContext();
71965
71978
  this._markAttributeContext.valueToPosition = this.valueToPosition.bind(this);
71966
- this._markAttributeContext.getCenter = () => {
71967
- return this.angleAxisHelper.center();
71968
- };
71979
+ this._markAttributeContext.getCenter = () => this.angleAxisHelper.center();
71980
+ this._markAttributeContext.getLayoutRadius = () => this._computeLayoutRadius();
71969
71981
  }
71970
71982
  valueToPosition(angleValue, radiusValue) {
71971
71983
  if (isNil$1(angleValue) || isNil$1(radiusValue) || !this.angleAxisHelper || !this.radiusAxisHelper) {
@@ -84013,23 +84025,23 @@
84013
84025
  return undefined;
84014
84026
  }
84015
84027
  _autoUpdate(rect) {
84016
- var _a, _b, _c, _d;
84028
+ var _a, _b, _c, _d, _e;
84017
84029
  if (!this._auto) {
84018
84030
  return true;
84019
84031
  }
84020
84032
  const axisSpec = (_a = this._relatedAxisComponent) === null || _a === void 0 ? void 0 : _a.getSpec();
84021
84033
  const bandSizeResult = this._getAxisBandSize(axisSpec);
84022
84034
  const { bandSize, maxBandSize, minBandSize } = bandSizeResult !== null && bandSizeResult !== void 0 ? bandSizeResult : {};
84023
- if ((rect === null || rect === void 0 ? void 0 : rect.height) === ((_b = this._cacheRect) === null || _b === void 0 ? void 0 : _b.height) &&
84024
- (rect === null || rect === void 0 ? void 0 : rect.width) === ((_c = this._cacheRect) === null || _c === void 0 ? void 0 : _c.width) &&
84025
- this._fixedBandSize === bandSize) {
84026
- return this._cacheVisibility;
84027
- }
84028
- this._cacheRect = rect;
84029
84035
  let isShown = true;
84030
84036
  const scale = this._stateScale;
84031
84037
  scale.range(this._isHorizontal ? [0, rect.width] : axisSpec.inverse ? [0, rect.height] : [rect.height, 0]);
84032
84038
  if (isDiscrete(scale.type)) {
84039
+ if ((rect === null || rect === void 0 ? void 0 : rect.height) === ((_b = this._cacheRect) === null || _b === void 0 ? void 0 : _b.height) &&
84040
+ (rect === null || rect === void 0 ? void 0 : rect.width) === ((_c = this._cacheRect) === null || _c === void 0 ? void 0 : _c.width) &&
84041
+ this._fixedBandSize === bandSize) {
84042
+ return this._cacheVisibility;
84043
+ }
84044
+ this._cacheRect = rect;
84033
84045
  if (bandSizeResult) {
84034
84046
  if (this._start || this._end) {
84035
84047
  scale.rangeFactor([this._start, this._end], true);
@@ -84064,6 +84076,17 @@
84064
84076
  this._start = start;
84065
84077
  this._end = end;
84066
84078
  }
84079
+ else {
84080
+ const [start, end] = (_e = scale.rangeFactor()) !== null && _e !== void 0 ? _e : [this._start, this._end];
84081
+ if (start === 0 && end === 1) {
84082
+ this.hide();
84083
+ isShown = false;
84084
+ }
84085
+ else {
84086
+ this.show();
84087
+ isShown = true;
84088
+ }
84089
+ }
84067
84090
  this.setStartAndEnd(this._start, this._end);
84068
84091
  this._cacheVisibility = isShown;
84069
84092
  return isShown;
@@ -84486,11 +84509,11 @@
84486
84509
  this.layoutLevel = LayoutLevel.CustomMark;
84487
84510
  }
84488
84511
  static createComponent(spec, options) {
84489
- const titleSpec = spec.customMark;
84490
- if (!titleSpec) {
84512
+ const customMarkSpec = spec.customMark;
84513
+ if (!customMarkSpec) {
84491
84514
  return null;
84492
84515
  }
84493
- return [new CustomMark(spec.customMark, Object.assign(Object.assign({}, options), { specIndex: 0, specKey: 'customMark' }))];
84516
+ return [new CustomMark(customMarkSpec, Object.assign(Object.assign({}, options), { specIndex: 0, specKey: 'customMark' }))];
84494
84517
  }
84495
84518
  created() {
84496
84519
  super.created();
@@ -84570,9 +84593,8 @@
84570
84593
  this._linkedInBrushElementsMap = {};
84571
84594
  this._linkedOutOfBrushElementsMap = {};
84572
84595
  this._needInitOutState = true;
84573
- this._isFirstState = true;
84574
84596
  this._cacheInteractiveRangeAttrs = [];
84575
- this._needEnablePickable = true;
84597
+ this._needEnablePickable = false;
84576
84598
  }
84577
84599
  static createComponent(spec, options) {
84578
84600
  const brushSpec = spec.brush || options.defaultSpec;
@@ -84638,11 +84660,19 @@
84638
84660
  this._brushComponents.push(brush);
84639
84661
  this._cacheInteractiveRangeAttrs.push(interactiveAttr);
84640
84662
  brush.setUpdateDragMaskCallback((operateParams) => {
84663
+ var _a, _b, _c;
84641
84664
  const { operateType, operateMask } = operateParams;
84642
- if (this._isFirstState ||
84643
- (this._needInitOutState && brushMode === 'single' && operateType === IOperateType.drawing)) {
84665
+ let operateTypeCache = operateType;
84666
+ if (this._needInitOutState && brushMode === 'single' && operateType === IOperateType.drawing) {
84644
84667
  this._initMarkBrushState(componentIndex, 'outOfBrush');
84645
84668
  }
84669
+ (_c = (_b = (_a = this._option) === null || _a === void 0 ? void 0 : _a.getChart()) === null || _b === void 0 ? void 0 : _b.getEvent()) === null || _c === void 0 ? void 0 : _c.on('click', p => {
84670
+ if (!p.mark && operateTypeCache === IOperateType.brushClear) {
84671
+ this._initMarkBrushState(componentIndex, '');
84672
+ this._needInitOutState = true;
84673
+ operateTypeCache = null;
84674
+ }
84675
+ });
84646
84676
  if (operateType === IOperateType.drawing) {
84647
84677
  this._needInitOutState = false;
84648
84678
  this._needEnablePickable = true;
@@ -84651,10 +84681,6 @@
84651
84681
  this._needInitOutState = true;
84652
84682
  this._needEnablePickable = false;
84653
84683
  }
84654
- if (operateType === IOperateType.brushClear) {
84655
- this._initMarkBrushState(componentIndex, '');
84656
- this._needInitOutState = true;
84657
- }
84658
84684
  this._reconfigItem(operateMask, region);
84659
84685
  this._reconfigLinkedItem(operateMask, region);
84660
84686
  let eventType = ChartEvent.brushChange;
@@ -84903,7 +84929,6 @@
84903
84929
  });
84904
84930
  });
84905
84931
  });
84906
- this._isFirstState = false;
84907
84932
  }
84908
84933
  initEvent() {
84909
84934
  }
@@ -91116,7 +91141,7 @@
91116
91141
  }
91117
91142
  static createComponent(spec, options) {
91118
91143
  const markLineSpec = spec.markLine || options.defaultSpec;
91119
- if (isNil$1(markLineSpec)) {
91144
+ if (isEmpty(markLineSpec)) {
91120
91145
  return undefined;
91121
91146
  }
91122
91147
  if (!isArray$4(markLineSpec) && markLineSpec.visible !== false) {
@@ -91181,8 +91206,12 @@
91181
91206
  else if (isPositionLayout) {
91182
91207
  points = spec.positions;
91183
91208
  }
91184
- const dataPoints = data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData;
91185
91209
  const seriesData = this._relativeSeries.getViewData().latestData;
91210
+ const dataPoints = data
91211
+ ? data.latestData[0].latestData
91212
+ ? data.latestData[0].latestData
91213
+ : data.latestData
91214
+ : seriesData;
91186
91215
  let limitRect;
91187
91216
  if (spec.clip || ((_b = spec.label) === null || _b === void 0 ? void 0 : _b.confine)) {
91188
91217
  const { minX, maxX, minY, maxY } = this._computeClipRange([
@@ -91328,7 +91357,7 @@
91328
91357
  }
91329
91358
  static createComponent(spec, options) {
91330
91359
  const markAreaSpec = spec.markArea || options.defaultSpec;
91331
- if (isNil$1(markAreaSpec)) {
91360
+ if (isEmpty(markAreaSpec)) {
91332
91361
  return undefined;
91333
91362
  }
91334
91363
  if (!isArray$4(markAreaSpec) && markAreaSpec.visible !== false) {
@@ -91390,7 +91419,12 @@
91390
91419
  else if (isPositionLayout) {
91391
91420
  points = spec.positions;
91392
91421
  }
91393
- const dataPoints = data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData;
91422
+ const seriesData = this._relativeSeries.getViewData().latestData;
91423
+ const dataPoints = data
91424
+ ? data.latestData[0].latestData
91425
+ ? data.latestData[0].latestData
91426
+ : data.latestData
91427
+ : seriesData;
91394
91428
  let limitRect;
91395
91429
  if (spec.clip || ((_b = spec.label) === null || _b === void 0 ? void 0 : _b.confine)) {
91396
91430
  const { minX, maxX, minY, maxY } = this._computeClipRange([
@@ -91408,7 +91442,7 @@
91408
91442
  (_c = this._markerComponent) === null || _c === void 0 ? void 0 : _c.setAttributes({
91409
91443
  points: points,
91410
91444
  label: Object.assign(Object.assign({}, (_e = (_d = this._markerComponent) === null || _d === void 0 ? void 0 : _d.attribute) === null || _e === void 0 ? void 0 : _e.label), { text: this._spec.label.formatMethod
91411
- ? this._spec.label.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
91445
+ ? this._spec.label.formatMethod(dataPoints, seriesData)
91412
91446
  : (_h = (_g = (_f = this._markerComponent) === null || _f === void 0 ? void 0 : _f.attribute) === null || _g === void 0 ? void 0 : _g.label) === null || _h === void 0 ? void 0 : _h.text }),
91413
91447
  limitRect,
91414
91448
  dx: this.layoutOffsetX,
@@ -91462,7 +91496,7 @@
91462
91496
  }
91463
91497
  static createComponent(spec, options) {
91464
91498
  const markPointSpec = spec.markPoint || options.defaultSpec;
91465
- if (isNil$1(markPointSpec)) {
91499
+ if (isEmpty(markPointSpec)) {
91466
91500
  return undefined;
91467
91501
  }
91468
91502
  if (!isArray$4(markPointSpec) && markPointSpec.visible !== false) {
@@ -91506,7 +91540,12 @@
91506
91540
  else if (isPositionLayout) {
91507
91541
  point = spec.position;
91508
91542
  }
91509
- const dataPoints = data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData;
91543
+ const seriesData = this._relativeSeries.getViewData().latestData;
91544
+ const dataPoints = data
91545
+ ? data.latestData[0].latestData
91546
+ ? data.latestData[0].latestData
91547
+ : data.latestData
91548
+ : seriesData;
91510
91549
  let limitRect;
91511
91550
  if (spec.clip) {
91512
91551
  const { minX, maxX, minY, maxY } = this._computeClipRange([relativeSeries.getRegion()]);
@@ -91520,7 +91559,7 @@
91520
91559
  (_b = this._markerComponent) === null || _b === void 0 ? void 0 : _b.setAttributes({
91521
91560
  position: point,
91522
91561
  itemContent: Object.assign(Object.assign({}, (_d = (_c = this._markerComponent) === null || _c === void 0 ? void 0 : _c.attribute) === null || _d === void 0 ? void 0 : _d.itemContent), { textStyle: Object.assign(Object.assign({}, (_g = (_f = (_e = this._markerComponent) === null || _e === void 0 ? void 0 : _e.attribute) === null || _f === void 0 ? void 0 : _f.itemContent) === null || _g === void 0 ? void 0 : _g.textStyle), { text: ((_h = this._spec.itemContent.text) === null || _h === void 0 ? void 0 : _h.formatMethod)
91523
- ? this._spec.itemContent.text.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
91562
+ ? this._spec.itemContent.text.formatMethod(dataPoints, seriesData)
91524
91563
  : (_m = (_l = (_k = (_j = this._markerComponent) === null || _j === void 0 ? void 0 : _j.attribute) === null || _k === void 0 ? void 0 : _k.itemContent) === null || _l === void 0 ? void 0 : _l.textStyle) === null || _m === void 0 ? void 0 : _m.text }) }),
91525
91564
  limitRect,
91526
91565
  dx: this.layoutOffsetX,
@@ -91621,6 +91660,41 @@
91621
91660
  }
91622
91661
  return boundingClientRect.height / element.offsetHeight;
91623
91662
  };
91663
+ const measureTooltipText = (text, style) => {
91664
+ var _a;
91665
+ text = (text !== null && text !== void 0 ? text : '').toString();
91666
+ const measure = initTextMeasure(style);
91667
+ if (!style.multiLine) {
91668
+ const { width, height } = measure.fullMeasure(text);
91669
+ return {
91670
+ width,
91671
+ height,
91672
+ text
91673
+ };
91674
+ }
91675
+ let textLines = text.split('\n');
91676
+ textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\n' : line));
91677
+ const { width, height } = measure.fullMeasure(textLines);
91678
+ if (style.maxWidth && style.maxWidth <= width) {
91679
+ const bound = getRichTextBounds({
91680
+ wordBreak: (_a = style.wordBreak) !== null && _a !== void 0 ? _a : 'break-word',
91681
+ maxWidth: style.maxWidth,
91682
+ width: 0,
91683
+ height: 0,
91684
+ textConfig: textLines.map((line, i) => (Object.assign(Object.assign({}, style), { text: line })))
91685
+ });
91686
+ return {
91687
+ width: bound.width(),
91688
+ height: bound.height(),
91689
+ text: textLines
91690
+ };
91691
+ }
91692
+ return {
91693
+ width,
91694
+ height,
91695
+ text: textLines
91696
+ };
91697
+ };
91624
91698
 
91625
91699
  const TOOLTIP_EL_CLASS_NAME = 'vchart-tooltip-element';
91626
91700
  const TOOLTIP_CONTAINER_EL_CLASS_NAME = 'vchart-tooltip-container';
@@ -91996,182 +92070,208 @@
91996
92070
  const getHorizontalPositionType = (position, defaultCase) => { var _a, _b; return (_b = (_a = positionType[position]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : defaultCase; };
91997
92071
  const getVerticalPositionType = (position, defaultCase) => { var _a, _b; return (_b = (_a = positionType[position]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : defaultCase; };
91998
92072
 
91999
- const defaultTextAttributes = {
92073
+ const DEFAULT_TEXT_ATTRIBUTES = {
92000
92074
  fontFamily: THEME_CONSTANTS.defaultFontFamily,
92001
92075
  spacing: 10,
92002
- multiLine: false,
92003
92076
  wordBreak: 'break-word'
92004
92077
  };
92005
92078
  function getTextAttributes(style = {}, globalTheme, defaultAttributes) {
92006
92079
  var _a, _b;
92007
- const attrs = Object.assign(Object.assign({}, (defaultAttributes !== null && defaultAttributes !== void 0 ? defaultAttributes : defaultTextAttributes)), { fill: ((_a = style.fill) !== null && _a !== void 0 ? _a : style.fontColor), textAlign: style.textAlign, textBaseline: style.textBaseline, fontFamily: (_b = style.fontFamily) !== null && _b !== void 0 ? _b : globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.fontFamily, fontSize: style.fontSize, fontWeight: style.fontWeight, lineHeight: style.lineHeight, spacing: style.spacing, multiLine: style.multiLine, maxWidth: style.maxWidth, wordBreak: style.wordBreak });
92080
+ const attrs = Object.assign(Object.assign({}, (defaultAttributes !== null && defaultAttributes !== void 0 ? defaultAttributes : DEFAULT_TEXT_ATTRIBUTES)), { fill: ((_a = style.fill) !== null && _a !== void 0 ? _a : style.fontColor), textAlign: style.textAlign, textBaseline: style.textBaseline, fontFamily: (_b = style.fontFamily) !== null && _b !== void 0 ? _b : globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.fontFamily, fontSize: style.fontSize, fontWeight: style.fontWeight, lineHeight: style.lineHeight, spacing: style.spacing, multiLine: style.multiLine, maxWidth: style.maxWidth, wordBreak: style.wordBreak, autoWidth: style.autoWidth });
92008
92081
  return attrs;
92009
92082
  }
92010
-
92011
- const getTooltipAttributes = (actualTooltip, style) => {
92012
- const { spaceRow: commonSpaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;
92013
- const attribute = Object.assign(Object.assign({}, style), { title: {}, content: [], titleStyle: {
92083
+ const getPanelAttributes = (style) => {
92084
+ var _a;
92085
+ const { backgroundColor, border, shadow } = style;
92086
+ const panelAttrs = {
92087
+ lineWidth: (_a = border === null || border === void 0 ? void 0 : border.width) !== null && _a !== void 0 ? _a : 0,
92088
+ shadow: !!shadow
92089
+ };
92090
+ if (border === null || border === void 0 ? void 0 : border.color) {
92091
+ panelAttrs.stroke = border.color;
92092
+ }
92093
+ if (backgroundColor) {
92094
+ panelAttrs.fill = backgroundColor;
92095
+ }
92096
+ if (shadow) {
92097
+ panelAttrs.shadowColor = shadow.color;
92098
+ panelAttrs.shadowBlur = shadow.blur;
92099
+ panelAttrs.shadowOffsetX = shadow.x;
92100
+ panelAttrs.shadowOffsetY = shadow.y;
92101
+ panelAttrs.shadowSpread = shadow.spread;
92102
+ }
92103
+ const { radius } = border !== null && border !== void 0 ? border : {};
92104
+ if (isValid$1(radius)) {
92105
+ panelAttrs.cornerRadius = [radius, radius, radius, radius];
92106
+ }
92107
+ return panelAttrs;
92108
+ };
92109
+ const getTooltipAttributes = (actualTooltip, spec, globalTheme) => {
92110
+ var _a, _b, _c, _d, _e;
92111
+ const { style = {}, enterable, transitionDuration } = spec;
92112
+ const { panel = {}, titleLabel, shape, keyLabel, valueLabel, spaceRow: commonSpaceRow } = style;
92113
+ const padding = normalizePadding$1(panel.padding);
92114
+ const paddingSpec = normalizeLayoutPaddingSpec(panel.padding);
92115
+ const titleStyle = getTextAttributes(titleLabel, globalTheme);
92116
+ const keyStyle = getTextAttributes(keyLabel, globalTheme);
92117
+ const valueStyle = getTextAttributes(valueLabel, globalTheme);
92118
+ const shapeStyle = {
92119
+ fill: true,
92120
+ size: (_a = shape === null || shape === void 0 ? void 0 : shape.size) !== null && _a !== void 0 ? _a : 8,
92121
+ spacing: (_b = shape === null || shape === void 0 ? void 0 : shape.spacing) !== null && _b !== void 0 ? _b : 6
92122
+ };
92123
+ const attributes = {
92124
+ panel: getPanelAttributes(panel),
92125
+ padding,
92126
+ title: {},
92127
+ content: [],
92128
+ titleStyle: {
92014
92129
  value: titleStyle,
92015
92130
  spaceRow: commonSpaceRow
92016
- }, contentStyle: {
92131
+ },
92132
+ contentStyle: {
92017
92133
  shape: shapeStyle,
92018
92134
  key: keyStyle,
92019
92135
  value: valueStyle,
92020
92136
  spaceRow: commonSpaceRow
92021
- }, hasContentShape: false, keyWidth: 0, valueWidth: 0 });
92022
- ['key', 'value', 'shape'].forEach(key => {
92023
- delete attribute[key];
92024
- });
92137
+ },
92138
+ hasContentShape: false,
92139
+ keyWidth: 0,
92140
+ valueWidth: 0,
92141
+ enterable,
92142
+ transitionDuration
92143
+ };
92025
92144
  const { title = {}, content = [] } = actualTooltip;
92026
- let maxWidth = 0;
92027
- let containerHeight = padding.top + padding.bottom;
92028
- let titleMaxHeight = 0;
92029
- const { visible: titleVisible = true, value: titleValue = '', valueStyle: titleValueStyle, hasShape: titleHasShape, shapeType: titleShapeType = '', shapeHollow: titleShapeHollow, shapeColor: titleShapeColor, spaceRow: titleSpaceRow } = title;
92030
- attribute.title.visible = titleVisible;
92031
- attribute.title.spaceRow = titleSpaceRow !== null && titleSpaceRow !== void 0 ? titleSpaceRow : commonSpaceRow;
92032
- if (titleVisible) {
92033
- const lineTitleStyle = mergeSpec({}, titleStyle, getTextAttributes(titleValueStyle, undefined, {}));
92034
- const { text, width, height } = measureTooltipText(titleValue, lineTitleStyle);
92035
- attribute.title.value = Object.assign(Object.assign({ width,
92036
- height }, lineTitleStyle), { text });
92037
- maxWidth = width;
92038
- titleMaxHeight = height;
92039
- if (titleHasShape && builtinSymbolsMap[titleShapeType]) {
92040
- const titleShapeAttrs = {
92041
- symbolType: titleShapeType
92042
- };
92043
- if (titleShapeHollow) {
92044
- titleShapeAttrs.stroke = titleShapeColor;
92045
- }
92046
- else {
92047
- titleShapeAttrs.fill = titleShapeColor;
92048
- }
92049
- attribute.title.shape = titleShapeAttrs;
92050
- maxWidth += shapeStyle.size + shapeStyle.spacing;
92051
- titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);
92052
- }
92053
- attribute.title.width = maxWidth;
92054
- attribute.title.height = titleMaxHeight;
92055
- containerHeight += titleMaxHeight;
92056
- }
92057
- if (content.length) {
92058
- const filteredContent = content.filter(item => {
92059
- return (item.key || item.value) && item.visible !== false;
92060
- });
92061
- if (filteredContent.length) {
92062
- if (titleVisible) {
92063
- containerHeight += attribute.title.spaceRow;
92064
- }
92065
- const keyWidths = [];
92066
- const adaptiveKeyWidths = [];
92067
- const valueWidths = [];
92068
- const shapeWidths = [];
92069
- attribute.content = filteredContent.map((item, i) => {
92070
- let itemHeight = 0;
92071
- const { hasShape, key, shapeColor, shapeHollow, shapeType = '', shapeFill, shapeStroke, shapeLineWidth, shapeSize, value, isKeyAdaptive, spaceRow: lineSpaceRow } = item;
92072
- const itemAttrs = { height: 0, spaceRow: lineSpaceRow !== null && lineSpaceRow !== void 0 ? lineSpaceRow : commonSpaceRow };
92073
- if (isValid$1(key)) {
92074
- const lineKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(item.keyStyle, undefined, {}));
92075
- const { width, height, text } = measureTooltipText(key, lineKeyStyle);
92076
- itemAttrs.key = Object.assign(Object.assign({ width,
92077
- height }, lineKeyStyle), { text });
92078
- if (!isKeyAdaptive) {
92079
- keyWidths.push(width);
92080
- }
92081
- else {
92082
- adaptiveKeyWidths.push(width);
92083
- }
92084
- itemHeight = Math.max(itemHeight, height);
92145
+ let containerWidth = paddingSpec.left + paddingSpec.right;
92146
+ let containerHeight = paddingSpec.top + paddingSpec.bottom;
92147
+ let contentMaxWidth = 0;
92148
+ const filteredContent = content.filter(item => {
92149
+ return (item.key || item.value) && item.visible !== false;
92150
+ });
92151
+ const hasContent = !!filteredContent.length;
92152
+ let maxKeyWidth = 0;
92153
+ let maxAdaptiveKeyWidth = 0;
92154
+ let maxValueWidth = 0;
92155
+ let maxShapeWidth = 0;
92156
+ if (hasContent) {
92157
+ const keyWidths = [];
92158
+ const adaptiveKeyWidths = [];
92159
+ const valueWidths = [];
92160
+ const shapeWidths = [];
92161
+ attributes.content = filteredContent.map((item, i) => {
92162
+ let itemHeight = 0;
92163
+ const { hasShape: actualHasShape, key: actualKey, shapeType: actualShapeType = '', shapeFill: actualShapeFill, shapeStroke: actualShapeStroke, shapeLineWidth: actualShapeLineWidth, shapeSize: actualShapeSize, value: actualValue, isKeyAdaptive: actualIsKeyAdaptive, spaceRow: actualSpaceRow, keyStyle: actualKeyStyle, valueStyle: actualValueStyle, shapeColor: actualShapeColor, shapeHollow: actualShapeHollow } = item;
92164
+ const itemAttrs = { height: 0, spaceRow: actualSpaceRow !== null && actualSpaceRow !== void 0 ? actualSpaceRow : commonSpaceRow };
92165
+ if (isValid$1(actualKey)) {
92166
+ const itemKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(actualKeyStyle, undefined, {}));
92167
+ const { width, height, text } = measureTooltipText(actualKey, itemKeyStyle);
92168
+ itemAttrs.key = Object.assign(Object.assign({ width,
92169
+ height }, itemKeyStyle), { text });
92170
+ if (!actualIsKeyAdaptive) {
92171
+ keyWidths.push(width);
92085
92172
  }
92086
- if (isValid$1(value)) {
92087
- const lineValueStyle = mergeSpec({}, valueStyle, getTextAttributes(item.valueStyle, undefined, {}));
92088
- const { width, height, text } = measureTooltipText(value, lineValueStyle);
92089
- itemAttrs.value = Object.assign(Object.assign({ width,
92090
- height }, lineValueStyle), { text });
92091
- valueWidths.push(width);
92092
- itemHeight = Math.max(itemHeight, height);
92173
+ else {
92174
+ adaptiveKeyWidths.push(width);
92093
92175
  }
92094
- if (hasShape) {
92095
- const shape = {
92096
- visible: true,
92097
- symbolType: shapeType
92098
- };
92099
- const adaptiveShapeFill = shapeFill !== null && shapeFill !== void 0 ? shapeFill : shapeColor;
92100
- if (shapeHollow) {
92101
- shape.stroke = adaptiveShapeFill;
92102
- }
92103
- else {
92104
- shape.fill = adaptiveShapeFill;
92105
- }
92106
- shape.stroke = shapeStroke !== null && shapeStroke !== void 0 ? shapeStroke : adaptiveShapeFill;
92107
- shape.lineWidth = shapeLineWidth;
92108
- itemAttrs.shape = shape;
92109
- const shapeWidth = shapeSize !== null && shapeSize !== void 0 ? shapeSize : shapeStyle.size;
92110
- itemHeight = Math.max(shapeWidth, itemHeight);
92111
- shapeWidths.push(shapeWidth);
92176
+ itemHeight = Math.max(itemHeight, height);
92177
+ }
92178
+ if (isValid$1(actualValue)) {
92179
+ const itemValueStyle = mergeSpec({}, valueStyle, getTextAttributes(actualValueStyle, undefined, {}));
92180
+ const { width, height, text } = measureTooltipText(actualValue, itemValueStyle);
92181
+ itemAttrs.value = Object.assign(Object.assign({ width,
92182
+ height }, itemValueStyle), { text });
92183
+ valueWidths.push(width);
92184
+ itemHeight = Math.max(itemHeight, height);
92185
+ }
92186
+ if (actualHasShape) {
92187
+ const shape = {
92188
+ visible: true,
92189
+ symbolType: actualShapeType
92190
+ };
92191
+ const adaptiveShapeFill = actualShapeFill !== null && actualShapeFill !== void 0 ? actualShapeFill : actualShapeColor;
92192
+ if (actualShapeHollow) {
92193
+ shape.stroke = adaptiveShapeFill;
92112
92194
  }
92113
92195
  else {
92114
- itemAttrs.shape = { visible: false };
92196
+ shape.fill = adaptiveShapeFill;
92115
92197
  }
92116
- itemAttrs.height = itemHeight;
92117
- containerHeight += itemHeight;
92118
- if (i < filteredContent.length - 1) {
92119
- containerHeight += itemAttrs.spaceRow;
92120
- }
92121
- return itemAttrs;
92122
- });
92123
- const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0;
92124
- const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;
92125
- const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
92126
- const shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0;
92127
- maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth);
92128
- attribute.hasContentShape = !!shapeWidths.length;
92129
- attribute.keyWidth = maxKeyWidth;
92130
- attribute.valueWidth = maxValueWidth;
92131
- }
92132
- }
92133
- const containerSize = {
92134
- width: maxWidth + padding.left + padding.right,
92135
- height: containerHeight
92136
- };
92137
- attribute.panel.width = containerSize.width;
92138
- attribute.panel.height = containerSize.height;
92139
- return attribute;
92140
- };
92141
- const measureTooltipText = (text, style) => {
92142
- var _a;
92143
- text = (text !== null && text !== void 0 ? text : '').toString();
92144
- const measure = initTextMeasure(style);
92145
- if (!style.multiLine) {
92146
- const { width, height } = measure.fullMeasure(text);
92147
- return {
92148
- width,
92149
- height,
92150
- text
92151
- };
92198
+ shape.stroke = actualShapeStroke !== null && actualShapeStroke !== void 0 ? actualShapeStroke : adaptiveShapeFill;
92199
+ shape.lineWidth = actualShapeLineWidth;
92200
+ itemAttrs.shape = shape;
92201
+ const shapeWidth = actualShapeSize !== null && actualShapeSize !== void 0 ? actualShapeSize : shapeStyle.size;
92202
+ itemHeight = Math.max(shapeWidth, itemHeight);
92203
+ shapeWidths.push(shapeWidth);
92204
+ }
92205
+ else {
92206
+ itemAttrs.shape = { visible: false };
92207
+ }
92208
+ itemAttrs.height = itemHeight;
92209
+ containerHeight += itemHeight;
92210
+ if (i < filteredContent.length - 1) {
92211
+ containerHeight += itemAttrs.spaceRow;
92212
+ }
92213
+ return itemAttrs;
92214
+ });
92215
+ maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0;
92216
+ maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;
92217
+ maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
92218
+ maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0;
92219
+ contentMaxWidth = Math.max(maxShapeWidth + maxKeyWidth + keyStyle.spacing + maxValueWidth + valueStyle.spacing, maxShapeWidth + maxAdaptiveKeyWidth, contentMaxWidth);
92220
+ attributes.hasContentShape = !!shapeWidths.length;
92221
+ attributes.keyWidth = maxKeyWidth;
92222
+ attributes.valueWidth = maxValueWidth;
92223
+ }
92224
+ let titleMaxWidth = 0;
92225
+ let titleMaxHeight = 0;
92226
+ const { visible: actualTitleVisible = true, value: actualTitleValue = '', valueStyle: actualTitleValueStyle, spaceRow: actualTitleSpaceRow } = title;
92227
+ attributes.title.visible = actualTitleVisible;
92228
+ attributes.title.spaceRow = actualTitleSpaceRow !== null && actualTitleSpaceRow !== void 0 ? actualTitleSpaceRow : commonSpaceRow;
92229
+ let titleValueStyle = {};
92230
+ const isAutoWidthMode = () => titleValueStyle.autoWidth && titleValueStyle.multiLine !== false;
92231
+ if (actualTitleVisible) {
92232
+ titleValueStyle = mergeSpec({}, titleStyle, getTextAttributes(actualTitleValueStyle, undefined, {}));
92233
+ if (isAutoWidthMode()) {
92234
+ titleValueStyle.multiLine = (_c = titleValueStyle.multiLine) !== null && _c !== void 0 ? _c : true;
92235
+ titleValueStyle.maxWidth = (_d = titleValueStyle.maxWidth) !== null && _d !== void 0 ? _d : (hasContent ? Math.ceil(contentMaxWidth) : undefined);
92236
+ }
92237
+ const { text, width, height } = measureTooltipText(actualTitleValue, titleValueStyle);
92238
+ attributes.title.value = Object.assign(Object.assign({ width: isAutoWidthMode() ? Math.min(width, (_e = titleValueStyle.maxWidth) !== null && _e !== void 0 ? _e : Number.MAX_VALUE) : width, height }, titleValueStyle), { text });
92239
+ titleMaxWidth = attributes.title.value.width;
92240
+ titleMaxHeight = attributes.title.value.height;
92241
+ containerHeight += titleMaxHeight + (hasContent ? attributes.title.spaceRow : 0);
92242
+ }
92243
+ attributes.title.width = titleMaxWidth;
92244
+ attributes.title.height = titleMaxHeight;
92245
+ if (isAutoWidthMode()) {
92246
+ containerWidth += contentMaxWidth ? contentMaxWidth : titleMaxWidth;
92152
92247
  }
92153
- let textLines = text.split('\n');
92154
- textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\n' : line));
92155
- const { width, height } = measure.fullMeasure(textLines);
92156
- if (style.maxWidth && style.maxWidth <= width) {
92157
- const bound = getRichTextBounds({
92158
- wordBreak: (_a = style.wordBreak) !== null && _a !== void 0 ? _a : 'break-word',
92159
- maxWidth: style.maxWidth,
92160
- width: 0,
92161
- height: 0,
92162
- textConfig: textLines.map((line, i) => (Object.assign(Object.assign({}, style), { text: line })))
92248
+ else {
92249
+ containerWidth += Math.max(titleMaxWidth, contentMaxWidth);
92250
+ }
92251
+ if (hasContent) {
92252
+ attributes.content.forEach(item => {
92253
+ var _a;
92254
+ const value = item.value;
92255
+ if (value && ((_a = value.autoWidth) !== null && _a !== void 0 ? _a : true)) {
92256
+ value.width =
92257
+ containerWidth -
92258
+ paddingSpec.left -
92259
+ paddingSpec.right -
92260
+ maxShapeWidth -
92261
+ maxKeyWidth -
92262
+ keyStyle.spacing -
92263
+ valueStyle.spacing;
92264
+ value.multiLine = true;
92265
+ if (!value.maxWidth) {
92266
+ value.maxWidth = Math.ceil(value.width);
92267
+ }
92268
+ attributes.valueWidth = Math.max(attributes.valueWidth, value.width);
92269
+ }
92163
92270
  });
92164
- return {
92165
- width: bound.width(),
92166
- height: bound.height(),
92167
- text: textLines
92168
- };
92169
92271
  }
92170
- return {
92171
- width,
92172
- height,
92173
- text: textLines
92174
- };
92272
+ attributes.panel.width = containerWidth;
92273
+ attributes.panel.height = containerHeight;
92274
+ return attributes;
92175
92275
  };
92176
92276
 
92177
92277
  var TooltipResult;
@@ -92190,7 +92290,8 @@
92190
92290
  constructor(tooltipId, component) {
92191
92291
  this._visible = true;
92192
92292
  this._id = '';
92193
- this._attributeCache = null;
92293
+ this._attributes = null;
92294
+ this._isReleased = false;
92194
92295
  this.showTooltip = (activeType, data, params) => {
92195
92296
  var _a;
92196
92297
  let changePositionOnly = !!params.changePositionOnly;
@@ -92207,7 +92308,7 @@
92207
92308
  this._changeTooltip = (visible, params, changePositionOnly, activeType, data) => {
92208
92309
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
92209
92310
  const tooltipSpec = this._component.getSpec();
92210
- if (!tooltipSpec) {
92311
+ if (this._isReleased || !tooltipSpec) {
92211
92312
  return TooltipResult.failed;
92212
92313
  }
92213
92314
  if (!visible) {
@@ -92257,6 +92358,9 @@
92257
92358
  };
92258
92359
  this._changeTooltipPosition = (changePositionOnly, actualTooltip, spec, activeType, data, params) => {
92259
92360
  var _a, _b, _c;
92361
+ if (this._isReleased) {
92362
+ return TooltipResult.failed;
92363
+ }
92260
92364
  const event = params.event;
92261
92365
  if (spec.handler) {
92262
92366
  return (_c = (_b = (_a = spec.handler).showTooltip) === null || _b === void 0 ? void 0 : _b.call(_a, activeType, data, params)) !== null && _c !== void 0 ? _c : TooltipResult.success;
@@ -92581,6 +92685,7 @@
92581
92685
  return;
92582
92686
  }
92583
92687
  this._removeTooltip();
92688
+ this._isReleased = true;
92584
92689
  }
92585
92690
  _throttle(callback) {
92586
92691
  const tooltipSpec = this._component.getSpec();
@@ -92604,57 +92709,14 @@
92604
92709
  return Object.assign(Object.assign({}, DEFAULT_OPTIONS), { offsetX: (_a = offset === null || offset === void 0 ? void 0 : offset.x) !== null && _a !== void 0 ? _a : DEFAULT_OPTIONS.offsetX, offsetY: (_b = offset === null || offset === void 0 ? void 0 : offset.y) !== null && _b !== void 0 ? _b : DEFAULT_OPTIONS.offsetY });
92605
92710
  }
92606
92711
  _getTooltipBoxSize(actualTooltip, changePositionOnly) {
92607
- var _a, _b, _c, _d;
92608
- if (!changePositionOnly || isNil$1(this._attributeCache)) {
92609
- this._attributeCache = getTooltipAttributes(actualTooltip, this._style);
92610
- }
92611
- return {
92612
- width: (_b = (_a = this._attributeCache) === null || _a === void 0 ? void 0 : _a.panel) === null || _b === void 0 ? void 0 : _b.width,
92613
- height: (_d = (_c = this._attributeCache) === null || _c === void 0 ? void 0 : _c.panel) === null || _d === void 0 ? void 0 : _d.height
92614
- };
92615
- }
92616
- _getStyle() {
92617
- var _a, _b, _c, _d, _e;
92618
- const tooltipSpec = this._component.getSpec();
92619
- const { style = {}, enterable, transitionDuration } = tooltipSpec;
92620
- const { panel = {}, titleLabel, shape, keyLabel, valueLabel, spaceRow } = style;
92621
- const { backgroundColor, border, shadow, padding } = panel;
92622
- const panelStyle = {
92623
- lineWidth: (_a = border === null || border === void 0 ? void 0 : border.width) !== null && _a !== void 0 ? _a : 0,
92624
- shadow: !!shadow
92625
- };
92626
- if (border === null || border === void 0 ? void 0 : border.color) {
92627
- panelStyle.stroke = border.color;
92628
- }
92629
- if (backgroundColor) {
92630
- panelStyle.fill = backgroundColor;
92631
- }
92632
- if (shadow) {
92633
- panelStyle.shadowColor = shadow.color;
92634
- panelStyle.shadowBlur = shadow.blur;
92635
- panelStyle.shadowOffsetX = shadow.x;
92636
- panelStyle.shadowOffsetY = shadow.y;
92637
- panelStyle.shadowSpread = shadow.spread;
92638
- }
92639
- const { radius } = border !== null && border !== void 0 ? border : {};
92640
- if (isValid$1(radius)) {
92641
- panelStyle.cornerRadius = [radius, radius, radius, radius];
92712
+ var _a, _b, _c, _d, _e, _f;
92713
+ if (!changePositionOnly || isNil$1(this._attributes)) {
92714
+ const globalTheme = (_b = (_a = this._chartOption).getTheme) === null || _b === void 0 ? void 0 : _b.call(_a);
92715
+ this._attributes = getTooltipAttributes(actualTooltip, this._component.getSpec(), globalTheme);
92642
92716
  }
92643
- const globalTheme = (_c = (_b = this._chartOption).getTheme) === null || _c === void 0 ? void 0 : _c.call(_b);
92644
92717
  return {
92645
- panel: panelStyle,
92646
- title: getTextAttributes(titleLabel, globalTheme),
92647
- shape: {
92648
- fill: true,
92649
- size: (_d = shape === null || shape === void 0 ? void 0 : shape.size) !== null && _d !== void 0 ? _d : 8,
92650
- spacing: (_e = shape === null || shape === void 0 ? void 0 : shape.spacing) !== null && _e !== void 0 ? _e : 6
92651
- },
92652
- key: getTextAttributes(keyLabel, globalTheme),
92653
- value: getTextAttributes(valueLabel, globalTheme),
92654
- padding,
92655
- spaceRow,
92656
- enterable,
92657
- transitionDuration
92718
+ width: (_d = (_c = this._attributes) === null || _c === void 0 ? void 0 : _c.panel) === null || _d === void 0 ? void 0 : _d.width,
92719
+ height: (_f = (_e = this._attributes) === null || _e === void 0 ? void 0 : _e.panel) === null || _f === void 0 ? void 0 : _f.height
92658
92720
  };
92659
92721
  }
92660
92722
  _getParentElement(spec) {
@@ -92665,7 +92727,6 @@
92665
92727
  }
92666
92728
  _initFromSpec() {
92667
92729
  this._option = this._getDefaultOption();
92668
- this._style = this._getStyle();
92669
92730
  this.changeTooltip = this._throttle(this._changeTooltip);
92670
92731
  this.changeTooltipPosition = this._throttle(this._changeTooltipPosition);
92671
92732
  }
@@ -92699,22 +92760,24 @@
92699
92760
  }
92700
92761
  return numArr;
92701
92762
  };
92702
- function getDomStyles(style, attributeCache) {
92703
- var _a, _b, _c, _d, _e, _f, _g;
92704
- const { panel: { fill: fillColor, shadow, shadowBlur, shadowColor, shadowOffsetX, shadowOffsetY, shadowSpread, cornerRadius, stroke: strokeColor, lineWidth = 0 }, padding, key, value, title, shape, enterable, transitionDuration } = style;
92705
- const { panel: panelAttribute, title: titleAttribute, content: contentAttribute, keyWidth, valueWidth } = attributeCache !== null && attributeCache !== void 0 ? attributeCache : {};
92706
- const backgroundColor = fillColor;
92763
+ function getDomStyles(attributes) {
92764
+ var _a, _b, _c, _d, _e;
92765
+ const { panel = {}, title: titleAttribute, content: contentAttribute, titleStyle = {}, contentStyle = {}, padding, keyWidth, valueWidth, enterable, transitionDuration } = attributes !== null && attributes !== void 0 ? attributes : {};
92766
+ const { fill: backgroundColor, shadow, shadowBlur, shadowColor, shadowOffsetX, shadowOffsetY, shadowSpread, cornerRadius, stroke: strokeColor, lineWidth = 0, width = 0, height = 0 } = panel;
92767
+ const { value: title = {} } = titleStyle;
92768
+ const { shape = {}, key = {}, value = {} } = contentStyle;
92707
92769
  const shapeStyle = getShapeStyle(shape);
92708
92770
  const keyStyle = getLabelStyle(key);
92709
92771
  const valueStyle = getLabelStyle(value);
92772
+ const { bottom, left, right, top } = normalizeLayoutPaddingSpec(padding);
92710
92773
  const styles = {
92711
92774
  panel: {
92712
- width: getPixelPropertyStr(((_a = panelAttribute === null || panelAttribute === void 0 ? void 0 : panelAttribute.width) !== null && _a !== void 0 ? _a : 0) + lineWidth * 2),
92713
- minHeight: getPixelPropertyStr(((_b = panelAttribute === null || panelAttribute === void 0 ? void 0 : panelAttribute.height) !== null && _b !== void 0 ? _b : 0) + lineWidth * 2),
92714
- paddingBottom: getPixelPropertyStr(padding.bottom),
92715
- paddingLeft: getPixelPropertyStr(padding.left),
92716
- paddingRight: getPixelPropertyStr(padding.right),
92717
- paddingTop: getPixelPropertyStr(padding.top),
92775
+ width: getPixelPropertyStr(width + lineWidth * 2),
92776
+ minHeight: getPixelPropertyStr(height + lineWidth * 2),
92777
+ paddingBottom: getPixelPropertyStr(bottom),
92778
+ paddingLeft: getPixelPropertyStr(left),
92779
+ paddingRight: getPixelPropertyStr(right),
92780
+ paddingTop: getPixelPropertyStr(top),
92718
92781
  borderColor: strokeColor,
92719
92782
  borderWidth: getPixelPropertyStr(lineWidth),
92720
92783
  borderRadius: getPixelPropertyStr(cornerRadius),
@@ -92733,20 +92796,20 @@
92733
92796
  common: shapeStyle,
92734
92797
  items: [],
92735
92798
  width: getPixelPropertyStr(shape.size),
92736
- marginRight: getPixelPropertyStr((_c = shape.spacing) !== null && _c !== void 0 ? _c : DEFAULT_SHAPE_SPACING),
92737
- marginBottom: getPixelPropertyStr(-((_e = (_d = contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute[(contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute.length) - 1]) === null || _d === void 0 ? void 0 : _d.spaceRow) !== null && _e !== void 0 ? _e : 0))
92799
+ marginRight: getPixelPropertyStr((_a = shape.spacing) !== null && _a !== void 0 ? _a : DEFAULT_SHAPE_SPACING),
92800
+ marginBottom: getPixelPropertyStr(-((_c = (_b = contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute[(contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute.length) - 1]) === null || _b === void 0 ? void 0 : _b.spaceRow) !== null && _c !== void 0 ? _c : 0))
92738
92801
  },
92739
92802
  keyColumn: {
92740
92803
  common: keyStyle,
92741
92804
  items: contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute.map(({ key, spaceRow }, i) => (Object.assign(Object.assign(Object.assign({ marginTop: '0px', marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px' }, keyStyle), getLabelStyle(key)), ((key === null || key === void 0 ? void 0 : key.multiLine) ? { width: getPixelPropertyStr(Math.ceil(key.width)) } : undefined)))),
92742
92805
  width: getPixelPropertyStr(keyWidth),
92743
- marginRight: getPixelPropertyStr((_f = key.spacing) !== null && _f !== void 0 ? _f : DEFAULT_KEY_SPACING)
92806
+ marginRight: getPixelPropertyStr((_d = key.spacing) !== null && _d !== void 0 ? _d : DEFAULT_KEY_SPACING)
92744
92807
  },
92745
92808
  valueColumn: {
92746
92809
  common: valueStyle,
92747
92810
  items: contentAttribute === null || contentAttribute === void 0 ? void 0 : contentAttribute.map(({ value, spaceRow }, i) => (Object.assign(Object.assign(Object.assign({ marginTop: '0px', marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px' }, valueStyle), getLabelStyle(value)), ((value === null || value === void 0 ? void 0 : value.multiLine) ? { width: getPixelPropertyStr(Math.ceil(value.width)) } : undefined)))),
92748
92811
  width: getPixelPropertyStr(valueWidth),
92749
- marginRight: getPixelPropertyStr((_g = value.spacing) !== null && _g !== void 0 ? _g : DEFAULT_VALUE_SPACING)
92812
+ marginRight: getPixelPropertyStr((_e = value.spacing) !== null && _e !== void 0 ? _e : DEFAULT_VALUE_SPACING)
92750
92813
  }
92751
92814
  };
92752
92815
  return styles;
@@ -93451,7 +93514,7 @@
93451
93514
  valueToHtml: this._option.sanitize,
93452
93515
  getTooltipStyle: () => this._domStyle,
93453
93516
  getTooltipActual: () => this._tooltipActual,
93454
- getTooltipAttributes: () => this._attributeCache
93517
+ getTooltipAttributes: () => this._attributes
93455
93518
  }, [tooltipSpec.className], this.id);
93456
93519
  }
93457
93520
  }
@@ -93482,7 +93545,7 @@
93482
93545
  }
93483
93546
  }
93484
93547
  _initStyle() {
93485
- this._domStyle = getDomStyles(this._style, this._attributeCache);
93548
+ this._domStyle = getDomStyles(this._attributes);
93486
93549
  }
93487
93550
  _getParentElement(spec) {
93488
93551
  var _a;
@@ -93528,7 +93591,7 @@
93528
93591
  if (this._layer) {
93529
93592
  this._layer.removeAllChild();
93530
93593
  }
93531
- this._attributeCache = null;
93594
+ this._attributes = null;
93532
93595
  }
93533
93596
  _updateTooltip(visible, params, actualTooltip) {
93534
93597
  this._visible = visible;
@@ -93550,7 +93613,7 @@
93550
93613
  }
93551
93614
  const pos = actualTooltip === null || actualTooltip === void 0 ? void 0 : actualTooltip.position;
93552
93615
  if (!params.changePositionOnly) {
93553
- this._tooltipComponent.setAttributes(Object.assign(Object.assign({}, this._attributeCache), pos));
93616
+ this._tooltipComponent.setAttributes(Object.assign(Object.assign({}, this._attributes), pos));
93554
93617
  }
93555
93618
  else if (isValid$1(pos)) {
93556
93619
  this._tooltipComponent.setAttributes(pos);
@@ -93906,12 +93969,6 @@
93906
93969
  }
93907
93970
  release() {
93908
93971
  var _a, _b;
93909
- this.event.emit(ChartEvent.tooltipHide, {
93910
- tooltip: this
93911
- });
93912
- this.event.emit(ChartEvent.tooltipRelease, {
93913
- tooltip: this
93914
- });
93915
93972
  super.release();
93916
93973
  this._eventList.forEach(({ eventType, handler }) => {
93917
93974
  this.event.off(eventType, handler);
@@ -93920,6 +93977,14 @@
93920
93977
  (_b = (_a = this.tooltipHandler) === null || _a === void 0 ? void 0 : _a.release) === null || _b === void 0 ? void 0 : _b.call(_a);
93921
93978
  this._isTooltipShown = false;
93922
93979
  }
93980
+ beforeRelease() {
93981
+ this.event.emit(ChartEvent.tooltipHide, {
93982
+ tooltip: this
93983
+ });
93984
+ this.event.emit(ChartEvent.tooltipRelease, {
93985
+ tooltip: this
93986
+ });
93987
+ }
93923
93988
  _initHandler() {
93924
93989
  var _a, _b, _c;
93925
93990
  const renderMode = (_a = this._spec.renderMode) !== null && _a !== void 0 ? _a : 'html';