@visactor/vchart 1.4.2-beta.0 → 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 (151) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +353 -274
  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/axis/base-axis.d.ts +2 -0
  8. package/cjs/component/axis/base-axis.js +7 -5
  9. package/cjs/component/axis/base-axis.js.map +1 -1
  10. package/cjs/component/brush/brush.d.ts +0 -1
  11. package/cjs/component/brush/brush.js +10 -7
  12. package/cjs/component/brush/brush.js.map +1 -1
  13. package/cjs/component/custom-mark/custom-mark.js +2 -1
  14. package/cjs/component/custom-mark/custom-mark.js.map +1 -1
  15. package/cjs/component/data-zoom/data-filter-base-component.js +6 -4
  16. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  17. package/cjs/component/marker/mark-area/mark-area.js +3 -3
  18. package/cjs/component/marker/mark-area/mark-area.js.map +1 -1
  19. package/cjs/component/marker/mark-line/mark-line.js +2 -2
  20. package/cjs/component/marker/mark-line/mark-line.js.map +1 -1
  21. package/cjs/component/marker/mark-point/mark-point.js +3 -3
  22. package/cjs/component/marker/mark-point/mark-point.js.map +1 -1
  23. package/cjs/component/tooltip/handler/base.d.ts +2 -4
  24. package/cjs/component/tooltip/handler/base.js +15 -38
  25. package/cjs/component/tooltip/handler/base.js.map +1 -1
  26. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  27. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  28. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  29. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  30. package/cjs/component/tooltip/handler/dom/util.d.ts +1 -2
  31. package/cjs/component/tooltip/handler/dom/util.js +14 -13
  32. package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
  33. package/cjs/component/tooltip/handler/interface/style.d.ts +4 -23
  34. package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
  35. package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -11
  36. package/cjs/component/tooltip/handler/utils/attribute.js +136 -126
  37. package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
  38. package/cjs/component/tooltip/handler/utils/common.d.ts +8 -0
  39. package/cjs/component/tooltip/handler/utils/common.js +42 -2
  40. package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
  41. package/cjs/component/tooltip/handler/utils/index.d.ts +0 -1
  42. package/cjs/component/tooltip/handler/utils/index.js +1 -2
  43. package/cjs/component/tooltip/handler/utils/index.js.map +1 -1
  44. package/cjs/component/tooltip/interface/common.d.ts +2 -2
  45. package/cjs/component/tooltip/interface/common.js.map +1 -1
  46. package/cjs/component/tooltip/interface/theme.d.ts +5 -3
  47. package/cjs/component/tooltip/interface/theme.js.map +1 -1
  48. package/cjs/component/tooltip/tooltip.d.ts +1 -0
  49. package/cjs/component/tooltip/tooltip.js +7 -4
  50. package/cjs/component/tooltip/tooltip.js.map +1 -1
  51. package/cjs/core/index.d.ts +1 -1
  52. package/cjs/core/index.js +1 -1
  53. package/cjs/core/index.js.map +1 -1
  54. package/cjs/core/util.d.ts +3 -0
  55. package/cjs/core/util.js +12 -0
  56. package/cjs/core/util.js.map +1 -0
  57. package/cjs/core/vchart.d.ts +3 -0
  58. package/cjs/core/vchart.js +2 -2
  59. package/cjs/core/vchart.js.map +1 -1
  60. package/cjs/interaction/trigger.js +1 -2
  61. package/cjs/layout/base-layout.js +2 -1
  62. package/cjs/mark/box-plot.js +1 -1
  63. package/cjs/model/base-model.d.ts +1 -0
  64. package/cjs/model/base-model.js +1 -0
  65. package/cjs/model/base-model.js.map +1 -1
  66. package/cjs/model/interface.d.ts +2 -1
  67. package/cjs/model/interface.js.map +1 -1
  68. package/cjs/series/polar/polar.js +1 -1
  69. package/cjs/series/polar/polar.js.map +1 -1
  70. package/cjs/series/sankey/sankey.js +14 -7
  71. package/cjs/series/sankey/sankey.js.map +1 -1
  72. package/cjs/util/text.d.ts +3 -3
  73. package/cjs/util/text.js +5 -1
  74. package/cjs/util/text.js.map +1 -1
  75. package/esm/chart/base-chart.js +3 -1
  76. package/esm/chart/base-chart.js.map +1 -1
  77. package/esm/component/axis/base-axis.d.ts +2 -0
  78. package/esm/component/axis/base-axis.js +7 -5
  79. package/esm/component/axis/base-axis.js.map +1 -1
  80. package/esm/component/brush/brush.d.ts +0 -1
  81. package/esm/component/brush/brush.js +10 -6
  82. package/esm/component/brush/brush.js.map +1 -1
  83. package/esm/component/custom-mark/custom-mark.js +2 -1
  84. package/esm/component/custom-mark/custom-mark.js.map +1 -1
  85. package/esm/component/data-zoom/data-filter-base-component.js +6 -4
  86. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  87. package/esm/component/marker/mark-area/mark-area.js +5 -5
  88. package/esm/component/marker/mark-area/mark-area.js.map +1 -1
  89. package/esm/component/marker/mark-line/mark-line.js +4 -4
  90. package/esm/component/marker/mark-line/mark-line.js.map +1 -1
  91. package/esm/component/marker/mark-point/mark-point.js +5 -5
  92. package/esm/component/marker/mark-point/mark-point.js.map +1 -1
  93. package/esm/component/tooltip/handler/base.d.ts +2 -4
  94. package/esm/component/tooltip/handler/base.js +14 -39
  95. package/esm/component/tooltip/handler/base.js.map +1 -1
  96. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  97. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  98. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  99. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  100. package/esm/component/tooltip/handler/dom/util.d.ts +1 -2
  101. package/esm/component/tooltip/handler/dom/util.js +14 -14
  102. package/esm/component/tooltip/handler/dom/util.js.map +1 -1
  103. package/esm/component/tooltip/handler/interface/style.d.ts +4 -23
  104. package/esm/component/tooltip/handler/interface/style.js.map +1 -1
  105. package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -11
  106. package/esm/component/tooltip/handler/utils/attribute.js +131 -123
  107. package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
  108. package/esm/component/tooltip/handler/utils/common.d.ts +8 -0
  109. package/esm/component/tooltip/handler/utils/common.js +41 -1
  110. package/esm/component/tooltip/handler/utils/common.js.map +1 -1
  111. package/esm/component/tooltip/handler/utils/index.d.ts +0 -1
  112. package/esm/component/tooltip/handler/utils/index.js +0 -2
  113. package/esm/component/tooltip/handler/utils/index.js.map +1 -1
  114. package/esm/component/tooltip/interface/common.d.ts +2 -2
  115. package/esm/component/tooltip/interface/common.js.map +1 -1
  116. package/esm/component/tooltip/interface/theme.d.ts +5 -3
  117. package/esm/component/tooltip/interface/theme.js.map +1 -1
  118. package/esm/component/tooltip/tooltip.d.ts +1 -0
  119. package/esm/component/tooltip/tooltip.js +7 -4
  120. package/esm/component/tooltip/tooltip.js.map +1 -1
  121. package/esm/core/index.d.ts +1 -1
  122. package/esm/core/index.js +1 -1
  123. package/esm/core/index.js.map +1 -1
  124. package/esm/core/util.d.ts +3 -0
  125. package/esm/core/util.js +6 -0
  126. package/esm/core/util.js.map +1 -0
  127. package/esm/core/vchart.d.ts +3 -0
  128. package/esm/core/vchart.js +3 -1
  129. package/esm/core/vchart.js.map +1 -1
  130. package/esm/interaction/trigger.js +1 -2
  131. package/esm/layout/base-layout.js +2 -1
  132. package/esm/mark/box-plot.js +1 -1
  133. package/esm/model/base-model.d.ts +1 -0
  134. package/esm/model/base-model.js +1 -0
  135. package/esm/model/base-model.js.map +1 -1
  136. package/esm/model/interface.d.ts +2 -1
  137. package/esm/model/interface.js.map +1 -1
  138. package/esm/series/polar/polar.js +1 -1
  139. package/esm/series/polar/polar.js.map +1 -1
  140. package/esm/series/sankey/sankey.js +12 -5
  141. package/esm/series/sankey/sankey.js.map +1 -1
  142. package/esm/util/text.d.ts +3 -3
  143. package/esm/util/text.js +2 -0
  144. package/esm/util/text.js.map +1 -1
  145. package/package.json +4 -4
  146. package/cjs/component/tooltip/handler/utils/style.d.ts +0 -4
  147. package/cjs/component/tooltip/handler/utils/style.js +0 -32
  148. package/cjs/component/tooltip/handler/utils/style.js.map +0 -1
  149. package/esm/component/tooltip/handler/utils/style.d.ts +0 -4
  150. package/esm/component/tooltip/handler/utils/style.js +0 -26
  151. 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.0";
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) {
@@ -77504,19 +77516,31 @@
77504
77516
  this._tooltipHelper = new SankeySeriesTooltipHelper(this);
77505
77517
  }
