@visactor/vrender-components 0.15.0-alpha.20 → 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 +12 -10
  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 +282 -169
  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 +5 -3
  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);
@@ -3205,69 +3211,74 @@
3205
3211
  };
3206
3212
 
3207
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
+ }
3208
3223
  constructor(attributes) {
3209
3224
  super(vutils.merge({}, Segment.defaultAttributes, attributes));
3210
3225
  this.name = 'segment';
3211
3226
  }
3212
- computeLineAngle() {
3213
- const { points } = this.attribute;
3214
- const start = points[0];
3215
- const startInside = points[1];
3216
- const endInside = points[points.length - 2];
3217
- const end = points[points.length - 1];
3218
- const startVector = [start.x - startInside.x, start.y - startInside.y];
3219
- const startAngle = Math.atan2(startVector[1], startVector[0]);
3220
- const endVector = [end.x - endInside.x, end.y - endInside.y];
3221
- const endAngle = Math.atan2(endVector[1], endVector[0]);
3222
- this._startAngle = startAngle;
3223
- this._endAngle = endAngle;
3224
- }
3225
3227
  render() {
3226
3228
  this.removeAllChild();
3227
- 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;
3228
3231
  if (!visible) {
3229
3232
  return;
3230
3233
  }
3231
- if (points.length > 1) {
3232
- this.computeLineAngle();
3233
- }
3234
- const startSymbolShape = this.renderSymbol(startSymbol, 'start');
3235
- const endSymbolShape = this.renderSymbol(endSymbol, 'end');
3234
+ this._computeLineAngle();
3235
+ const startSymbolShape = this._renderSymbol(startSymbol, 'start');
3236
+ const endSymbolShape = this._renderSymbol(endSymbol, 'end');
3236
3237
  this.startSymbol = startSymbolShape;
3237
3238
  this.endSymbol = endSymbolShape;
3238
- let pointsAfterClip = points;
3239
- if (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.visible) {
3240
- const startSize = (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.clip) ? (startSymbol === null || startSymbol === void 0 ? void 0 : startSymbol.size) || 10 : 0;
3241
- const pointsStart = {
3242
- x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),
3243
- y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)
3244
- };
3245
- pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];
3246
- }
3247
- if (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.visible) {
3248
- const endSize = (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.clip) ? (endSymbol === null || endSymbol === void 0 ? void 0 : endSymbol.size) || 10 : 0;
3249
- const pointsEnd = {
3250
- x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),
3251
- y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)
3252
- };
3253
- 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
+ });
3254
3260
  }
3255
- const line = vrender.createLine(Object.assign({ points: pointsAfterClip, fill: false }, lineStyle));
3256
- line.name = 'line';
3257
- line.id = this._getNodeId('line');
3258
- if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.line)) {
3259
- 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);
3260
3269
  }
3261
- this.line = line;
3262
- this.add(line);
3263
3270
  }
3264
- renderSymbol(attribute, dim) {
3271
+ _renderSymbol(attribute, dim) {
3272
+ const points = this._getMainSegmentPoints();
3273
+ if (!points.length) {
3274
+ return;
3275
+ }
3265
3276
  const { autoRotate = true } = attribute;
3266
3277
  let symbol;
3267
3278
  if (attribute === null || attribute === void 0 ? void 0 : attribute.visible) {
3268
3279
  const startAngle = this._startAngle;
3269
3280
  const endAngle = this._endAngle;
3270
- const { points, state } = this.attribute;
3281
+ const { state } = this.attribute;
3271
3282
  const start = points[0];
3272
3283
  const end = points[points.length - 1];
3273
3284
  const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;
@@ -3275,20 +3286,22 @@
3275
3286
  let rotate;
3276
3287
  if (dim === 'start') {
3277
3288
  position = {
3278
- x: start.x + (startAngle ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),
3279
- 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)
3280
3293
  };
3281
3294
  rotate = startAngle + Math.PI / 2;
3282
3295
  }
3283
3296
  else {
3284
3297
  position = {
3285
- x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),
3286
- 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)
3287
3300
  };
3288
3301
  rotate = endAngle + Math.PI / 2;
3289
3302
  }
3290
3303
  symbol = vrender.createSymbol(Object.assign(Object.assign(Object.assign({}, position), { symbolType: symbolType, size, angle: autoRotate ? rotate + refAngle : 0, strokeBoundsBuffer: 0 }), style));
