@visactor/vchart 2.0.20-alpha.2 → 2.0.20-alpha.3

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 (128) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +194 -98
  3. package/build/index.js +194 -98
  4. package/build/index.min.js +2 -2
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/compile/compiler.d.ts +0 -2
  7. package/cjs/compile/compiler.js +2 -14
  8. package/cjs/compile/compiler.js.map +1 -1
  9. package/cjs/compile/mark/interface.d.ts +1 -0
  10. package/cjs/compile/mark/interface.js.map +1 -1
  11. package/cjs/compile/mark/mark-state-manager.d.ts +1 -0
  12. package/cjs/compile/mark/mark-state-manager.js +3 -0
  13. package/cjs/compile/mark/mark-state-manager.js.map +1 -1
  14. package/cjs/component/axis/base-axis.d.ts +9 -1
  15. package/cjs/component/axis/base-axis.js +37 -7
  16. package/cjs/component/axis/base-axis.js.map +1 -1
  17. package/cjs/component/axis/cartesian/axis.js +4 -3
  18. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  19. package/cjs/component/axis/cartesian/interface/spec.d.ts +1 -0
  20. package/cjs/component/axis/cartesian/interface/spec.js.map +1 -1
  21. package/cjs/component/axis/mixin/band-axis-mixin.d.ts +1 -0
  22. package/cjs/component/axis/mixin/band-axis-mixin.js +1 -1
  23. package/cjs/component/axis/mixin/band-axis-mixin.js.map +1 -1
  24. package/cjs/component/axis/mixin/linear-axis-mixin.d.ts +1 -0
  25. package/cjs/component/axis/mixin/linear-axis-mixin.js +1 -1
  26. package/cjs/component/axis/mixin/linear-axis-mixin.js.map +1 -1
  27. package/cjs/component/axis/polar/axis.js +1 -1
  28. package/cjs/component/axis/polar/axis.js.map +1 -1
  29. package/cjs/component/legend/continuous/interface.d.ts +5 -2
  30. package/cjs/component/legend/continuous/interface.js.map +1 -1
  31. package/cjs/component/legend/continuous/util.js +12 -4
  32. package/cjs/component/legend/continuous/util.js.map +1 -1
  33. package/cjs/constant/funnel.js +1 -1
  34. package/cjs/constant/gradient.js +1 -1
  35. package/cjs/constant/hierarchy.js +1 -1
  36. package/cjs/constant/label.js +1 -1
  37. package/cjs/constant/layout.js +1 -1
  38. package/cjs/constant/marker.js +1 -1
  39. package/cjs/constant/polar.js +1 -1
  40. package/cjs/constant/scatter.js +1 -1
  41. package/cjs/constant/scroll-bar.js +2 -1
  42. package/cjs/constant/sunburst.js +1 -1
  43. package/cjs/constant/waterfall.js +1 -1
  44. package/cjs/constant/word-cloud.js +1 -1
  45. package/cjs/core/interface.js +1 -1
  46. package/cjs/core/util.js +1 -1
  47. package/cjs/core/vchart.js +1 -1
  48. package/cjs/data/initialize.js +1 -1
  49. package/cjs/data/register.js +1 -1
  50. package/cjs/env/env.js +1 -1
  51. package/cjs/env/index.js +1 -1
  52. package/cjs/event/bubble.js +1 -1
  53. package/cjs/event/event-dispatcher.js +1 -1
  54. package/cjs/event/event.js +1 -1
  55. package/cjs/event/index.js +1 -1
  56. package/cjs/event/interface.js +1 -2
  57. package/cjs/mark/base/base-mark.d.ts +1 -0
  58. package/cjs/mark/base/base-mark.js +11 -4
  59. package/cjs/mark/base/base-mark.js.map +1 -1
  60. package/cjs/mark/interface/common.d.ts +1 -0
  61. package/cjs/mark/interface/common.js.map +1 -1
  62. package/cjs/series/base/base-series.js +1 -1
  63. package/cjs/series/base/base-series.js.map +1 -1
  64. package/cjs/series/pie/pie.d.ts +2 -0
  65. package/cjs/series/pie/pie.js +6 -4
  66. package/cjs/series/pie/pie.js.map +1 -1
  67. package/esm/compile/compiler.d.ts +0 -2
  68. package/esm/compile/compiler.js +2 -14
  69. package/esm/compile/compiler.js.map +1 -1
  70. package/esm/compile/mark/interface.d.ts +1 -0
  71. package/esm/compile/mark/interface.js.map +1 -1
  72. package/esm/compile/mark/mark-state-manager.d.ts +1 -0
  73. package/esm/compile/mark/mark-state-manager.js +3 -0
  74. package/esm/compile/mark/mark-state-manager.js.map +1 -1
  75. package/esm/component/axis/base-axis.d.ts +9 -1
  76. package/esm/component/axis/base-axis.js +37 -7
  77. package/esm/component/axis/base-axis.js.map +1 -1
  78. package/esm/component/axis/cartesian/axis.js +4 -3
  79. package/esm/component/axis/cartesian/axis.js.map +1 -1
  80. package/esm/component/axis/cartesian/interface/spec.d.ts +1 -0
  81. package/esm/component/axis/cartesian/interface/spec.js.map +1 -1
  82. package/esm/component/axis/mixin/band-axis-mixin.d.ts +1 -0
  83. package/esm/component/axis/mixin/band-axis-mixin.js +1 -1
  84. package/esm/component/axis/mixin/band-axis-mixin.js.map +1 -1
  85. package/esm/component/axis/mixin/linear-axis-mixin.d.ts +1 -0
  86. package/esm/component/axis/mixin/linear-axis-mixin.js +1 -1
  87. package/esm/component/axis/mixin/linear-axis-mixin.js.map +1 -1
  88. package/esm/component/axis/polar/axis.js +1 -1
  89. package/esm/component/axis/polar/axis.js.map +1 -1
  90. package/esm/component/legend/continuous/interface.d.ts +5 -2
  91. package/esm/component/legend/continuous/interface.js.map +1 -1
  92. package/esm/component/legend/continuous/util.js +9 -2
  93. package/esm/component/legend/continuous/util.js.map +1 -1
  94. package/esm/constant/funnel.js +1 -1
  95. package/esm/constant/gradient.js +1 -1
  96. package/esm/constant/hierarchy.js +1 -1
  97. package/esm/constant/label.js +1 -1
  98. package/esm/constant/layout.js +1 -1
  99. package/esm/constant/marker.js +1 -1
  100. package/esm/constant/polar.js +1 -1
  101. package/esm/constant/scatter.js +1 -1
  102. package/esm/constant/scroll-bar.js +2 -1
  103. package/esm/constant/sunburst.js +1 -1
  104. package/esm/constant/waterfall.js +1 -1
  105. package/esm/constant/word-cloud.js +1 -1
  106. package/esm/core/interface.js +1 -1
  107. package/esm/core/util.js +1 -1
  108. package/esm/core/vchart.js +1 -1
  109. package/esm/data/initialize.js +1 -1
  110. package/esm/data/register.js +1 -1
  111. package/esm/env/env.js +1 -1
  112. package/esm/env/index.js +1 -1
  113. package/esm/event/bubble.js +1 -1
  114. package/esm/event/event-dispatcher.js +1 -1
  115. package/esm/event/event.js +1 -1
  116. package/esm/event/index.js +1 -1
  117. package/esm/event/interface.js +1 -2
  118. package/esm/mark/base/base-mark.d.ts +1 -0
  119. package/esm/mark/base/base-mark.js +12 -4
  120. package/esm/mark/base/base-mark.js.map +1 -1
  121. package/esm/mark/interface/common.d.ts +1 -0
  122. package/esm/mark/interface/common.js.map +1 -1
  123. package/esm/series/base/base-series.js +1 -1
  124. package/esm/series/base/base-series.js.map +1 -1
  125. package/esm/series/pie/pie.d.ts +2 -0
  126. package/esm/series/pie/pie.js +7 -4
  127. package/esm/series/pie/pie.js.map +1 -1
  128. package/package.json +7 -7