77506
77518
  getNodeOrdinalColorScale(item) {
77507
- var _a, _b, _c, _d, _e, _f, _g, _h;
77508
- const colorDomain = !isNil$1((_b = (_a = this._option.globalScale.getScale('color')) === null || _a === void 0 ? void 0 : _a.domain()) === null || _b === void 0 ? void 0 : _b[0])
77519
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
77520
+ if (!isNil$1((_c = (_b = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalScale) === null || _b === void 0 ? void 0 : _b.getScale('color')) === null || _c === void 0 ? void 0 : _c._specified)) {
77521
+ const specified = this._option.globalScale.getScale('color')._specified;
77522
+ const colorDomain = [];
77523
+ const colorRange = [];
77524
+ for (const key in specified) {
77525
+ colorDomain.push(key);
77526
+ colorRange.push(specified[key]);
77527
+ }
77528
+ const ordinalScale = new ColorOrdinalScale();
77529
+ (_e = (_d = ordinalScale.domain(colorDomain)).range) === null || _e === void 0 ? void 0 : _e.call(_d, colorRange);
77530
+ return ordinalScale.scale(item);
77531
+ }
77532
+ const colorDomain = !isNil$1((_g = (_f = this._option.globalScale.getScale('color')) === null || _f === void 0 ? void 0 : _f.domain()) === null || _g === void 0 ? void 0 : _g[0])
77509
77533
  ? this._option.globalScale.getScale('color').domain()
77510
77534
  : this.getNodeList();
77511
- let colorRange = (_d = (_c = this._option.globalScale.getScale('color')) === null || _c === void 0 ? void 0 : _c.range()) !== null && _d !== void 0 ? _d : getDataScheme(this._option.getTheme().colorScheme, this.type);
77512
- if (((_e = this._option.globalScale.getScale('color')) === null || _e === void 0 ? void 0 : _e.domain().length) === 0 ||
77535
+ let colorRange = (_j = (_h = this._option.globalScale.getScale('color')) === null || _h === void 0 ? void 0 : _h.range()) !== null && _j !== void 0 ? _j : getDataScheme(this._option.getTheme().colorScheme, this.type);
77536
+ if (((_k = this._option.globalScale.getScale('color')) === null || _k === void 0 ? void 0 : _k.domain().length) === 0 ||
77513
77537
  isNil$1(this._option.globalScale.getScale('color').domain()[0])) {
77514
77538
  if (colorDomain.length > 10) {
77515
- colorRange = (_f = getDataScheme(this._option.getTheme().colorScheme, this.type)[1]) === null || _f === void 0 ? void 0 : _f.scheme;
77539
+ colorRange = (_l = getDataScheme(this._option.getTheme().colorScheme, this.type)[1]) === null || _l === void 0 ? void 0 : _l.scheme;
77516
77540
  }
77517
77541
  }
77518
77542
  const ordinalScale = new ColorOrdinalScale();
77519
- (_h = (_g = ordinalScale.domain(colorDomain)).range) === null || _h === void 0 ? void 0 : _h.call(_g, colorRange);
77543
+ (_o = (_m = ordinalScale.domain(colorDomain)).range) === null || _o === void 0 ? void 0 : _o.call(_m, colorRange);
77520
77544
  return ordinalScale.scale(item);
77521
77545
  }
77522
77546
  getNodeList() {
@@ -84001,23 +84025,23 @@
84001
84025
  return undefined;
84002
84026
  }
84003
84027
  _autoUpdate(rect) {
84004
- var _a, _b, _c, _d;
84028
+ var _a, _b, _c, _d, _e;
84005
84029
  if (!this._auto) {
84006
84030
  return true;
84007
84031
  }
84008
84032
  const axisSpec = (_a = this._relatedAxisComponent) === null || _a === void 0 ? void 0 : _a.getSpec();
84009
84033
  const bandSizeResult = this._getAxisBandSize(axisSpec);
84010
84034
  const { bandSize, maxBandSize, minBandSize } = bandSizeResult !== null && bandSizeResult !== void 0 ? bandSizeResult : {};
84011
- if ((rect === null || rect === void 0 ? void 0 : rect.height) === ((_b = this._cacheRect) === null || _b === void 0 ? void 0 : _b.height) &&
84012
- (rect === null || rect === void 0 ? void 0 : rect.width) === ((_c = this._cacheRect) === null || _c === void 0 ? void 0 : _c.width) &&
84013
- this._fixedBandSize === bandSize) {
84014
- return this._cacheVisibility;
84015
- }
84016
- this._cacheRect = rect;
84017
84035
  let isShown = true;
84018
84036
  const scale = this._stateScale;
84019
84037
  scale.range(this._isHorizontal ? [0, rect.width] : axisSpec.inverse ? [0, rect.height] : [rect.height, 0]);
84020
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;
84021
84045
  if (bandSizeResult) {
84022
84046
  if (this._start || this._end) {
84023
84047
  scale.rangeFactor([this._start, this._end], true);
@@ -84052,6 +84076,17 @@
84052
84076
  this._start = start;
84053
84077
  this._end = end;
84054
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
+ }
84055
84090
  this.setStartAndEnd(this._start, this._end);
84056
84091
  this._cacheVisibility = isShown;
84057
84092
  return isShown;
@@ -84474,11 +84509,11 @@
84474
84509
  this.layoutLevel = LayoutLevel.CustomMark;
84475
84510
  }
84476
84511
  static createComponent(spec, options) {
84477
- const titleSpec = spec.customMark;
84478
- if (!titleSpec) {
84512
+ const customMarkSpec = spec.customMark;
84513
+ if (!customMarkSpec) {
84479
84514
  return null;
84480
84515
  }
84481
- 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' }))];
84482
84517
  }
84483
84518
  created() {
84484
84519
  super.created();
@@ -84558,9 +84593,8 @@
84558
84593
  this._linkedInBrushElementsMap = {};
84559
84594
  this._linkedOutOfBrushElementsMap = {};
84560
84595
  this._needInitOutState = true;
84561
- this._isFirstState = true;
84562
84596
  this._cacheInteractiveRangeAttrs = [];
84563
- this._needEnablePickable = true;
84597
+ this._needEnablePickable = false;
84564
84598
  }
84565
84599
  static createComponent(spec, options) {
84566
84600
  const brushSpec = spec.brush || options.defaultSpec;
@@ -84626,11 +84660,19 @@
84626
84660
  this._brushComponents.push(brush);
84627
84661
  this._cacheInteractiveRangeAttrs.push(interactiveAttr);
84628
84662
  brush.setUpdateDragMaskCallback((operateParams) => {
84663
+ var _a, _b, _c;
84629
84664
  const { operateType, operateMask } = operateParams;
84630
- if (this._isFirstState ||
84631
- (this._needInitOutState && brushMode === 'single' && operateType === IOperateType.drawing)) {
84665
+ let operateTypeCache = operateType;
84666
+ if (this._needInitOutState && brushMode === 'single' && operateType === IOperateType.drawing) {
84632
84667
  this._initMarkBrushState(componentIndex, 'outOfBrush');
84633
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
+ });
84634
84676
  if (operateType === IOperateType.drawing) {
84635
84677
  this._needInitOutState = false;
84636
84678
  this._needEnablePickable = true;
@@ -84639,10 +84681,6 @@
84639
84681
  this._needInitOutState = true;
84640
84682
  this._needEnablePickable = false;
84641
84683
  }
84642
- if (operateType === IOperateType.brushClear) {
84643
- this._initMarkBrushState(componentIndex, '');
84644
- this._needInitOutState = true;
84645
- }
84646
84684
  this._reconfigItem(operateMask, region);
84647
84685
  this._reconfigLinkedItem(operateMask, region);
84648
84686
  let eventType = ChartEvent.brushChange;
@@ -84891,7 +84929,6 @@
84891
84929
  });
84892
84930
  });
84893
84931
  });
