@visactor/vrender-components 0.17.0-alpha.3 → 0.17.0-alpha.4

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 (81) hide show
  1. package/cjs/data-zoom/config.d.ts +0 -6
  2. package/cjs/data-zoom/config.js +1 -7
  3. package/cjs/data-zoom/config.js.map +1 -1
  4. package/cjs/data-zoom/data-zoom.d.ts +3 -2
  5. package/cjs/data-zoom/data-zoom.js +19 -15
  6. package/cjs/data-zoom/data-zoom.js.map +1 -1
  7. package/cjs/data-zoom/type.d.ts +6 -0
  8. package/cjs/data-zoom/type.js +6 -1
  9. package/cjs/data-zoom/type.js.map +1 -1
  10. package/cjs/index.d.ts +1 -1
  11. package/cjs/index.js +1 -1
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/label/animate/animate.d.ts +8 -2
  14. package/cjs/label/animate/animate.js +37 -3
  15. package/cjs/label/animate/animate.js.map +1 -1
  16. package/cjs/label/area.d.ts +15 -0
  17. package/cjs/label/area.js +41 -0
  18. package/cjs/label/area.js.map +1 -0
  19. package/cjs/label/base.d.ts +7 -4
  20. package/cjs/label/base.js +37 -42
  21. package/cjs/label/base.js.map +1 -1
  22. package/cjs/label/dataLabel.js +8 -5
  23. package/cjs/label/dataLabel.js.map +1 -1
  24. package/cjs/label/line.d.ts +1 -1
  25. package/cjs/label/line.js +2 -9
  26. package/cjs/label/line.js.map +1 -1
  27. package/cjs/label/type.d.ts +22 -2
  28. package/cjs/label/type.js +1 -2
  29. package/cjs/label/type.js.map +1 -1
  30. package/cjs/label/util.d.ts +4 -0
  31. package/cjs/label/util.js +14 -2
  32. package/cjs/label/util.js.map +1 -1
  33. package/cjs/legend/discrete/discrete.d.ts +3 -0
  34. package/cjs/legend/discrete/discrete.js +45 -38
  35. package/cjs/legend/discrete/discrete.js.map +1 -1
  36. package/cjs/legend/discrete/type.d.ts +1 -0
  37. package/cjs/legend/discrete/type.js.map +1 -1
  38. package/cjs/link-path/type.js +1 -1
  39. package/cjs/scrollbar/scrollbar.js.map +1 -1
  40. package/dist/index.js +243 -141
  41. package/dist/index.min.js +1 -1
  42. package/es/data-zoom/config.d.ts +0 -6
  43. package/es/data-zoom/config.js +0 -7
  44. package/es/data-zoom/config.js.map +1 -1
  45. package/es/data-zoom/data-zoom.d.ts +3 -2
  46. package/es/data-zoom/data-zoom.js +10 -4
  47. package/es/data-zoom/data-zoom.js.map +1 -1
  48. package/es/data-zoom/type.d.ts +6 -0
  49. package/es/data-zoom/type.js +6 -1
  50. package/es/data-zoom/type.js.map +1 -1
  51. package/es/index.d.ts +1 -1
  52. package/es/index.js +1 -1
  53. package/es/index.js.map +1 -1
  54. package/es/label/animate/animate.d.ts +8 -2
  55. package/es/label/animate/animate.js +35 -0
  56. package/es/label/animate/animate.js.map +1 -1
  57. package/es/label/area.d.ts +15 -0
  58. package/es/label/area.js +39 -0
  59. package/es/label/area.js.map +1 -0
  60. package/es/label/base.d.ts +7 -4
  61. package/es/label/base.js +39 -44
  62. package/es/label/base.js.map +1 -1
  63. package/es/label/dataLabel.js +11 -4
  64. package/es/label/dataLabel.js.map +1 -1
  65. package/es/label/line.d.ts +1 -1
  66. package/es/label/line.js +3 -8
  67. package/es/label/line.js.map +1 -1
  68. package/es/label/type.d.ts +22 -2
  69. package/es/label/type.js +1 -2
  70. package/es/label/type.js.map +1 -1
  71. package/es/label/util.d.ts +4 -0
  72. package/es/label/util.js +13 -1
  73. package/es/label/util.js.map +1 -1
  74. package/es/legend/discrete/discrete.d.ts +3 -0
  75. package/es/legend/discrete/discrete.js +44 -36
  76. package/es/legend/discrete/discrete.js.map +1 -1
  77. package/es/legend/discrete/type.d.ts +1 -0
  78. package/es/legend/discrete/type.js.map +1 -1
  79. package/es/link-path/type.js +1 -1
  80. package/es/scrollbar/scrollbar.js.map +1 -1
  81. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -10101,32 +10101,37 @@
10101
10101
  }(BaseSymbol);
10102
10102
  var close$1 = new CloseSymbol();
10103
10103
 
10104
- function rect(ctx, size, x, y) {
10104
+ function rectSizeArray(ctx, size, x, y) {
10105
10105
  return ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]), !1;
10106
10106
  }
