@visactor/vrender-components 0.15.0-alpha.16 → 0.15.0-alpha.18

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 (139) hide show
  1. package/cjs/axis/animate/group-transition.d.ts +2 -1
  2. package/cjs/axis/animate/group-transition.js +3 -3
  3. package/cjs/axis/animate/group-transition.js.map +1 -1
  4. package/cjs/axis/base.d.ts +5 -8
  5. package/cjs/axis/base.js +16 -32
  6. package/cjs/axis/base.js.map +1 -1
  7. package/cjs/axis/circle.d.ts +3 -23
  8. package/cjs/axis/circle.js +3 -84
  9. package/cjs/axis/circle.js.map +1 -1
  10. package/cjs/axis/config.d.ts +0 -17
  11. package/cjs/axis/config.js +0 -17
  12. package/cjs/axis/config.js.map +1 -1
  13. package/cjs/axis/grid/base.d.ts +24 -0
  14. package/cjs/axis/{grid.js → grid/base.js} +67 -20
  15. package/cjs/axis/grid/base.js.map +1 -0
  16. package/cjs/axis/grid/circle.d.ts +9 -0
  17. package/cjs/axis/grid/circle.js +92 -0
  18. package/cjs/axis/grid/circle.js.map +1 -0
  19. package/cjs/axis/grid/index.d.ts +3 -0
  20. package/cjs/axis/grid/index.js +22 -0
  21. package/cjs/axis/grid/index.js.map +1 -0
  22. package/cjs/axis/grid/line.d.ts +10 -0
  23. package/cjs/axis/grid/line.js +103 -0
  24. package/cjs/axis/grid/line.js.map +1 -0
  25. package/cjs/axis/grid/type.d.ts +63 -0
  26. package/cjs/axis/grid/type.js +6 -0
  27. package/cjs/axis/grid/type.js.map +1 -0
  28. package/cjs/axis/index.d.ts +0 -1
  29. package/cjs/axis/index.js +3 -3
  30. package/cjs/axis/index.js.map +1 -1
  31. package/cjs/axis/line.d.ts +3 -24
  32. package/cjs/axis/line.js +16 -117
  33. package/cjs/axis/line.js.map +1 -1
  34. package/cjs/axis/mixin/circle.d.ts +17 -0
  35. package/cjs/axis/mixin/circle.js +30 -0
  36. package/cjs/axis/mixin/circle.js.map +1 -0
  37. package/cjs/axis/mixin/line.d.ts +14 -0
  38. package/cjs/axis/mixin/line.js +32 -0
  39. package/cjs/axis/mixin/line.js.map +1 -0
  40. package/cjs/axis/type.d.ts +0 -55
  41. package/cjs/axis/type.js.map +1 -1
  42. package/cjs/core/base.d.ts +2 -1
  43. package/cjs/core/base.js +4 -2
  44. package/cjs/core/base.js.map +1 -1
  45. package/cjs/core/type.js +2 -1
  46. package/cjs/crosshair/base.js +1 -2
  47. package/cjs/index.d.ts +3 -1
  48. package/cjs/index.js +9 -8
  49. package/cjs/index.js.map +1 -1
  50. package/cjs/indicator/type.js +2 -1
  51. package/cjs/jsx/component-type.d.ts +4 -0
  52. package/cjs/jsx/component-type.js +13 -0
  53. package/cjs/jsx/component-type.js.map +1 -0
  54. package/cjs/jsx/index.d.ts +1 -0
  55. package/cjs/jsx/index.js +21 -0
  56. package/cjs/jsx/index.js.map +1 -0
  57. package/cjs/link-path/index.js +1 -2
  58. package/cjs/link-path/link-path.js +2 -1
  59. package/cjs/marker/point.js +1 -1
  60. package/cjs/poptip/register.d.ts +1 -1
  61. package/cjs/poptip/register.js +8 -6
  62. package/cjs/poptip/register.js.map +1 -1
  63. package/cjs/util/matrix.d.ts +1 -1
  64. package/cjs/util/matrix.js.map +1 -1
  65. package/cjs/util/text.js +3 -3
  66. package/cjs/util/text.js.map +1 -1
  67. package/dist/index.js +638 -588
  68. package/dist/index.min.js +1 -1
  69. package/es/axis/animate/group-transition.d.ts +2 -1
  70. package/es/axis/animate/group-transition.js +3 -3
  71. package/es/axis/animate/group-transition.js.map +1 -1
  72. package/es/axis/base.d.ts +5 -8
  73. package/es/axis/base.js +15 -33
  74. package/es/axis/base.js.map +1 -1
  75. package/es/axis/circle.d.ts +3 -23
  76. package/es/axis/circle.js +4 -85
  77. package/es/axis/circle.js.map +1 -1
  78. package/es/axis/config.d.ts +0 -17
  79. package/es/axis/config.js +0 -17
  80. package/es/axis/config.js.map +1 -1
  81. package/es/axis/grid/base.d.ts +24 -0
  82. package/es/axis/{grid.js → grid/base.js} +69 -21
  83. package/es/axis/grid/base.js.map +1 -0
  84. package/es/axis/grid/circle.d.ts +9 -0
  85. package/es/axis/grid/circle.js +92 -0
  86. package/es/axis/grid/circle.js.map +1 -0
  87. package/es/axis/grid/index.d.ts +3 -0
  88. package/es/axis/grid/index.js +6 -0
  89. package/es/axis/grid/index.js.map +1 -0
  90. package/es/axis/grid/line.d.ts +10 -0
  91. package/es/axis/grid/line.js +102 -0
  92. package/es/axis/grid/line.js.map +1 -0
  93. package/es/axis/grid/type.d.ts +63 -0
  94. package/es/axis/grid/type.js +2 -0
  95. package/es/axis/grid/type.js.map +1 -0
  96. package/es/axis/index.d.ts +0 -1
  97. package/es/axis/index.js +0 -2
  98. package/es/axis/index.js.map +1 -1
  99. package/es/axis/line.d.ts +3 -24
  100. package/es/axis/line.js +8 -109
  101. package/es/axis/line.js.map +1 -1
  102. package/es/axis/mixin/circle.d.ts +17 -0
  103. package/es/axis/mixin/circle.js +25 -0
  104. package/es/axis/mixin/circle.js.map +1 -0
  105. package/es/axis/mixin/line.d.ts +14 -0
  106. package/es/axis/mixin/line.js +23 -0
  107. package/es/axis/mixin/line.js.map +1 -0
  108. package/es/axis/type.d.ts +0 -55
  109. package/es/axis/type.js.map +1 -1
  110. package/es/core/base.d.ts +2 -1
  111. package/es/core/base.js +3 -3
  112. package/es/core/base.js.map +1 -1
  113. package/es/core/type.js +2 -1
  114. package/es/crosshair/base.js +1 -2
  115. package/es/index.d.ts +3 -1
  116. package/es/index.js +5 -1
  117. package/es/index.js.map +1 -1
  118. package/es/indicator/type.js +2 -1
  119. package/es/jsx/component-type.d.ts +4 -0
  120. package/es/jsx/component-type.js +5 -0
  121. package/es/jsx/component-type.js.map +1 -0
  122. package/es/jsx/index.d.ts +1 -0
  123. package/es/jsx/index.js +2 -0
  124. package/es/jsx/index.js.map +1 -0
  125. package/es/link-path/index.js +1 -2
  126. package/es/link-path/link-path.js +2 -1
  127. package/es/marker/point.js +1 -1
  128. package/es/poptip/register.d.ts +1 -1
  129. package/es/poptip/register.js +7 -6
  130. package/es/poptip/register.js.map +1 -1
  131. package/es/util/matrix.d.ts +1 -1
  132. package/es/util/matrix.js.map +1 -1
  133. package/es/util/text.js +3 -3
  134. package/es/util/text.js.map +1 -1
  135. package/package.json +4 -4
  136. package/cjs/axis/grid.d.ts +0 -9
  137. package/cjs/axis/grid.js.map +0 -1
  138. package/es/axis/grid.d.ts +0 -9
  139. package/es/axis/grid.js.map +0 -1
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@
36
36
  });