package/build/index.js CHANGED
@@ -22141,9 +22141,10 @@
22141
22141
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
22142
22142
  } else {
22143
22143
  const {
22144
- backgroundCornerRadius: backgroundCornerRadius
22144
+ backgroundCornerRadius: backgroundCornerRadius,
22145
+ backgroundOpacity = 1
22145
22146
  } = graphic.attribute;
22146
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
22147
+ context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity, context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
22147
22148
  }
22148
22149
  shouldReCalBounds && boundsAllocate.free(b), restore();
22149
22150
  }
@@ -44077,8 +44078,9 @@
44077
44078
  const label = labels[i];
44078
44079
  if (!label) continue;
44079
44080
  const baseMark = this.getRelatedGraphic(label.attribute);
44080
- let backgroundColor = baseMark.getAttributes(!0).fill,
44081
- foregroundColor = label.attribute.fill;
44081
+ let backgroundColor = baseMark.getAttributes(!0).fill;
44082
+ const backgroundOpacity = baseMark.getAttributes(!0).fillOpacity;
44083
+ let foregroundColor = label.attribute.fill;
44082
44084
  if (isObject$2(backgroundColor) && backgroundColor.gradient) {
44083
44085
  const firstStopColor = null === (_g = null === (_f = backgroundColor.stops) || void 0 === _f ? void 0 : _f[0]) || void 0 === _g ? void 0 : _g.color;
44084
44086
  firstStopColor && (backgroundColor = firstStopColor, foregroundColor = firstStopColor);
@@ -44092,11 +44094,26 @@
44092
44094
  if (fill && label.setAttributes({
44093
44095
  fill: fill
44094
44096
  }), 0 === label.attribute.lineWidth || 0 === label.attribute.strokeOpacity) continue;
44095
- const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
44096
- stroke && label.setAttributes({
44097
- stroke: stroke
44098
- });
44097
+ if ("background" === interactInvertType) label.setAttributes({
44098
+ stroke: !1
44099
+ });else {
44100
+ const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
44101
+ stroke && label.setAttributes({
44102
+ stroke: stroke
44103
+ });
44104
+ }
44099
44105
  } else if (isIntersect && "none" !== interactInvertType) {
44106
+ if ("background" === interactInvertType) {
44107
+ const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
44108
+ fill && label.setAttributes({
44109
+ fill: fill
44110
+ }), label.setAttributes({
44111
+ stroke: !1,
44112
+ background: backgroundColor,
44113
+ backgroundOpacity: backgroundOpacity
44114
+ });
44115
+ continue;
44116
+ }
44100
44117
  if (0 === label.attribute.lineWidth || 0 === label.attribute.strokeOpacity) continue;
44101
44118
  if (label.attribute.stroke) {
44102
44119
  label.setAttributes({
@@ -44113,6 +44130,9 @@
44113
44130
  stroke: stroke
44114
44131
  });
44115
44132
  }
44133
+ !1 === isInside && "background" === interactInvertType && label.setAttributes({
44134
+ background: null
44135
+ });
44116
44136
  }