3291
- symbol.name = `${dim}-symbol`;
3304
+ symbol.name = `${this.name}-${dim}-symbol`;
3292
3305
  symbol.id = this._getNodeId(`${dim}-symbol`);
3293
3306
  if (!vutils.isEmpty(state === null || state === void 0 ? void 0 : state.symbol)) {
3294
3307
  symbol.states = state.symbol;
@@ -3297,11 +3310,69 @@
3297
3310
  }
3298
3311
  return symbol;
3299
3312
  }
3300
- getStartAngle() {
3301
- 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;
3302
3332
  }
3303
- getEndAngle() {
3304
- 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;
3305
3376
  }
3306
3377
  }
3307
3378
  Segment.defaultAttributes = {
@@ -4361,7 +4432,7 @@
4361
4432
  }
4362
4433
  beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4363
4434
  const { flush = false } = this.attribute.label || {};
4364
- if (flush) {
4435
+ if (flush && labelShapes.length) {
4365
4436
  const { orient, start, end } = this.attribute;
4366
4437
  const isX = orient === 'bottom' || orient === 'top';
4367
4438
  const first = labelShapes[0];
@@ -6013,6 +6084,10 @@
6013
6084
  })(exports.IMarkPointItemPosition || (exports.IMarkPointItemPosition = {}));
6014
6085
 
6015
6086
  class Marker extends AbstractComponent {
6087
+ constructor() {
6088
+ super(...arguments);
6089
+ this.name = 'marker';
6090
+ }
6016
6091
  _initContainer() {
6017
6092
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6018
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 }));
@@ -6280,47 +6355,84 @@
6280
6355
  }
6281
6356
  };