10107
+ function rectSize(ctx, size, x, y) {
10108
+ var w = size,
10109
+ h = size / 2;
10110
+ return ctx.rect(x - w / 2, y - h / 2, w, h), !1;
10111
+ }
10107
10112
  var RectSymbol = /*#__PURE__*/function (_BaseSymbol) {
10108
10113
  _inherits(RectSymbol, _BaseSymbol);
10109
10114
  var _super = _createSuper(RectSymbol);
10110
10115
  function RectSymbol() {
10111
10116
  var _this;
10112
10117
  _classCallCheck(this, RectSymbol);
10113
- _this = _super.apply(this, arguments), _this.type = "rect", _this.pathStr = "M-0.5,-0.5h1v1h-1Z";
10118
+ _this = _super.apply(this, arguments), _this.type = "rect", _this.pathStr = "M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z";
10114
10119
  return _this;
10115
10120
  }
10116
10121
  _createClass(RectSymbol, [{
10117
10122
  key: "draw",
10118
10123
  value: function draw(ctx, size, x, y) {
10119
- return rect(ctx, vutils.isNumber(size) ? [size, size] : size, x, y);
10124
+ return vutils.isNumber(size) ? rectSize(ctx, size, x, y) : rectSizeArray(ctx, size, x, y);
10120
10125
  }
10121
10126
  }, {
10122
10127
  key: "drawOffset",
10123
10128
  value: function drawOffset(ctx, size, x, y, offset) {
10124
- return rect(ctx, vutils.isNumber(size) ? [size + 2 * offset, size + 2 * offset] : [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
10129
+ return vutils.isNumber(size) ? rectSize(ctx, size + 2 * offset, x, y) : rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
10125
10130
  }
10126
10131
  }]);
10127
10132
  return RectSymbol;
10128
10133
  }(BaseSymbol);
10129
- var rect$1 = new RectSymbol();
10134
+ var rect = new RectSymbol();
10130
10135
 
10131
10136
  var tempBounds = new vutils.AABBBounds();
10132
10137
  var CustomSymbolClass = /*#__PURE__*/function () {
@@ -10165,7 +10170,7 @@
10165
10170
  return CustomSymbolClass;
10166
10171
  }();
10167
10172
 
10168
- var builtinSymbols = [circle$1, cross$1, diamond$1, square$1, thinTriangle$1, triangle, star$1, arrow$1, wedge$1, stroke$1, wye$1, triangleLeft, triangleRight, triangleUp, triangleDown, arrow2Left$1, arrow2Right$1, arrow2Up$1, arrow2Down$1, rect$1, lineV$1, lineH$1, close$1];
10173
+ var builtinSymbols = [circle$1, cross$1, diamond$1, square$1, thinTriangle$1, triangle, star$1, arrow$1, wedge$1, stroke$1, wye$1, triangleLeft, triangleRight, triangleUp, triangleDown, arrow2Left$1, arrow2Right$1, arrow2Up$1, arrow2Down$1, rect, lineV$1, lineH$1, close$1];
10169
10174
  var builtinSymbolsMap = {};
10170
10175
  builtinSymbols.forEach(function (symbol) {
10171
10176
  builtinSymbolsMap[symbol.type] = symbol;
@@ -10173,7 +10178,6 @@
10173
10178
  var builtInSymbolStrMap = {
10174
10179
  arrowLeft: "M 0.25 -0.5 L -0.25 0 l 0.5 0.5",
10175
10180
  arrowRight: "M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5",
10176
- rect: "M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z",
10177
10181
  rectRound: "M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z",
10178
10182
  roundLine: "M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z"
10179
10183
  };
@@ -11244,7 +11248,8 @@
11244
11248
  var _this2 = this;
11245
11249
  var _a;
11246
11250
  var _this$attribute = this.attribute,
11247
- textConfig = _this$attribute.textConfig,
11251
+ _this$attribute$textC = _this$attribute.textConfig,
11252
+ textConfig = _this$attribute$textC === void 0 ? [] : _this$attribute$textC,
11248
11253
  maxWidth = _this$attribute.maxWidth,
11249
11254
  maxHeight = _this$attribute.maxHeight,
11250
11255
  width = _this$attribute.width,
@@ -20691,6 +20696,45 @@
20691
20696
  var _a, _b;
20692
20697
  return (_b = (_a = animationEffects[type]) === null || _a === void 0 ? void 0 : _a.call(animationEffects, textAttribute)) !== null && _b !== void 0 ? _b : { from: {}, to: {} };
20693
20698
  }
20699
+ function updateAnimation(prev, next, animationConfig) {
20700
+ if (!vutils.isArray(animationConfig)) {
20701
+ const { duration, easing, increaseEffect = true } = animationConfig;
20702
+ prev.animate().to(next.attribute, duration, easing);
20703
+ increaseEffect && playIncreaseCount(prev, next, duration, easing);
20704
+ return;
20705
+ }
20706
+ animationConfig.forEach((cfg, i) => {
20707
+ const { duration, easing, increaseEffect = true, channel } = cfg;
20708
+ const { from, to } = update(prev, next, channel, cfg.options);
20709
+ if (!vutils.isEmpty(to)) {
20710
+ prev.animate().to(to, duration, easing);
20711
+ }
20712
+ if ('text' in from && 'text' in to && increaseEffect) {
20713
+ playIncreaseCount(prev, next, duration, easing);
20714
+ }
20715
+ });
20716
+ }
20717
+ const update = (prev, next, channel, options) => {
20718
+ const from = Object.assign({}, prev.attribute);
20719
+ const to = Object.assign({}, next.attribute);
20720
+ vutils.array(options === null || options === void 0 ? void 0 : options.excludeChannels).forEach(key => {
20721
+ delete to[key];
20722
+ });
20723
+ Object.keys(to).forEach(key => {
20724
+ if (channel && !channel.includes(key)) {
20725
+ delete to[key];
20726
+ }
20727
+ });
20728
+ return { from, to };
20729
+ };
20730
+ function playIncreaseCount(prev, next, duration, easing) {
20731
+ if (prev.attribute.text !== next.attribute.text &&
20732
+ vutils.isValidNumber(Number(prev.attribute.text) * Number(next.attribute.text))) {
20733
+ prev
20734
+ .animate()
20735
+ .play(new IncreaseCount({ text: prev.attribute.text }, { text: next.attribute.text }, duration, easing));
20736
+ }
20737
+ }
20694
20738
  const DefaultLabelAnimation = {
20695
20739
  mode: 'same-time',
20696
20740
  duration: 300,
@@ -20884,6 +20928,24 @@
20884
20928
  }
20885
20929
  return points;
20886
20930
  };
20931
+ function labelingLineOrArea(textBounds, graphicBounds, position = 'end', offset = 0) {
20932
+ if (!textBounds || !graphicBounds) {
20933
+ return;
20934
+ }
20935
+ const { x1, x2 } = textBounds;
20936
+ const width = Math.abs(x2 - x1);
20937
+ const anchorX = graphicBounds.x1;
20938
+ const anchorY = graphicBounds.y1;
20939
+ let x = anchorX;
20940
+ const y = anchorY;
20941
+ if (position === 'end') {
20942
+ x = anchorX + width / 2 + offset;
20943
+ }
20944
+ else if (position === 'start') {
20945
+ x = anchorX - width / 2 - offset;
20946
+ }
20947
+ return { x, y };
20948
+ }
20887
20949
 
20888
20950
  class LabelBase extends AbstractComponent {
20889
20951
  setBitmap(bitmap) {
@@ -21037,7 +21099,7 @@
21037
21099
  return text;
21038
21100
  }
21039
21101
  _prepare() {
21040
- var _a, _b, _c, _d;
21102
+ var _a, _b, _c, _d, _e;
21041
21103
  const currentBaseMarks = [];
21042
21104
  let baseMarks;
21043
21105
  if (vutils.isFunction(this.attribute.getBaseMarks)) {
@@ -21054,7 +21116,7 @@
21054
21116
  (_a = this._idToGraphic) === null || _a === void 0 ? void 0 : _a.clear();
21055
21117
  (_b = this._idToPoint) === null || _b === void 0 ? void 0 : _b.clear();
21056
21118
  this._baseMarks = currentBaseMarks;
21057
- this._isCollectionBase = ((_c = currentBaseMarks === null || currentBaseMarks === void 0 ? void 0 : currentBaseMarks[0]) === null || _c === void 0 ? void 0 : _c.type) === 'line' || ((_d = currentBaseMarks === null || currentBaseMarks === void 0 ? void 0 : currentBaseMarks[0]) === null || _d === void 0 ? void 0 : _d.type) === 'area';
21119
+ this._isCollectionBase = this.attribute.type === 'line-data';
21058
21120
  if (!currentBaseMarks || currentBaseMarks.length === 0) {
21059
21121
  return;
21060
21122
  }
@@ -21100,6 +21162,15 @@
21100
21162
  }
21101
21163
  }
21102
21164
  }
21165
+ if (this.attribute.animation !== false) {
21166
+ this._animationConfig = {
21167
+ enter: vutils.merge({}, DefaultLabelAnimation, this.attribute.animation, (_c = this.attribute.animationEnter) !== null && _c !== void 0 ? _c : {}),
21168
+ exit: vutils.merge({}, DefaultLabelAnimation, this.attribute.animation, (_d = this.attribute.animationExit) !== null && _d !== void 0 ? _d : {}),
21169
+ update: vutils.isArray(this.attribute.animationUpdate)
21170
+ ? this.attribute.animationUpdate
21171
+ : vutils.merge({}, DefaultLabelAnimation, this.attribute.animation, (_e = this.attribute.animationUpdate) !== null && _e !== void 0 ? _e : {})
21172
+ };
21173
+ }
21103
21174
  }
21104
21175
  getRelatedGrphic(item) {
21105
21176
  return this._idToGraphic.get(item.id);
@@ -21247,12 +21318,6 @@
21247
21318
  }
21248
21319
  }