84894
- this._isFirstState = false;
84895
84932
  }
84896
84933
  initEvent() {
84897
84934
  }
@@ -86000,7 +86037,7 @@
86000
86037
  component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
86001
86038
  }
86002
86039
  _getAxisAttributes() {
86003
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
86040
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
86004
86041
  const spec = this._spec;
86005
86042
  let titleAngle = spec.title.angle;
86006
86043
  let titleTextStyle;
@@ -86077,12 +86114,14 @@
86077
86114
  text: transformStateStyle(spec.title.state),
86078
86115
  shape: transformStateStyle((_g = spec.title.shape) === null || _g === void 0 ? void 0 : _g.state),
86079
86116
  background: transformStateStyle((_h = spec.title.background) === null || _h === void 0 ? void 0 : _h.state)
86080
- }
86117
+ },
86118
+ pickable: ((_j = spec.title.style) === null || _j === void 0 ? void 0 : _j.pickable) !== false,
86119
+ childrenPickable: ((_k = spec.title.style) === null || _k === void 0 ? void 0 : _k.pickable) !== false
86081
86120
  },
86082
86121
  panel: {
86083
- visible: (_j = spec.background) === null || _j === void 0 ? void 0 : _j.visible,
86084
- style: transformToGraphic((_k = spec.background) === null || _k === void 0 ? void 0 : _k.style),
86085
- state: transformStateStyle((_l = spec.background) === null || _l === void 0 ? void 0 : _l.state)
86122
+ visible: (_l = spec.background) === null || _l === void 0 ? void 0 : _l.visible,
86123
+ style: transformToGraphic((_m = spec.background) === null || _m === void 0 ? void 0 : _m.style),
86124
+ state: transformStateStyle((_o = spec.background) === null || _o === void 0 ? void 0 : _o.state)
86086
86125
  }
