@visactor/vrender-components 0.15.0-alpha.19 → 0.15.0-alpha.21

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 (99) hide show
  1. package/cjs/axis/line.js +1 -1
  2. package/cjs/axis/line.js.map +1 -1
  3. package/cjs/index.d.ts +1 -1
  4. package/cjs/index.js +1 -1
  5. package/cjs/index.js.map +1 -1
  6. package/cjs/label/base.js +15 -12
  7. package/cjs/label/base.js.map +1 -1
  8. package/cjs/label/type.d.ts +1 -0
  9. package/cjs/label/type.js.map +1 -1
  10. package/cjs/legend/discrete/discrete.js +28 -27
  11. package/cjs/legend/discrete/discrete.js.map +1 -1
  12. package/cjs/legend/size/size.d.ts +2 -2
  13. package/cjs/legend/size/size.js.map +1 -1
  14. package/cjs/marker/area.d.ts +1 -20
  15. package/cjs/marker/area.js +33 -35
  16. package/cjs/marker/area.js.map +1 -1
  17. package/cjs/marker/base.d.ts +1 -0
  18. package/cjs/marker/base.js +3 -0
  19. package/cjs/marker/base.js.map +1 -1
  20. package/cjs/marker/config.d.ts +1 -1
  21. package/cjs/marker/config.js.map +1 -1
  22. package/cjs/marker/line.js +23 -12
  23. package/cjs/marker/line.js.map +1 -1
  24. package/cjs/marker/point.d.ts +7 -7
  25. package/cjs/marker/point.js +16 -7
  26. package/cjs/marker/point.js.map +1 -1
  27. package/cjs/marker/type.d.ts +7 -4
  28. package/cjs/marker/type.js.map +1 -1
  29. package/cjs/marker/util.d.ts +1 -0
  30. package/cjs/marker/util.js +3 -0
  31. package/cjs/marker/util.js.map +1 -0
  32. package/cjs/pager/pager.js +4 -2
  33. package/cjs/pager/pager.js.map +1 -1
  34. package/cjs/segment/segment.d.ts +11 -6
  35. package/cjs/segment/segment.js +82 -40
  36. package/cjs/segment/segment.js.map +1 -1
  37. package/cjs/segment/type.d.ts +5 -3
  38. package/cjs/segment/type.js.map +1 -1
  39. package/cjs/util/index.d.ts +1 -1
  40. package/cjs/util/index.js +1 -1
  41. package/cjs/util/index.js.map +1 -1
  42. package/cjs/util/{labelSmartInvert.js → label-smartInvert.js} +1 -1
  43. package/cjs/util/label-smartInvert.js.map +1 -0
  44. package/cjs/util/limit-shape.d.ts +3 -0
  45. package/cjs/util/limit-shape.js +14 -0
  46. package/cjs/util/limit-shape.js.map +1 -0
  47. package/dist/index.js +285 -171
  48. package/dist/index.min.js +1 -1
  49. package/es/axis/line.js +1 -1
  50. package/es/axis/line.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/base.js +8 -5
  55. package/es/label/base.js.map +1 -1
  56. package/es/label/type.d.ts +1 -0
  57. package/es/label/type.js.map +1 -1
  58. package/es/legend/discrete/discrete.js +26 -25
  59. package/es/legend/discrete/discrete.js.map +1 -1
  60. package/es/legend/size/size.d.ts +2 -2
  61. package/es/legend/size/size.js.map +1 -1
  62. package/es/marker/area.d.ts +1 -20
  63. package/es/marker/area.js +34 -34
  64. package/es/marker/area.js.map +1 -1
  65. package/es/marker/base.d.ts +1 -0
  66. package/es/marker/base.js +3 -0
  67. package/es/marker/base.js.map +1 -1
  68. package/es/marker/config.d.ts +1 -1
  69. package/es/marker/config.js.map +1 -1
  70. package/es/marker/line.js +24 -11
  71. package/es/marker/line.js.map +1 -1
  72. package/es/marker/point.d.ts +7 -7
  73. package/es/marker/point.js +17 -6
  74. package/es/marker/point.js.map +1 -1
  75. package/es/marker/type.d.ts +7 -4
  76. package/es/marker/type.js.map +1 -1
  77. package/es/marker/util.d.ts +1 -0
  78. package/es/marker/util.js +3 -0
  79. package/es/marker/util.js.map +1 -0
  80. package/es/pager/pager.js +4 -2
  81. package/es/pager/pager.js.map +1 -1
  82. package/es/segment/segment.d.ts +11 -6
  83. package/es/segment/segment.js +81 -41
  84. package/es/segment/segment.js.map +1 -1
  85. package/es/segment/type.d.ts +5 -3
  86. package/es/segment/type.js.map +1 -1
  87. package/es/util/index.d.ts +1 -1
  88. package/es/util/index.js +1 -1
  89. package/es/util/index.js.map +1 -1
  90. package/es/util/{labelSmartInvert.js → label-smartInvert.js} +1 -1
  91. package/es/util/label-smartInvert.js.map +1 -0
  92. package/es/util/limit-shape.d.ts +3 -0
  93. package/es/util/limit-shape.js +8 -0
  94. package/es/util/limit-shape.js.map +1 -0
  95. package/package.json +4 -4
  96. package/cjs/util/labelSmartInvert.js.map +0 -1
  97. package/es/util/labelSmartInvert.js.map +0 -1
  98. /package/cjs/util/{labelSmartInvert.d.ts → label-smartInvert.d.ts} +0 -0
  99. /package/es/util/{labelSmartInvert.d.ts → label-smartInvert.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1711,8 +1711,14 @@
1711
1711
  }