21249
21320
  _renderWithAnimation(labels) {
21250
- var _a, _b, _c, _d, _e;
21251
- const animationConfig = ((_a = this.attribute.animation) !== null && _a !== void 0 ? _a : {});
21252
- const mode = (_b = animationConfig.mode) !== null && _b !== void 0 ? _b : DefaultLabelAnimation.mode;
21253
- const duration = (_c = animationConfig.duration) !== null && _c !== void 0 ? _c : DefaultLabelAnimation.duration;
21254
- const easing = (_d = animationConfig.easing) !== null && _d !== void 0 ? _d : DefaultLabelAnimation.easing;
21255
- const delay = (_e = animationConfig.delay) !== null && _e !== void 0 ? _e : 0;
21256
21321
  const currentTextMap = new Map();
21257
21322
  const prevTextMap = this._graphicToText || new Map();
21258
21323
  const texts = [];
@@ -21276,13 +21341,7 @@
21276
21341
  this._syncStateWithRelatedGraphic(relatedGraphic);
21277
21342
  relatedGraphic.once('animate-bind', a => {
21278
21343
  text.setAttributes(from);
21279
- const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
21280
- mode,
21281
- duration,
21282
- easing,
21283
- to,
21284
- delay
21285
- });
21344
+ const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, to, this._animationConfig.enter);
21286
21345
  relatedGraphic.on('afterAttributeUpdate', listener);
21287
21346
  });
21288
21347
  }
@@ -21292,25 +21351,19 @@
21292
21351
  prevTextMap.delete(textKey);
21293
21352
  currentTextMap.set(textKey, prevLabel);
21294
21353
  const prevText = prevLabel.text;