86087
86126
  };
86088
86127
  }
@@ -91102,7 +91141,7 @@
91102
91141
  }
91103
91142
  static createComponent(spec, options) {
91104
91143
  const markLineSpec = spec.markLine || options.defaultSpec;
91105
- if (isNil$1(markLineSpec)) {
91144
+ if (isEmpty(markLineSpec)) {
91106
91145
  return undefined;
91107
91146
  }
91108
91147
  if (!isArray$4(markLineSpec) && markLineSpec.visible !== false) {
@@ -91167,8 +91206,12 @@
91167
91206
  else if (isPositionLayout) {
91168
91207
  points = spec.positions;
91169
91208
  }
91170
- const dataPoints = data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData;
91171
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;
91172
91215
  let limitRect;
91173
91216
  if (spec.clip || ((_b = spec.label) === null || _b === void 0 ? void 0 : _b.confine)) {
91174
91217
  const { minX, maxX, minY, maxY } = this._computeClipRange([
@@ -91314,7 +91357,7 @@
91314
91357
  }
91315
91358
  static createComponent(spec, options) {
91316
91359
  const markAreaSpec = spec.markArea || options.defaultSpec;
91317
- if (isNil$1(markAreaSpec)) {
91360
+ if (isEmpty(markAreaSpec)) {
91318
91361
  return undefined;
91319
91362
  }
91320
91363
  if (!isArray$4(markAreaSpec) && markAreaSpec.visible !== false) {
@@ -91376,7 +91419,12 @@
91376
91419
  else if (isPositionLayout) {
91377
91420
  points = spec.positions;
91378
91421
  }
91379
- 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;
91380
91428
  let limitRect;
91381
91429
  if (spec.clip || ((_b = spec.label) === null || _b === void 0 ? void 0 : _b.confine)) {
91382
91430
  const { minX, maxX, minY, maxY } = this._computeClipRange([
@@ -91394,7 +91442,7 @@
91394
91442
  (_c = this._markerComponent) === null || _c === void 0 ? void 0 : _c.setAttributes({
91395
91443
  points: points,
91396
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
91397
- ? this._spec.label.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
91445
+ ? this._spec.label.formatMethod(dataPoints, seriesData)
91398
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 }),
91399
91447
  limitRect,
91400
91448
  dx: this.layoutOffsetX,
@@ -91448,7 +91496,7 @@
91448
91496
  }
91449
91497
  static createComponent(spec, options) {
91450
91498
  const markPointSpec = spec.markPoint || options.defaultSpec;
91451
- if (isNil$1(markPointSpec)) {
91499
+ if (isEmpty(markPointSpec)) {
91452
91500
  return undefined;
91453
91501
  }
91454
91502
  if (!isArray$4(markPointSpec) && markPointSpec.visible !== false) {
@@ -91492,7 +91540,12 @@
91492
91540
  else if (isPositionLayout) {
91493
91541
  point = spec.position;
91494
91542
  }
91495
- 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;
91496
91549
  let limitRect;
91497
91550
  if (spec.clip) {
91498
91551
  const { minX, maxX, minY, maxY } = this._computeClipRange([relativeSeries.getRegion()]);
@@ -91506,7 +91559,7 @@
91506
91559
  (_b = this._markerComponent) === null || _b === void 0 ? void 0 : _b.setAttributes({
91507
91560
  position: point,
91508
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)
91509
- ? this._spec.itemContent.text.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
91562
+ ? this._spec.itemContent.text.formatMethod(dataPoints, seriesData)
91510
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 }) }),
91511
91564
  limitRect,
91512
91565
  dx: this.layoutOffsetX,
@@ -91607,6 +91660,41 @@
91607
91660
  }
91608
91661
  return boundingClientRect.height / element.offsetHeight;
91609
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
+ };
91610
91698
 
91611
91699
  const TOOLTIP_EL_CLASS_NAME = 'vchart-tooltip-element';
91612
91700
  const TOOLTIP_CONTAINER_EL_CLASS_NAME = 'vchart-tooltip-container';
@@ -91982,182 +92070,208 @@
91982
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; };
91983
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; };
91984
92072
 
91985
- const defaultTextAttributes = {
92073
+ const DEFAULT_TEXT_ATTRIBUTES = {
91986
92074
  fontFamily: THEME_CONSTANTS.defaultFontFamily,
91987
92075
  spacing: 10,
91988
- multiLine: false,
91989
92076
  wordBreak: 'break-word'
91990
92077
  };
91991
92078
  function getTextAttributes(style = {}, globalTheme, defaultAttributes) {
91992
92079
  var _a, _b;
91993
- 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 });
91994
92081
  return attrs;
91995
92082
  }
91996
-
91997
- const getTooltipAttributes = (actualTooltip, style) => {
91998
- const { spaceRow: commonSpaceRow, padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle } = style;
91999
- 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: {
92000
92129
  value: titleStyle,
92001
92130
  spaceRow: commonSpaceRow
92002
- }, contentStyle: {
92131
+ },
92132
+ contentStyle: {
92003
92133
  shape: shapeStyle,
92004
92134
  key: keyStyle,
92005
92135
  value: valueStyle,
92006
92136
  spaceRow: commonSpaceRow
92007
- }, hasContentShape: false, keyWidth: 0, valueWidth: 0 });
92008
- ['key', 'value', 'shape'].forEach(key => {
92009
- delete attribute[key];
92010
- });
92137
+ },
92138
+ hasContentShape: false,
92139
+ keyWidth: 0,
92140
+ valueWidth: 0,
92141
+ enterable,
92142
+ transitionDuration
92143
+ };
92011
92144
  const { title = {}, content = [] } = actualTooltip;
92012
- let maxWidth = 0;
92013
- let containerHeight = padding.top + padding.bottom;
92014
- let titleMaxHeight = 0;
92015
- const { visible: titleVisible = true, value: titleValue = '', valueStyle: titleValueStyle, hasShape: titleHasShape, shapeType: titleShapeType = '', shapeHollow: titleShapeHollow, shapeColor: titleShapeColor, spaceRow: titleSpaceRow } = title;
92016
- attribute.title.visible = titleVisible;
92017
- attribute.title.spaceRow = titleSpaceRow !== null && titleSpaceRow !== void 0 ? titleSpaceRow : commonSpaceRow;
92018
- if (titleVisible) {
92019
- const lineTitleStyle = mergeSpec({}, titleStyle, getTextAttributes(titleValueStyle, undefined, {}));
92020
- const { text, width, height } = measureTooltipText(titleValue, lineTitleStyle);
92021
- attribute.title.value = Object.assign(Object.assign({ width,
92022
- height }, lineTitleStyle), { text });
92023
- maxWidth = width;
92024
- titleMaxHeight = height;
92025
- if (titleHasShape && builtinSymbolsMap[titleShapeType]) {
92026
- const titleShapeAttrs = {
92027
- symbolType: titleShapeType
92028
- };
92029
- if (titleShapeHollow) {
92030
- titleShapeAttrs.stroke = titleShapeColor;
92031
- }
92032
- else {
92033
- titleShapeAttrs.fill = titleShapeColor;
92034
- }
92035
- attribute.title.shape = titleShapeAttrs;
92036
- maxWidth += shapeStyle.size + shapeStyle.spacing;
92037
- titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);
92038
- }
92039
- attribute.title.width = maxWidth;
92040
- attribute.title.height = titleMaxHeight;
92041
- containerHeight += titleMaxHeight;
92042
- }
92043
- if (content.length) {
92044
- const filteredContent = content.filter(item => {
92045
- return (item.key || item.value) && item.visible !== false;
92046
- });
92047
- if (filteredContent.length) {
92048
- if (titleVisible) {
92049
- containerHeight += attribute.title.spaceRow;
92050
- }
92051
- const keyWidths = [];
92052
- const adaptiveKeyWidths = [];
92053
- const valueWidths = [];
92054
- const shapeWidths = [];
92055
- attribute.content = filteredContent.map((item, i) => {
92056
- let itemHeight = 0;
92057
- const { hasShape, key, shapeColor, shapeHollow, shapeType = '', shapeFill, shapeStroke, shapeLineWidth, shapeSize, value, isKeyAdaptive, spaceRow: lineSpaceRow } = item;
92058
- const itemAttrs = { height: 0, spaceRow: lineSpaceRow !== null && lineSpaceRow !== void 0 ? lineSpaceRow : commonSpaceRow };
92059
- if (isValid$1(key)) {
92060
- const lineKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(item.keyStyle, undefined, {}));
92061
- const { width, height, text } = measureTooltipText(key, lineKeyStyle);
92062
- itemAttrs.key = Object.assign(Object.assign({ width,
92063
- height }, lineKeyStyle), { text });
92064
- if (!isKeyAdaptive) {
92065
- keyWidths.push(width);
92066
- }
92067
- else {
92068
- adaptiveKeyWidths.push(width);
92069
- }
92070
- 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);
92071
92172
  }
92072
- if (isValid$1(value)) {
92073
- const lineValueStyle = mergeSpec({}, valueStyle, getTextAttributes(item.valueStyle, undefined, {}));
92074
- const { width, height, text } = measureTooltipText(value, lineValueStyle);
92075
- itemAttrs.value = Object.assign(Object.assign({ width,
92076
- height }, lineValueStyle), { text });
92077
- valueWidths.push(width);
92078
- itemHeight = Math.max(itemHeight, height);
92173
+ else {
92174
+ adaptiveKeyWidths.push(width);
92079
92175
  }
92080
- if (hasShape) {
92081
- const shape = {
92082
- visible: true,
92083
- symbolType: shapeType
92084
- };
92085
- const adaptiveShapeFill = shapeFill !== null && shapeFill !== void 0 ? shapeFill : shapeColor;
92086
- if (shapeHollow) {
92087
- shape.stroke = adaptiveShapeFill;
92088
- }
92089
- else {
92090
- shape.fill = adaptiveShapeFill;
92091
- }
92092
- shape.stroke = shapeStroke !== null && shapeStroke !== void 0 ? shapeStroke : adaptiveShapeFill;
92093
- shape.lineWidth = shapeLineWidth;
92094
- itemAttrs.shape = shape;
92095
- const shapeWidth = shapeSize !== null && shapeSize !== void 0 ? shapeSize : shapeStyle.size;
92096
- itemHeight = Math.max(shapeWidth, itemHeight);
92097
- 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;
92098
92194
  }
92099
92195
  else {
92100
- itemAttrs.shape = { visible: false };
92196
+ shape.fill = adaptiveShapeFill;
92101
92197
  }
92102
- itemAttrs.height = itemHeight;
92103
- containerHeight += itemHeight;
92104
- if (i < filteredContent.length - 1) {
92105
- containerHeight += itemAttrs.spaceRow;
92106
- }
92107
- return itemAttrs;
92108
- });
92109
- const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0;
92110
- const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;
92111
- const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0;
92112
- const shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0;
92113
- maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth);
92114
- attribute.hasContentShape = !!shapeWidths.length;
92115
- attribute.keyWidth = maxKeyWidth;
92116
- attribute.valueWidth = maxValueWidth;
92117
- }
92118
- }
92119
- const containerSize = {
92120
- width: maxWidth + padding.left + padding.right,
92121
- height: containerHeight
92122
- };
92123
- attribute.panel.width = containerSize.width;
92124
- attribute.panel.height = containerSize.height;
92125
- return attribute;
92126
- };
92127
- const measureTooltipText = (text, style) => {
92128
- var _a;
92129
- text = (text !== null && text !== void 0 ? text : '').toString();
92130
- const measure = initTextMeasure(style);
92131
- if (!style.multiLine) {
92132
- const { width, height } = measure.fullMeasure(text);
92133
- return {
92134
- width,
92135
- height,
92136
- text
92137
- };
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;
92138
92247
  }
92139
- let textLines = text.split('\n');
92140
- textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\n' : line));
92141
- const { width, height } = measure.fullMeasure(textLines);
92142
- if (style.maxWidth && style.maxWidth <= width) {
92143
- const bound = getRichTextBounds({
92144
- wordBreak: (_a = style.wordBreak) !== null && _a !== void 0 ? _a : 'break-word',
92145
- maxWidth: style.maxWidth,
92146
- width: 0,
92147
- height: 0,
92148
- 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
+ }
92149
92270
  });
92150
- return {
92151
- width: bound.width(),
92152
- height: bound.height(),
92153
- text: textLines
92154
- };
92155
92271
  }