1712
1712
  _prepare() {
1713
1713
  var _a;
1714
- const baseMarks = getMarksByName(this.getRootNode(), this.attribute.baseMarkGroupName);
1715
1714
  const currentBaseMarks = [];
1715
+ let baseMarks;
1716
+ if (vutils.isFunction(this.attribute.getBaseMarks)) {
1717
+ baseMarks = this.attribute.getBaseMarks();
1718
+ }
1719
+ else {
1720
+ baseMarks = getMarksByName(this.getRootNode(), this.attribute.baseMarkGroupName);
1721
+ }
1716
1722
  baseMarks.forEach(mark => {
1717
1723
  if (mark.releaseStatus !== 'willRelease') {
1718
1724
  currentBaseMarks.push(mark);
@@ -1886,7 +1892,7 @@
1886
1892
  const prevTextMap = this._graphicToText || new Map();
1887
1893
  const texts = [];
1888
1894
  labels.forEach((text, index) => {
1889
- var _a;
1895
+ var _a, _b, _c, _d, _e, _f, _g;
1890
1896
  const labelLine = this._labelLine(text);
1891
1897
  const relatedGraphic = this._idToGraphic.get(text.attribute.id);
1892
1898
  const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
@@ -1918,7 +1924,8 @@
1918
1924
  prevText.animate().to(text.attribute, duration, easing);
1919
1925
  if (prevLabel.labelLine) {
1920
1926
  prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
1921
- points: (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points
1927
+ 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,
1928
+ points: (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.points
1922
1929
  }), duration, easing);
1923
1930
  }
1924
1931
  if (animationConfig.increaseEffect !== false &&
@@ -3204,69 +3211,74 @@
3204
3211
  };
3205
3212
 
3206
3213
  class Segment extends AbstractComponent {
3214
+ getStartAngle() {
3215
+ return this._startAngle;
3216
+ }
3217
+ getEndAngle() {
3218
+ return this._endAngle;
3219
+ }
3220
+ getMainSegmentPoints() {
3221
+ return this._mainSegmentPoints;
3222
+ }
3207
3223
  constructor(attributes) {
3208
3224
  super(vutils.merge({}, Segment.defaultAttributes, attributes));
3209
3225
  this.name = 'segment';
3210
3226
  }
3211
- computeLineAngle() {
3212
- const { points } = this.attribute;
3213
- const start = points[0];
3214
- const startInside = points[1];
3215
- const endInside = points[points.length - 2];
3216
- const end = points[points.length - 1];
3217
- const startVector = [start.x - startInside.x, start.y - startInside.y];
3218
- const startAngle = Math.atan2(startVector[1], startVector[0]);
3219
- const endVector = [end.x - endInside.x, end.y - endInside.y];
3220
- const endAngle = Math.atan2(endVector[1], endVector[0]);
3221
- this._startAngle = startAngle;
3222
- this._endAngle = endAngle;
3223
- }
3224
3227
  render() {
3225
3228
  this.removeAllChild();
3226
- const { points, startSymbol, endSymbol, lineStyle, state, visible = true } = this.attribute;
3229
+ this._reset();
3230
+ const { startSymbol, endSymbol, lineStyle, state, visible = true, multiSegment, mainSegmentIndex } = this.attribute;
3227
3231
  if (!visible) {
3228
3232
  return;
3229
3233
  }
3230
- if (points.length > 1) {
3231
- this.computeLineAngle();
3232
- }
3233
- const startSymbolShape = this.renderSymbol(startSymbol, 'start');
3234
- const endSymbolShape = this.renderSymbol(endSymbol, 'end');
3234
+ this._computeLineAngle();
3235
+ const startSymbolShape = this._renderSymbol(startSymbol, 'start');
3236
+ const endSymbolShape = this._renderSymbol(endSymbol, 'end');
3235
3237
  this.startSymbol = startSymbolShape;
3236
3238
  this.endSymbol = endSymbolShape;
3237
- let pointsAfterClip = points;
3238
- if (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.visible) {
3239
- const startSize = (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.clip) ? (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.size) || 10 : 0;
3240
- const pointsStart = {
3241
- x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),
3242
- y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)
3243
- };
3244
- pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];
3245
- }
3246
- if (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.visible) {
3247
- const endSize = (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.clip) ? (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.size) || 10 : 0;
3248
- const pointsEnd = {
3249
- x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),
3250
- y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)
3251
- };
3252
- pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];
3239
+ if (multiSegment) {
3240
+ const points = [...this.attribute.points];
3241
+ if (vutils.isValidNumber(mainSegmentIndex)) {
3242
+ points[mainSegmentIndex] = this._clipPoints(points[mainSegmentIndex]);
3243
+ }
3244
+ else {
3245
+ const clipPoints = this._clipPoints(vutils.flattenArray(points));
3246
+ points[0][0] = clipPoints[0];
3247
+ points[points.length - 1][points[points.length - 1].length - 1] =
3248
+ clipPoints[clipPoints.length - 1];
3249
+ }
3250
+ points.forEach((point, index) => {
3251
+ var _a, _b;
3252
+ const line = vrender.createLine(Object.assign(Object.assign({ points: point }, (vutils.isArray(lineStyle) ? (_a = lineStyle[index]) !== null && _a !== void 0 ? _a : lineStyle[lineStyle.length - 1] : lineStyle)), { fill: false }));
3253
+ line.name = `${this.name}-line`;
3254
+ line.id = this._getNodeId('line' + index);
3255
+ if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
3256
+ line.states = vutils.isArray(state.line) ? (_b = state.line[index]) !== null && _b !== void 0 ? _b : state.line[state.line.length - 1] : state.line;
3257
+ }
3258
+ this.add(line);
3259
+ });
3253
3260
  }
3254
- const line = vrender.createLine(Object.assign({ points: pointsAfterClip, fill: false }, lineStyle));
3255
- line.name = 'line';
3256
- line.id = this._getNodeId('line');
3257
- if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
3258
- line.states = state.line;
3261
+ else {
3262
+ const line = vrender.createLine(Object.assign(Object.assign({ points: this._clipPoints(this.attribute.points) }, vutils.array(lineStyle)[0]), { fill: false }));
3263
+ line.name = `${this.name}-line`;
3264
+ line.id = this._getNodeId('line');
3265
+ if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
3266
+ line.states = [].concat(state.line)[0];
3267
+ }
3268
+ this.add(line);
3259
3269
  }