6282
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
+
6283
6384
  class MarkLine extends Marker {
6284
6385
  constructor(attributes) {
6285
6386
  super(vutils.merge({}, MarkLine.defaultAttributes, attributes));
6286
6387
  }
6287
6388
  setLabelPos() {
6288
- var _a, _b, _c, _d, _e;
6289
- const { points, label } = this.attribute;
6290
- const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'end';
6291
- const labelAngle = this._line.getEndAngle();
6292
- const labelOffsetX = (label === null || label === void 0 ? void 0 : label.refX) * Math.cos(labelAngle) + label.refY * Math.cos(labelAngle - Math.PI / 2);
6293
- const labelOffsetY = (label === null || label === void 0 ? void 0 : label.refX) * Math.sin(labelAngle) + label.refY * Math.sin(labelAngle - Math.PI / 2);
6294
- if (labelPosition.includes('start') || labelPosition.includes('Start')) {
6295
- (_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 = {
6296
6399
  x: points[0].x + labelOffsetX,
6297
6400
  y: points[0].y + labelOffsetY
6298
- });
6401
+ };
6299
6402
  }
6300
- else if (labelPosition.includes('middle') || labelPosition.includes('Middle')) {
6301
- (_c = this._label) === null || _c === void 0 ? void 0 : _c.setAttributes({
6403
+ else if (position.includes('middle') || position.includes('Middle')) {
6404
+ labelPoint = {
6302
6405
  x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
6303
6406
  y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
6304
- });
6407
+ };
6305
6408
  }
6306
6409
  else {
6307
- (_d = this._label) === null || _d === void 0 ? void 0 : _d.setAttributes({
6410
+ labelPoint = {
6308
6411
  x: points[points.length - 1].x + labelOffsetX,
6309
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
6310
6423
  });
6311
6424
  }
6312
- this._label.setAttributes({
6313
- angle: label.autoRotate && labelAngle + ((_e = label === null || label === void 0 ? void 0 : label.refAngle) !== null && _e !== void 0 ? _e : 0),
6314
- textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_LINE_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
6315
- });
6316
6425
  }
6317
6426
  initMarker(container) {
6318
- const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute;
6427
+ const { points, startSymbol, endSymbol, label, lineStyle, mainSegmentIndex, multiSegment } = this
6428
+ .attribute;
6319
6429
  const line = new Segment({
6320
6430
  points,
6321
6431
  startSymbol,
6322
6432
  endSymbol,
6323
- lineStyle
6433
+ lineStyle,
6434
+ mainSegmentIndex,
6435
+ multiSegment
6324
6436
  });
6325
6437
  line.name = 'mark-line-line';
6326
6438
  this._line = line;
@@ -6350,58 +6462,54 @@
6350
6462
  constructor(attributes) {
6351
6463
  super(vutils.merge({}, MarkArea.defaultAttributes, attributes));
6352
6464
  }
6353
- getLeftPos() {
6354
- return {
6355
- x: this._area.AABBBounds.x1,
6356
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6357
- };
6358
- }
6359
- getRightPos() {
6360
- return {
6361
- x: this._area.AABBBounds.x2,
6362
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6363
- };
6364
- }
6365
- getTopPos() {
6366
- return {
6367
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6368
- y: this._area.AABBBounds.y1
6369
- };
6370
- }
6371
- getBottomPos() {
6372
- return {
6373
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6374
- y: this._area.AABBBounds.y2
6375
- };
6376
- }
6377
- getMiddlePos() {
6378
- return {
6379
- x: (this._area.AABBBounds.x1 + this._area.AABBBounds.x2) / 2,
6380
- y: (this._area.AABBBounds.y1 + this._area.AABBBounds.y2) / 2
6381
- };
6382
- }
6383
- setLabelPos() {
6384
- var _a, _b, _c, _d, _e, _f, _g;
6385
- const { label } = this.attribute;
6386
- const labelPosition = (_a = label === null || label === void 0 ? void 0 : label.position) !== null && _a !== void 0 ? _a : 'middle';
6387
- if (labelPosition.includes('left') || labelPosition.includes('Left')) {
6388
- (_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
+ };
6389
6472
  }
6390
- else if (labelPosition.includes('right') || labelPosition.includes('Right')) {
6391
- (_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
+ };
6392
6478
  }
6393
- else if (labelPosition.includes('top') || labelPosition.includes('Top')) {
6394
- (_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
+ };
6395
6484
  }
6396
- else if (labelPosition.includes('bottom') || labelPosition.includes('Bottom')) {
6397
- (_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
+ };
6398
6490
  }
6399
- else {
6400
- (_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
+ }
6401
6512
  }
6402
- (_g = this._label) === null || _g === void 0 ? void 0 : _g.setAttributes({
6403
- textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
6404
- });
6405
6513
  }
6406
6514
  initMarker(container) {
6407
6515
  const { points, label, areaStyle } = this.attribute;
@@ -6432,31 +6540,43 @@
6432
6540
  setLabelPos() {
6433
6541
  }
6434
6542
  setItemAttributes(item, itemContent, itemPosition, itemType) {
6435
- var _a;
6543
+ var _a, _b;
6544
+ if (!item) {
6545
+ return;
6546
+ }
6436
6547
  const { autoRotate = true, refX = 0, refY = 0, refAngle = 0, textStyle, richTextStyle, imageStyle, position = exports.IMarkPointItemPosition.middle } = itemContent;
6437
6548
  const itemAngle = ((_a = this._line) === null || _a === void 0 ? void 0 : _a.getEndAngle()) || 0;
6438
6549
  const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);
6439
6550
  const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
6440
6551
  if (itemType === 'text') {
6441
- 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) }));
6442
6553
  }