92156
- return {
92157
- width,
92158
- height,
92159
- text: textLines
92160
- };
92272
+ attributes.panel.width = containerWidth;
92273
+ attributes.panel.height = containerHeight;
92274
+ return attributes;
92161
92275
  };
92162
92276
 
92163
92277
  var TooltipResult;
@@ -92176,7 +92290,8 @@
92176
92290
  constructor(tooltipId, component) {
92177
92291
  this._visible = true;
92178
92292
  this._id = '';
92179
- this._attributeCache = null;
92293
+ this._attributes = null;
92294
+ this._isReleased = false;
92180
92295
  this.showTooltip = (activeType, data, params) => {
92181
92296
  var _a;
92182
92297
  let changePositionOnly = !!params.changePositionOnly;
@@ -92193,7 +92308,7 @@
92193
92308
  this._changeTooltip = (visible, params, changePositionOnly, activeType, data) => {
92194
92309
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
92195
92310
  const tooltipSpec = this._component.getSpec();
92196
- if (!tooltipSpec) {
92311
+ if (this._isReleased || !tooltipSpec) {
92197
92312
  return TooltipResult.failed;
92198
92313
  }
92199
92314
  if (!visible) {
@@ -92243,6 +92358,9 @@
92243
92358
  };
92244
92359
  this._changeTooltipPosition = (changePositionOnly, actualTooltip, spec, activeType, data, params) => {
92245
92360
  var _a, _b, _c;
92361
+ if (this._isReleased) {
92362
+ return TooltipResult.failed;
92363
+ }
92246
92364
  const event = params.event;
92247
92365
  if (spec.handler) {
92248
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;
@@ -92567,6 +92685,7 @@
92567
92685
  return;
92568
92686
  }
92569
92687
  this._removeTooltip();
92688
+ this._isReleased = true;
92570
92689
  }
92571
92690
  _throttle(callback) {
92572
92691
  const tooltipSpec = this._component.getSpec();
@@ -92590,57 +92709,14 @@
92590
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 });
92591
92710
  }
92592
92711
  _getTooltipBoxSize(actualTooltip, changePositionOnly) {
92593
- var _a, _b, _c, _d;
92594
- if (!changePositionOnly || isNil$1(this._attributeCache)) {
92595
- this._attributeCache = getTooltipAttributes(actualTooltip, this._style);
92596
- }
92597
- return {
92598
- width: (_b = (_a = this._attributeCache) === null || _a === void 0 ? void 0 : _a.panel) === null || _b === void 0 ? void 0 : _b.width,
92599
- height: (_d = (_c = this._attributeCache) === null || _c === void 0 ? void 0 : _c.panel) === null || _d === void 0 ? void 0 : _d.height
92600
- };
92601
- }
92602
- _getStyle() {
92603
- var _a, _b, _c, _d, _e;
92604
- const tooltipSpec = this._component.getSpec();
92605
- const { style = {}, enterable, transitionDuration } = tooltipSpec;
92606
- const { panel = {}, titleLabel, shape, keyLabel, valueLabel, spaceRow } = style;
92607
- const { backgroundColor, border, shadow, padding } = panel;
92608
- const panelStyle = {
92609
- lineWidth: (_a = border === null || border === void 0 ? void 0 : border.width) !== null && _a !== void 0 ? _a : 0,
92610
- shadow: !!shadow
92611
- };
92612
- if (border === null || border === void 0 ? void 0 : border.color) {
92613
- panelStyle.stroke = border.color;
92614
- }
92615
- if (backgroundColor) {
92616
- panelStyle.fill = backgroundColor;
92617
- }
92618
- if (shadow) {
92619
- panelStyle.shadowColor = shadow.color;
92620
- panelStyle.shadowBlur = shadow.blur;
92621
- panelStyle.shadowOffsetX = shadow.x;
92622
- panelStyle.shadowOffsetY = shadow.y;
92623
- panelStyle.shadowSpread = shadow.spread;
92624
- }
92625
- const { radius } = border !== null && border !== void 0 ? border : {};
92626
- if (isValid$1(radius)) {
92627
- 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);
92628
92716
  }
92629
- const globalTheme = (_c = (_b = this._chartOption).getTheme) === null || _c === void 0 ? void 0 : _c.call(_b);
92630
92717
  return {
92631
- panel: panelStyle,
92632
- title: getTextAttributes(titleLabel, globalTheme),
92633
- shape: {
92634
- fill: true,
92635
- size: (_d = shape === null || shape === void 0 ? void 0 : shape.size) !== null && _d !== void 0 ? _d : 8,
92636
- spacing: (_e = shape === null || shape === void 0 ? void 0 : shape.spacing) !== null && _e !== void 0 ? _e : 6
92637
- },
92638
- key: getTextAttributes(keyLabel, globalTheme),
92639
- value: getTextAttributes(valueLabel, globalTheme),
92640
- padding,
92641
- spaceRow,
92642
- enterable,
92643
- 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
92644
92720
  };
92645
92721
  }
92646
92722
  _getParentElement(spec) {
@@ -92651,7 +92727,6 @@
92651
92727
  }
92652
92728
  _initFromSpec() {
92653
92729
  this._option = this._getDefaultOption();
92654
- this._style = this._getStyle();
92655
92730
  this.changeTooltip = this._throttle(this._changeTooltip);
92656
92731
  this.changeTooltipPosition = this._throttle(this._changeTooltipPosition);
92657
92732
  }
@@ -92685,22 +92760,24 @@
92685
92760
  }