3260
- this.line = line;
3261
- this.add(line);
3262
3270
  }
3263
- renderSymbol(attribute, dim) {
3271
+ _renderSymbol(attribute, dim) {
3272
+ const points = this._getMainSegmentPoints();
3273
+ if (!points.length) {
3274
+ return;
3275
+ }
3264
3276
  const { autoRotate = true } = attribute;
3265
3277
  let symbol;
3266
3278
  if (attribute === null || attribute === void 0 ? void 0 : attribute.visible) {
3267
3279
  const startAngle = this._startAngle;
3268
3280
  const endAngle = this._endAngle;
3269
- const { points, state } = this.attribute;
3281
+ const { state } = this.attribute;
3270
3282
  const start = points[0];
3271
3283
  const end = points[points.length - 1];
3272
3284
  const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;
@@ -3274,20 +3286,22 @@
3274
3286
  let rotate;
3275
3287
  if (dim === 'start') {
3276
3288
  position = {
3277
- x: start.x + (startAngle ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),
3278
- y: start.y + (startAngle ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)
3289
+ x: start.x +
3290
+ (vutils.isValidNumber(startAngle) ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),
3291
+ y: start.y +
3292
+ (vutils.isValidNumber(startAngle) ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)
3279
3293
  };
3280
3294
  rotate = startAngle + Math.PI / 2;
3281
3295
  }
3282
3296
  else {
3283
3297
  position = {
3284
- x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
3285
- y: end.y + (endAngle ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)
3298
+ x: end.x + (vutils.isValidNumber(endAngle) ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
3299
+ y: end.y + (vutils.isValidNumber(endAngle) ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)
3286
3300
  };
3287
3301
  rotate = endAngle + Math.PI / 2;
3288
3302
  }
3289
3303
  symbol = vrender.createSymbol(Object.assign(Object.assign(Object.assign({}, position), { symbolType: symbolType, size, angle: autoRotate ? rotate + refAngle : 0, strokeBoundsBuffer: 0 }), style));
3290
- symbol.name = `${dim}-symbol`;
3304
+ symbol.name = `${this.name}-${dim}-symbol`;
3291
3305
  symbol.id = this._getNodeId(`${dim}-symbol`);
3292
3306
  if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.symbol)) {
3293
3307
  symbol.states = state.symbol;
@@ -3296,11 +3310,69 @@
3296
3310
  }
3297
3311
  return symbol;
3298
3312
  }
3299
- getStartAngle() {
3300
- return this._startAngle;
3313
+ _getMainSegmentPoints() {
3314
+ if (this._mainSegmentPoints) {
3315
+ return this._mainSegmentPoints;
3316
+ }
3317
+ const { points: originPoints, multiSegment, mainSegmentIndex } = this.attribute;
3318
+ let points;
3319
+ if (multiSegment) {
3320
+ if (vutils.isValidNumber(mainSegmentIndex)) {
3321
+ points = originPoints[mainSegmentIndex];
3322
+ }
3323
+ else {
3324
+ points = vutils.flattenArray(originPoints);
3325
+ }
3326
+ }
3327
+ else {
3328
+ points = originPoints;
3329
+ }
3330
+ this._mainSegmentPoints = points;
3331
+ return points;
3301
3332
  }
3302
- getEndAngle() {
3303
- return this._endAngle;
3333
+ _clipPoints(points) {
3334
+ const { startSymbol, endSymbol } = this.attribute;
3335
+ let pointsAfterClip = points;
3336
+ if (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.visible) {
3337
+ const startSize = (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.clip) ? (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.size) || 10 : 0;
3338
+ const pointsStart = {
3339
+ x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),
3340
+ y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)
3341
+ };
3342
+ pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];
3343
+ }
3344
+ if (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.visible) {
3345
+ const endSize = (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.clip) ? (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.size) || 10 : 0;
3346
+ const pointsEnd = {
3347
+ x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),
3348
+ y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)
3349
+ };
3350
+ pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];
3351
+ }
3352
+ return pointsAfterClip;
3353
+ }
3354
+ _computeLineAngle() {
3355
+ const points = this._getMainSegmentPoints();
3356
+ if (points.length <= 1) {
3357
+ return;
3358
+ }
3359
+ const start = points[0];
3360
+ const startInside = points[1];
3361
+ const endInside = points[points.length - 2];
3362
+ const end = points[points.length - 1];
3363
+ const startVector = [start.x - startInside.x, start.y - startInside.y];
3364
+ const startAngle = Math.atan2(startVector[1], startVector[0]);
3365
+ const endVector = [end.x - endInside.x, end.y - endInside.y];
3366
+ const endAngle = Math.atan2(endVector[1], endVector[0]);
3367
+ this._startAngle = startAngle;
3368
+ this._endAngle = endAngle;
3369
+ }
3370
+ _reset() {
3371
+ this.startSymbol = null;
3372
+ this.endSymbol = null;
3373
+ this._startAngle = null;
3374
+ this._endAngle = null;
3375
+ this._mainSegmentPoints = null;
3304
3376
  }