37
37
  }
38
38
  setAttribute(key, value, forceUpdateTag) {
39
- if (vutils.isPlainObject(this.attribute[key])) {
39
+ if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(value)) {
40
40
  vutils.merge(this.attribute[key], value);
41
41
  }
42
42
  else {
@@ -77,7 +77,7 @@
77
77
  }
78
78
  for (let i = 0; i < keys.length; i++) {
79
79
  const key = keys[i];
80
- if (vutils.isPlainObject(this.attribute[key])) {
80
+ if (vutils.isPlainObject(this.attribute[key]) && !vutils.isFunction(this.attribute[key]) && !vutils.isFunction(params[key])) {
81
81
  vutils.merge(this.attribute[key], params[key]);
82
82
  }
83
83
  else {
@@ -575,16 +575,16 @@
575
575
  }, getTextBounds: useNaiveCanvas ? undefined : vrender.getTextBounds, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
576
576
  };
577
577
  function measureTextSize(text, textSpec) {
578
- var _a, _b;
578
+ var _a;
579
579
  if (!text) {
580
580
  return { width: 0, height: 0 };
581
581
  }
582
582
  const bounds = vrender.getTextBounds({
583
583
  text,
584
- fontFamily: (_a = textSpec.fontFamily) !== null && _a !== void 0 ? _a : '',
584
+ fontFamily: textSpec.fontFamily,
585
585
  fontSize: textSpec.fontSize || 12,
586
586
  fontWeight: textSpec.fontWeight,
587
- textAlign: (_b = textSpec.textAlign) !== null && _b !== void 0 ? _b : 'center',
587
+ textAlign: (_a = textSpec.textAlign) !== null && _a !== void 0 ? _a : 'center',
588
588
  textBaseline: textSpec.textBaseline,
589
589
  ellipsis: !!textSpec.ellipsis,
590
590
  maxLineWidth: textSpec.maxLineWidth || Infinity,
@@ -1103,16 +1103,21 @@
1103
1103
  injectable()
1104
1104
  ], PopTipForClipedTextPlugin);
1105
1105
 
1106
- const popTipModule = new ContainerModule(bind => {
1107
- bind(PopTipRenderContribution).toSelf().inSingletonScope();
1108
- bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
1109
- bind(PopTipPlugin).toSelf().inSingletonScope();
1110
- bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
1111
- bind(PopTipForClipedTextPlugin).toSelf().inSingletonScope();
1112
- bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
1106
+ const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {
1107
+ if (!isBound(PopTipRenderContribution)) {
1108
+ bind(PopTipRenderContribution).toSelf().inSingletonScope();
1109
+ bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
1110
+ }
1111
+ if (!isBound(PopTipPlugin)) {
1112
+ bind(PopTipPlugin).toSelf();
1113
+ bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
1114
+ }
1115
+ if (!isBound(PopTipForClipedTextPlugin)) {
1116
+ bind(PopTipForClipedTextPlugin).toSelf();
1117
+ bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
1118
+ }
1113
1119
  });
1114
- function loadPoptip(defaultPoptipTheme) {
1115
- vutils.merge(theme.poptip, defaultPoptipTheme);
1120
+ function loadPoptip() {
1116
1121
  vrender.container.load(popTipModule);
1117
1122
  }
1118
1123
  function setPoptipTheme(defaultPoptipTheme) {
@@ -3198,156 +3203,6 @@
3198
3203
  pickable: false
3199
3204
  };
3200
3205
 
3201
- function getLinePath(points, closed) {
3202
- let path = '';
3203
- if (points.length === 0) {
3204
- return path;
3205
- }
3206
- points.forEach((point, index) => {
3207
- if (index === 0) {
3208
- path = `M${point.x},${point.y}`;
3209
- }
3210
- else {
3211
- path += `L${point.x},${point.y}`;
3212
- }
3213
- });
3214
- if (closed) {
3215
- path += 'Z';
3216
- }
3217
- return path;
3218
- }
3219
- function getArcPath(center, points, reverse, closed) {
3220
- let path = '';
3221
- if (!center || points.length === 0) {
3222
- return path;
3223
- }
3224
- const firstPoint = points[0];
3225
- const radius = vutils.PointService.distancePP(center, firstPoint);
3226
- const sweepFlag = reverse ? 0 : 1;
3227
- if (closed) {
3228
- path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y + radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;
3229
- }
3230
- else {
3231
- points.forEach((point, index) => {
3232
- if (index === 0) {
3233
- path = `M${point.x},${point.y}`;
3234
- }
3235
- else {
3236
- path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
3237
- }
3238
- });
3239
- }
3240
- return path;
3241
- }
3242
- function getRegionPath(from, to, attribute) {
3243
- const { type, closed } = attribute;
3244
- const reversePoints = to.slice(0).reverse();
3245
- let regionPath = '';
3246
- let nextPath = '';
3247
- if (type === 'line' && attribute.smoothLink && attribute.center) {
3248
- const fromStart = from[0];
3249
- const toEnd = reversePoints[0];
3250
- const center = attribute.center;
3251
- regionPath = getLinePath(from, !!closed);
3252
- nextPath = getLinePath(reversePoints, !!closed);
3253
- const toEndRadius = vutils.PointService.distancePP(toEnd, center);
3254
- const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
3255
- regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
3256
- nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
3257
- }
3258
- else if (type === 'circle') {
3259
- const { center } = attribute;
3260
- regionPath = getArcPath(center, from, false, !!closed);
3261
- nextPath = getArcPath(center, reversePoints, true, !!closed);
3262
- }
3263
- else if (type === 'line' || type === 'polygon') {
3264
- regionPath = getLinePath(from, !!closed);
3265
- nextPath = getLinePath(reversePoints, !!closed);
3266
- }
3267
- if (closed) {
3268
- regionPath += nextPath;
3269
- }
3270
- else {
3271
- nextPath = 'L' + nextPath.substring(1);
3272
- regionPath += nextPath;
3273
- regionPath += 'Z';
3274
- }
3275
- return regionPath;
3276
- }
3277
- class Grid extends AbstractComponent {
3278
- constructor(attributes) {
3279
- super(vutils.merge({}, Grid.defaultAttributes, attributes));
3280
- this.name = 'grid';
3281
- }
3282
- render() {
3283
- this.removeAllChild();
3284
- const { type, items, style, closed, alternateColor, depth = 0 } = this.attribute;
3285
- if (vutils.isEmpty(items)) {
3286
- return;
3287
- }
3288
- items.forEach((item, index) => {
3289
- const { id, points } = item;
3290
- let path = '';
3291
- if (type === 'line' || type === 'polygon') {
3292
- path = getLinePath(points, !!closed);
3293
- }
3294
- else if (type === 'circle') {
3295
- const { center } = this.attribute;
3296
- path = getArcPath(center, points, false, !!closed);
3297
- }
3298
- const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, Grid.defaultAttributes.style, style(item, index)) : style)));
3299
- shape.name = `${this.name}-line`;
3300
- shape.id = this._getNodeId(`path-${id}`);
3301
- this.add(shape);
3302
- });
3303
- if (depth && type === 'line') {
3304
- items.forEach((item, index) => {
3305
- const { id, points } = item;
3306
- const nextPoints = [];
3307
- nextPoints.push(points[0]);
3308
- const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
3309
- const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
3310
- const ratio = depth / dirLen;
3311
- nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
3312
- const path = getLinePath(nextPoints, !!closed);
3313
- const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
3314
- const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
3315
- const shape = vrender.createPath(Object.assign({ path, z: 0, alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * vutils.pi) / 2 : 0, beta: deltaX < deltaY ? -vutils.pi / 2 : 0, anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y] }, (vutils.isFunction(style) ? vutils.merge({}, Grid.defaultAttributes.style, style(item, index)) : style)));
3316
- shape.name = `${this.name}-line`;
3317
- shape.id = this._getNodeId(`path-${id}`);
3318
- this.add(shape);
3319
- });
3320
- }
3321
- if (items.length > 1 && alternateColor) {
3322
- const colors = vutils.isArray(alternateColor)
3323
- ? alternateColor
3324
- : [alternateColor, 'transparent'];
3325
- const getColor = (index) => colors[index % colors.length];
3326
- for (let index = 0; index < items.length - 1; index++) {
3327
- const [prev, curr] = [items[index].points, items[index + 1].points];
3328
- const path = getRegionPath(prev, curr, this.attribute);
3329
- const shape = vrender.createPath({
3330
- path,
3331
- fill: getColor(index)
3332
- });
3333
- shape.name = `${this.name}-region`;
3334
- shape.id = this._getNodeId(`region-${index}`);
3335
- this.add(shape);
3336
- }
3337
- }
3338
- }
3339
- _getNodeId(id) {
3340
- return `${this.id}-${id}`;
3341
- }
3342
- }
3343
- Grid.defaultAttributes = {
3344
- style: {
3345
- lineWidth: 1,
3346
- stroke: '#416180'
3347
- },
3348
- zIndex: 0
3349
- };
3350
-
3351
3206
  class Segment extends AbstractComponent {
3352
3207
  constructor(attributes) {
3353
3208
  super(vutils.merge({}, Segment.defaultAttributes, attributes));
@@ -3565,23 +3420,6 @@
3565
3420
  stroke: '#000',
3566
3421
  strokeOpacity: 1
3567
3422
  }
3568
- },
3569
- grid: {
3570
- style: {
3571
- lineWidth: 1,
3572
- stroke: '#999',
3573
- strokeOpacity: 1,
3574
- lineDash: [4, 4]
3575
- }
3576
- },
3577
- subGrid: {
3578
- visible: false,
3579
- style: {
3580
- lineWidth: 1,
3581
- stroke: '#999',
3582
- strokeOpacity: 1,
3583
- lineDash: [4, 4]
3584
- }
3585
3423
  }