92686
92761
  return numArr;
92687
92762
  };
92688
- function getDomStyles(style, attributeCache) {
92689
- var _a, _b, _c, _d, _e, _f, _g;
92690
- const { panel: { fill: fillColor, shadow, shadowBlur, shadowColor, shadowOffsetX, shadowOffsetY, shadowSpread, cornerRadius, stroke: strokeColor, lineWidth = 0 }, padding, key, value, title, shape, enterable, transitionDuration } = style;
92691
- const { panel: panelAttribute, title: titleAttribute, content: contentAttribute, keyWidth, valueWidth } = attributeCache !== null && attributeCache !== void 0 ? attributeCache : {};
92692
- 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;
92693
92769
  const shapeStyle = getShapeStyle(shape);
92694
92770
  const keyStyle = getLabelStyle(key);
92695
92771
  const valueStyle = getLabelStyle(value);
92772
+ const { bottom, left, right, top } = normalizeLayoutPaddingSpec(padding);
92696
92773
  const styles = {
92697
92774
  panel: {
92698
- width: getPixelPropertyStr(((_a = panelAttribute === null || panelAttribute === void 0 ? void 0 : panelAttribute.width) !== null && _a !== void 0 ? _a : 0) + lineWidth * 2),
92699
- minHeight: getPixelPropertyStr(((_b = panelAttribute === null || panelAttribute === void 0 ? void 0 : panelAttribute.height) !== null && _b !== void 0 ? _b : 0) + lineWidth * 2),
92700
- paddingBottom: getPixelPropertyStr(padding.bottom),
92701
- paddingLeft: getPixelPropertyStr(padding.left),
92702
- paddingRight: getPixelPropertyStr(padding.right),
92703
- 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),
92704
92781
  borderColor: strokeColor,
92705
92782
  borderWidth: getPixelPropertyStr(lineWidth),
92706
92783
  borderRadius: getPixelPropertyStr(cornerRadius),
@@ -92719,20 +92796,20 @@
92719
92796
  common: shapeStyle,
92720
92797
  items: [],
92721
92798
  width: getPixelPropertyStr(shape.size),
92722
- marginRight: getPixelPropertyStr((_c = shape.spacing) !== null && _c !== void 0 ? _c : DEFAULT_SHAPE_SPACING),
92723
- 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))
92724
92801
  },