3305
3377
  }
3306
3378
  Segment.defaultAttributes = {
@@ -4360,7 +4432,7 @@
4360
4432
  }
4361
4433
  beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4362
4434
  const { flush = false } = this.attribute.label || {};
4363
- if (flush) {
4435
+ if (flush && labelShapes.length) {
4364
4436
  const { orient, start, end } = this.attribute;
4365
4437
  const isX = orient === 'bottom' || orient === 'top';
4366
4438
  const first = labelShapes[0];
@@ -6012,6 +6084,10 @@
6012
6084
  })(exports.IMarkPointItemPosition || (exports.IMarkPointItemPosition = {}));
6013
6085
 
6014
6086
  class Marker extends AbstractComponent {
6087
+ constructor() {
6088
+ super(...arguments);
6089
+ this.name = 'marker';
6090
+ }
6015
6091
  _initContainer() {
6016
6092
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6017
6093
  const groupClip = vrender.createGroup(Object.assign(Object.assign({}, (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.clipRange), { clip: (_c = vutils.isValid((_b = this.attribute) === null || _b === void 0 ? void 0 : _b.clipRange)) !== null && _c !== void 0 ? _c : false }));
@@ -6279,47 +6355,84 @@
6279
6355
  }
6280
6356
  };
6281
6357
 
6358
+ function limitShapeInBounds(shape, bounds) {
6359
+ const { x1: regionMinX, y1: regionMinY, x2: regionMaxX, y2: regionMaxY } = bounds;
6360
+ const { x1, y1, x2, y2 } = shape.AABBBounds;
6361
+ const { dx: originDx = 0, dy: originDy = 0 } = shape.attribute;
6362
+ let dx = 0;
6363
+ let dy = 0;
6364
+ if (x1 < regionMinX) {
6365
+ dx = regionMinX - x1;
6366
+ }
6367
+ if (y1 < regionMinY) {
6368
+ dy = regionMinY - y1;
6369
+ }
6370
+ if (x2 > regionMaxX) {
6371
+ dx = regionMaxX - x2;
6372
+ }
6373
+ if (y2 > regionMaxY) {
6374
+ dy = regionMaxY - y2;
6375
+ }
6376
+ if (dx) {
6377
+ shape.setAttribute('dx', dx + originDx);
6378
+ }
6379
+ if (dy) {
6380
+ shape.setAttribute('dy', dy + originDy);
6381
+ }
6382
+ }
6383
+
6282
6384
  class MarkLine extends Marker {
6283
6385
  constructor(attributes) {
6284
6386
  super(vutils.merge({}, MarkLine.defaultAttributes, attributes));
6285
6387
  }
6286
6388
  setLabelPos() {
6287
- var _a, _b, _c, _d, _e;
6288
- const { points, label } = this.attribute;
6289
- const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'end';
6290
- const labelAngle = this._line.getEndAngle();
6291
- const labelOffsetX = (label === null || label === void 0 ? void 0 : label.refX) * Math.cos(labelAngle) + label.refY * Math.cos(labelAngle - Math.PI / 2);
6292
- const labelOffsetY = (label === null || label === void 0 ? void 0 : label.refX) * Math.sin(labelAngle) + label.refY * Math.sin(labelAngle - Math.PI / 2);
6293
- if (labelPosition.includes('start') || labelPosition.includes('Start')) {
6294
- (_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes({
6389
+ var _a, _b;
6390
+ const { label = {}, clipRange } = this.attribute;
6391
+ const { position = 'end', refX = 0, refY = 0, autoRange } = label;
6392
+ const points = this._line.getMainSegmentPoints();
6393
+ const labelAngle = (_a = this._line.getEndAngle()) !== null && _a !== void 0 ? _a : 0;
6394
+ const labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2);
6395
+ const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);
6396
+ let labelPoint;
6397
+ if (position.includes('start') || position.includes('Start')) {
6398
+ labelPoint = {
6295
6399
  x: points[0].x + labelOffsetX,
6296
6400
  y: points[0].y + labelOffsetY
6297
- });
6401
+ };
6298
6402
  }
6299
- else if (labelPosition.includes('middle') || labelPosition.includes('Middle')) {
6300
- (_c = this._label) === null || _c === void 0 ? void 0 : _c.setAttributes({
6403
+ else if (position.includes('middle') || position.includes('Middle')) {
6404
+ labelPoint = {
6301
6405
  x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
6302
6406
  y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
6303
- });
6407
+ };
6304
6408
  }
6305
6409
  else {
6306
- (_d = this._label) === null || _d === void 0 ? void 0 : _d.setAttributes({
6410
+ labelPoint = {
6307
6411
  x: points[points.length - 1].x + labelOffsetX,
6308
6412
  y: points[points.length - 1].y + labelOffsetY
6413
+ };
6414
+ }
6415
+ this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), { angle: label.autoRotate ? labelAngle + ((_b = label === null || label === void 0 ? void 0 : label.refAngle) !== null && _b !== void 0 ? _b : 0) : 0, textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[position]), label.textStyle) }));
6416
+ if (clipRange && autoRange) {
6417
+ const { x, y, width, height } = clipRange;
6418
+ limitShapeInBounds(this._label, {
6419
+ x1: x,
6420
+ y1: y,
6421
+ x2: x + width,
6422
+ y2: y + height
6309
6423
  });
6310
6424
  }
6311
- this._label.setAttributes({
6312
- angle: label.autoRotate && labelAngle + ((_e = label === null || label === void 0 ? void 0 : label.refAngle) !== null && _e !== void 0 ? _e : 0),
6313
- textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
6314
- });
6315
6425
  }