3586
3424
  };
3587
3425
 
@@ -3678,7 +3516,7 @@
3678
3516
  }
3679
3517
  }
3680
3518
  _renderInner(container) {
3681
- const { title, label, tick, line, grid, items } = this.attribute;
3519
+ const { title, label, tick, line, items } = this.attribute;
3682
3520
  const axisContainer = vrender.createGroup({ x: 0, y: 0, zIndex: 1 });
3683
3521
  axisContainer.name = exports.AXIS_ELEMENT_NAME.axisContainer;
3684
3522
  axisContainer.id = this._getNodeId('container');
@@ -3707,9 +3545,6 @@
3707
3545
  this.afterLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
3708
3546
  });
3709
3547
  }
3710
- if (grid === null || grid === void 0 ? void 0 : grid.visible) {
3711
- this.renderGrid(container);
3712
- }
3713
3548
  }
3714
3549
  if (title === null || title === void 0 ? void 0 : title.visible) {
3715
3550
  this.renderTitle(axisContainer);
@@ -3826,13 +3661,6 @@
3826
3661
  axisTitle.id = this._getNodeId('title');
3827
3662
  container.add(axisTitle);
3828
3663
  }
3829
- renderGrid(container) {
3830
- const { visible } = this.attribute.subGrid || {};
3831
- if (visible) {
3832
- this._renderGridByType('subGrid', container);
3833
- }
3834
- this._renderGridByType('grid', container);
3835
- }
3836
3664
  getVerticalCoord(point, offset, inside) {
3837
3665
  const vector = this.getVerticalVector(offset, inside, point);
3838
3666
  return {
@@ -4003,13 +3831,6 @@
4003
3831
  });
4004
3832
  return data;
4005
3833
  }
4006
- _renderGridByType(type, container) {
4007
- const gridAttrs = this.getGridAttribute(type);
4008
- const gridGroup = new Grid(Object.assign(Object.assign({ pickable: false }, gridAttrs), { zIndex: 0 }));
4009
- gridGroup.name = type === 'subGrid' ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
4010
- gridGroup.id = this._getNodeId(type);
4011
- container.add(gridGroup);
4012
- }
4013
3834
  }
4014
3835
 
4015
3836
  const methods = {
@@ -4308,15 +4129,31 @@
4308
4129
  }
4309
4130
  }
4310
4131
 
4311
- function getCirclePoints(center, count, radius, startAngle, endAngle) {
4312
- const points = [];
4313
- const range = endAngle - startAngle;
4314
- for (let i = 0; i < count; i++) {
4315
- const angle = startAngle + (i * range) / count;
4316
- points.push(vutils.polarToCartesian(center, radius, angle));
4132
+ class LineAxisMixin {
4133
+ isInValidValue(value) {
4134
+ return value < 0 || value > 1;
4135
+ }
4136
+ getTickCoord(tickValue) {
4137
+ const { start } = this.attribute;
4138
+ const axisVector = this.getRelativeVector();
4139
+ return {
4140
+ x: start.x + axisVector[0] * tickValue,
4141
+ y: start.y + axisVector[1] * tickValue
4142
+ };
4143
+ }
4144
+ getRelativeVector(point) {
4145
+ const { start, end } = this.attribute;
4146
+ return [end.x - start.x, end.y - start.y];
4147
+ }
4148
+ getVerticalVector(offset, inside = false, point) {
4149
+ const { verticalFactor = 1 } = this.attribute;
4150
+ const axisVector = this.getRelativeVector();
4151
+ const normalizedAxisVector = normalize(axisVector);
4152
+ const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
4153
+ return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
4317
4154
  }
4318
- return points;
4319
4155
  }
4156
+
4320
4157
  class LineAxis extends AxisBase {
4321
4158
  constructor(attributes, mode) {
4322
4159
  super(vutils.merge({}, LineAxis.defaultAttributes, attributes), mode);
@@ -4354,28 +4191,6 @@
4354
4191
  axisLineGroup.id = this._getNodeId('line');
4355
4192
  container.add(axisLineGroup);
4356
4193
  }
4357
- isInValidValue(value) {
4358
- return value < 0 || value > 1;
4359
- }
4360
- getTickCoord(tickValue) {
4361
- const { start } = this.attribute;
4362
- const axisVector = this.getRelativeVector();
4363
- return {
4364
- x: start.x + axisVector[0] * tickValue,
4365
- y: start.y + axisVector[1] * tickValue
4366
- };
4367
- }
4368
- getRelativeVector() {
4369
- const { start, end } = this.attribute;
4370
- return [end.x - start.x, end.y - start.y];
4371
- }
4372
- getVerticalVector(offset, inside = false) {
4373
- const { verticalFactor = 1 } = this.attribute;
4374
- const axisVector = this.getRelativeVector();
4375
- const normalizedAxisVector = normalize(axisVector);
4376
- const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
4377
- return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
4378
- }
4379
4194
  getTitleAttribute() {
4380
4195
  var _a, _b, _c, _d, _e, _f, _g, _h;
4381
4196
  const _j = this.attribute.title, { position = 'middle', space = 4, textStyle = {}, autoRotate = true, shape, background, state } = _j, restAttrs = __rest(_j, ["position", "space", "textStyle", "autoRotate", "shape", "background", "state"]);
@@ -4460,7 +4275,7 @@
4460
4275
  }
4461
4276
  const offset = tickLength + labelLength + space;
4462
4277
  const titlePoint = this.getVerticalCoord(point, offset, false);
4463
- const vector = this.getVerticalVector(offset, false);
4278
+ const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });
4464
4279
  let { angle } = restAttrs;
4465
4280
  let textAlign;
4466
4281
  if (position === 'start') {
@@ -4508,129 +4323,35 @@
4508
4323
  }
4509
4324
  return attrs;
4510
4325
  }