92725
92802
  keyColumn: {
92726
92803
  common: keyStyle,
92727
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)))),
92728
92805
  width: getPixelPropertyStr(keyWidth),
92729
- 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)
92730
92807
  },
92731
92808
  valueColumn: {
92732
92809
  common: valueStyle,
92733
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)))),
92734
92811
  width: getPixelPropertyStr(valueWidth),
92735
- 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)
92736
92813
  }
92737
92814
  };
92738
92815
  return styles;
@@ -93437,7 +93514,7 @@
93437
93514
  valueToHtml: this._option.sanitize,
93438
93515
  getTooltipStyle: () => this._domStyle,
93439
93516
  getTooltipActual: () => this._tooltipActual,
93440
- getTooltipAttributes: () => this._attributeCache
93517
+ getTooltipAttributes: () => this._attributes
93441
93518
  }, [tooltipSpec.className], this.id);
93442
93519
  }
93443
93520
  }
@@ -93468,7 +93545,7 @@
93468
93545
  }
93469
93546
  }
93470
93547
  _initStyle() {
93471
- this._domStyle = getDomStyles(this._style, this._attributeCache);
93548
+ this._domStyle = getDomStyles(this._attributes);
93472
93549
  }
93473
93550
  _getParentElement(spec) {
93474
93551
  var _a;
@@ -93514,7 +93591,7 @@
93514
93591
  if (this._layer) {
93515
93592
  this._layer.removeAllChild();
93516
93593
  }
93517
- this._attributeCache = null;
93594
+ this._attributes = null;
93518
93595
  }