6316
6426
  initMarker(container) {
6317
- const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute;
6427
+ const { points, startSymbol, endSymbol, label, lineStyle, mainSegmentIndex, multiSegment } = this
6428
+ .attribute;
6318
6429
  const line = new Segment({
6319
6430
  points,
6320
6431
  startSymbol,
6321
6432
  endSymbol,
6322
- lineStyle
6433
+ lineStyle,
6434
+ mainSegmentIndex,
6435
+ multiSegment
6323
6436
  });
6324
6437
  line.name = 'mark-line-line';
6325
6438
  this._line = line;
@@ -6349,58 +6462,54 @@
6349
6462
  constructor(attributes) {
6350
6463
  super(vutils.merge({}, MarkArea.defaultAttributes, attributes));
6351
6464
  }
6352
- getLeftPos() {
6353
- return {
6354
- x: this._area.AABBBounds.x1,
6355
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6356
- };
6357
- }
6358
- getRightPos() {
6359
- return {
6360
- x: this._area.AABBBounds.x2,
6361
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6362
- };
6363
- }
6364
- getTopPos() {
6365
- return {
6366
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6367
- y: this._area.AABBBounds.y1
6368
- };
6369
- }
6370
- getBottomPos() {
6371
- return {
6372
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6373
- y: this._area.AABBBounds.y2
6374
- };
6375
- }
6376
- getMiddlePos() {
6377
- return {
6378
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6379
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6380
- };
6381
- }
6382
- setLabelPos() {
6383
- var _a, _b, _c, _d, _e, _f, _g;
6384
- const { label } = this.attribute;
6385
- const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'middle';
6386
- if (labelPosition.includes('left') || labelPosition.includes('Left')) {
6387
- (_b = this._label) === null || _b === void 0 ? void 0 : _b.setAttributes(Object.assign({}, this.getLeftPos()));
6465
+ _getPositionByDirection(area, direction) {
6466
+ const { x1, x2, y1, y2 } = this._area.AABBBounds;
6467
+ if (direction.includes('left') || direction.includes('Left')) {
6468
+ return {
6469
+ x: x1,
6470
+ y: (y1 + y2) / 2
6471
+ };
6388
6472
  }
6389
- else if (labelPosition.includes('right') || labelPosition.includes('Right')) {
6390
- (_c = this._label) === null || _c === void 0 ? void 0 : _c.setAttributes(Object.assign({}, this.getRightPos()));
6473
+ if (direction.includes('right') || direction.includes('Right')) {
6474
+ return {
6475
+ x: x2,
6476
+ y: (y1 + y2) / 2
6477
+ };
6391
6478
  }
6392
- else if (labelPosition.includes('top') || labelPosition.includes('Top')) {
6393
- (_d = this._label) === null || _d === void 0 ? void 0 : _d.setAttributes(Object.assign({}, this.getTopPos()));
6479
+ if (direction.includes('top') || direction.includes('Top')) {
6480
+ return {
6481
+ x: (x1 + x2) / 2,
6482
+ y: y1
6483
+ };
6394
6484
  }
6395
- else if (labelPosition.includes('bottom') || labelPosition.includes('Bottom')) {
6396
- (_e = this._label) === null || _e === void 0 ? void 0 : _e.setAttributes(Object.assign({}, this.getBottomPos()));
6485
+ if (direction.includes('bottom') || direction.includes('Bottom')) {
6486
+ return {
6487
+ x: (x1 + x2) / 2,
6488
+ y: y2
6489
+ };
6397
6490
  }
6398
- else {
6399
- (_f = this._label) === null || _f === void 0 ? void 0 : _f.setAttributes(Object.assign({}, this.getMiddlePos()));
6491
+ return {
6492
+ x: (x1 + x2) / 2,
6493
+ y: (y1 + y2) / 2
6494
+ };
6495
+ }
6496
+ setLabelPos() {
6497
+ var _a;
6498
+ if (this._label && this._area) {
6499
+ const { label } = this.attribute;
6500
+ const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'middle';
6501
+ const labelPoint = this._getPositionByDirection(this._area, labelPosition);
6502
+ this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), { textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle) }));
6503
+ if (this.attribute.clipRange && (label === null || label === void 0 ? void 0 : label.autoRange)) {
6504
+ const { x, y, width, height } = this.attribute.clipRange;
6505
+ limitShapeInBounds(this._label, {
6506
+ x1: x,
6507
+ y1: y,
6508
+ x2: x + width,
6509
+ y2: y + height
6510
+ });
6511
+ }
6400
6512
  }
6401
- (_g = this._label) === null || _g === void 0 ? void 0 : _g.setAttributes({
6402
- textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
6403
- });
6404
6513
  }
6405
6514
  initMarker(container) {
6406
6515
  const { points, label, areaStyle } = this.attribute;
@@ -6431,31 +6540,43 @@
6431
6540
  setLabelPos() {
6432
6541
  }
6433
6542
  setItemAttributes(item, itemContent, itemPosition, itemType) {
6434
- var _a;
6543
+ var _a, _b;
6544
+ if (!item) {
6545
+ return;
6546
+ }
6435
6547
  const { autoRotate = true, refX = 0, refY = 0, refAngle = 0, textStyle, richTextStyle, imageStyle, position = exports.IMarkPointItemPosition.middle } = itemContent;
6436
6548
  const itemAngle = ((_a = this._line) === null || _a === void 0 ? void 0 : _a.getEndAngle()) || 0;
6437
6549
  const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);
6438
6550
  const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
6439
6551
  if (itemType === 'text') {
6440
- item === null || item === void 0 ? void 0 : item.setAttributes(Object.assign(Object.assign({}, textStyle), { textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(itemContent === null || itemContent === void 0 ? void 0 : itemContent.position) || 'end']), textStyle === null || textStyle === void 0 ? void 0 : textStyle.textStyle) }));
6552
+ item.setAttributes(Object.assign(Object.assign({}, textStyle), { textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(itemContent === null || itemContent === void 0 ? void 0 : itemContent.position) || 'end']), textStyle === null || textStyle === void 0 ? void 0 : textStyle.textStyle) }));
6441
6553
  }