4511
- _getGridPoint(gridType, point) {
4512
- let gridPoints;
4513
- if (gridType === 'line') {
4514
- const { length } = this.attribute.grid;
4515
- const endPoint = this.getVerticalCoord(point, length, true);
4516
- gridPoints = [point, endPoint];
4326
+ getTextBaseline(vector, inside) {
4327
+ let base = 'middle';
4328
+ const { verticalFactor = 1 } = this.attribute;
4329
+ const factor = (inside ? 1 : -1) * verticalFactor;
4330
+ if (vutils.isNumberClose(vector[1], 0)) {
4331
+ if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
4332
+ base = factor === 1 ? 'bottom' : 'top';
4333
+ }
4334
+ else {
4335
+ base = 'middle';
4336
+ }
4517
4337
  }
4518
- else if (gridType === 'circle' || gridType === 'polygon') {
4519
- const { center, sides, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute.grid;
4520
- const distance = vutils.PointService.distancePP(center, point);
4521
- gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
4338
+ else if (vector[1] > 0) {
4339
+ base = 'top';
4522
4340
  }
4523
- return gridPoints;
4341
+ else if (vector[1] < 0) {
4342
+ base = 'bottom';
4343
+ }
4344
+ return base;
4524
4345
  }
4525
- getGridAttribute(type) {
4526
- const { type: gridType, alignWithLabel = true } = this.attribute.grid;
4527
- let tickSegment = 1;
4528
- const count = this.data.length;
4529
- if (count >= 2) {
4530
- tickSegment = this.data[1].value - this.data[0].value;
4531
- }
4532
- let gridAttribute;
4533
- let items = [];
4534
- if (type === 'grid') {
4535
- gridAttribute = this.attribute.grid;
4536
- const gridItems = [];
4537
- this.data.forEach(item => {
4538
- let { point } = item;
4539
- if (!alignWithLabel) {
4540
- const value = item.value - tickSegment / 2;
4541
- if (this.isInValidValue(value)) {
4542
- return;
4543
- }
4544
- point = this.getTickCoord(value);
4545
- }
4546
- gridItems.push({
4547
- id: item.label,
4548
- datum: item,
4549
- points: this._getGridPoint(gridType, point)
4550
- });
4551
- });
4552
- items = gridItems;
4553
- }
4554
- else {
4555
- gridAttribute = vutils.merge({}, this.attribute.grid, this.attribute.subGrid);
4556
- const subGridItems = [];
4557
- const { count: subCount = 4 } = this.attribute.subTick || {};
4558
- const tickLineCount = this.data.length;
4559
- if (tickLineCount >= 2) {
4560
- const points = [];
4561
- this.data.forEach((item) => {
4562
- let tickValue = item.value;
4563
- if (!alignWithLabel) {
4564
- const value = item.value - tickSegment / 2;
4565
- if (this.isInValidValue(value)) {
4566
- return;
4567
- }
4568
- tickValue = value;
4569
- }
4570
- points.push({
4571
- value: tickValue
4572
- });
4573
- });
4574
- for (let i = 0; i < points.length - 1; i++) {
4575
- const pre = points[i];
4576
- const next = points[i + 1];
4577
- subGridItems.push({
4578
- id: `sub-${i}-0`,
4579
- points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
4580
- datum: {}
4581
- });
4582
- for (let j = 0; j < subCount; j++) {
4583
- const percent = (j + 1) / (subCount + 1);
4584
- const value = (1 - percent) * pre.value + percent * next.value;
4585
- const point = this.getTickCoord(value);
4586
- subGridItems.push({
4587
- id: `sub-${i}-${j + 1}`,
4588
- points: this._getGridPoint(gridType, point),
4589
- datum: {}
4590
- });
4591
- }
4592
- if (i === points.length - 2) {
4593
- subGridItems.push({
4594
- id: `sub-${i}-${subCount + 1}`,
4595
- points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
4596
- datum: {}
4597
- });
4598
- }
4599
- }
4600
- items = subGridItems;
4601
- }
4602
- }
4603
- return Object.assign(Object.assign({}, gridAttribute), { items });
4604
- }
4605
- getTextBaseline(vector, inside) {
4606
- let base = 'middle';
4607
- const { verticalFactor = 1 } = this.attribute;
4608
- const factor = (inside ? 1 : -1) * verticalFactor;
4609
- if (vutils.isNumberClose(vector[1], 0)) {
4610
- if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
4611
- base = factor === 1 ? 'bottom' : 'top';
4612
- }
4613
- else {
4614
- base = 'middle';
4615
- }
4616
- }
4617
- else if (vector[1] > 0) {
4618
- base = 'top';
4619
- }
4620
- else if (vector[1] < 0) {
4621
- base = 'bottom';
4622
- }
4623
- return base;
4624
- }
4625
- getLabelAlign(vector, inside, angle) {
4626
- const orient = this.attribute.orient;
4627
- if (vutils.isValidNumber(angle)) {
4628
- if (orient === 'top' || orient === 'bottom') {
4629
- return getXAxisLabelAlign(orient, angle);
4630
- }
4631
- if (orient === 'left' || orient === 'right') {
4632
- return getYAxisLabelAlign(orient, angle);
4633
- }
4346
+ getLabelAlign(vector, inside, angle) {
4347
+ const orient = this.attribute.orient;
4348
+ if (vutils.isValidNumber(angle)) {
4349
+ if (orient === 'top' || orient === 'bottom') {
4350
+ return getXAxisLabelAlign(orient, angle);
4351
+ }
4352
+ if (orient === 'left' || orient === 'right') {
4353
+ return getYAxisLabelAlign(orient, angle);
4354
+ }
4634
4355
  }
4635
4356
  return {
4636
4357
  textAlign: this.getTextAlign(vector),
@@ -4835,29 +4556,9 @@
4835
4556
  }
4836
4557
  }
4837
4558
  LineAxis.defaultAttributes = DEFAULT_AXIS_THEME;
4559
+ vutils.mixin(LineAxis, LineAxisMixin);
4838
4560
 
4839
- class CircleAxis extends AxisBase {
4840
- constructor(attributes) {
4841
- super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
4842
- }
4843
- renderLine(container) {
4844
- const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
4845
- let arcRadius = radius;
4846
- let arcInnerRadius = innerRadius;
4847
- if (inside && innerRadius > 0) {
4848
- arcRadius = innerRadius;
4849
- arcInnerRadius = 0;
4850
- }
4851
- const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
4852
- endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
4853
- const axisLine = vrender.createCircle(arcAttrs);
4854
- axisLine.name = exports.AXIS_ELEMENT_NAME.line;
4855
- axisLine.id = this._getNodeId('line');
4856
- if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
4857
- axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
4858
- }
4859
- container.add(axisLine);
4860
- }
4561
+ class CircleAxisMixin {
4861
4562
  isInValidValue(value) {
4862
4563
  const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
4863
4564
  if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
@@ -4880,6 +4581,30 @@
4880
4581
  const { center } = this.attribute;
4881
4582
  return [point.y - center.y, -1 * (point.x - center.x)];
4882
4583
  }
4584
+ }
4585
+
4586
+ class CircleAxis extends AxisBase {
4587
+ constructor(attributes) {
4588
+ super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
4589
+ }
4590
+ renderLine(container) {
4591
+ const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
4592
+ let arcRadius = radius;
4593
+ let arcInnerRadius = innerRadius;
4594
+ if (inside && innerRadius > 0) {
4595
+ arcRadius = innerRadius;
4596
+ arcInnerRadius = 0;
4597
+ }
4598
+ const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
4599
+ endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
4600
+ const axisLine = vrender.createCircle(arcAttrs);
4601
+ axisLine.name = exports.AXIS_ELEMENT_NAME.line;
4602
+ axisLine.id = this._getNodeId('line');
4603
+ if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
4604
+ axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
4605
+ }
4606
+ container.add(axisLine);
4607
+ }
4883
4608
  getTitleAttribute() {
4884
4609
  var _a, _b, _c, _d, _e, _f, _g, _h;
4885
4610
  const { center, radius, innerRadius = 0 } = this.attribute;
@@ -4932,40 +4657,541 @@
4932
4657
  if (background && background.visible) {
4933
4658
  attrs.panel = Object.assign({ visible: true }, background.style);
4934
4659
  }
4935
- return attrs;
4936
- }
4937
- getSubTickLineItems() {
4938
- var _a, _b;
4939
- const { subTick } = this.attribute;
4940
- const subTickLineItems = [];
4941
- const { count: subCount = 4, inside = false, length = 2 } = subTick;
4942
- const tickLineItems = this.tickLineItems;
4943
- const tickLineCount = tickLineItems.length;
4944
- if (tickLineCount >= 2) {
4945
- const tickSegment = this.data[1].value - this.data[0].value;
4946
- const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
4947
- for (let i = 0; i < tickLineCount; i++) {
4948
- const pre = tickLineItems[i];
4949
- const next = tickLineItems[i + 1];
4950
- for (let j = 0; j < subCount; j++) {
4951
- const percent = (j + 1) / (subCount + 1);
4952
- const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
4953
- const point = this.getTickCoord(value);
4954
- const endPoint = this.getVerticalCoord(point, length, inside);
4955
- subTickLineItems.push({
4956
- start: point,
4957
- end: endPoint,
4958
- value
4660
+ return attrs;
4661
+ }
4662
+ getSubTickLineItems() {
4663
+ var _a, _b;
4664
+ const { subTick } = this.attribute;
4665
+ const subTickLineItems = [];
4666
+ const { count: subCount = 4, inside = false, length = 2 } = subTick;
4667
+ const tickLineItems = this.tickLineItems;
4668
+ const tickLineCount = tickLineItems.length;
4669
+ if (tickLineCount >= 2) {
4670
+ const tickSegment = this.data[1].value - this.data[0].value;
4671
+ const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
4672
+ for (let i = 0; i < tickLineCount; i++) {
4673
+ const pre = tickLineItems[i];
4674
+ const next = tickLineItems[i + 1];
4675
+ for (let j = 0; j < subCount; j++) {
4676
+ const percent = (j + 1) / (subCount + 1);
4677
+ const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
4678
+ const point = this.getTickCoord(value);
4679
+ const endPoint = this.getVerticalCoord(point, length, inside);
4680
+ subTickLineItems.push({
4681
+ start: point,
4682
+ end: endPoint,
4683
+ value
4684
+ });
4685
+ }
4686
+ }
4687
+ }
4688
+ return subTickLineItems;
4689
+ }
4690
+ getTextBaseline(vector) {
4691
+ let base = 'middle';
4692
+ if (vutils.isNumberClose(vector[1], 0)) {
4693
+ base = 'middle';
4694
+ }
4695
+ else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
4696
+ base = 'top';
4697
+ }
4698
+ else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
4699
+ base = 'bottom';
4700
+ }
4701
+ return base;
4702
+ }
4703
+ beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4704
+ return;
4705
+ }
4706
+ handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4707
+ return;
4708
+ }
4709
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4710
+ return;
4711
+ }
4712
+ getLabelAlign(vector, inside, angle) {
4713
+ return {
4714
+ textAlign: this.getTextAlign(vector),
4715
+ textBaseline: this.getTextBaseline(vector)
4716
+ };
4717
+ }
4718
+ }
4719
+ CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
4720
+ vutils.mixin(CircleAxis, CircleAxisMixin);
4721
+
4722
+ function getElMap(g) {
4723
+ const elMap = {};
4724
+ traverseGroup(g, (el) => {
4725
+ if (el.type !== 'group' && el.id) {
4726
+ elMap[el.id] = el;
4727
+ }
4728
+ });
4729
+ return elMap;
4730
+ }
4731
+ class GroupTransition extends vrender.ACustomAnimate {
4732
+ constructor() {
4733
+ super(...arguments);
4734
+ this.mode = vrender.AnimateMode.NORMAL;
4735
+ }
4736
+ onBind() {
4737
+ const currentInnerView = this.target.getInnerView();
4738
+ const prevInnerView = this.target.getPrevInnerView();
4739
+ if (!prevInnerView) {
4740
+ return;
4741
+ }
4742
+ this._oldElementMap = getElMap(prevInnerView);
4743
+ this._newElementAttrMap = {};
4744
+ traverseGroup(currentInnerView, (el) => {
4745
+ var _a, _b, _c, _d, _e, _f;
4746
+ if (el.type !== 'group' && el.id) {
4747
+ const oldEl = this._oldElementMap[el.id];
4748
+ if (oldEl) {
4749
+ if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
4750
+ const newProps = vutils.cloneDeep(el.attribute);
4751
+ this._newElementAttrMap[el.id] = {
4752
+ state: 'update',
4753
+ node: el,
4754
+ attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
4755
+ };
4756
+ el.setAttributes(oldEl.attribute);
4757
+ }
4758
+ }
4759
+ else {
4760
+ const finalOpacityAttrs = {
4761
+ opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
4762
+ fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
4763
+ strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
4764
+ };
4765
+ this._newElementAttrMap[el.id] = {
4766
+ state: 'enter',
4767
+ node: el,
4768
+ attrs: finalOpacityAttrs
4769
+ };
4770
+ el.setAttributes({
4771
+ opacity: 0,
4772
+ fillOpacity: 0,
4773
+ strokeOpacity: 0
4774
+ });
4775
+ }
4776
+ }
4777
+ });
4778
+ }
4779
+ onStart() {
4780
+ let duration = this.duration;
4781
+ let easing = this.easing;
4782
+ Object.keys(this._newElementAttrMap).forEach(id => {
4783
+ var _a, _b, _c, _d, _e, _f, _g;
4784
+ const { node, attrs, state } = this._newElementAttrMap[id];
4785
+ if (state === 'enter') {
4786
+ duration = vutils.isValidNumber((_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.enter) === null || _b === void 0 ? void 0 : _b.duration) ? (_c = this.params) === null || _c === void 0 ? void 0 : _c.enter.duration : duration;
4787
+ easing = ((_e = (_d = this.params) === null || _d === void 0 ? void 0 : _d.enter) === null || _e === void 0 ? void 0 : _e.easing) ? (_g = (_f = this.params) === null || _f === void 0 ? void 0 : _f.enter) === null || _g === void 0 ? void 0 : _g.easing : easing;
4788
+ }
4789
+ if (node.type === 'path') {
4790
+ node
4791
+ .animate({
4792
+ interpolate(key, ratio, from, to, nextAttributes) {
4793
+ if (key === 'path') {
4794
+ nextAttributes.path = vutils.interpolateString(from, to)(ratio);
4795
+ return true;
4796
+ }
4797
+ return false;
4798
+ }
4799
+ })
4800
+ .to(attrs, duration, easing);
4801
+ }
4802
+ else {
4803
+ node
4804
+ .animate()
4805
+ .to(attrs, duration, easing);
4806
+ }
4807
+ });
4808
+ }
4809
+ onUpdate(end, ratio, out) {
4810
+ }
4811
+ }
4812
+
4813
+ class GroupFadeIn extends vrender.ACustomAnimate {
4814
+ constructor(from, to, duration, easing) {
4815
+ super(null, null, duration, easing);
4816
+ }
4817
+ getEndProps() {
4818
+ return {};
4819
+ }
4820
+ onBind() {
4821
+ this.target.setTheme({
4822
+ common: {
4823
+ opacity: 0
4824
+ }
4825
+ });
4826
+ return;
4827
+ }
4828
+ onEnd() {
4829
+ this.target.setTheme({
4830
+ common: {
4831
+ opacity: 1
4832
+ }
4833
+ });
4834
+ return;
4835
+ }
4836
+ onUpdate(end, ratio, out) {
4837
+ this.target.setTheme({
4838
+ common: {
4839
+ opacity: ratio
4840
+ }
4841
+ });
4842
+ }
4843
+ }
4844
+ class GroupFadeOut extends vrender.ACustomAnimate {
4845
+ constructor(from, to, duration, easing) {
4846
+ super(null, null, duration, easing);
4847
+ }
4848
+ getEndProps() {
4849
+ return {};
4850
+ }
4851
+ onBind() {
4852
+ this.target.setTheme({
4853
+ common: {
4854
+ opacity: 1
4855
+ }
4856
+ });
4857
+ return;
4858
+ }
4859
+ onEnd() {
4860
+ this.target.setTheme({
4861
+ common: {
4862
+ opacity: 0
4863
+ }
4864
+ });
4865
+ return;
4866
+ }
4867
+ onUpdate(end, ratio, out) {
4868
+ this.target.setTheme({
4869
+ common: {
4870
+ opacity: 1 - ratio
4871
+ }
4872
+ });
4873
+ }
4874
+ }
4875
+
4876
+ function getLinePath(points, closed) {
4877
+ let path = '';
4878
+ if (points.length === 0) {
4879
+ return path;
4880
+ }
4881
+ points.forEach((point, index) => {
4882
+ if (index === 0) {
4883
+ path = `M${point.x},${point.y}`;
4884
+ }
4885
+ else {
4886
+ path += `L${point.x},${point.y}`;
4887
+ }
4888
+ });
4889
+ if (closed) {
4890
+ path += 'Z';
4891
+ }
4892
+ return path;
4893
+ }
4894
+ function getArcPath(center, points, reverse, closed) {
4895
+ let path = '';
4896
+ if (!center || points.length === 0) {
4897
+ return path;
4898
+ }
4899
+ const firstPoint = points[0];
4900
+ const radius = vutils.PointService.distancePP(center, firstPoint);
4901
+ const sweepFlag = reverse ? 0 : 1;
4902
+ if (closed) {
4903
+ path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y + radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;
4904
+ }
4905
+ else {
4906
+ points.forEach((point, index) => {
4907
+ if (index === 0) {
4908
+ path = `M${point.x},${point.y}`;
4909
+ }
4910
+ else {
4911
+ path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
4912
+ }
4913
+ });
4914
+ }
4915
+ return path;
4916
+ }
4917
+ function getRegionPath(from, to, attribute) {
4918
+ const { type, closed } = attribute;
4919
+ const reversePoints = to.slice(0).reverse();
4920
+ let regionPath = '';
4921
+ let nextPath = '';
4922
+ if (type === 'line' && attribute.smoothLink && attribute.center) {
4923
+ const fromStart = from[0];
4924
+ const toEnd = reversePoints[0];
4925
+ const center = attribute.center;
4926
+ regionPath = getLinePath(from, !!closed);
4927
+ nextPath = getLinePath(reversePoints, !!closed);
4928
+ const toEndRadius = vutils.PointService.distancePP(toEnd, center);
4929
+ const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
4930
+ regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
4931
+ nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
4932
+ }
4933
+ else if (type === 'circle') {
4934
+ const { center } = attribute;
4935
+ regionPath = getArcPath(center, from, false, !!closed);
4936
+ nextPath = getArcPath(center, reversePoints, true, !!closed);
4937
+ }
4938
+ else if (type === 'line' || type === 'polygon') {
4939
+ regionPath = getLinePath(from, !!closed);
4940
+ nextPath = getLinePath(reversePoints, !!closed);
4941
+ }
4942
+ if (closed) {
4943
+ regionPath += nextPath;
4944
+ }
4945
+ else {
4946
+ nextPath = 'L' + nextPath.substring(1);
4947
+ regionPath += nextPath;
4948
+ regionPath += 'Z';
4949
+ }
4950
+ return regionPath;
4951
+ }
4952
+ class BaseGrid extends AbstractComponent {
4953
+ constructor() {
4954
+ super(...arguments);
4955
+ this.name = 'axis-grid';
4956
+ this.data = [];
4957
+ }
4958
+ getInnerView() {
4959
+ return this._innerView;
4960
+ }
4961
+ getPrevInnerView() {
4962
+ return this._prevInnerView;
4963
+ }
4964
+ render() {
4965
+ this.removeAllChild();
4966
+ this._prevInnerView = this._innerView;
4967
+ this._innerView = vrender.createGroup({ x: 0, y: 0, pickable: false });
4968
+ this.add(this._innerView);
4969
+ const { items, visible } = this.attribute;
4970
+ if (items && items.length && visible !== false) {
4971
+ this.data = this._transformItems(items);
4972
+ this._renderGrid(this._innerView);
4973
+ }
4974
+ }
4975
+ getVerticalCoord(point, offset, inside) {
4976
+ const vector = this.getVerticalVector(offset, inside, point);
4977
+ return {
4978
+ x: point.x + vector[0],
4979
+ y: point.y + vector[1]
4980
+ };
4981
+ }
4982
+ _transformItems(items) {
4983
+ const data = [];
4984
+ items.forEach((item) => {
4985
+ var _a;
4986
+ data.push(Object.assign(Object.assign({}, item), { point: this.getTickCoord(item.value), id: (_a = item.id) !== null && _a !== void 0 ? _a : item.label }));
4987
+ });
4988
+ return data;
4989
+ }
4990
+ _renderGrid(container) {
4991
+ const { visible } = this.attribute.subGrid || {};
4992
+ if (visible) {
4993
+ this._renderGridByType(true, container);
4994
+ }
4995
+ this._renderGridByType(false, container);
4996
+ }
4997
+ _renderGridByType(isSubGrid, container) {
4998
+ const gridAttrs = vutils.merge({}, this.attribute, this.getGridAttribute(isSubGrid));
4999
+ const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;
5000
+ const name = isSubGrid ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
5001
+ items.forEach((item, index) => {
5002
+ const { id, points } = item;
5003
+ let path = '';
5004
+ if (type === 'line' || type === 'polygon') {
5005
+ path = getLinePath(points, !!closed);
5006
+ }
5007
+ else if (type === 'circle') {
5008
+ const { center } = this.attribute;
5009
+ path = getArcPath(center, points, false, !!closed);
5010
+ }
5011
+ const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : style)));
5012
+ shape.name = `${name}-line`;
5013
+ shape.id = this._getNodeId(`${name}-path-${id}`);
5014
+ container.add(shape);
5015
+ });
5016
+ if (depth && type === 'line') {
5017
+ items.forEach((item, index) => {
5018
+ const { id, points } = item;
5019
+ const nextPoints = [];
5020
+ nextPoints.push(points[0]);
5021
+ const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
5022
+ const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
5023
+ const ratio = depth / dirLen;
5024
+ nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
5025
+ const path = getLinePath(nextPoints, !!closed);
5026
+ const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
5027
+ const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
5028
+ const shape = vrender.createPath(Object.assign({ path, z: 0, alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * vutils.pi) / 2 : 0, beta: deltaX < deltaY ? -vutils.pi / 2 : 0, anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y] }, (vutils.isFunction(style) ? vutils.merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : style)));
5029
+ shape.name = `${name}-line`;
5030
+ shape.id = this._getNodeId(`${name}-path-${id}`);
5031
+ container.add(shape);
5032
+ });
5033
+ }
5034
+ if (items.length > 1 && alternateColor) {
5035
+ const colors = vutils.isArray(alternateColor)
5036
+ ? alternateColor
5037
+ : [alternateColor, 'transparent'];
5038
+ const getColor = (index) => colors[index % colors.length];
5039
+ for (let index = 0; index < items.length - 1; index++) {
5040
+ const [prev, curr] = [items[index].points, items[index + 1].points];
5041
+ const path = getRegionPath(prev, curr, gridAttrs);
5042
+ const shape = vrender.createPath({
5043
+ path,
5044
+ fill: getColor(index)
5045
+ });
5046
+ shape.name = `${name}-region`;
5047
+ shape.id = this._getNodeId(`${name}-region-${index}`);
5048
+ container.add(shape);
5049
+ }
5050
+ }
5051
+ }
5052
+ _getNodeId(id) {
5053
+ return `${this.id}-${id}`;
5054
+ }
5055
+ }
5056
+ BaseGrid.defaultAttributes = {
5057
+ style: {
5058
+ lineWidth: 1,
5059
+ stroke: '#999',
5060
+ strokeOpacity: 1,
5061
+ lineDash: [4, 4]
5062
+ },
5063
+ subGrid: {
5064
+ visible: false,
5065
+ style: {
5066
+ lineWidth: 1,
5067
+ stroke: '#999',
5068
+ strokeOpacity: 1,
5069
+ lineDash: [4, 4]
5070
+ }
5071
+ }
5072
+ };
5073
+
5074
+ function getCirclePoints(center, count, radius, startAngle, endAngle) {
5075
+ const points = [];
5076
+ const range = endAngle - startAngle;
5077
+ for (let i = 0; i < count; i++) {
5078
+ const angle = startAngle + (i * range) / count;
5079
+ points.push(vutils.polarToCartesian(center, radius, angle));
5080
+ }
5081
+ return points;
5082
+ }
5083
+ class LineAxisGrid extends BaseGrid {
5084
+ constructor(attributes, mode) {
5085
+ super(vutils.merge({}, BaseGrid.defaultAttributes, attributes), mode);
5086
+ if (mode === '3d') {
5087
+ this.setMode(mode);
5088
+ }
5089
+ }
5090
+ _getGridPoint(gridType, point) {
5091
+ let gridPoints;
5092
+ if (gridType === 'line') {
5093
+ const { length } = this.attribute;
5094
+ const endPoint = this.getVerticalCoord(point, length, true);
5095
+ gridPoints = [point, endPoint];
5096
+ }
5097
+ else if (gridType === 'circle' || gridType === 'polygon') {
5098
+ const { center, sides = 6, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
5099
+ const distance = vutils.PointService.distancePP(center, point);
5100
+ gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
5101
+ }
5102
+ return gridPoints;
5103
+ }
5104
+ getGridAttribute(isSubGrid) {
5105
+ const { type: gridType, alignWithLabel = true } = this.attribute;
5106
+ let tickSegment = 1;
5107
+ const count = this.data.length;
5108
+ if (count >= 2) {
5109
+ tickSegment = this.data[1].value - this.data[0].value;
5110
+ }
5111
+ let gridAttribute;
5112
+ let items = [];
5113
+ if (!isSubGrid) {
5114
+ gridAttribute = this.attribute;
5115
+ const gridItems = [];
5116
+ this.data.forEach(item => {
5117
+ let { point } = item;
5118
+ if (!alignWithLabel) {
5119
+ const value = item.value - tickSegment / 2;
5120
+ if (this.isInValidValue(value)) {
5121
+ return;
5122
+ }
5123
+ point = this.getTickCoord(value);
5124
+ }
5125
+ gridItems.push({
5126
+ id: item.label,
5127
+ datum: item,
5128
+ points: this._getGridPoint(gridType, point)
5129
+ });
5130
+ });
5131
+ items = gridItems;
5132
+ }
5133
+ else {
5134
+ gridAttribute = vutils.merge({}, this.attribute, this.attribute.subGrid);
5135
+ const subGridItems = [];
5136
+ const { count: subCount = 4 } = this.attribute.subGrid || {};
5137
+ const tickLineCount = this.data.length;
5138
+ if (tickLineCount >= 2) {
5139
+ const points = [];
5140
+ this.data.forEach((item) => {
5141
+ let tickValue = item.value;
5142
+ if (!alignWithLabel) {
5143
+ const value = item.value - tickSegment / 2;
5144
+ if (this.isInValidValue(value)) {
5145
+ return;
5146
+ }
5147
+ tickValue = value;
5148
+ }
5149
+ points.push({
5150
+ value: tickValue
5151
+ });
5152
+ });
5153
+ for (let i = 0; i < points.length - 1; i++) {
5154
+ const pre = points[i];
5155
+ const next = points[i + 1];
5156
+ subGridItems.push({
5157
+ id: `sub-${i}-0`,
5158
+ points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
5159
+ datum: {}
4959
5160
  });
5161
+ for (let j = 0; j < subCount; j++) {
5162
+ const percent = (j + 1) / (subCount + 1);
5163
+ const value = (1 - percent) * pre.value + percent * next.value;
5164
+ const point = this.getTickCoord(value);
5165
+ subGridItems.push({
5166
+ id: `sub-${i}-${j + 1}`,
5167
+ points: this._getGridPoint(gridType, point),
5168
+ datum: {}
5169
+ });
5170
+ }
5171
+ if (i === points.length - 2) {
5172
+ subGridItems.push({
5173
+ id: `sub-${i}-${subCount + 1}`,
5174
+ points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
5175
+ datum: {}
5176
+ });
5177
+ }
4960
5178
  }
5179
+ items = subGridItems;
4961
5180
  }
4962
5181
  }
4963
- return subTickLineItems;
5182
+ return Object.assign(Object.assign({}, gridAttribute), { items });
5183
+ }
5184
+ }
5185
+ vutils.mixin(LineAxisGrid, LineAxisMixin);
5186
+
5187
+ class CircleAxisGrid extends BaseGrid {
5188
+ constructor(attributes) {
5189
+ super(vutils.merge({}, BaseGrid.defaultAttributes, attributes));
4964
5190
  }
4965
- getGridAttribute(type) {
5191
+ getGridAttribute(isSubGrid) {
4966
5192
  let gridAttribute;
4967
5193
  let items = [];
4968
- const { radius, innerRadius = 0, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, center, grid } = this.attribute;
5194
+ const _a = this.attribute, { radius, innerRadius = 0, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, center, subGrid } = _a, grid = __rest(_a, ["radius", "innerRadius", "startAngle", "endAngle", "center", "subGrid"]);
4969
5195
  const { alignWithLabel = true } = grid || {};
4970
5196
  const length = radius - innerRadius;
4971
5197
  let tickSegment = 1;
@@ -4973,8 +5199,8 @@
4973
5199
  if (count >= 2) {
4974
5200
  tickSegment = this.data[1].value - this.data[0].value;
4975
5201
  }
4976
- if (type === 'grid') {
4977
- gridAttribute = this.attribute.grid;
5202
+ if (!isSubGrid) {
5203
+ gridAttribute = grid;
4978
5204
  const gridItems = [];
4979
5205
  let data;
4980
5206
  if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
@@ -5002,9 +5228,9 @@
5002
5228
  items = gridItems;
5003
5229
  }
5004
5230
  else {
5005
- gridAttribute = vutils.merge({}, this.attribute.grid, this.attribute.subGrid);
5231
+ gridAttribute = vutils.merge({}, grid, subGrid);
5006
5232
  const subGridItems = [];
5007
- const { count: subCount = 4 } = this.attribute.subTick || {};
5233
+ const { count: subCount = 4 } = subGrid || {};
5008
5234
  const tickLineCount = this.data.length;
5009
5235
  if (tickLineCount >= 2) {
5010
5236
  const points = [];
@@ -5048,192 +5274,10 @@
5048
5274
  }
5049
5275
  }
5050
5276
  return Object.assign(Object.assign({}, gridAttribute), { items,
5051
- center });
5052
- }
5053
- getTextBaseline(vector) {
5054
- let base = 'middle';
5055
- if (vutils.isNumberClose(vector[1], 0)) {
5056
- base = 'middle';
5057
- }
5058
- else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
5059
- base = 'top';
5060
- }
5061
- else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
5062
- base = 'bottom';
5063
- }
5064
- return base;
5065
- }
5066
- beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5067
- return;
5068
- }
5069
- handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5070
- return;
5071
- }
5072
- afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5073
- return;
5074
- }
5075
- getLabelAlign(vector, inside, angle) {
5076
- return {
5077
- textAlign: this.getTextAlign(vector),
5078
- textBaseline: this.getTextBaseline(vector)
5079
- };
5080
- }
5081
- }
5082
- CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
5083
-
5084
- function getElMap(g) {
5085
- const elMap = {};
5086
- traverseGroup(g, (el) => {
5087
- if (el.type !== 'group' && el.id) {
5088
- elMap[el.id] = el;
5089
- }
5090
- });
5091
- return elMap;
5092
- }
5093
- class GroupTransition extends vrender.ACustomAnimate {
5094
- constructor() {
5095
- super(...arguments);
5096
- this.mode = vrender.AnimateMode.NORMAL;
5097
- }
5098
- onBind() {
5099
- const currentInnerView = this.target.getInnerView();
5100
- const prevInnerView = this.target.getPrevInnerView();
5101
- if (!prevInnerView) {
5102
- return;
5103
- }
5104
- this._oldElementMap = getElMap(prevInnerView);
5105
- this._newElementAttrMap = {};
5106
- traverseGroup(currentInnerView, (el) => {
5107
- var _a, _b, _c, _d, _e, _f;
5108
- if (el.type !== 'group' && el.id) {
5109
- const oldEl = this._oldElementMap[el.id];
5110
- if (oldEl) {
5111
- if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
5112
- const newProps = vutils.cloneDeep(el.attribute);
5113
- this._newElementAttrMap[el.id] = {
5114
- state: 'update',
5115
- node: el,
5116
- attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
5117
- };
5118
- el.setAttributes(oldEl.attribute);
5119
- }
5120
- }
5121
- else {
5122
- const finalOpacityAttrs = {
5123
- opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
5124
- fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
5125
- strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
5126
- };
5127
- this._newElementAttrMap[el.id] = {
5128
- state: 'enter',
5129
- node: el,
5130
- attrs: finalOpacityAttrs
5131
- };
5132
- el.setAttributes({
5133
- opacity: 0,
5134
- fillOpacity: 0,
5135
- strokeOpacity: 0
5136
- });
5137
- }
5138
- }
5139
- });
5140
- }
5141
- onStart() {
5142
- let duration = this.duration;
5143
- let easing = this.easing;
5144
- Object.keys(this._newElementAttrMap).forEach(id => {
5145
- var _a, _b, _c;
5146
- const { node, attrs, state } = this._newElementAttrMap[id];
5147
- if (state === 'enter') {
5148
- duration = vutils.isValidNumber((_a = this.params.enter) === null || _a === void 0 ? void 0 : _a.duration) ? this.params.enter.duration : duration;
5149
- easing = ((_b = this.params.enter) === null || _b === void 0 ? void 0 : _b.easing) ? (_c = this.params.enter) === null || _c === void 0 ? void 0 : _c.easing : easing;
5150
- }
5151
- if (node.type === 'path') {
5152
- node
5153
- .animate({
5154
- interpolate(key, ratio, from, to, nextAttributes) {
5155
- if (key === 'path') {
5156
- nextAttributes.path = vutils.interpolateString(from, to)(ratio);
5157
- return true;
5158
- }
5159
- return false;
5160
- }
5161
- })
5162
- .to(attrs, duration, easing);
5163
- }
5164
- else {
5165
- node
5166
- .animate()
5167
- .to(attrs, duration, easing);
5168
- }
5169
- });
5170
- }
5171
- onUpdate(end, ratio, out) {
5172
- }
5173
- }
5174
-
5175
- class GroupFadeIn extends vrender.ACustomAnimate {
5176
- constructor(from, to, duration, easing) {
5177
- super(null, null, duration, easing);
5178
- }
5179
- getEndProps() {
5180
- return {};
5181
- }
5182
- onBind() {
5183
- this.target.setTheme({
5184
- common: {
5185
- opacity: 0
5186
- }
5187
- });
5188
- return;
5189
- }
5190
- onEnd() {
5191
- this.target.setTheme({
5192
- common: {
5193
- opacity: 1
5194
- }
5195
- });
5196
- return;
5197
- }
5198
- onUpdate(end, ratio, out) {
5199
- this.target.setTheme({
5200
- common: {
5201
- opacity: ratio
5202
- }
5203
- });
5204
- }
5205
- }
5206
- class GroupFadeOut extends vrender.ACustomAnimate {
5207
- constructor(from, to, duration, easing) {
5208
- super(null, null, duration, easing);
5209
- }
5210
- getEndProps() {
5211
- return {};
5212
- }
5213
- onBind() {
5214
- this.target.setTheme({
5215
- common: {
5216
- opacity: 1
5217
- }
5218
- });
5219
- return;
5220
- }
5221
- onEnd() {
5222
- this.target.setTheme({
5223
- common: {
5224
- opacity: 0
5225
- }
5226
- });
5227
- return;
5228
- }
5229
- onUpdate(end, ratio, out) {
5230
- this.target.setTheme({
5231
- common: {
5232
- opacity: 1 - ratio
5233
- }
5234
- });
5277
+ center, type: 'line' });
5235
5278
  }