93519
93596
  _updateTooltip(visible, params, actualTooltip) {
93520
93597
  this._visible = visible;
@@ -93536,7 +93613,7 @@
93536
93613
  }
93537
93614
  const pos = actualTooltip === null || actualTooltip === void 0 ? void 0 : actualTooltip.position;
93538
93615
  if (!params.changePositionOnly) {
93539
- this._tooltipComponent.setAttributes(Object.assign(Object.assign({}, this._attributeCache), pos));
93616
+ this._tooltipComponent.setAttributes(Object.assign(Object.assign({}, this._attributes), pos));
93540
93617
  }
93541
93618
  else if (isValid$1(pos)) {
93542
93619
  this._tooltipComponent.setAttributes(pos);
@@ -93892,12 +93969,6 @@
93892
93969
  }
93893
93970
  release() {
93894
93971
  var _a, _b;
93895
- this.event.emit(ChartEvent.tooltipHide, {
93896
- tooltip: this
93897
- });
93898
- this.event.emit(ChartEvent.tooltipRelease, {
93899
- tooltip: this
93900
- });
93901
93972
  super.release();
93902
93973
  this._eventList.forEach(({ eventType, handler }) => {
93903
93974
  this.event.off(eventType, handler);
@@ -93906,6 +93977,14 @@
93906
93977
  (_b = (_a = this.tooltipHandler) === null || _a === void 0 ? void 0 : _a.release) === null || _b === void 0 ? void 0 : _b.call(_a);
93907
93978
  this._isTooltipShown = false;
93908
93979
  }
93980
+ beforeRelease() {
93981
+ this.event.emit(ChartEvent.tooltipHide, {
93982
+ tooltip: this
93983
+ });
93984
+ this.event.emit(ChartEvent.tooltipRelease, {
93985
+ tooltip: this
93986
+ });
93987
+ }
93909
93988
  _initHandler() {
93910
93989
  var _a, _b, _c;
93911
93990
  const renderMode = (_a = this._spec.renderMode) !== null && _a !== void 0 ? _a : 'html';