6442
6554
  else if (itemType === 'richText') {
6443
- item === null || item === void 0 ? void 0 : item.setAttributes({
6555
+ item.setAttributes({
6444
6556
  dx: this.getItemDx(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dx) || 0),
6445
6557
  dy: this.getItemDy(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dy) || 0)
6446
6558
  });
6447
6559
  }
6448
6560
  else if (itemType === 'image') {
6449
- item === null || item === void 0 ? void 0 : item.setAttributes({
6561
+ item.setAttributes({
6450
6562
  dx: this.getItemDx(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dx) || 0),
6451
6563
  dy: this.getItemDy(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dy) || 0)
6452
6564
  });
6453
6565
  }
6454
- item === null || item === void 0 ? void 0 : item.setAttributes({
6566
+ item.setAttributes({
6455
6567
  x: itemPosition.x + (itemOffsetX || 0),
6456
6568
  y: itemPosition.y + (itemOffsetY || 0),
6457
6569
  angle: autoRotate && itemAngle + refAngle
6458
6570
  });
6571
+ if (this.attribute.clipRange && ((_b = this.attribute.itemContent) === null || _b === void 0 ? void 0 : _b.autoRange)) {
6572
+ const { x, y, width, height } = this.attribute.clipRange;
6573
+ limitShapeInBounds(item, {
6574
+ x1: x,
6575
+ y1: y,
6576
+ x2: x + width,
6577
+ y2: y + height
6578
+ });
6579
+ }
6459
6580
  }
6460
6581
  getItemDx(item, position, style) {
6461
6582
  var _a, _b;
@@ -6463,7 +6584,7 @@
6463
6584
  if (position.includes('inside')) {
6464
6585
  return -width;
6465
6586
  }
6466
- else if (position === 'insideTop') {
6587
+ if (position === 'insideTop') {
6467
6588
  return 0;
6468
6589
  }
6469
6590
  return 0;
@@ -6474,7 +6595,7 @@
6474
6595
  if (position.includes('top') || position.includes('Top')) {
6475
6596
  return -height;
6476
6597
  }
6477
- else if (position.includes('middle') || position.includes('Middle')) {
6598
+ if (position.includes('middle') || position.includes('Middle')) {
6478
6599
  return -height / 2;
6479
6600
  }
6480
6601
  return 0;
@@ -6670,7 +6791,8 @@
6670
6791
  const changeEvent = new vrender.CustomEvent('toPrev', {
6671
6792
  current: this._current,
6672
6793
  total: this._total,
6673
- direction: 'pre'
6794
+ direction: 'pre',
6795
+ event: e
6674
6796
  });
6675
6797
  changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
6676
6798
  this.dispatchEvent(changeEvent);
@@ -6689,7 +6811,8 @@
6689
6811
  const changeEvent = new vrender.CustomEvent('toNext', {
6690
6812
  current: this._current,
6691
6813
  total: this._total,
6692
- direction: 'next'
6814
+ direction: 'next',
6815
+ event: e
6693
6816
  });
6694
6817
  changeEvent.manager = (_b = this.stage) === null || _b === void 0 ? void 0 : _b.eventSystem.manager;
6695
6818
  this.dispatchEvent(changeEvent);
@@ -6915,16 +7038,16 @@
6915
7038
  const legendItem = target.delegate;
6916
7039
  const selected = legendItem.hasState(exports.LegendStateValue.selected);
6917
7040
  if (selected) {
6918
- this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover);
7041
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover, e);
6919
7042
  }
6920
7043
  else {
6921
- this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover);
7044
+ this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover, e);
6922
7045
  }