21295
- prevText.animate().to(text.attribute, duration, easing);
21354
+ const { duration, easing } = this._animationConfig.update;
21355
+ updateAnimation(prevText, text, this._animationConfig.update);
21296
21356
  if (prevLabel.labelLine) {
21297
21357
  prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
21298
21358
  visible: (_f = (_d = (((_b = (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.line) === null || _b === void 0 ? void 0 : _b.visible) && ((_c = text.attribute) === null || _c === void 0 ? void 0 : _c.visible))) !== null && _d !== void 0 ? _d : (_e = text.attribute) === null || _e === void 0 ? void 0 : _e.visible) !== null && _f !== void 0 ? _f : true,
21299
21359
  points: (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.points
21300
21360
  }), duration, easing);
21301
21361
  }
21302
- if (animationConfig.increaseEffect !== false &&
21303
- prevText.attribute.text !== text.attribute.text &&
21304
- vutils.isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))) {
21305
- prevText
21306
- .animate()
21307
- .play(new IncreaseCount({ text: prevText.attribute.text }, { text: text.attribute.text }, duration, easing));
21308
- }
21309
21362
  }
21310
21363
  });
21311
21364
  prevTextMap.forEach(label => {
21312
21365
  var _a;
21313
- (_a = label.text) === null || _a === void 0 ? void 0 : _a.animate().to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing).onEnd(() => {
21366
+ (_a = label.text) === null || _a === void 0 ? void 0 : _a.animate().to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, this._animationConfig.exit.duration, this._animationConfig.exit.easing).onEnd(() => {
21314
21367
  this.removeChild(label.text);
21315
21368
  if (label === null || label === void 0 ? void 0 : label.labelLine) {
21316
21369
  this.removeChild(label.labelLine);
@@ -21359,7 +21412,7 @@
21359
21412
  relatedGraphic.on('afterAttributeUpdate', this._handleRelatedGraphicSetState);
21360
21413
  }
21361
21414
  }
21362
- _afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, { mode, duration, easing, to, delay }) {
21415
+ _afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, to, { mode, duration, easing, delay }) {
21363
21416
  const listener = (event) => {
21364
21417
  var _a, _b;
21365
21418
  const { detail } = event;
@@ -21377,7 +21430,7 @@
21377
21430
  text.setAttributes(to);
21378
21431
  return;
21379
21432
  }
21380
- const onEnd = () => {
21433
+ const onStart = () => {
21381
21434
  if (relatedGraphic) {
21382
21435
  relatedGraphic.onAnimateBind = undefined;
21383
21436
  relatedGraphic.removeEventListener('afterAttributeUpdate', listener);
@@ -21386,14 +21439,14 @@
21386
21439
  switch (mode) {
21387
21440
  case 'after':
21388
21441
  if (detail.animationState.end) {
21389
- text.animate({ onEnd }).wait(delay).to(to, duration, easing);
21442
+ text.animate({ onStart }).wait(delay).to(to, duration, easing);
21390
21443
  }
21391
21444
  break;
21392
21445
  case 'after-all':
21393
21446
  if (index === texts.length - 1) {
21394
21447
  if (detail.animationState.end) {
21395
21448
  texts.forEach(t => {
21396
- t.animate({ onEnd }).wait(delay).to(to, duration, easing);
21449
+ t.animate({ onStart }).wait(delay).to(to, duration, easing);
21397
21450
  });
21398
21451
  }
21399
21452
  }
@@ -21404,12 +21457,12 @@
21404
21457
  const point = this._idToPoint.get(text.attribute.id);
21405
21458
  if (point &&
21406
21459
  (!text.animates || !text.animates.has('label-animate')) &&
21407
- this._baseMarks[0].containsPoint(point.x, point.y, IContainPointMode.LOCAL, (_b = this.stage) === null || _b === void 0 ? void 0 : _b.pickerService)) {
21408
- text.animate({ onEnd }).wait(delay).to(to, duration, easing);
21460
+ relatedGraphic.containsPoint(point.x, point.y, IContainPointMode.LOCAL, (_b = this.stage) === null || _b === void 0 ? void 0 : _b.pickerService)) {
21461
+ text.animate({ onStart }).wait(delay).to(to, duration, easing);
21409
21462
  }
21410
21463
  }
21411
21464
  else if (detail.animationState.isFirstFrameOfStep) {
21412
- text.animate({ onEnd }).wait(delay).to(to, duration, easing);
21465
+ text.animate({ onStart }).wait(delay).to(to, duration, easing);
21413
21466
  }
21414
21467
  break;
21415
21468
  }
@@ -21643,22 +21696,7 @@
21643
21696
  };
21644
21697
  }
21645
21698
  labeling(textBounds, graphicBounds, position = 'end', offset = 0) {
21646
- if (!textBounds || !graphicBounds) {
21647
- return;
21648
- }
21649
- const { x1, x2 } = textBounds;
21650
- const width = Math.abs(x2 - x1);
21651
- const anchorX = graphicBounds.x1;
21652
- const anchorY = graphicBounds.y1;
21653
- let x = anchorX;
21654
- const y = anchorY;
21655
- if (position === 'end') {
21656
- x = anchorX + width / 2 + offset;
21657
- }
21658
- else if (position === 'start') {
21659
- x = anchorX - width / 2 - offset;
21660
- }
21661
- return { x, y };
21699
+ return labelingLineOrArea(textBounds, graphicBounds, position, offset);
21662
21700
  }
21663
21701
  }
21664
21702
  LineLabel.defaultAttributes = {
@@ -22420,10 +22458,49 @@
22420
22458
  pickable: false
22421
22459
  };
22422
22460
 
22461
+ class AreaLabel extends LabelBase {
22462
+ constructor(attributes) {
22463
+ super(vutils.merge({}, AreaLabel.defaultAttributes, attributes));
22464
+ this.name = 'line-label';
22465
+ }
22466
+ getGraphicBounds(graphic, point = {}) {
22467
+ var _a;
22468
+ if (graphic.type !== 'area') {
22469
+ return super.getGraphicBounds(graphic, point);
22470
+ }
22471
+ const { position = 'end' } = this.attribute;
22472
+ const points = ((_a = graphic === null || graphic === void 0 ? void 0 : graphic.attribute) === null || _a === void 0 ? void 0 : _a.points) || [point];
22473
+ const index = position === 'start' ? 0 : points.length - 1;
22474
+ return {
22475
+ x1: points[index].x,
22476
+ x2: points[index].x,
22477
+ y1: points[index].y,
22478
+ y2: points[index].y
22479
+ };
22480
+ }
22481
+ labeling(textBounds, graphicBounds, position = 'end', offset = 0) {
22482
+ return labelingLineOrArea(textBounds, graphicBounds, position, offset);
22483
+ }
22484
+ }
22485
+ AreaLabel.defaultAttributes = {
22486
+ textStyle: {
22487
+ fontSize: 12,
22488
+ fill: '#000',
22489
+ textAlign: 'center',
22490
+ textBaseline: 'middle',
22491
+ boundsPadding: [-1, 0, -1, 0]
22492
+ },
22493
+ position: 'end',
22494
+ offset: 6,
22495
+ pickable: false
22496
+ };
22497
+
22423
22498
  const labelComponentMap = {
22424
22499
  rect: RectLabel,
22425
22500
  symbol: SymbolLabel,
22426
22501
  arc: ArcLabel,
22502
+ line: LineLabel,
22503
+ area: AreaLabel,
22427
22504
  'line-data': LineDataLabel
22428
22505
  };
22429
22506
  class DataLabel extends AbstractComponent {
@@ -22432,6 +22509,7 @@
22432
22509
  this.name = 'data-label';
22433
22510
  }
22434
22511
  render() {
22512
+ var _a;
22435
22513
  const { dataLabels, size } = this.attribute;
22436
22514
  if (!dataLabels || dataLabels.length === 0) {
22437
22515
  return;
@@ -22451,20 +22529,21 @@
22451
22529
  const dataLabel = dataLabels[i];
22452
22530
  const labelComponent = labelComponentMap[dataLabel.type] || LabelBase;
22453
22531
  if (labelComponent) {
22454
- const { baseMarkGroupName } = dataLabel;
22455
- let component = this._componentMap.get(baseMarkGroupName);
22532
+ const { baseMarkGroupName, type } = dataLabel;
22533
+ const id = (_a = dataLabel.id) !== null && _a !== void 0 ? _a : `${baseMarkGroupName}-${type}-${i}`;
22534
+ let component = this._componentMap.get(id);
22456
22535
  if (component) {
22457
22536
  component.setBitmapTool(tool);
22458
22537
  component.setBitmap(bitmap);
22459
22538
  component.setAttributes(dataLabel);
22460
- currentComponentMap.set(baseMarkGroupName, component);
22539
+ currentComponentMap.set(id, component);
22461
22540
  }
22462
22541
  else {
22463
22542
  component = new labelComponent(dataLabel);
22464
22543
  component.setBitmap(bitmap);
22465
22544
  component.setBitmapTool(tool);
22466
22545
  this.add(component);
22467
- currentComponentMap.set(baseMarkGroupName, component);
22546
+ currentComponentMap.set(id, component);
22468
22547
  }
22469
22548
  }
22470
22549
  }
@@ -24710,13 +24789,6 @@
24710
24789
  }
24711
24790
  vutils.mixin(CircleAxisGrid, CircleAxisMixin);
24712
24791
 
24713
- var DataZoomActiveTag;
24714
- (function (DataZoomActiveTag) {
24715
- DataZoomActiveTag["startHandler"] = "startHandler";
24716
- DataZoomActiveTag["endHandler"] = "endHandler";
24717
- DataZoomActiveTag["middleHandler"] = "middleHandler";
24718
- DataZoomActiveTag["background"] = "background";
24719
- })(DataZoomActiveTag || (DataZoomActiveTag = {}));
24720
24792
  const DEFAULT_DATA_ZOOM_ATTRIBUTES = {
24721
24793
  orient: 'bottom',
24722
24794
  showDetail: 'auto',
@@ -24815,6 +24887,14 @@
24815
24887
  }
24816
24888
  };
24817
24889
 
24890
+ exports.DataZoomActiveTag = void 0;
24891
+ (function (DataZoomActiveTag) {
24892
+ DataZoomActiveTag["startHandler"] = "startHandler";
24893
+ DataZoomActiveTag["endHandler"] = "endHandler";
24894
+ DataZoomActiveTag["middleHandler"] = "middleHandler";
24895
+ DataZoomActiveTag["background"] = "background";
24896
+ })(exports.DataZoomActiveTag || (exports.DataZoomActiveTag = {}));
24897
+
24818
24898
  const delayMap$1 = {
24819
24899
  debounce: vutils.debounce,
24820
24900
  throttle: vutils.throttle
@@ -24842,23 +24922,23 @@
24842
24922
  this._onHandlerPointerDown = (e, tag) => {
24843
24923
  e.stopPropagation();
24844
24924
  if (tag === 'start') {
24845
- this._activeTag = DataZoomActiveTag.startHandler;
24925
+ this._activeTag = exports.DataZoomActiveTag.startHandler;
24846
24926
  this._activeItem = this._startHandler;
24847
24927
  }
24848
24928
  else if (tag === 'end') {
24849
- this._activeTag = DataZoomActiveTag.endHandler;
24929
+ this._activeTag = exports.DataZoomActiveTag.endHandler;
24850
24930
  this._activeItem = this._endHandler;
24851
24931
  }
24852
24932
  else if (tag === 'middleRect') {
24853
- this._activeTag = DataZoomActiveTag.middleHandler;
24933
+ this._activeTag = exports.DataZoomActiveTag.middleHandler;
24854
24934
  this._activeItem = this._middleHandlerRect;
24855
24935
  }
24856
24936
  else if (tag === 'middleSymbol') {
24857
- this._activeTag = DataZoomActiveTag.middleHandler;
24937
+ this._activeTag = exports.DataZoomActiveTag.middleHandler;
24858
24938
  this._activeItem = this._middleHandlerSymbol;
24859
24939
  }
24860
24940
  else if (tag === 'background') {
24861
- this._activeTag = DataZoomActiveTag.background;
24941
+ this._activeTag = exports.DataZoomActiveTag.background;
24862
24942
  this._activeItem = this._background;
24863
24943
  }
24864
24944
  this._activeState = true;
@@ -24866,6 +24946,7 @@
24866
24946
  this._activeCache.lastPos = this.eventPosToStagePos(e);
24867
24947
  };
24868
24948
  this._onHandlerPointerMove = (e) => {
24949
+ var _a;
24869
24950
  e.stopPropagation();
24870
24951
  const { start: startAttr, end: endAttr, brushSelect, realTime = true } = this.attribute;
24871
24952
  const pos = this.eventPosToStagePos(e);
@@ -24873,24 +24954,24 @@
24873
24954
  const dis = (pos[attPos] - this._activeCache.lastPos[attPos]) / max;
24874
24955
  let { start, end } = this.state;
24875
24956
  if (this._activeState) {
24876
- if (this._activeTag === DataZoomActiveTag.middleHandler) {
24957
+ if (this._activeTag === exports.DataZoomActiveTag.middleHandler) {
24877
24958
  this.moveZoomWithMiddle((this.state.start + this.state.end) / 2 + dis);
24878
24959
  }
24879
- else if (this._activeTag === DataZoomActiveTag.startHandler) {
24960
+ else if (this._activeTag === exports.DataZoomActiveTag.startHandler) {
24880
24961
  if (start + dis > end) {
24881
24962
  start = end;
24882
24963
  end = start + dis;
24883
- this._activeTag = DataZoomActiveTag.endHandler;
24964
+ this._activeTag = exports.DataZoomActiveTag.endHandler;
24884
24965
  }
24885
24966
  else {
24886
24967
  start = start + dis;
24887
24968
  }
24888
24969
  }
24889
- else if (this._activeTag === DataZoomActiveTag.endHandler) {
24970
+ else if (this._activeTag === exports.DataZoomActiveTag.endHandler) {
24890
24971
  if (end + dis < start) {
24891
24972
  end = start;
24892
24973
  start = end + dis;
24893
- this._activeTag = DataZoomActiveTag.startHandler;
24974
+ this._activeTag = exports.DataZoomActiveTag.startHandler;
24894
24975
  }
24895
24976
  else {
24896
24977
  end = end + dis;
@@ -24903,7 +24984,7 @@
24903
24984
  end = Math.min(Math.max(end, 0), 1);
24904
24985
  if (startAttr !== start || endAttr !== end) {
24905
24986
  this.setStateAttr(start, end, true);
24906
- realTime && this._updateStateCallback && this._updateStateCallback(start, end);
24987
+ realTime && ((_a = this._updateStateCallback) === null || _a === void 0 ? void 0 : _a.call(this, start, end, this._activeTag));
24907
24988
  this._dispatchChangeEvent(start, end);
24908
24989
  }
24909
24990
  };
@@ -25008,10 +25089,11 @@
25008
25089
  };
25009
25090
  }
25010
25091
  _onHandlerPointerUp(e) {
25092
+ var _a;
25011
25093
  e.preventDefault();
25012
25094
  const { start, end, brushSelect, realTime = true } = this.attribute;
25013
25095
  if (this._activeState) {
25014
- if (this._activeTag === DataZoomActiveTag.background) {
25096
+ if (this._activeTag === exports.DataZoomActiveTag.background) {
25015
25097
  const pos = this.eventPosToStagePos(e);
25016
25098
  this.backgroundDragZoom(this._activeCache.startPos, pos);
25017
25099
  }
@@ -25020,7 +25102,7 @@
25020
25102
  brushSelect && this.renderDragMask();
25021
25103
  if (!realTime || start !== this.state.start || end !== this.state.end) {
25022
25104
  this.setStateAttr(this.state.start, this.state.end, true);
25023
- this._updateStateCallback && this._updateStateCallback(this.state.start, this.state.end);
25105
+ (_a = this._updateStateCallback) === null || _a === void 0 ? void 0 : _a.call(this, this.state.start, this.state.end, this._activeTag);
25024
25106
  this._dispatchChangeEvent(this.state.start, this.state.end);
25025
25107
  }
25026
25108
  }
@@ -25070,11 +25152,11 @@
25070
25152
  const { dragMaskStyle } = this.attribute;
25071
25153
  const { position, width, height } = this.getLayoutAttrFromConfig();
25072
25154
  if (this._isHorizontal) {
25073
- this._dragMask = this._container.createOrUpdateChild('dragMask', Object.assign({ x: vutils.clamp(this.dragMaskSize() < 0 ? this._activeCache.lastPos.x : this._activeCache.startPos.x, position.x, position.x + width), y: position.y, width: (this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize())) ||
25155
+ this._dragMask = this._container.createOrUpdateChild('dragMask', Object.assign({ x: vutils.clamp(this.dragMaskSize() < 0 ? this._activeCache.lastPos.x : this._activeCache.startPos.x, position.x, position.x + width), y: position.y, width: (this._activeState && this._activeTag === exports.DataZoomActiveTag.background && Math.abs(this.dragMaskSize())) ||
25074
25156
  0, height }, dragMaskStyle), 'rect');
25075
25157
  }
25076
25158
  else {
25077
- this._dragMask = this._container.createOrUpdateChild('dragMask', Object.assign({ x: position.x, y: vutils.clamp(this.dragMaskSize() < 0 ? this._activeCache.lastPos.y : this._activeCache.startPos.y, position.y, position.y + height), width, height: (this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize())) ||
25159
+ this._dragMask = this._container.createOrUpdateChild('dragMask', Object.assign({ x: position.x, y: vutils.clamp(this.dragMaskSize() < 0 ? this._activeCache.lastPos.y : this._activeCache.startPos.y, position.y, position.y + height), width, height: (this._activeState && this._activeTag === exports.DataZoomActiveTag.background && Math.abs(this.dragMaskSize())) ||
25078
25160
  0 }, dragMaskStyle), 'rect');
25079
25161
  }
25080
25162
  }
@@ -25393,13 +25475,14 @@
25393
25475
  this.dispatchEvent(changeEvent);
25394
25476
  }
25395
25477
  setStartAndEnd(start, end) {
25478
+ var _a;
25396
25479
  const { start: startAttr, end: endAttr } = this.attribute;
25397
25480
  if (vutils.isValid(start) && vutils.isValid(end) && (start !== this.state.start || end !== this.state.end)) {
25398
25481
  this.state.start = start;
25399
25482
  this.state.end = end;
25400
25483
  if (startAttr !== this.state.start || endAttr !== this.state.end) {
25401
25484
  this.setStateAttr(start, end, true);
25402
- this._updateStateCallback && this._updateStateCallback(start, end);
25485
+ (_a = this._updateStateCallback) === null || _a === void 0 ? void 0 : _a.call(this, start, end, this._activeTag);
25403
25486
  this._dispatchChangeEvent(start, end);
25404
25487
  }
25405
25488
  }
@@ -26486,51 +26569,23 @@
26486
26569
  const target = e.target;
26487
26570
  if ((_a = target === null || target === void 0 ? void 0 : target.name) === null || _a === void 0 ? void 0 : _a.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
26488
26571
  const legendItem = target.delegate;
26489
- const selected = legendItem.hasState(exports.LegendStateValue.selected);
26490
- if (selected) {
26491
- this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover, e);
26492
- }
26493
- else {
26494
- this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover, e);
26495
- }
26496
- const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
26497
- if (focusButton) {
26498
- focusButton.setAttribute('visible', true);
26572
+ if (this._lastActiveItem) {
26573
+ if (this._lastActiveItem.id === legendItem.id) {
26574
+ return;
26575
+ }
26576
+ this._unHover(this._lastActiveItem, e);
26499
26577
  }
26500
- this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem, e);
26578
+ this._hover(legendItem, e);
26579
+ }
26580
+ else if (this._lastActiveItem) {
26581
+ this._unHover(this._lastActiveItem, e);
26582
+ this._lastActiveItem = null;
26501
26583
  }
26502
26584
  };
26503
26585
  this._onUnHover = (e) => {
26504
- var _a;
26505
- const target = e.target;
26506
- if ((_a = target === null || target === void 0 ? void 0 : target.name) === null || _a === void 0 ? void 0 : _a.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
26507
- const legendItem = target.delegate;
26508
- let attributeUpdate = false;
26509
- if (legendItem.hasState(exports.LegendStateValue.unSelectedHover) ||
26510
- legendItem.hasState(exports.LegendStateValue.selectedHover)) {
26511
- attributeUpdate = true;
26512
- }
26513
- legendItem.removeState(exports.LegendStateValue.unSelectedHover);
26514
- legendItem.removeState(exports.LegendStateValue.selectedHover);
26515
- legendItem
26516
- .getChildren()[0]
26517
- .getChildren()
26518
- .forEach((child) => {
26519
- if (!attributeUpdate &&
26520
- (child.hasState(exports.LegendStateValue.unSelectedHover) || child.hasState(exports.LegendStateValue.selectedHover))) {
26521
- attributeUpdate = true;
26522
- }
26523
- child.removeState(exports.LegendStateValue.unSelectedHover);
26524
- child.removeState(exports.LegendStateValue.selectedHover);
26525
- });
26526
- const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
26527
- if (focusButton) {
26528
- focusButton.setAttribute('visible', false);
26529
- }
26530
- if (attributeUpdate) {
26531
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
26532
- }
26533
- this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem, e);
26586
+ if (this._lastActiveItem) {
26587
+ this._unHover(this._lastActiveItem, e);
26588
+ this._lastActiveItem = null;
26534
26589
  }
26535
26590
  };
26536
26591
  this._onClick = (e) => {
@@ -26720,7 +26775,7 @@
26720
26775
  const { hover = true, select = true } = this.attribute;
26721
26776
  if (hover) {
26722
26777
  this._itemsContainer.addEventListener('pointermove', this._onHover);
26723
- this._itemsContainer.addEventListener('pointerout', this._onUnHover);
26778
+ this._itemsContainer.addEventListener('pointerleave', this._onUnHover);
26724
26779
  }
26725
26780
  if (select) {
26726
26781
  this._itemsContainer.addEventListener('pointerdown', this._onClick);
@@ -26748,6 +26803,7 @@
26748
26803
  itemGroup = createGroup(Object.assign({ x: 0, y: 0 }, background === null || background === void 0 ? void 0 : background.style));
26749
26804
  this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup, background === null || background === void 0 ? void 0 : background.state);
26750
26805
  }
26806
+ itemGroup.id = `${id !== null && id !== void 0 ? id : label}-${index}`;
26751
26807
  itemGroup.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
26752
26808
  const innerGroup = createGroup({
26753
26809
  x: 0,
@@ -26756,22 +26812,26 @@
26756
26812
  });
26757
26813
  itemGroup.add(innerGroup);
26758
26814
  let focusStartX = 0;
26759
- const shapeSize = vutils.get(shapeAttr, 'style.size', DEFAULT_SHAPE_SIZE);
26760
- const shapeSpace = vutils.get(shapeAttr, 'space', DEFAULT_SHAPE_SPACE);
26761
- const itemShape = createSymbol(Object.assign(Object.assign({ x: 0, y: 0, symbolType: 'circle', strokeBoundsBuffer: 0 }, shape), shapeAttr.style));
26762
- Object.keys(shapeAttr.state || {}).forEach(key => {
26763
- const color = shapeAttr.state[key].fill ||
26764
- shapeAttr.state[key].stroke;
26765
- if (shape.fill && vutils.isNil(shapeAttr.state[key].fill) && color) {
26766
- shapeAttr.state[key].fill = color;
26767
- }
26768
- if (shape.stroke && vutils.isNil(shapeAttr.state[key].stroke) && color) {
26769
- shapeAttr.state[key].stroke = color;
26770
- }
26771
- });
26772
- this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeAttr === null || shapeAttr === void 0 ? void 0 : shapeAttr.state);
26773
- itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
26774
- innerGroup.add(itemShape);
26815
+ let shapeSize = 0;
26816
+ let shapeSpace = 0;
26817
+ if ((shapeAttr === null || shapeAttr === void 0 ? void 0 : shapeAttr.visible) !== false) {
26818
+ shapeSize = vutils.get(shapeAttr, 'style.size', DEFAULT_SHAPE_SIZE);
26819
+ shapeSpace = vutils.get(shapeAttr, 'space', DEFAULT_SHAPE_SPACE);
26820
+ const itemShape = createSymbol(Object.assign(Object.assign({ x: 0, y: 0, symbolType: 'circle', strokeBoundsBuffer: 0 }, shape), shapeAttr.style));
26821
+ Object.keys(shapeAttr.state || {}).forEach(key => {
26822
+ const color = shapeAttr.state[key].fill ||
26823
+ shapeAttr.state[key].stroke;
26824
+ if (shape.fill && vutils.isNil(shapeAttr.state[key].fill) && color) {
26825
+ shapeAttr.state[key].fill = color;
26826
+ }
26827
+ if (shape.stroke && vutils.isNil(shapeAttr.state[key].stroke) && color) {
26828
+ shapeAttr.state[key].stroke = color;
26829
+ }
26830
+ });
26831
+ this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeAttr === null || shapeAttr === void 0 ? void 0 : shapeAttr.state);
26832
+ itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
26833
+ innerGroup.add(itemShape);
26834
+ }
26775
26835
  let focusShape;
26776
26836
  let focusSpace = 0;
26777
26837
  if (focus) {
@@ -26973,6 +27033,48 @@
26973
27033
  this._pager.addEventListener('toNext', onPaging);
26974
27034
  return true;
26975
27035
  }
27036
+ _hover(legendItem, e) {
27037
+ this._lastActiveItem = legendItem;
27038
+ const selected = legendItem.hasState(exports.LegendStateValue.selected);
27039
+ if (selected) {
27040
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover, e);
27041
+ }
27042
+ else {
27043
+ this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover, e);
27044
+ }
27045
+ const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
27046
+ if (focusButton) {
27047
+ focusButton.setAttribute('visible', true);
27048
+ }
27049
+ this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem, e);
27050
+ }
27051
+ _unHover(legendItem, e) {
27052
+ let attributeUpdate = false;
27053
+ if (legendItem.hasState(exports.LegendStateValue.unSelectedHover) || legendItem.hasState(exports.LegendStateValue.selectedHover)) {
27054
+ attributeUpdate = true;
27055
+ }
27056
+ legendItem.removeState(exports.LegendStateValue.unSelectedHover);
27057
+ legendItem.removeState(exports.LegendStateValue.selectedHover);
27058
+ legendItem
27059
+ .getChildren()[0]
27060
+ .getChildren()
27061
+ .forEach((child) => {
27062
+ if (!attributeUpdate &&
27063
+ (child.hasState(exports.LegendStateValue.unSelectedHover) || child.hasState(exports.LegendStateValue.selectedHover))) {
27064
+ attributeUpdate = true;
27065
+ }
27066
+ child.removeState(exports.LegendStateValue.unSelectedHover);
27067
+ child.removeState(exports.LegendStateValue.selectedHover);
27068
+ });
27069
+ const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
27070
+ if (focusButton) {
27071
+ focusButton.setAttribute('visible', false);
27072
+ }
27073
+ if (attributeUpdate) {
27074
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
27075
+ }
27076
+ this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem, e);
27077
+ }
26976
27078
  _setLegendItemState(legendItem, stateName, e) {
26977
27079
  const keepCurrentStates = true;
26978
27080
  let attributeUpdate = false;
@@ -30160,7 +30262,7 @@
30160
30262
  }
30161
30263
  };
30162
30264
 
30163
- const version = "0.17.0-alpha.3";
30265
+ const version = "0.17.0-alpha.4";
30164
30266
 
30165
30267
  exports.AbstractComponent = AbstractComponent;
30166
30268
  exports.ArcInfo = ArcInfo;