5236
5279
  }
5280
+ vutils.mixin(CircleAxisGrid, CircleAxisMixin);
5237
5281
 
5238
5282
  var DataZoomActiveTag;
5239
5283
  (function (DataZoomActiveTag) {
@@ -10310,7 +10354,11 @@
10310
10354
  }
10311
10355
  Tooltip.defaultAttributes = defaultAttributes;
10312
10356
 
10313
- const version = "0.15.0-alpha.16";
10357
+ function VTag(params) {
10358
+ return new Tag(params ? params.attribute : {});
10359
+ }
10360
+
10361
+ const version = "0.15.0-alpha.18";
10314
10362
 
10315
10363
  exports.AbstractComponent = AbstractComponent;
10316
10364
  exports.ArcInfo = ArcInfo;
@@ -10318,6 +10366,7 @@
10318
10366
  exports.BasePlayer = BasePlayer;
10319
10367
  exports.Brush = Brush;
10320
10368
  exports.CircleAxis = CircleAxis;
10369
+ exports.CircleAxisGrid = CircleAxisGrid;
10321
10370
  exports.CircleCrosshair = CircleCrosshair;
10322
10371
  exports.ColorContinuousLegend = ColorContinuousLegend;
10323
10372
  exports.ContinuousPlayer = ContinuousPlayer;
@@ -10334,13 +10383,13 @@
10334
10383
  exports.DataZoom = DataZoom;
10335
10384
  exports.DiscreteLegend = DiscreteLegend;
10336
10385
  exports.DiscretePlayer = DiscretePlayer;
10337
- exports.Grid = Grid;
10338
10386
  exports.GroupFadeIn = GroupFadeIn;
10339
10387
  exports.GroupFadeOut = GroupFadeOut;
10340
10388
  exports.GroupTransition = GroupTransition;
10341
10389
  exports.Indicator = Indicator;
10342
10390
  exports.LabelBase = LabelBase;
10343
10391
  exports.LineAxis = LineAxis;
10392
+ exports.LineAxisGrid = LineAxisGrid;
10344
10393
  exports.LineCrosshair = LineCrosshair;
10345
10394
  exports.LineLabel = LineLabel;
10346
10395
  exports.LinkPath = LinkPath;
@@ -10361,6 +10410,7 @@
10361
10410
  exports.Tag = Tag;
10362
10411
  exports.Title = Title;
10363
10412
  exports.Tooltip = Tooltip;
10413
+ exports.VTag = VTag;
10364
10414
  exports.getHorizontalPath = getHorizontalPath;
10365
10415
  exports.getSizeHandlerPath = getSizeHandlerPath;
10366
10416
  exports.getVerticalPath = getVerticalPath;