6443
6554
  else if (itemType === 'richText') {
6444
- item === null || item === void 0 ? void 0 : item.setAttributes({
6555
+ item.setAttributes({
6445
6556
  dx: this.getItemDx(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dx) || 0),
6446
6557
  dy: this.getItemDy(item, position, richTextStyle) + ((richTextStyle === null || richTextStyle === void 0 ? void 0 : richTextStyle.dy) || 0)
6447
6558
  });
6448
6559
  }
6449
6560
  else if (itemType === 'image') {
6450
- item === null || item === void 0 ? void 0 : item.setAttributes({
6561
+ item.setAttributes({
6451
6562
  dx: this.getItemDx(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dx) || 0),
6452
6563
  dy: this.getItemDy(item, position, imageStyle) + ((imageStyle === null || imageStyle === void 0 ? void 0 : imageStyle.dy) || 0)
6453
6564
  });
6454
6565
  }
6455
- item === null || item === void 0 ? void 0 : item.setAttributes({
6566
+ item.setAttributes({
6456
6567
  x: itemPosition.x + (itemOffsetX || 0),
6457
6568
  y: itemPosition.y + (itemOffsetY || 0),
6458
6569
  angle: autoRotate && itemAngle + refAngle
6459
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
+ }
6460
6580
  }
6461
6581
  getItemDx(item, position, style) {
6462
6582
  var _a, _b;
@@ -6464,7 +6584,7 @@
6464
6584
  if (position.includes('inside')) {
6465
6585
  return -width;
6466
6586
  }
6467
- else if (position === 'insideTop') {
6587
+ if (position === 'insideTop') {
6468
6588
  return 0;
6469
6589
  }
6470
6590
  return 0;
@@ -6475,7 +6595,7 @@
6475
6595
  if (position.includes('top') || position.includes('Top')) {
6476
6596
  return -height;
6477
6597
  }
6478
- else if (position.includes('middle') || position.includes('Middle')) {
6598
+ if (position.includes('middle') || position.includes('Middle')) {
6479
6599
  return -height / 2;
6480
6600
  }
6481
6601
  return 0;
@@ -6671,7 +6791,8 @@
6671
6791
  const changeEvent = new vrender.CustomEvent('toPrev', {
6672
6792
  current: this._current,
6673
6793
  total: this._total,
6674
- direction: 'pre'
6794
+ direction: 'pre',
6795
+ event: e
6675
6796
  });
6676
6797
  changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
6677
6798
  this.dispatchEvent(changeEvent);
@@ -6690,7 +6811,8 @@
6690
6811
  const changeEvent = new vrender.CustomEvent('toNext', {
6691
6812
  current: this._current,
6692
6813
  total: this._total,
6693
- direction: 'next'
6814
+ direction: 'next',
6815
+ event: e
6694
6816
  });
6695
6817
  changeEvent.manager = (_b = this.stage) === null || _b === void 0 ? void 0 : _b.eventSystem.manager;
6696
6818
  this.dispatchEvent(changeEvent);
@@ -6916,16 +7038,16 @@
6916
7038
  const legendItem = target.delegate;
6917
7039
  const selected = legendItem.hasState(exports.LegendStateValue.selected);
6918
7040
  if (selected) {
6919
- this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover);
7041
+ this._setLegendItemState(legendItem, exports.LegendStateValue.selectedHover, e);
6920
7042
  }
6921
7043
  else {
6922
- this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover);
7044
+ this._setLegendItemState(legendItem, exports.LegendStateValue.unSelectedHover, e);
6923
7045
  }
6924
7046
  const focusButton = legendItem.getChildren()[0].find(node => node.name === exports.LEGEND_ELEMENT_NAME.focus, false);
6925
7047
  if (focusButton) {
6926
7048
  focusButton.setAttribute('visible', true);
6927
7049
  }
6928
- this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem);
7050
+ this._dispatchEvent(exports.LegendEvent.legendItemHover, legendItem, e);
6929
7051
  }
6930
7052
  };
6931
7053
  this._onUnHover = (e) => {
@@ -6956,9 +7078,9 @@
6956
7078
  focusButton.setAttribute('visible', false);
6957
7079
  }
6958
7080
  if (attributeUpdate) {
6959
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7081
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
6960
7082
  }
6961
- this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem);
7083
+ this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem, e);
6962
7084
  }
6963
7085
  };
6964
7086
  this._onClick = (e) => {
@@ -6971,25 +7093,17 @@
6971
7093
  legendItem.toggleState(exports.LegendStateValue.focus);
6972
7094
  if (isFocusSelected) {
6973
7095
  (_b = this._itemsContainer) === null || _b === void 0 ? void 0 : _b.getChildren().forEach(item => {
6974
- this._removeLegendItemState(item, [
6975
- exports.LegendStateValue.unSelected,
6976
- exports.LegendStateValue.unSelectedHover,
6977
- exports.LegendStateValue.focus
6978
- ]);
6979
- 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);
6980
7098
  });
6981
7099
  }
6982
7100
  else {
6983
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
6984
- 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);
6985
7103
  (_c = this._itemsContainer) === null || _c === void 0 ? void 0 : _c.getChildren().forEach(item => {
6986
7104
  if (legendItem !== item) {
6987
- this._removeLegendItemState(item, [
6988
- exports.LegendStateValue.selected,
6989
- exports.LegendStateValue.selectedHover,
6990
- exports.LegendStateValue.focus
6991
- ]);
6992
- 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);
6993
7107
  }
6994
7108
  });