44117
44137
  }
44118
44138
  _canPlaceInside(textBound, shapeBound) {
@@ -49656,7 +49676,31 @@
49656
49676
  return graphicCreator.symbol(style);
49657
49677
  }
49658
49678
  _renderHandlerText(value, position) {
49659
- var _a, _b, _c;
49679
+ return graphicCreator.text(this._getHandlerTextAttributes(value, position));
49680
+ }
49681
+ _getHandlerPosition(isStart) {
49682
+ return this.attribute.range && isStart ? "start" : "end";
49683
+ }
49684
+ _getHandlerTextStyle(value, position) {
49685
+ const {
49686
+ align: align,
49687
+ handlerSize = 14,
49688
+ handlerText = {},
49689
+ railHeight: railHeight,
49690
+ railWidth: railWidth,
49691
+ slidable: slidable
49692
+ } = this.attribute;
49693
+ return isFunction$1(handlerText.style) ? handlerText.style(value, position, {
49694
+ layout: this.attribute.layout,
49695
+ align: align,
49696
+ railWidth: railWidth,
49697
+ railHeight: railHeight,
49698
+ handlerSize: handlerSize,
49699
+ slidable: slidable
49700
+ }) : handlerText.style;
49701
+ }
49702
+ _getHandlerTextAttributes(value, position) {
49703
+ var _a, _b;
49660
49704
  const {
49661
49705
  align: align,
49662
49706
  handlerSize = 14,
@@ -49668,13 +49712,13 @@
49668
49712
  isHorizontal = this._isHorizontal,
49669
49713
  pos = this.calculatePosByValue(value, position),
49670
49714
  textSpace = null !== (_a = handlerText.space) && void 0 !== _a ? _a : 4,
49715
+ handlerTextStyle = this._getHandlerTextStyle(value, position),
49671
49716
  textStyle = {
49672
49717
  text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_b = handlerText.precision) && void 0 !== _b ? _b : 0),
49673
- lineHeight: null === (_c = handlerText.style) || void 0 === _c ? void 0 : _c.lineHeight,
49718
+ lineHeight: null == handlerTextStyle ? void 0 : handlerTextStyle.lineHeight,
49674
49719
  cursor: !1 === slidable ? "default" : getDefaultCursor(isHorizontal)
49675
49720
  };
49676
- isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos);
49677
- return graphicCreator.text(Object.assign(Object.assign({}, textStyle), handlerText.style));
49721
+ return isHorizontal ? "top" === align ? (textStyle.textBaseline = "bottom", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight - handlerSize) / 2 - textSpace) : (textStyle.textBaseline = "top", textStyle.textAlign = "center", textStyle.x = pos, textStyle.y = (railHeight + handlerSize) / 2 + textSpace) : "left" === align ? (textStyle.textBaseline = "middle", textStyle.textAlign = "end", textStyle.x = (railWidth - handlerSize) / 2 - textSpace, textStyle.y = pos) : (textStyle.textBaseline = "middle", textStyle.textAlign = "start", textStyle.x = (railWidth + handlerSize) / 2 + textSpace, textStyle.y = pos), Object.assign(Object.assign({}, textStyle), handlerTextStyle);
49678
49722
  }