6923
7046
  const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
6924
7047
  if (focusButton) {
6925
7048
  focusButton.setAttribute('visible', true);
6926
7049
  }
6927
- this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem);
7050
+ this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem, e);
6928
7051
  }
6929
7052
  };
6930
7053
  this._onUnHover = (e) => {
@@ -6955,9 +7078,9 @@
6955
7078
  focusButton.setAttribute('visible', false);
6956
7079
  }
6957
7080
  if (attributeUpdate) {
6958
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7081
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
6959
7082
  }
6960
- this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem);
7083
+ this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem, e);
6961
7084
  }
6962
7085
  };
6963
7086
  this._onClick = (e) => {
@@ -6970,25 +7093,17 @@
6970
7093
  legendItem.toggleState(exports.LegendStateValue.focus);
6971
7094
  if (isFocusSelected) {
6972
7095
  (_b = this._itemsContainer) === null || _b === void 0 ? void 0 : _b.getChildren().forEach(item => {
6973
- this._removeLegendItemState(item, [
6974
- exports.LegendStateValue.unSelected,
6975
- exports.LegendStateValue.unSelectedHover,
6976
- exports.LegendStateValue.focus
6977
- ]);
6978
- this._setLegendItemState(item, exports.LegendStateValue.selected);
7096
+ this._removeLegendItemState(item, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover, exports.LegendStateValue.focus], e);
7097
+ this._setLegendItemState(item, exports.LegendStateValue.selected, e);
6979
7098
  });
6980
7099
  }
6981
7100
  else {
6982
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
6983
- this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
7101
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
7102
+ this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
6984
7103
  (_c = this._itemsContainer) === null || _c === void 0 ? void 0 : _c.getChildren().forEach(item => {
6985
7104
  if (legendItem !== item) {
6986
- this._removeLegendItemState(item, [
6987
- exports.LegendStateValue.selected,
6988
- exports.LegendStateValue.selectedHover,
6989
- exports.LegendStateValue.focus
6990
- ]);
6991
- this._setLegendItemState(item, exports.LegendStateValue.unSelected);
7105
+ this._removeLegendItemState(item, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover, exports.LegendStateValue.focus], e);
7106
+ this._setLegendItemState(item, exports.LegendStateValue.unSelected, e);
6992
7107
  }
6993
7108
  });