6995
7109
  }
@@ -7003,33 +7117,30 @@
7003
7117
  const currentSelectedItems = this._getSelectedLegends();
7004
7118
  if (selectMode === 'multiple') {
7005
7119
  if (allowAllCanceled === false && isSelected && currentSelectedItems.length === 1) {
7006
- this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
7120
+ this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
7007
7121
  return;
7008
7122
  }
7009
7123
  if (isSelected) {
7010
- this._removeLegendItemState(legendItem, [exports.LegendStateValue.selected, exports.LegendStateValue.selectedHover]);
7011
- 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);
7012
7126
  }
7013
7127
  else {
7014
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
7015
- 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);
7016
7130
  }
7017
7131
  }
7018
7132
  else {
7019
- this._setLegendItemState(legendItem, exports.LegendStateValue.selected);
7020
- 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);
7021
7135
  (_e = this._itemsContainer) === null || _e === void 0 ? void 0 : _e.getChildren().forEach(item => {
7022
7136
  if (legendItem !== item) {
7023
- this._removeLegendItemState(item, [
7024
- exports.LegendStateValue.selected,
7025
- exports.LegendStateValue.selectedHover
7026
- ]);
7027
- 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);
7028
7139
  }
7029
7140
  });
7030
7141
  }
7031
7142
  }
7032
- this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem);
7143
+ this._dispatchEvent(exports.LegendEvent.legendItemClick, legendItem, e);
7033
7144
  }
7034
7145
  };
7035
7146
  }
@@ -7400,7 +7511,8 @@
7400
7511
  this._pager.addEventListener('toNext', onPaging);
7401
7512
  return true;
7402
7513
  }
7403
- _setLegendItemState(legendItem, stateName, keepCurrentStates = true) {
7514
+ _setLegendItemState(legendItem, stateName, e) {
7515
+ const keepCurrentStates = true;
7404
7516
  let attributeUpdate = false;
7405
7517
  if (!legendItem.hasState(stateName)) {
7406
7518
  attributeUpdate = true;
@@ -7418,10 +7530,10 @@
7418
7530
  }
7419
7531
  });
7420
7532
  if (attributeUpdate) {
7421
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7533
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
7422
7534
  }
7423
7535
  }
7424
- _removeLegendItemState(legendItem, stateNames) {
7536
+ _removeLegendItemState(legendItem, stateNames, e) {
7425
7537
  let attributeUpdate = false;
7426
7538
  stateNames.forEach(name => {
7427
7539
  if (!attributeUpdate && legendItem.hasState(name)) {
@@ -7443,7 +7555,7 @@
7443
7555
  }
7444
7556
  });
7445
7557
  if (attributeUpdate) {
7446
- this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7558
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem, e);
7447
7559
  }
7448
7560
  }
7449
7561
  _getSelectedLegends() {
@@ -7462,7 +7574,7 @@
7462
7574
  shape.delegate = delegateShape;
7463
7575
  shape.states = vutils.merge({}, DEFAULT_STATES, states);
7464
7576
  }
7465
- _dispatchEvent(eventName, legendItem) {
7577
+ _dispatchEvent(eventName, legendItem, event) {
7466
7578
  var _a;
7467
7579
  const currentSelectedItems = this._getSelectedLegends();
7468
7580
  currentSelectedItems.sort((pre, next) => pre.index - next.index);
@@ -7472,7 +7584,8 @@
7472
7584
  data: legendItem.data,
7473
7585
  selected: legendItem.hasState(exports.LegendStateValue.selected),
7474
7586
  currentSelectedItems,
7475
- currentSelected
7587
+ currentSelected,
7588
+ event
7476
7589
  });
7477
7590
  changeEvent.manager = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventSystem.manager;
7478
7591
  this.dispatchEvent(changeEvent);
@@ -10359,7 +10472,7 @@
10359
10472
  return new Tag(params ? params.attribute : {});
10360
10473
  }
10361
10474
 
10362
- const version = "0.15.0-alpha.20";
10475
+ const version = "0.15.0-alpha.21";
10363
10476
 
10364
10477
  exports.AbstractComponent = AbstractComponent;
10365
10478
  exports.ArcInfo = ArcInfo;