49679
49723
  _renderTooltip() {
49680
49724
  var _a;
@@ -49802,31 +49846,19 @@
49802
49846
  }
49803
49847
  }
49804
49848
  _updateHandler(handler, position, value) {
49805
- var _a;
49806
49849
  const isHorizontal = this._isHorizontal;
49807
49850
  handler.setAttribute(isHorizontal ? "x" : "y", position);
49808
49851
  const updateHandlerText = handler.name === SLIDER_ELEMENT_NAME.startHandler ? this._startHandlerText : this._endHandlerText;
49809
49852
  if (updateHandlerText) {
49810
- const {
49811
- handlerText = {}
49812
- } = this.attribute;
49813
- updateHandlerText.setAttributes({
49814
- text: handlerText.formatter ? handlerText.formatter(value) : value.toFixed(null !== (_a = handlerText.precision) && void 0 !== _a ? _a : 0),
49815
- [isHorizontal ? "x" : "y"]: position
49816
- });
49853
+ const handlerPosition = this._getHandlerPosition(handler.name === SLIDER_ELEMENT_NAME.startHandler);
49854
+ updateHandlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
49817
49855
  }
49818
49856
  handler.name === SLIDER_ELEMENT_NAME.startHandler ? (this._currentValue.startValue = value, this._currentValue.startPos = position) : (this._currentValue.endValue = value, this._currentValue.endPos = position);
49819
49857
  }
49820
49858
  _updateHandlerText(handlerText, position, value) {
49821
- var _a;
49822
49859
  const isHorizontal = this._isHorizontal,
49823
- {
49824
- handlerText: handlerTextAttr = {}
49825
- } = this.attribute;
49826
- handlerText.setAttributes({
49827
- [isHorizontal ? "x" : "y"]: position,
49828
- text: handlerTextAttr.formatter ? handlerTextAttr.formatter(value) : value.toFixed(null !== (_a = handlerTextAttr.precision) && void 0 !== _a ? _a : 0)
49829
- });
49860
+ handlerPosition = this._getHandlerPosition(handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText);
49861
+ handlerText.setAttributes(this._getHandlerTextAttributes(value, handlerPosition));
49830
49862
  const updateHandler = handlerText.name === SLIDER_ELEMENT_NAME.startHandlerText ? this._startHandler : this._endHandler;
49831
49863
  updateHandler && updateHandler.setAttributes({
49832
49864
  [isHorizontal ? "x" : "y"]: position
@@ -55097,33 +55129,6 @@
55097
55129
  updateLayoutTag() {
55098
55130
  this._layoutState = LayoutState.before;
55099
55131
  }
55100
- _isGeoRegionRoamDragEnabled() {
55101
- var _a, _b;
55102
- const chartSpec = (_b = (_a = this._compileChart) === null || _a === void 0 ? void 0 : _a.getSpec) === null || _b === void 0 ? void 0 : _b.call(_a);
55103
- const regions = chartSpec === null || chartSpec === void 0 ? void 0 : chartSpec.region;
55104
- if (!isArray$1(regions)) {
55105
- return false;
55106
- }
55107
- return regions.some((region) => {
55108
- var _a;
55109
- if ((region === null || region === void 0 ? void 0 : region.coordinate) !== 'geo' || !region.roam) {
55110
- return false;
55111
- }
55112
- if (region.roam === true) {
55113
- return true;
55114
- }
55115
- return (_a = region.roam.drag) !== null && _a !== void 0 ? _a : true;
55116
- });
55117
- }
55118
- _shouldDisableCanvasTouchAction() {
55119
- if (!isTrueBrowser(this._option.mode)) {
55120
- return false;
55121
- }
55122
- const supportsTouchEvents = isValid$1(this._option.supportsTouchEvents)
55123
- ? this._option.supportsTouchEvents
55124
- : vglobal.supportsTouchEvents;
55125
- return supportsTouchEvents === false && this._isGeoRegionRoamDragEnabled();
55126
- }
55127
55132
  _setCanvasStyle() {
55128
55133
  if (!this._stage) {
55129
55134
  return;
@@ -55134,7 +55139,6 @@
55134
55139
  const canvas = this.getCanvas();
55135
55140
  if (canvas) {
55136
55141
  canvas.style.display = 'block';
55137
- canvas.style.touchAction = this._shouldDisableCanvasTouchAction() ? 'none' : '';
55138
55142
  }
55139
55143
  }
55140
55144
  }
@@ -55153,7 +55157,6 @@
55153
55157
  this._cachedMarks = null;
55154
55158
  }
55155
55159
  chart.compile();
55156
- this._setCanvasStyle();
55157
55160
  chart.afterCompile();
55158
55161
  }
55159
55162
  clearNextRender() {
@@ -57733,6 +57736,9 @@
57733
57736
  }
57734
57737
  });