6994
7109
  }
@@ -7002,33 +7117,30 @@
7002
7117
  const currentSelectedItems = this._getSelectedLegends();
7003
7118
  if (selectMode === 'multiple') {
7004
7119
  if (allowAllCanceled === false && isSelected && currentSelectedItems.length === 1) {
7005
- this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
7120
+ this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
7006
7121
  return;
7007
7122
  }
7008
7123
  if (isSelected) {
7009
- this._removeLegendItemState(legendItem, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover]);
7010
- this._setLegendItemState(legendItem, exports.LegendStateValue.unSelected);
7124
+ this._removeLegendItemState(legendItem, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover], e);
7125
+ this._setLegendItemState(legendItem, exports.LegendStateValue.unSelected, e);
7011
7126
  }
7012
7127
  else {
7013
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
7014
- this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
7128
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
7129
+ this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
7015
7130
  }
7016
7131
  }
7017
7132
  else {
7018
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
7019
- this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover]);
7133
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selected, e);
7134
+ this._removeLegendItemState(legendItem, [exports.LegendStateValue.unSelected, exports.LegendStateValue.unSelectedHover], e);
7020
7135
  (_e = this._itemsContainer) === null || _e === void 0 ? void 0 : _e.getChildren().forEach(item => {
7021
7136
  if (legendItem !== item) {
7022
- this._removeLegendItemState(item, [
7023
- exports.LegendStateValue.selected,
7024
- exports.LegendStateValue.selectedHover
7025
- ]);
7026
- this._setLegendItemState(item, exports.LegendStateValue.unSelected);
7137
+ this._removeLegendItemState(item, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover], e);
7138
+ this._setLegendItemState(item, exports.LegendStateValue.unSelected, e);
7027
7139
  }
7028
7140
  });
7029
7141
  }
7030
7142
  }
7031
- this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
7143
+ this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
7032
7144
  }
7033
7145
  };
7034
7146
  }
@@ -7399,7 +7511,8 @@
7399
7511
  this._pager.addEventListener('toNext', onPaging);
7400
7512
  return true;
7401
7513
  }
7402
- _setLegendItemState(legendItem, stateName, keepCurrentStates = true) {
7514
+ _setLegendItemState(legendItem, stateName, e) {
7515
+ const keepCurrentStates = true;
7403
7516
  let attributeUpdate = false;
7404
7517
  if (!legendItem.hasState(stateName)) {
7405
7518
  attributeUpdate = true;
@@ -7417,10 +7530,10 @@
7417
7530
  }
7418
7531
  });
7419
7532
  if (attributeUpdate) {
7420
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7533
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
7421
7534
  }
7422
7535
  }
7423
- _removeLegendItemState(legendItem, stateNames) {
7536
+ _removeLegendItemState(legendItem, stateNames, e) {
7424
7537
  let attributeUpdate = false;
7425
7538
  stateNames.forEach(name => {
7426
7539
  if (!attributeUpdate && legendItem.hasState(name)) {
@@ -7442,7 +7555,7 @@
7442
7555
  }
7443
7556
  });
7444
7557
  if (attributeUpdate) {
7445
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7558
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
7446
7559
  }
7447
7560
  }
7448
7561
  _getSelectedLegends() {
@@ -7461,7 +7574,7 @@
7461
7574
  shape.delegate = delegateShape;
7462
7575
  shape.states = vutils.merge({}, DEFAULT_STATES, states);
7463
7576
  }
7464
- _dispatchEvent(eventName, legendItem) {
7577
+ _dispatchEvent(eventName, legendItem, event) {
7465
7578
  var _a;
7466
7579
  const currentSelectedItems = this._getSelectedLegends();
7467
7580
  currentSelectedItems.sort((pre, next) => pre.index - next.index);
@@ -7471,7 +7584,8 @@
7471
7584
  data: legendItem.data,
7472
7585
  selected: legendItem.hasState(exports.LegendStateValue.selected),
7473
7586
  currentSelectedItems,
7474
- currentSelected
7587
+ currentSelected,
7588
+ event
7475
7589
  });
7476
7590
  changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
7477
7591
  this.dispatchEvent(changeEvent);
@@ -10358,7 +10472,7 @@
10358
10472
  return new Tag(params ? params.attribute : {});
10359
10473
  }
10360
10474
 
10361
- const version = "0.15.0-alpha.19";
10475
+ const version = "0.15.0-alpha.21";
10362
10476
 
10363
10477
  exports.AbstractComponent = AbstractComponent;
10364
10478
  exports.ArcInfo = ArcInfo;