57735
57738
  }
57739
+ clearAllStateInfo() {
57740
+ this._stateInfoList = [];
57741
+ }
57736
57742
  _isMultiMark() {
57737
57743
  return !this._mark || isMultiDatumMark(this._mark.type);
57738
57744
  }
@@ -58746,7 +58752,11 @@
58746
58752
  return;
58747
58753
  }
58748
58754
  this._product = mark.getProduct();
58755
+ this._product.clearStates();
58749
58756
  this._graphics = mark.getGraphics();
58757
+ this._graphics.forEach(g => {
58758
+ g.clearStates();
58759
+ });
58750
58760
  this._graphicMap = mark._graphicMap;
58751
58761
  this._graphicMap.forEach(g => {
58752
58762
  g.context = Object.assign(Object.assign({}, g.context), this._getCommonContext());
@@ -59241,6 +59251,9 @@
59241
59251
  if (this.isCommited()) {
59242
59252
  if (this.getVisible() &&
59243
59253
  (!this._skipBeforeLayouted || this.getCompiler().getLayoutState() !== LayoutState.before)) {
59254
+ if (!this._product) {
59255
+ this._initProduct();
59256
+ }
59244
59257
  log(`render mark: ${this.getProductId()}, type is ${this.type}`);
59245
59258
  this.renderInner();
59246
59259
  }
@@ -59455,6 +59468,14 @@
59455
59468
  runAnimation() {
59456
59469
  this._runStateAnimation(this.getGraphics());
59457
59470
  }
59471
+ clearBeforeReInit() {
59472
+ this.state.clearAllStateInfo();
59473
+ this.uncommit();
59474
+ this.stateStyle = {};
59475
+ this.getGraphics().forEach(g => {
59476
+ g.clearStates();
59477
+ });
59478
+ }
59458
59479
  }
59459
59480
 
59460
59481
  exports.MarkTypeEnum = void 0;
@@ -63554,6 +63575,7 @@
63554
63575
  super.reInit(spec);
63555
63576
  const marks = this.getMarksWithoutRoot();
63556
63577
  marks.forEach(mark => {
63578
+ mark.clearBeforeReInit();
63557
63579
  this._spec[mark.name] && this.initMarkStyleWithSpec(mark, this._spec[mark.name]);
63558
63580
  });
63559
63581
  this.initMarkStyle();
@@ -66151,6 +66173,9 @@
66151
66173
  getTickData(index = 0) {
66152
66174
  return this._tickData[index];
66153
66175
  }
66176
+ getVisible() {
66177
+ return this._visible;
66178
+ }
66154
66179
  get visible() {
66155
66180
  return this._visible;
66156
66181
  }
@@ -66161,20 +66186,34 @@
66161
66186
  return this._coordinateType;
66162
66187
  }
66163
66188
  constructor(spec, options) {
66164
- var _a;
66189
+ var _a, _b;
66165
66190
  super(spec, options);
66166
66191
  this.specKey = 'axes';
66167
66192
  this._scales = [];
66168
66193
  this._tickData = [];
66169
66194
  this._visible = true;
66195
+ this._specVisible = true;
66196
+ this._hideWhenEmpty = false;
66170
66197
  this._tick = undefined;
66171
66198
  this._onTickDataChange = (tickData) => {
66172
66199
  this._forceLayout();
66173
66200
  tickData === null || tickData === void 0 ? void 0 : tickData.updateData();
66174
66201
  };
66175
- this._visible = (_a = spec.visible) !== null && _a !== void 0 ? _a : true;
66202
+ this._specVisible = (_a = spec.visible) !== null && _a !== void 0 ? _a : true;
66203
+ this._hideWhenEmpty = (_b = spec.hideWhenEmpty) !== null && _b !== void 0 ? _b : false;
66204
+ this._visible = this._specVisible;
66176
66205
  this._coordinateType = 'none';
66177
66206
  }
66207
+ setAttrFromSpec() {
66208
+ var _a, _b;
66209
+ super.setAttrFromSpec();
66210
+ this._specVisible = (_a = this._spec.visible) !== null && _a !== void 0 ? _a : true;
66211
+ this._hideWhenEmpty = (_b = this._spec.hideWhenEmpty) !== null && _b !== void 0 ? _b : false;
66212
+ this._visible = this._specVisible;
66213
+ if (this._scale) {
66214
+ this._refreshVisibilityByData();
66215
+ }
66216
+ }
66178
66217
  getVRenderComponents() {
66179
66218
  var _a, _b;
66180
66219
  return [(_a = this._axisMark) === null || _a === void 0 ? void 0 : _a.getProduct(), (_b = this._gridMark) === null || _b === void 0 ? void 0 : _b.getProduct()].filter(isValid$1);
@@ -66186,8 +66225,9 @@
66186
66225
  this.initEvent();
66187
66226
  this.initScales();
66188
66227
  this.updateSeriesScale();
66228
+ this._refreshVisibilityByData();
66189
66229
  this._shouldComputeTickData() && this._initData();
66190
- if (this._visible) {
66230
+ if (this._specVisible) {
66191
66231
  const axisMark = this._createMark({ type: 'component', name: `axis-${this.getOrient()}` }, {
66192
66232
  componentType: this.getOrient() === 'angle' ? AxisEnum.circleAxis : AxisEnum.lineAxis,
66193
66233
  mode: this._spec.mode
@@ -66217,6 +66257,7 @@
66217
66257
  this._marks.addMark(gridMark);
66218
66258
  this._gridMark = gridMark;
66219
66259
  }
66260
+ this._syncComponentVisibility();
66220
66261
  if (((_h = this._option.globalInstance) === null || _h === void 0 ? void 0 : _h.isAnimationEnable()) &&
66221
66262
  get$1(this._option.getChart().getSpec(), 'animation') !== false &&
66222
66263
  this._spec.animation === true) {
@@ -66237,7 +66278,7 @@
66237
66278
  }
66238
66279
  }
66239
66280
  _shouldComputeTickData() {
66240
- return this.getVisible() || this._spec.forceInitTick;
66281
+ return this._specVisible && (this.getVisible() || this._spec.forceInitTick || this._hideWhenEmpty);
66241
66282
  }
66242
66283
  _initData() {
66243
66284
  const tickData = this._initTickDataSet(this._tickTransformOption());
@@ -66249,40 +66290,41 @@
66249
66290
  }
66250
66291
  collectData(depth, rawData) {
66251
66292
  const data = [];
66252
- eachSeries(this._regions, s => {
66253
- var _a;
66254
- let field = this.collectSeriesField(depth, s);
66255
- field = (isArray$1(field) ? (isContinuous(this._scale.type) ? field : [field[0]]) : [field]);
66256
- if (!depth) {
66257
- this._dataFieldText = s.getFieldAlias(field[0]);
66258
- }
66259
- if (field) {
66260
- const viewData = s.getViewData();
66261
- if (rawData) {
66262
- field.forEach(f => {
66263
- data.push(s.getRawDataStatisticsByField(f, !!isContinuous(this._scale.type)));
66264
- });
66265
- }
66266
- else if (viewData && viewData.latestData && viewData.latestData.length) {
66267
- const seriesData = (_a = s.getViewDataStatistics) === null || _a === void 0 ? void 0 : _a.call(s);
66268
- const userSetBreaks = this.type === ComponentTypeEnum.cartesianLinearAxis && this._spec.breaks && this._spec.breaks.length;
66269
- field.forEach(f => {
66270
- var _a;
66271
- if ((_a = seriesData === null || seriesData === void 0 ? void 0 : seriesData.latestData) === null || _a === void 0 ? void 0 : _a[f]) {
66272
- if (userSetBreaks) {
66273
- data.push(Object.assign(Object.assign({}, seriesData.latestData[f]), { values: viewData.latestData.map((obj) => obj[f]) }));
66274
- }
66275
- else {
66276
- data.push(seriesData.latestData[f]);
66293
+ this._regions &&
66294
+ eachSeries(this._regions, s => {
66295
+ var _a;
66296
+ let field = this.collectSeriesField(depth, s);
66297
+ field = (isArray$1(field) ? (isContinuous(this._scale.type) ? field : [field[0]]) : [field]);
66298
+ if (!depth) {
66299
+ this._dataFieldText = s.getFieldAlias(field[0]);
66300
+ }
66301
+ if (field) {
66302
+ const viewData = s.getViewData();
66303
+ if (rawData) {
66304
+ field.forEach(f => {
66305
+ data.push(s.getRawDataStatisticsByField(f, !!isContinuous(this._scale.type)));
66306
+ });
66307
+ }
66308
+ else if (viewData && viewData.latestData && viewData.latestData.length) {
66309
+ const seriesData = (_a = s.getViewDataStatistics) === null || _a === void 0 ? void 0 : _a.call(s);
66310
+ const userSetBreaks = this.type === ComponentTypeEnum.cartesianLinearAxis && this._spec.breaks && this._spec.breaks.length;
66311
+ field.forEach(f => {
66312
+ var _a;
66313
+ if ((_a = seriesData === null || seriesData === void 0 ? void 0 : seriesData.latestData) === null || _a === void 0 ? void 0 : _a[f]) {
66314
+ if (userSetBreaks) {
66315
+ data.push(Object.assign(Object.assign({}, seriesData.latestData[f]), { values: viewData.latestData.map((obj) => obj[f]) }));
66316
+ }
66317
+ else {
66318
+ data.push(seriesData.latestData[f]);
66319
+ }
66277
66320
  }
66278
- }
66279
- });
66321
+ });
66322
+ }
66280
66323
  }
66281
- }
66282
- }, {
66283
- userId: this._seriesUserId,
66284
- specIndex: this._seriesIndex
66285
- });
66324
+ }, {
66325
+ userId: this._seriesUserId,
66326
+ specIndex: this._seriesIndex
66327
+ });
66286
66328
  return data;
66287
66329
  }
66288
66330
  isSeriesDataEnable() {
@@ -66342,6 +66384,30 @@
66342
66384
  }
66343
66385
  updateScaleDomain() {
66344
66386
  }
66387
+ _hasCollectedSeriesData() {
66388
+ return this.collectData(0).length > 0;
66389
+ }
66390
+ _refreshVisibilityByData() {
66391
+ const nextVisible = this._specVisible && (!this._hideWhenEmpty || this._hasCollectedSeriesData());
66392
+ const changed = this._visible !== nextVisible;
66393
+ this._visible = nextVisible;
66394
+ if (this._axisMark || this._gridMark) {
66395
+ this._syncComponentVisibility();
66396
+ }
66397
+ if (changed) {
66398
+ this._forceLayout();
66399
+ }
66400
+ return changed;
66401
+ }
66402
+ _syncComponentVisibility() {
66403
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
66404
+ (_a = this._axisMark) === null || _a === void 0 ? void 0 : _a.setVisible(this._visible);
66405
+ (_b = this._gridMark) === null || _b === void 0 ? void 0 : _b.setVisible(this._visible && ((_c = this._spec.grid) === null || _c === void 0 ? void 0 : _c.visible) !== false);
66406
+ (_g = (_f = (_e = (_d = this._axisMark) === null || _d === void 0 ? void 0 : _d.getComponent) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.setAttributes) === null || _g === void 0 ? void 0 : _g.call(_f, { visibleAll: this._visible });
66407
+ (_l = (_k = (_j = (_h = this._gridMark) === null || _h === void 0 ? void 0 : _h.getComponent) === null || _j === void 0 ? void 0 : _j.call(_h)) === null || _k === void 0 ? void 0 : _k.setAttributes) === null || _l === void 0 ? void 0 : _l.call(_k, {
66408
+ visibleAll: this._visible && ((_m = this._spec.grid) === null || _m === void 0 ? void 0 : _m.visible) !== false
66409
+ });
66410
+ }
66345
66411
  _clearRawDomain() {
66346
66412
  }
66347
66413
  onLayoutEnd() {
@@ -66803,6 +66869,10 @@
66803
66869
  return padding;
66804
66870
  };
66805
66871
  this._updateAxisLayout = () => {
66872
+ if (!this._visible) {
66873
+ this._syncComponentVisibility();
66874
+ return;
66875
+ }
66806
66876
  const startPoint = this.getLayoutStartPoint();
66807
66877
  const _a = this._getUpdateAttribute(false), { grid: updateGridAttrs } = _a, updateAxisAttrs = __rest$e(_a, ["grid"]);
66808
66878
  const axisAttrs = mergeSpec({ x: startPoint.x, y: startPoint.y }, this._axisStyle, updateAxisAttrs);
@@ -66810,6 +66880,7 @@
66810
66880
  if (this._gridMark) {
66811
66881
  this._gridMark.setSimpleStyle(mergeSpec({ x: startPoint.x, y: startPoint.y }, this._getGridAttributes(), updateGridAttrs));
66812
66882
  }
66883
+ this._syncComponentVisibility();
66813
66884
  };
66814
66885
  this._fixAxisOnZero = () => {
66815
66886
  const { onZero, visible } = this._spec.domainLine;
@@ -66976,7 +67047,7 @@
66976
67047
  setAttrFromSpec() {
66977
67048
  var _a;
66978
67049
  super.setAttrFromSpec();
66979
- if (this.visible) {
67050
+ if (this._specVisible) {
66980
67051
  const isX = isXAxis(this.getOrient());
66981
67052
  if (isX) {
66982
67053
  if (isUndefined$1(this._spec.maxHeight)) {
@@ -67306,7 +67377,7 @@
67306
67377
  }
67307
67378
  initEvent() {
67308
67379
  super.initEvent();
67309
- if (this.visible) {
67380
+ if (this._specVisible) {
67310
67381
  this.event.on(exports.ChartEvent.layoutEnd, this._updateAxisLayout);
67311
67382
  this.event.on(exports.ChartEvent.layoutEnd, this._fixAxisOnZero);
67312
67383
  this.event.on(exports.ChartEvent.layoutRectUpdate, () => {
@@ -67825,6 +67896,7 @@
67825
67896
  }
67826
67897
  this._updateNiceLabelFormatter(domain);
67827
67898
  this._domainAfterSpec = this._scale.domain();
67899
+ this._refreshVisibilityByData();
67828
67900
  this.event.emit(exports.ChartEvent.scaleDomainUpdate, { model: this });
67829
67901
  this.event.emit(exports.ChartEvent.scaleUpdate, { model: this, value: 'domain' });
67830
67902
  }
@@ -68223,6 +68295,7 @@
68223
68295
  }
68224
68296
  }
68225
68297
  this.transformScaleDomain();
68298
+ this._refreshVisibilityByData();
68226
68299
  this.event.emit(exports.ChartEvent.scaleDomainUpdate, { model: this });
68227
68300
  this.event.emit(exports.ChartEvent.scaleUpdate, { model: this, value: 'domain' });
68228
68301
  }
@@ -78444,6 +78517,14 @@
78444
78517
  this._labelMark = null;
78445
78518
  this._labelLineMark = null;
78446
78519
  this._emptyArcMark = null;
78520
+ this._pendingViewDataLabelUpdate = false;
78521
+ this.flushViewDataLabelUpdate = () => {
78522
+ if (!this._pendingViewDataLabelUpdate) {
78523
+ return;
78524
+ }
78525
+ this._pendingViewDataLabelUpdate = false;
78526
+ this._viewDataLabel.getDataView().reRunAllTransform();
78527
+ };
78447
78528
  this.dataToCentralPosition = (datum) => {
78448
78529
  const angle = datum[ARC_MIDDLE_ANGLE];
78449
78530
  if (isNil$1(angle)) {
@@ -78619,12 +78700,13 @@
78619
78700
  var _a;
78620
78701
  super.initEvent();
78621
78702
  (_a = this._viewDataLabel.getDataView()) === null || _a === void 0 ? void 0 : _a.target.addListener('change', this.viewDataLabelUpdate.bind(this));
78703
+ this.event.on(exports.ChartEvent.afterRender, this.flushViewDataLabelUpdate);
78622
78704
  }
78623
78705
  initGroups() {
78624
78706
  return;
78625
78707
  }
78626
78708
  onLayoutEnd() {
78627
- this._viewDataLabel.getDataView().reRunAllTransform();
78709
+ this._pendingViewDataLabelUpdate = true;
78628
78710
  this.onMarkPositionUpdate();
78629
78711
  super.onLayoutEnd();
78630
78712
  }
@@ -79028,7 +79110,7 @@
79028
79110
  }
79029
79111
  setAttrFromSpec() {
79030
79112
  super.setAttrFromSpec();
79031
- if (this.visible) {
79113
+ if (this._specVisible) {
79032
79114
  this._axisStyle = this._getAxisAttributes();
79033
79115
  this._gridStyle = this._getGridAttributes();
79034
79116
  }
@@ -95554,6 +95636,20 @@
95554
95636
  return data;
95555
95637
  };
95556
95638
 
95639
+ function transformHandlerText(handlerText) {
95640
+ if (!handlerText) {
95641
+ return handlerText;
95642
+ }
95643
+ const nextHandlerText = Object.assign({}, handlerText);
95644
+ const handlerTextStyle = handlerText.style;
95645
+ if (isFunction$1(handlerTextStyle)) {
95646
+ nextHandlerText.style = (value, position, context) => transformToGraphic(handlerTextStyle(value, position, context));
95647
+ }
95648
+ else if (!isEmpty(handlerTextStyle)) {
95649
+ nextHandlerText.style = transformToGraphic(handlerTextStyle);
95650
+ }
95651
+ return nextHandlerText;
95652
+ }
95557
95653
  function getContinuousLegendAttributes(spec) {
95558
95654
  const _a = mergeSpec({}, spec), { title = {}, handler = {}, rail = {}, track = {}, startText, endText, handlerText, sizeBackground, background = {}, type, id, visible, orient, position, data, defaultSelected, field, filter, regionId, regionIndex, seriesIndex, seriesId, padding } = _a, restSpec = __rest$e(_a, ["title", "handler", "rail", "track", "startText", "endText", "handlerText", "sizeBackground", "background", "type", "id", "visible", "orient", "position", "data", "defaultSelected", "field", "filter", "regionId", "regionIndex", "seriesIndex", "seriesId", "padding"]);
95559
95655
  const attrs = restSpec;
@@ -95581,7 +95677,7 @@
95581
95677
  }
95582
95678
  attrs.startText = transformComponentStyle(startText);
95583
95679
  attrs.endText = transformComponentStyle(endText);
95584
- attrs.handlerText = transformComponentStyle(handlerText);
95680
+ attrs.handlerText = transformHandlerText(handlerText);
95585
95681
  if (!isEmpty(sizeBackground)) {
95586
95682
  attrs.sizeBackground = transformToGraphic(sizeBackground);
95587
95683
  }