@visactor/vrender-components 0.14.7 → 0.15.0-alpha.12

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 (145) 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/type.js +2 -1
  43. package/cjs/crosshair/base.js +1 -2
  44. package/cjs/index.d.ts +3 -1
  45. package/cjs/index.js +9 -8
  46. package/cjs/index.js.map +1 -1
  47. package/cjs/indicator/type.js +2 -1
  48. package/cjs/jsx/component-type.d.ts +4 -0
  49. package/cjs/jsx/component-type.js +13 -0
  50. package/cjs/jsx/component-type.js.map +1 -0
  51. package/cjs/jsx/index.d.ts +1 -0
  52. package/cjs/jsx/index.js +21 -0
  53. package/cjs/jsx/index.js.map +1 -0
  54. package/cjs/link-path/index.js +1 -2
  55. package/cjs/link-path/link-path.js +2 -1
  56. package/cjs/marker/point.js +1 -1
  57. package/cjs/poptip/contribution.js +3 -1
  58. package/cjs/poptip/contribution.js.map +1 -1
  59. package/cjs/poptip/poptip.js +5 -2
  60. package/cjs/poptip/poptip.js.map +1 -1
  61. package/cjs/poptip/register.d.ts +1 -1
  62. package/cjs/poptip/register.js +8 -6
  63. package/cjs/poptip/register.js.map +1 -1
  64. package/cjs/poptip/type.d.ts +2 -0
  65. package/cjs/poptip/type.js.map +1 -1
  66. package/cjs/util/matrix.d.ts +1 -1
  67. package/cjs/util/matrix.js.map +1 -1
  68. package/cjs/util/text.js +3 -3
  69. package/cjs/util/text.js.map +1 -1
  70. package/dist/index.js +647 -588
  71. package/dist/index.min.js +1 -1
  72. package/es/axis/animate/group-transition.d.ts +2 -1
  73. package/es/axis/animate/group-transition.js +3 -3
  74. package/es/axis/animate/group-transition.js.map +1 -1
  75. package/es/axis/base.d.ts +5 -8
  76. package/es/axis/base.js +15 -33
  77. package/es/axis/base.js.map +1 -1
  78. package/es/axis/circle.d.ts +3 -23
  79. package/es/axis/circle.js +4 -85
  80. package/es/axis/circle.js.map +1 -1
  81. package/es/axis/config.d.ts +0 -17
  82. package/es/axis/config.js +0 -17
  83. package/es/axis/config.js.map +1 -1
  84. package/es/axis/grid/base.d.ts +24 -0
  85. package/es/axis/{grid.js → grid/base.js} +69 -21
  86. package/es/axis/grid/base.js.map +1 -0
  87. package/es/axis/grid/circle.d.ts +9 -0
  88. package/es/axis/grid/circle.js +92 -0
  89. package/es/axis/grid/circle.js.map +1 -0
  90. package/es/axis/grid/index.d.ts +3 -0
  91. package/es/axis/grid/index.js +6 -0
  92. package/es/axis/grid/index.js.map +1 -0
  93. package/es/axis/grid/line.d.ts +10 -0
  94. package/es/axis/grid/line.js +102 -0
  95. package/es/axis/grid/line.js.map +1 -0
  96. package/es/axis/grid/type.d.ts +63 -0
  97. package/es/axis/grid/type.js +2 -0
  98. package/es/axis/grid/type.js.map +1 -0
  99. package/es/axis/index.d.ts +0 -1
  100. package/es/axis/index.js +0 -2
  101. package/es/axis/index.js.map +1 -1
  102. package/es/axis/line.d.ts +3 -24
  103. package/es/axis/line.js +8 -109
  104. package/es/axis/line.js.map +1 -1
  105. package/es/axis/mixin/circle.d.ts +17 -0
  106. package/es/axis/mixin/circle.js +25 -0
  107. package/es/axis/mixin/circle.js.map +1 -0
  108. package/es/axis/mixin/line.d.ts +14 -0
  109. package/es/axis/mixin/line.js +23 -0
  110. package/es/axis/mixin/line.js.map +1 -0
  111. package/es/axis/type.d.ts +0 -55
  112. package/es/axis/type.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/contribution.js +3 -1
  129. package/es/poptip/contribution.js.map +1 -1
  130. package/es/poptip/poptip.js +5 -1
  131. package/es/poptip/poptip.js.map +1 -1
  132. package/es/poptip/register.d.ts +1 -1
  133. package/es/poptip/register.js +7 -6
  134. package/es/poptip/register.js.map +1 -1
  135. package/es/poptip/type.d.ts +2 -0
  136. package/es/poptip/type.js.map +1 -1
  137. package/es/util/matrix.d.ts +1 -1
  138. package/es/util/matrix.js.map +1 -1
  139. package/es/util/text.js +3 -3
  140. package/es/util/text.js.map +1 -1
  141. package/package.json +4 -4
  142. package/cjs/axis/grid.d.ts +0 -9
  143. package/cjs/axis/grid.js.map +0 -1
  144. package/es/axis/grid.d.ts +0 -9
  145. package/es/axis/grid.js.map +0 -1
package/dist/index.js CHANGED
@@ -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,
@@ -719,7 +719,10 @@
719
719
  }
720
720
  render() {
721
721
  var _a, _b, _c, _d, _e, _f, _g, _h;
722
- const { title = '', titleStyle = {}, position, content = '', contentStyle = {}, panel = {}, space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, maxWidthPercent, visible, state, dx = 0, dy = 0 } = this.attribute;
722
+ const { titleStyle = {}, position, contentStyle = {}, panel = {}, space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, maxWidthPercent, visible, state, dx = 0, dy = 0 } = this.attribute;
723
+ let { title = '', content = '' } = this.attribute;
724
+ title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title;
725
+ content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;
723
726
  const parsedPadding = vutils.normalizePadding(padding);
724
727
  const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group');
725
728
  const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];
@@ -959,8 +962,14 @@
959
962
  if (visible === false || (visibleCb && visibleCb(graphic) === false)) {
960
963
  return;
961
964
  }
965
+ const attribute = {};
966
+ graphic.attribute.poptip &&
967
+ vutils.merge(attribute, PopTip.defaultAttributes, graphic.attribute.poptip);
962
968
  if (!this.poptipComponent) {
963
- this.poptipComponent = new PopTip(graphic.attribute.poptip);
969
+ this.poptipComponent = new PopTip(attribute);
970
+ }
971
+ else {
972
+ this.poptipComponent.initAttributes(attribute);
964
973
  }
965
974
  let poptip = graphic.attribute.poptip || {};
966
975
  if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {
@@ -1095,16 +1104,21 @@
1095
1104
  injectable()
1096
1105
  ], PopTipForClipedTextPlugin);
1097
1106
 
1098
- const popTipModule = new ContainerModule(bind => {
1099
- bind(PopTipRenderContribution).toSelf().inSingletonScope();
1100
- bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
1101
- bind(PopTipPlugin).toSelf().inSingletonScope();
1102
- bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
1103
- bind(PopTipForClipedTextPlugin).toSelf().inSingletonScope();
1104
- bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
1107
+ const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {
1108
+ if (!isBound(PopTipRenderContribution)) {
1109
+ bind(PopTipRenderContribution).toSelf().inSingletonScope();
1110
+ bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
1111
+ }
1112
+ if (!isBound(PopTipPlugin)) {
1113
+ bind(PopTipPlugin).toSelf();
1114
+ bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
1115
+ }
1116
+ if (!isBound(PopTipForClipedTextPlugin)) {
1117
+ bind(PopTipForClipedTextPlugin).toSelf();
1118
+ bind(vrender.AutoEnablePlugins).toService(PopTipForClipedTextPlugin);
1119
+ }
1105
1120
  });
1106
- function loadPoptip(defaultPoptipTheme) {
1107
- vutils.merge(theme.poptip, defaultPoptipTheme);
1121
+ function loadPoptip() {
1108
1122
  vrender.container.load(popTipModule);
1109
1123
  }
1110
1124
  function setPoptipTheme(defaultPoptipTheme) {
@@ -3163,156 +3177,6 @@
3163
3177
  pickable: false
3164
3178
  };
3165
3179
 
3166
- function getLinePath(points, closed) {
3167
- let path = '';
3168
- if (points.length === 0) {
3169
- return path;
3170
- }
3171
- points.forEach((point, index) => {
3172
- if (index === 0) {
3173
- path = `M${point.x},${point.y}`;
3174
- }
3175
- else {
3176
- path += `L${point.x},${point.y}`;
3177
- }
3178
- });
3179
- if (closed) {
3180
- path += 'Z';
3181
- }
3182
- return path;
3183
- }
3184
- function getArcPath(center, points, reverse, closed) {
3185
- let path = '';
3186
- if (!center || points.length === 0) {
3187
- return path;
3188
- }
3189
- const firstPoint = points[0];
3190
- const radius = vutils.PointService.distancePP(center, firstPoint);
3191
- const sweepFlag = reverse ? 0 : 1;
3192
- if (closed) {
3193
- 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`;
3194
- }
3195
- else {
3196
- points.forEach((point, index) => {
3197
- if (index === 0) {
3198
- path = `M${point.x},${point.y}`;
3199
- }
3200
- else {
3201
- path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
3202
- }
3203
- });
3204
- }
3205
- return path;
3206
- }
3207
- function getRegionPath(from, to, attribute) {
3208
- const { type, closed } = attribute;
3209
- const reversePoints = to.slice(0).reverse();
3210
- let regionPath = '';
3211
- let nextPath = '';
3212
- if (type === 'line' && attribute.smoothLink && attribute.center) {
3213
- const fromStart = from[0];
3214
- const toEnd = reversePoints[0];
3215
- const center = attribute.center;
3216
- regionPath = getLinePath(from, !!closed);
3217
- nextPath = getLinePath(reversePoints, !!closed);
3218
- const toEndRadius = vutils.PointService.distancePP(toEnd, center);
3219
- const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
3220
- regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
3221
- nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
3222
- }
3223
- else if (type === 'circle') {
3224
- const { center } = attribute;
3225
- regionPath = getArcPath(center, from, false, !!closed);
3226
- nextPath = getArcPath(center, reversePoints, true, !!closed);
3227
- }
3228
- else if (type === 'line' || type === 'polygon') {
3229
- regionPath = getLinePath(from, !!closed);
3230
- nextPath = getLinePath(reversePoints, !!closed);
3231
- }
3232
- if (closed) {
3233
- regionPath += nextPath;
3234
- }
3235
- else {
3236
- nextPath = 'L' + nextPath.substring(1);
3237
- regionPath += nextPath;
3238
- regionPath += 'Z';
3239
- }
3240
- return regionPath;
3241
- }
3242
- class Grid extends AbstractComponent {
3243
- constructor(attributes) {
3244
- super(vutils.merge({}, Grid.defaultAttributes, attributes));
3245
- this.name = 'grid';
3246
- }
3247
- render() {
3248
- this.removeAllChild();
3249
- const { type, items, style, closed, alternateColor, depth = 0 } = this.attribute;
3250
- if (vutils.isEmpty(items)) {
3251
- return;
3252
- }
3253
- items.forEach((item, index) => {
3254
- const { id, points } = item;
3255
- let path = '';
3256
- if (type === 'line' || type === 'polygon') {
3257
- path = getLinePath(points, !!closed);
3258
- }
3259
- else if (type === 'circle') {
3260
- const { center } = this.attribute;
3261
- path = getArcPath(center, points, false, !!closed);
3262
- }
3263
- const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, Grid.defaultAttributes.style, style(item, index)) : style)));
3264
- shape.name = `${this.name}-line`;
3265
- shape.id = this._getNodeId(`path-${id}`);
3266
- this.add(shape);
3267
- });
3268
- if (depth && type === 'line') {
3269
- items.forEach((item, index) => {
3270
- const { id, points } = item;
3271
- const nextPoints = [];
3272
- nextPoints.push(points[0]);
3273
- const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
3274
- const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
3275
- const ratio = depth / dirLen;
3276
- nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
3277
- const path = getLinePath(nextPoints, !!closed);
3278
- const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
3279
- const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
3280
- 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)));
3281
- shape.name = `${this.name}-line`;
3282
- shape.id = this._getNodeId(`path-${id}`);
3283
- this.add(shape);
3284
- });
3285
- }
3286
- if (items.length > 1 && alternateColor) {
3287
- const colors = vutils.isArray(alternateColor)
3288
- ? alternateColor
3289
- : [alternateColor, 'transparent'];
3290
- const getColor = (index) => colors[index % colors.length];
3291
- for (let index = 0; index < items.length - 1; index++) {
3292
- const [prev, curr] = [items[index].points, items[index + 1].points];
3293
- const path = getRegionPath(prev, curr, this.attribute);
3294
- const shape = vrender.createPath({
3295
- path,
3296
- fill: getColor(index)
3297
- });
3298
- shape.name = `${this.name}-region`;
3299
- shape.id = this._getNodeId(`region-${index}`);
3300
- this.add(shape);
3301
- }
3302
- }
3303
- }
3304
- _getNodeId(id) {
3305
- return `${this.id}-${id}`;
3306
- }
3307
- }
3308
- Grid.defaultAttributes = {
3309
- style: {
3310
- lineWidth: 1,
3311
- stroke: '#416180'
3312
- },
3313
- zIndex: 0
3314
- };
3315
-
3316
3180
  class Segment extends AbstractComponent {
3317
3181
  constructor(attributes) {
3318
3182
  super(vutils.merge({}, Segment.defaultAttributes, attributes));
@@ -3530,23 +3394,6 @@
3530
3394
  stroke: '#000',
3531
3395
  strokeOpacity: 1
3532
3396
  }
3533
- },
3534
- grid: {
3535
- style: {
3536
- lineWidth: 1,
3537
- stroke: '#999',
3538
- strokeOpacity: 1,
3539
- lineDash: [4, 4]
3540
- }
3541
- },
3542
- subGrid: {
3543
- visible: false,
3544
- style: {
3545
- lineWidth: 1,
3546
- stroke: '#999',
3547
- strokeOpacity: 1,
3548
- lineDash: [4, 4]
3549
- }
3550
3397
  }
3551
3398
  };
3552
3399
 
@@ -3643,7 +3490,7 @@
3643
3490
  }
3644
3491
  }
3645
3492
  _renderInner(container) {
3646
- const { title, label, tick, line, grid, items } = this.attribute;
3493
+ const { title, label, tick, line, items } = this.attribute;
3647
3494
  const axisContainer = vrender.createGroup({ x: 0, y: 0, zIndex: 1 });
3648
3495
  axisContainer.name = exports.AXIS_ELEMENT_NAME.axisContainer;
3649
3496
  axisContainer.id = this._getNodeId('container');
@@ -3672,9 +3519,6 @@
3672
3519
  this.afterLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
3673
3520
  });
3674
3521
  }
3675
- if (grid === null || grid === void 0 ? void 0 : grid.visible) {
3676
- this.renderGrid(container);
3677
- }
3678
3522
  }
3679
3523
  if (title === null || title === void 0 ? void 0 : title.visible) {
3680
3524
  this.renderTitle(axisContainer);
@@ -3791,13 +3635,6 @@
3791
3635
  axisTitle.id = this._getNodeId('title');
3792
3636
  container.add(axisTitle);
3793
3637
  }
3794
- renderGrid(container) {
3795
- const { visible } = this.attribute.subGrid || {};
3796
- if (visible) {
3797
- this._renderGridByType('subGrid', container);
3798
- }
3799
- this._renderGridByType('grid', container);
3800
- }
3801
3638
  getVerticalCoord(point, offset, inside) {
3802
3639
  const vector = this.getVerticalVector(offset, inside, point);
3803
3640
  return {
@@ -3968,13 +3805,6 @@
3968
3805
  });
3969
3806
  return data;
3970
3807
  }
3971
- _renderGridByType(type, container) {
3972
- const gridAttrs = this.getGridAttribute(type);
3973
- const gridGroup = new Grid(Object.assign(Object.assign({ pickable: false }, gridAttrs), { zIndex: 0 }));
3974
- gridGroup.name = type === 'subGrid' ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
3975
- gridGroup.id = this._getNodeId(type);
3976
- container.add(gridGroup);
3977
- }
3978
3808
  }
3979
3809
 
3980
3810
  const methods = {
@@ -4273,15 +4103,31 @@
4273
4103
  }
4274
4104
  }
4275
4105
 
4276
- function getCirclePoints(center, count, radius, startAngle, endAngle) {
4277
- const points = [];
4278
- const range = endAngle - startAngle;
4279
- for (let i = 0; i < count; i++) {
4280
- const angle = startAngle + (i * range) / count;
4281
- points.push(vutils.polarToCartesian(center, radius, angle));
4106
+ class LineAxisMixin {
4107
+ isInValidValue(value) {
4108
+ return value < 0 || value > 1;
4109
+ }
4110
+ getTickCoord(tickValue) {
4111
+ const { start } = this.attribute;
4112
+ const axisVector = this.getRelativeVector();
4113
+ return {
4114
+ x: start.x + axisVector[0] * tickValue,
4115
+ y: start.y + axisVector[1] * tickValue
4116
+ };
4117
+ }
4118
+ getRelativeVector(point) {
4119
+ const { start, end } = this.attribute;
4120
+ return [end.x - start.x, end.y - start.y];
4121
+ }
4122
+ getVerticalVector(offset, inside = false, point) {
4123
+ const { verticalFactor = 1 } = this.attribute;
4124
+ const axisVector = this.getRelativeVector();
4125
+ const normalizedAxisVector = normalize(axisVector);
4126
+ const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
4127
+ return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
4282
4128
  }
4283
- return points;
4284
4129
  }
4130
+
4285
4131
  class LineAxis extends AxisBase {
4286
4132
  constructor(attributes, mode) {
4287
4133
  super(vutils.merge({}, LineAxis.defaultAttributes, attributes), mode);
@@ -4319,28 +4165,6 @@
4319
4165
  axisLineGroup.id = this._getNodeId('line');
4320
4166
  container.add(axisLineGroup);
4321
4167
  }
4322
- isInValidValue(value) {
4323
- return value < 0 || value > 1;
4324
- }
4325
- getTickCoord(tickValue) {
4326
- const { start } = this.attribute;
4327
- const axisVector = this.getRelativeVector();
4328
- return {
4329
- x: start.x + axisVector[0] * tickValue,
4330
- y: start.y + axisVector[1] * tickValue
4331
- };
4332
- }
4333
- getRelativeVector() {
4334
- const { start, end } = this.attribute;
4335
- return [end.x - start.x, end.y - start.y];
4336
- }
4337
- getVerticalVector(offset, inside = false) {
4338
- const { verticalFactor = 1 } = this.attribute;
4339
- const axisVector = this.getRelativeVector();
4340
- const normalizedAxisVector = normalize(axisVector);
4341
- const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
4342
- return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
4343
- }
4344
4168
  getTitleAttribute() {
4345
4169
  var _a, _b, _c, _d, _e, _f, _g, _h;
4346
4170
  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"]);
@@ -4425,7 +4249,7 @@
4425
4249
  }
4426
4250
  const offset = tickLength + labelLength + space;
4427
4251
  const titlePoint = this.getVerticalCoord(point, offset, false);
4428
- const vector = this.getVerticalVector(offset, false);
4252
+ const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });
4429
4253
  let { angle } = restAttrs;
4430
4254
  let textAlign;
4431
4255
  if (position === 'start') {
@@ -4473,129 +4297,35 @@
4473
4297
  }
4474
4298
  return attrs;
4475
4299
  }
4476
- _getGridPoint(gridType, point) {
4477
- let gridPoints;
4478
- if (gridType === 'line') {
4479
- const { length } = this.attribute.grid;
4480
- const endPoint = this.getVerticalCoord(point, length, true);
4481
- gridPoints = [point, endPoint];
4300
+ getTextBaseline(vector, inside) {
4301
+ let base = 'middle';
4302
+ const { verticalFactor = 1 } = this.attribute;
4303
+ const factor = (inside ? 1 : -1) * verticalFactor;
4304
+ if (vutils.isNumberClose(vector[1], 0)) {
4305
+ if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
4306
+ base = factor === 1 ? 'bottom' : 'top';
4307
+ }
4308
+ else {
4309
+ base = 'middle';
4310
+ }
4482
4311
  }
4483
- else if (gridType === 'circle' || gridType === 'polygon') {
4484
- const { center, sides, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute.grid;
4485
- const distance = vutils.PointService.distancePP(center, point);
4486
- gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
4312
+ else if (vector[1] > 0) {
4313
+ base = 'top';
4487
4314
  }
4488
- return gridPoints;
4315
+ else if (vector[1] < 0) {
4316
+ base = 'bottom';
4317
+ }
4318
+ return base;
4489
4319
  }
4490
- getGridAttribute(type) {
4491
- const { type: gridType, alignWithLabel = true } = this.attribute.grid;
4492
- let tickSegment = 1;
4493
- const count = this.data.length;
4494
- if (count >= 2) {
4495
- tickSegment = this.data[1].value - this.data[0].value;
4496
- }
4497
- let gridAttribute;
4498
- let items = [];
4499
- if (type === 'grid') {
4500
- gridAttribute = this.attribute.grid;
4501
- const gridItems = [];
4502
- this.data.forEach(item => {
4503
- let { point } = item;
4504
- if (!alignWithLabel) {
4505
- const value = item.value - tickSegment / 2;
4506
- if (this.isInValidValue(value)) {
4507
- return;
4508
- }
4509
- point = this.getTickCoord(value);
4510
- }
4511
- gridItems.push({
4512
- id: item.label,
4513
- datum: item,
4514
- points: this._getGridPoint(gridType, point)
4515
- });
4516
- });
4517
- items = gridItems;
4518
- }
4519
- else {
4520
- gridAttribute = vutils.merge({}, this.attribute.grid, this.attribute.subGrid);
4521
- const subGridItems = [];
4522
- const { count: subCount = 4 } = this.attribute.subTick || {};
4523
- const tickLineCount = this.data.length;
4524
- if (tickLineCount >= 2) {
4525
- const points = [];
4526
- this.data.forEach((item) => {
4527
- let tickValue = item.value;
4528
- if (!alignWithLabel) {
4529
- const value = item.value - tickSegment / 2;
4530
- if (this.isInValidValue(value)) {
4531
- return;
4532
- }
4533
- tickValue = value;
4534
- }
4535
- points.push({
4536
- value: tickValue
4537
- });
4538
- });
4539
- for (let i = 0; i < points.length - 1; i++) {
4540
- const pre = points[i];
4541
- const next = points[i + 1];
4542
- subGridItems.push({
4543
- id: `sub-${i}-0`,
4544
- points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
4545
- datum: {}
4546
- });
4547
- for (let j = 0; j < subCount; j++) {
4548
- const percent = (j + 1) / (subCount + 1);
4549
- const value = (1 - percent) * pre.value + percent * next.value;
4550
- const point = this.getTickCoord(value);
4551
- subGridItems.push({
4552
- id: `sub-${i}-${j + 1}`,
4553
- points: this._getGridPoint(gridType, point),
4554
- datum: {}
4555
- });
4556
- }
4557
- if (i === points.length - 2) {
4558
- subGridItems.push({
4559
- id: `sub-${i}-${subCount + 1}`,
4560
- points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
4561
- datum: {}
4562
- });
4563
- }
4564
- }
4565
- items = subGridItems;
4566
- }
4567
- }
4568
- return Object.assign(Object.assign({}, gridAttribute), { items });
4569
- }
4570
- getTextBaseline(vector, inside) {
4571
- let base = 'middle';
4572
- const { verticalFactor = 1 } = this.attribute;
4573
- const factor = (inside ? 1 : -1) * verticalFactor;
4574
- if (vutils.isNumberClose(vector[1], 0)) {
4575
- if (vutils.isNumberClose(vector[0], 0) && !Object.is(vector[0], -0) && !Object.is(vector[1], -0)) {
4576
- base = factor === 1 ? 'bottom' : 'top';
4577
- }
4578
- else {
4579
- base = 'middle';
4580
- }
4581
- }
4582
- else if (vector[1] > 0) {
4583
- base = 'top';
4584
- }
4585
- else if (vector[1] < 0) {
4586
- base = 'bottom';
4587
- }
4588
- return base;
4589
- }
4590
- getLabelAlign(vector, inside, angle) {
4591
- const orient = this.attribute.orient;
4592
- if (vutils.isValidNumber(angle)) {
4593
- if (orient === 'top' || orient === 'bottom') {
4594
- return getXAxisLabelAlign(orient, angle);
4595
- }
4596
- if (orient === 'left' || orient === 'right') {
4597
- return getYAxisLabelAlign(orient, angle);
4598
- }
4320
+ getLabelAlign(vector, inside, angle) {
4321
+ const orient = this.attribute.orient;
4322
+ if (vutils.isValidNumber(angle)) {
4323
+ if (orient === 'top' || orient === 'bottom') {
4324
+ return getXAxisLabelAlign(orient, angle);
4325
+ }
4326
+ if (orient === 'left' || orient === 'right') {
4327
+ return getYAxisLabelAlign(orient, angle);
4328
+ }
4599
4329
  }
4600
4330
  return {
4601
4331
  textAlign: this.getTextAlign(vector),
@@ -4800,29 +4530,9 @@
4800
4530
  }
4801
4531
  }
4802
4532
  LineAxis.defaultAttributes = DEFAULT_AXIS_THEME;
4533
+ vutils.mixin(LineAxis, LineAxisMixin);
4803
4534
 
4804
- class CircleAxis extends AxisBase {
4805
- constructor(attributes) {
4806
- super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
4807
- }
4808
- renderLine(container) {
4809
- const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
4810
- let arcRadius = radius;
4811
- let arcInnerRadius = innerRadius;
4812
- if (inside && innerRadius > 0) {
4813
- arcRadius = innerRadius;
4814
- arcInnerRadius = 0;
4815
- }
4816
- const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
4817
- endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
4818
- const axisLine = vrender.createCircle(arcAttrs);
4819
- axisLine.name = exports.AXIS_ELEMENT_NAME.line;
4820
- axisLine.id = this._getNodeId('line');
4821
- if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
4822
- axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
4823
- }
4824
- container.add(axisLine);
4825
- }
4535
+ class CircleAxisMixin {
4826
4536
  isInValidValue(value) {
4827
4537
  const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
4828
4538
  if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
@@ -4845,6 +4555,30 @@
4845
4555
  const { center } = this.attribute;
4846
4556
  return [point.y - center.y, -1 * (point.x - center.x)];
4847
4557
  }
4558
+ }
4559
+
4560
+ class CircleAxis extends AxisBase {
4561
+ constructor(attributes) {
4562
+ super(vutils.merge({}, CircleAxis.defaultAttributes, attributes));
4563
+ }
4564
+ renderLine(container) {
4565
+ const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line, inside = false } = this.attribute;
4566
+ let arcRadius = radius;
4567
+ let arcInnerRadius = innerRadius;
4568
+ if (inside && innerRadius > 0) {
4569
+ arcRadius = innerRadius;
4570
+ arcInnerRadius = 0;
4571
+ }
4572
+ const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
4573
+ endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line === null || line === void 0 ? void 0 : line.style);
4574
+ const axisLine = vrender.createCircle(arcAttrs);
4575
+ axisLine.name = exports.AXIS_ELEMENT_NAME.line;
4576
+ axisLine.id = this._getNodeId('line');
4577
+ if (!vutils.isEmpty(line === null || line === void 0 ? void 0 : line.state)) {
4578
+ axisLine.states = vutils.merge({}, DEFAULT_STATES$1, line.state);
4579
+ }
4580
+ container.add(axisLine);
4581
+ }
4848
4582
  getTitleAttribute() {
4849
4583
  var _a, _b, _c, _d, _e, _f, _g, _h;
4850
4584
  const { center, radius, innerRadius = 0 } = this.attribute;
@@ -4897,40 +4631,541 @@
4897
4631
  if (background && background.visible) {
4898
4632
  attrs.panel = Object.assign({ visible: true }, background.style);
4899
4633
  }
4900
- return attrs;
4901
- }
4902
- getSubTickLineItems() {
4903
- var _a, _b;
4904
- const { subTick } = this.attribute;
4905
- const subTickLineItems = [];
4906
- const { count: subCount = 4, inside = false, length = 2 } = subTick;
4907
- const tickLineItems = this.tickLineItems;
4908
- const tickLineCount = tickLineItems.length;
4909
- if (tickLineCount >= 2) {
4910
- const tickSegment = this.data[1].value - this.data[0].value;
4911
- const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
4912
- for (let i = 0; i < tickLineCount; i++) {
4913
- const pre = tickLineItems[i];
4914
- const next = tickLineItems[i + 1];
4915
- for (let j = 0; j < subCount; j++) {
4916
- const percent = (j + 1) / (subCount + 1);
4917
- const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
4918
- const point = this.getTickCoord(value);
4919
- const endPoint = this.getVerticalCoord(point, length, inside);
4920
- subTickLineItems.push({
4921
- start: point,
4922
- end: endPoint,
4923
- value
4634
+ return attrs;
4635
+ }
4636
+ getSubTickLineItems() {
4637
+ var _a, _b;
4638
+ const { subTick } = this.attribute;
4639
+ const subTickLineItems = [];
4640
+ const { count: subCount = 4, inside = false, length = 2 } = subTick;
4641
+ const tickLineItems = this.tickLineItems;
4642
+ const tickLineCount = tickLineItems.length;
4643
+ if (tickLineCount >= 2) {
4644
+ const tickSegment = this.data[1].value - this.data[0].value;
4645
+ const isAlignWithLable = (_b = (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.tick) === null || _b === void 0 ? void 0 : _b.alignWithLabel;
4646
+ for (let i = 0; i < tickLineCount; i++) {
4647
+ const pre = tickLineItems[i];
4648
+ const next = tickLineItems[i + 1];
4649
+ for (let j = 0; j < subCount; j++) {
4650
+ const percent = (j + 1) / (subCount + 1);
4651
+ const value = (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);
4652
+ const point = this.getTickCoord(value);
4653
+ const endPoint = this.getVerticalCoord(point, length, inside);
4654
+ subTickLineItems.push({
4655
+ start: point,
4656
+ end: endPoint,
4657
+ value
4658
+ });
4659
+ }
4660
+ }
4661
+ }
4662
+ return subTickLineItems;
4663
+ }
4664
+ getTextBaseline(vector) {
4665
+ let base = 'middle';
4666
+ if (vutils.isNumberClose(vector[1], 0)) {
4667
+ base = 'middle';
4668
+ }
4669
+ else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
4670
+ base = 'top';
4671
+ }
4672
+ else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
4673
+ base = 'bottom';
4674
+ }
4675
+ return base;
4676
+ }
4677
+ beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4678
+ return;
4679
+ }
4680
+ handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4681
+ return;
4682
+ }
4683
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4684
+ return;
4685
+ }
4686
+ getLabelAlign(vector, inside, angle) {
4687
+ return {
4688
+ textAlign: this.getTextAlign(vector),
4689
+ textBaseline: this.getTextBaseline(vector)
4690
+ };
4691
+ }
4692
+ }
4693
+ CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
4694
+ vutils.mixin(CircleAxis, CircleAxisMixin);
4695
+
4696
+ function getElMap(g) {
4697
+ const elMap = {};
4698
+ traverseGroup(g, (el) => {
4699
+ if (el.type !== 'group' && el.id) {
4700
+ elMap[el.id] = el;
4701
+ }
4702
+ });
4703
+ return elMap;
4704
+ }
4705
+ class GroupTransition extends vrender.ACustomAnimate {
4706
+ constructor() {
4707
+ super(...arguments);
4708
+ this.mode = vrender.AnimateMode.NORMAL;
4709
+ }
4710
+ onBind() {
4711
+ const currentInnerView = this.target.getInnerView();
4712
+ const prevInnerView = this.target.getPrevInnerView();
4713
+ if (!prevInnerView) {
4714
+ return;
4715
+ }
4716
+ this._oldElementMap = getElMap(prevInnerView);
4717
+ this._newElementAttrMap = {};
4718
+ traverseGroup(currentInnerView, (el) => {
4719
+ var _a, _b, _c, _d, _e, _f;
4720
+ if (el.type !== 'group' && el.id) {
4721
+ const oldEl = this._oldElementMap[el.id];
4722
+ if (oldEl) {
4723
+ if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
4724
+ const newProps = vutils.cloneDeep(el.attribute);
4725
+ this._newElementAttrMap[el.id] = {
4726
+ state: 'update',
4727
+ node: el,
4728
+ 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 })
4729
+ };
4730
+ el.setAttributes(oldEl.attribute);
4731
+ }
4732
+ }
4733
+ else {
4734
+ const finalOpacityAttrs = {
4735
+ opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
4736
+ fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
4737
+ strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
4738
+ };
4739
+ this._newElementAttrMap[el.id] = {
4740
+ state: 'enter',
4741
+ node: el,
4742
+ attrs: finalOpacityAttrs
4743
+ };
4744
+ el.setAttributes({
4745
+ opacity: 0,
4746
+ fillOpacity: 0,
4747
+ strokeOpacity: 0
4748
+ });
4749
+ }
4750
+ }
4751
+ });
4752
+ }
4753
+ onStart() {
4754
+ let duration = this.duration;
4755
+ let easing = this.easing;
4756
+ Object.keys(this._newElementAttrMap).forEach(id => {
4757
+ var _a, _b, _c, _d, _e, _f, _g;
4758
+ const { node, attrs, state } = this._newElementAttrMap[id];
4759
+ if (state === 'enter') {
4760
+ 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;
4761
+ 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;
4762
+ }
4763
+ if (node.type === 'path') {
4764
+ node
4765
+ .animate({
4766
+ interpolate(key, ratio, from, to, nextAttributes) {
4767
+ if (key === 'path') {
4768
+ nextAttributes.path = vutils.interpolateString(from, to)(ratio);
4769
+ return true;
4770
+ }
4771
+ return false;
4772
+ }
4773
+ })
4774
+ .to(attrs, duration, easing);
4775
+ }
4776
+ else {
4777
+ node
4778
+ .animate()
4779
+ .to(attrs, duration, easing);
4780
+ }
4781
+ });
4782
+ }
4783
+ onUpdate(end, ratio, out) {
4784
+ }
4785
+ }
4786
+
4787
+ class GroupFadeIn extends vrender.ACustomAnimate {
4788
+ constructor(from, to, duration, easing) {
4789
+ super(null, null, duration, easing);
4790
+ }
4791
+ getEndProps() {
4792
+ return {};
4793
+ }
4794
+ onBind() {
4795
+ this.target.setTheme({
4796
+ common: {
4797
+ opacity: 0
4798
+ }
4799
+ });
4800
+ return;
4801
+ }
4802
+ onEnd() {
4803
+ this.target.setTheme({
4804
+ common: {
4805
+ opacity: 1
4806
+ }
4807
+ });
4808
+ return;
4809
+ }
4810
+ onUpdate(end, ratio, out) {
4811
+ this.target.setTheme({
4812
+ common: {
4813
+ opacity: ratio
4814
+ }
4815
+ });
4816
+ }
4817
+ }
4818
+ class GroupFadeOut extends vrender.ACustomAnimate {
4819
+ constructor(from, to, duration, easing) {
4820
+ super(null, null, duration, easing);
4821
+ }
4822
+ getEndProps() {
4823
+ return {};
4824
+ }
4825
+ onBind() {
4826
+ this.target.setTheme({
4827
+ common: {
4828
+ opacity: 1
4829
+ }
4830
+ });
4831
+ return;
4832
+ }
4833
+ onEnd() {
4834
+ this.target.setTheme({
4835
+ common: {
4836
+ opacity: 0
4837
+ }
4838
+ });
4839
+ return;
4840
+ }
4841
+ onUpdate(end, ratio, out) {
4842
+ this.target.setTheme({
4843
+ common: {
4844
+ opacity: 1 - ratio
4845
+ }
4846
+ });
4847
+ }
4848
+ }
4849
+
4850
+ function getLinePath(points, closed) {
4851
+ let path = '';
4852
+ if (points.length === 0) {
4853
+ return path;
4854
+ }
4855
+ points.forEach((point, index) => {
4856
+ if (index === 0) {
4857
+ path = `M${point.x},${point.y}`;
4858
+ }
4859
+ else {
4860
+ path += `L${point.x},${point.y}`;
4861
+ }
4862
+ });
4863
+ if (closed) {
4864
+ path += 'Z';
4865
+ }
4866
+ return path;
4867
+ }
4868
+ function getArcPath(center, points, reverse, closed) {
4869
+ let path = '';
4870
+ if (!center || points.length === 0) {
4871
+ return path;
4872
+ }
4873
+ const firstPoint = points[0];
4874
+ const radius = vutils.PointService.distancePP(center, firstPoint);
4875
+ const sweepFlag = reverse ? 0 : 1;
4876
+ if (closed) {
4877
+ 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`;
4878
+ }
4879
+ else {
4880
+ points.forEach((point, index) => {
4881
+ if (index === 0) {
4882
+ path = `M${point.x},${point.y}`;
4883
+ }
4884
+ else {
4885
+ path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;
4886
+ }
4887
+ });
4888
+ }
4889
+ return path;
4890
+ }
4891
+ function getRegionPath(from, to, attribute) {
4892
+ const { type, closed } = attribute;
4893
+ const reversePoints = to.slice(0).reverse();
4894
+ let regionPath = '';
4895
+ let nextPath = '';
4896
+ if (type === 'line' && attribute.smoothLink && attribute.center) {
4897
+ const fromStart = from[0];
4898
+ const toEnd = reversePoints[0];
4899
+ const center = attribute.center;
4900
+ regionPath = getLinePath(from, !!closed);
4901
+ nextPath = getLinePath(reversePoints, !!closed);
4902
+ const toEndRadius = vutils.PointService.distancePP(toEnd, center);
4903
+ const fromStartRadius = vutils.PointService.distancePP(fromStart, center);
4904
+ regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
4905
+ nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
4906
+ }
4907
+ else if (type === 'circle') {
4908
+ const { center } = attribute;
4909
+ regionPath = getArcPath(center, from, false, !!closed);
4910
+ nextPath = getArcPath(center, reversePoints, true, !!closed);
4911
+ }
4912
+ else if (type === 'line' || type === 'polygon') {
4913
+ regionPath = getLinePath(from, !!closed);
4914
+ nextPath = getLinePath(reversePoints, !!closed);
4915
+ }
4916
+ if (closed) {
4917
+ regionPath += nextPath;
4918
+ }
4919
+ else {
4920
+ nextPath = 'L' + nextPath.substring(1);
4921
+ regionPath += nextPath;
4922
+ regionPath += 'Z';
4923
+ }
4924
+ return regionPath;
4925
+ }
4926
+ class BaseGrid extends AbstractComponent {
4927
+ constructor() {
4928
+ super(...arguments);
4929
+ this.name = 'axis-grid';
4930
+ this.data = [];
4931
+ }
4932
+ getInnerView() {
4933
+ return this._innerView;
4934
+ }
4935
+ getPrevInnerView() {
4936
+ return this._prevInnerView;
4937
+ }
4938
+ render() {
4939
+ this.removeAllChild();
4940
+ this._prevInnerView = this._innerView;
4941
+ this._innerView = vrender.createGroup({ x: 0, y: 0, pickable: false });
4942
+ this.add(this._innerView);
4943
+ const { items, visible } = this.attribute;
4944
+ if (items && items.length && visible !== false) {
4945
+ this.data = this._transformItems(items);
4946
+ this._renderGrid(this._innerView);
4947
+ }
4948
+ }
4949
+ getVerticalCoord(point, offset, inside) {
4950
+ const vector = this.getVerticalVector(offset, inside, point);
4951
+ return {
4952
+ x: point.x + vector[0],
4953
+ y: point.y + vector[1]
4954
+ };
4955
+ }
4956
+ _transformItems(items) {
4957
+ const data = [];
4958
+ items.forEach((item) => {
4959
+ var _a;
4960
+ data.push(Object.assign(Object.assign({}, item), { point: this.getTickCoord(item.value), id: (_a = item.id) !== null && _a !== void 0 ? _a : item.label }));
4961
+ });
4962
+ return data;
4963
+ }
4964
+ _renderGrid(container) {
4965
+ const { visible } = this.attribute.subGrid || {};
4966
+ if (visible) {
4967
+ this._renderGridByType(true, container);
4968
+ }
4969
+ this._renderGridByType(false, container);
4970
+ }
4971
+ _renderGridByType(isSubGrid, container) {
4972
+ const gridAttrs = vutils.merge({}, this.attribute, this.getGridAttribute(isSubGrid));
4973
+ const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;
4974
+ const name = isSubGrid ? `${exports.AXIS_ELEMENT_NAME.grid}-sub` : `${exports.AXIS_ELEMENT_NAME.grid}`;
4975
+ items.forEach((item, index) => {
4976
+ const { id, points } = item;
4977
+ let path = '';
4978
+ if (type === 'line' || type === 'polygon') {
4979
+ path = getLinePath(points, !!closed);
4980
+ }
4981
+ else if (type === 'circle') {
4982
+ const { center } = this.attribute;
4983
+ path = getArcPath(center, points, false, !!closed);
4984
+ }
4985
+ const shape = vrender.createPath(Object.assign({ path, z: depth }, (vutils.isFunction(style) ? vutils.merge({}, BaseGrid.defaultAttributes.style, style(item, index)) : style)));
4986
+ shape.name = `${name}-line`;
4987
+ shape.id = this._getNodeId(`${name}-path-${id}`);
4988
+ container.add(shape);
4989
+ });
4990
+ if (depth && type === 'line') {
4991
+ items.forEach((item, index) => {
4992
+ const { id, points } = item;
4993
+ const nextPoints = [];
4994
+ nextPoints.push(points[0]);
4995
+ const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };
4996
+ const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
4997
+ const ratio = depth / dirLen;
4998
+ nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
4999
+ const path = getLinePath(nextPoints, !!closed);
5000
+ const deltaX = vutils.abs(nextPoints[0].x - nextPoints[1].x);
5001
+ const deltaY = vutils.abs(nextPoints[0].y - nextPoints[1].y);
5002
+ 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)));
5003
+ shape.name = `${name}-line`;
5004
+ shape.id = this._getNodeId(`${name}-path-${id}`);
5005
+ container.add(shape);
5006
+ });
5007
+ }
5008
+ if (items.length > 1 && alternateColor) {
5009
+ const colors = vutils.isArray(alternateColor)
5010
+ ? alternateColor
5011
+ : [alternateColor, 'transparent'];
5012
+ const getColor = (index) => colors[index % colors.length];
5013
+ for (let index = 0; index < items.length - 1; index++) {
5014
+ const [prev, curr] = [items[index].points, items[index + 1].points];
5015
+ const path = getRegionPath(prev, curr, gridAttrs);
5016
+ const shape = vrender.createPath({
5017
+ path,
5018
+ fill: getColor(index)
5019
+ });
5020
+ shape.name = `${name}-region`;
5021
+ shape.id = this._getNodeId(`${name}-region-${index}`);
5022
+ container.add(shape);
5023
+ }
5024
+ }
5025
+ }
5026
+ _getNodeId(id) {
5027
+ return `${this.id}-${id}`;
5028
+ }
5029
+ }
5030
+ BaseGrid.defaultAttributes = {
5031
+ style: {
5032
+ lineWidth: 1,
5033
+ stroke: '#999',
5034
+ strokeOpacity: 1,
5035
+ lineDash: [4, 4]
5036
+ },
5037
+ subGrid: {
5038
+ visible: false,
5039
+ style: {
5040
+ lineWidth: 1,
5041
+ stroke: '#999',
5042
+ strokeOpacity: 1,
5043
+ lineDash: [4, 4]
5044
+ }
5045
+ }
5046
+ };
5047
+
5048
+ function getCirclePoints(center, count, radius, startAngle, endAngle) {
5049
+ const points = [];
5050
+ const range = endAngle - startAngle;
5051
+ for (let i = 0; i < count; i++) {
5052
+ const angle = startAngle + (i * range) / count;
5053
+ points.push(vutils.polarToCartesian(center, radius, angle));
5054
+ }
5055
+ return points;
5056
+ }
5057
+ class LineAxisGrid extends BaseGrid {
5058
+ constructor(attributes, mode) {
5059
+ super(vutils.merge({}, BaseGrid.defaultAttributes, attributes), mode);
5060
+ if (mode === '3d') {
5061
+ this.setMode(mode);
5062
+ }
5063
+ }
5064
+ _getGridPoint(gridType, point) {
5065
+ let gridPoints;
5066
+ if (gridType === 'line') {
5067
+ const { length } = this.attribute;
5068
+ const endPoint = this.getVerticalCoord(point, length, true);
5069
+ gridPoints = [point, endPoint];
5070
+ }
5071
+ else if (gridType === 'circle' || gridType === 'polygon') {
5072
+ const { center, sides = 6, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE } = this.attribute;
5073
+ const distance = vutils.PointService.distancePP(center, point);
5074
+ gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
5075
+ }
5076
+ return gridPoints;
5077
+ }
5078
+ getGridAttribute(isSubGrid) {
5079
+ const { type: gridType, alignWithLabel = true } = this.attribute;
5080
+ let tickSegment = 1;
5081
+ const count = this.data.length;
5082
+ if (count >= 2) {
5083
+ tickSegment = this.data[1].value - this.data[0].value;
5084
+ }
5085
+ let gridAttribute;
5086
+ let items = [];
5087
+ if (!isSubGrid) {
5088
+ gridAttribute = this.attribute;
5089
+ const gridItems = [];
5090
+ this.data.forEach(item => {
5091
+ let { point } = item;
5092
+ if (!alignWithLabel) {
5093
+ const value = item.value - tickSegment / 2;
5094
+ if (this.isInValidValue(value)) {
5095
+ return;
5096
+ }
5097
+ point = this.getTickCoord(value);
5098
+ }
5099
+ gridItems.push({
5100
+ id: item.label,
5101
+ datum: item,
5102
+ points: this._getGridPoint(gridType, point)
5103
+ });
5104
+ });
5105
+ items = gridItems;
5106
+ }
5107
+ else {
5108
+ gridAttribute = vutils.merge({}, this.attribute, this.attribute.subGrid);
5109
+ const subGridItems = [];
5110
+ const { count: subCount = 4 } = this.attribute.subGrid || {};
5111
+ const tickLineCount = this.data.length;
5112
+ if (tickLineCount >= 2) {
5113
+ const points = [];
5114
+ this.data.forEach((item) => {
5115
+ let tickValue = item.value;
5116
+ if (!alignWithLabel) {
5117
+ const value = item.value - tickSegment / 2;
5118
+ if (this.isInValidValue(value)) {
5119
+ return;
5120
+ }
5121
+ tickValue = value;
5122
+ }
5123
+ points.push({
5124
+ value: tickValue
5125
+ });
5126
+ });
5127
+ for (let i = 0; i < points.length - 1; i++) {
5128
+ const pre = points[i];
5129
+ const next = points[i + 1];
5130
+ subGridItems.push({
5131
+ id: `sub-${i}-0`,
5132
+ points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
5133
+ datum: {}
4924
5134
  });
5135
+ for (let j = 0; j < subCount; j++) {
5136
+ const percent = (j + 1) / (subCount + 1);
5137
+ const value = (1 - percent) * pre.value + percent * next.value;
5138
+ const point = this.getTickCoord(value);
5139
+ subGridItems.push({
5140
+ id: `sub-${i}-${j + 1}`,
5141
+ points: this._getGridPoint(gridType, point),
5142
+ datum: {}
5143
+ });
5144
+ }
5145
+ if (i === points.length - 2) {
5146
+ subGridItems.push({
5147
+ id: `sub-${i}-${subCount + 1}`,
5148
+ points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
5149
+ datum: {}
5150
+ });
5151
+ }
4925
5152
  }
5153
+ items = subGridItems;
4926
5154
  }
4927
5155
  }
4928
- return subTickLineItems;
5156
+ return Object.assign(Object.assign({}, gridAttribute), { items });
5157
+ }
5158
+ }
5159
+ vutils.mixin(LineAxisGrid, LineAxisMixin);
5160
+
5161
+ class CircleAxisGrid extends BaseGrid {
5162
+ constructor(attributes) {
5163
+ super(vutils.merge({}, BaseGrid.defaultAttributes, attributes));
4929
5164
  }
4930
- getGridAttribute(type) {
5165
+ getGridAttribute(isSubGrid) {
4931
5166
  let gridAttribute;
4932
5167
  let items = [];
4933
- const { radius, innerRadius = 0, startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, center, grid } = this.attribute;
5168
+ 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"]);
4934
5169
  const { alignWithLabel = true } = grid || {};
4935
5170
  const length = radius - innerRadius;
4936
5171
  let tickSegment = 1;
@@ -4938,8 +5173,8 @@
4938
5173
  if (count >= 2) {
4939
5174
  tickSegment = this.data[1].value - this.data[0].value;
4940
5175
  }
4941
- if (type === 'grid') {
4942
- gridAttribute = this.attribute.grid;
5176
+ if (!isSubGrid) {
5177
+ gridAttribute = grid;
4943
5178
  const gridItems = [];
4944
5179
  let data;
4945
5180
  if (Math.abs(endAngle - startAngle) % (Math.PI * 2) === 0) {
@@ -4967,9 +5202,9 @@
4967
5202
  items = gridItems;
4968
5203
  }
4969
5204
  else {
4970
- gridAttribute = vutils.merge({}, this.attribute.grid, this.attribute.subGrid);
5205
+ gridAttribute = vutils.merge({}, grid, subGrid);
4971
5206
  const subGridItems = [];
4972
- const { count: subCount = 4 } = this.attribute.subTick || {};
5207
+ const { count: subCount = 4 } = subGrid || {};
4973
5208
  const tickLineCount = this.data.length;
4974
5209
  if (tickLineCount >= 2) {
4975
5210
  const points = [];
@@ -5013,192 +5248,10 @@
5013
5248
  }
5014
5249
  }
5015
5250
  return Object.assign(Object.assign({}, gridAttribute), { items,
5016
- center });
5017
- }
5018
- getTextBaseline(vector) {
5019
- let base = 'middle';
5020
- if (vutils.isNumberClose(vector[1], 0)) {
5021
- base = 'middle';
5022
- }
5023
- else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {
5024
- base = 'top';
5025
- }
5026
- else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {
5027
- base = 'bottom';
5028
- }
5029
- return base;
5030
- }
5031
- beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5032
- return;
5033
- }
5034
- handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5035
- return;
5036
- }
5037
- afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
5038
- return;
5039
- }
5040
- getLabelAlign(vector, inside, angle) {
5041
- return {
5042
- textAlign: this.getTextAlign(vector),
5043
- textBaseline: this.getTextBaseline(vector)
5044
- };
5045
- }
5046
- }
5047
- CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
5048
-
5049
- function getElMap(g) {
5050
- const elMap = {};
5051
- traverseGroup(g, (el) => {
5052
- if (el.type !== 'group' && el.id) {
5053
- elMap[el.id] = el;
5054
- }
5055
- });
5056
- return elMap;
5057
- }
5058
- class GroupTransition extends vrender.ACustomAnimate {
5059
- constructor() {
5060
- super(...arguments);
5061
- this.mode = vrender.AnimateMode.NORMAL;
5062
- }
5063
- onBind() {
5064
- const currentInnerView = this.target.getInnerView();
5065
- const prevInnerView = this.target.getPrevInnerView();
5066
- if (!prevInnerView) {
5067
- return;
5068
- }
5069
- this._oldElementMap = getElMap(prevInnerView);
5070
- this._newElementAttrMap = {};
5071
- traverseGroup(currentInnerView, (el) => {
5072
- var _a, _b, _c, _d, _e, _f;
5073
- if (el.type !== 'group' && el.id) {
5074
- const oldEl = this._oldElementMap[el.id];
5075
- if (oldEl) {
5076
- if (!vutils.isEqual(el.attribute, oldEl.attribute)) {
5077
- const newProps = vutils.cloneDeep(el.attribute);
5078
- this._newElementAttrMap[el.id] = {
5079
- state: 'update',
5080
- node: el,
5081
- 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 })
5082
- };
5083
- el.setAttributes(oldEl.attribute);
5084
- }
5085
- }
5086
- else {
5087
- const finalOpacityAttrs = {
5088
- opacity: (_d = el.attribute.opacity) !== null && _d !== void 0 ? _d : 1,
5089
- fillOpacity: (_e = el.attribute.fillOpacity) !== null && _e !== void 0 ? _e : 1,
5090
- strokeOpacity: (_f = el.attribute.strokeOpacity) !== null && _f !== void 0 ? _f : 1
5091
- };
5092
- this._newElementAttrMap[el.id] = {
5093
- state: 'enter',
5094
- node: el,
5095
- attrs: finalOpacityAttrs
5096
- };
5097
- el.setAttributes({
5098
- opacity: 0,
5099
- fillOpacity: 0,
5100
- strokeOpacity: 0
5101
- });
5102
- }
5103
- }
5104
- });
5105
- }
5106
- onStart() {
5107
- let duration = this.duration;
5108
- let easing = this.easing;
5109
- Object.keys(this._newElementAttrMap).forEach(id => {
5110
- var _a, _b, _c;
5111
- const { node, attrs, state } = this._newElementAttrMap[id];
5112
- if (state === 'enter') {
5113
- duration = vutils.isValidNumber((_a = this.params.enter) === null || _a === void 0 ? void 0 : _a.duration) ? this.params.enter.duration : duration;
5114
- 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;
5115
- }
5116
- if (node.type === 'path') {
5117
- node
5118
- .animate({
5119
- interpolate(key, ratio, from, to, nextAttributes) {
5120
- if (key === 'path') {
5121
- nextAttributes.path = vutils.interpolateString(from, to)(ratio);
5122
- return true;
5123
- }
5124
- return false;
5125
- }
5126
- })
5127
- .to(attrs, duration, easing);
5128
- }
5129
- else {
5130
- node
5131
- .animate()
5132
- .to(attrs, duration, easing);
5133
- }
5134
- });
5135
- }
5136
- onUpdate(end, ratio, out) {
5137
- }
5138
- }
5139
-
5140
- class GroupFadeIn extends vrender.ACustomAnimate {
5141
- constructor(from, to, duration, easing) {
5142
- super(null, null, duration, easing);
5143
- }
5144
- getEndProps() {
5145
- return {};
5146
- }
5147
- onBind() {
5148
- this.target.setTheme({
5149
- common: {
5150
- opacity: 0
5151
- }
5152
- });
5153
- return;
5154
- }
5155
- onEnd() {
5156
- this.target.setTheme({
5157
- common: {
5158
- opacity: 1
5159
- }
5160
- });
5161
- return;
5162
- }
5163
- onUpdate(end, ratio, out) {
5164
- this.target.setTheme({
5165
- common: {
5166
- opacity: ratio
5167
- }
5168
- });
5169
- }
5170
- }
5171
- class GroupFadeOut extends vrender.ACustomAnimate {
5172
- constructor(from, to, duration, easing) {
5173
- super(null, null, duration, easing);
5174
- }
5175
- getEndProps() {
5176
- return {};
5177
- }
5178
- onBind() {
5179
- this.target.setTheme({
5180
- common: {
5181
- opacity: 1
5182
- }
5183
- });
5184
- return;
5185
- }
5186
- onEnd() {
5187
- this.target.setTheme({
5188
- common: {
5189
- opacity: 0
5190
- }
5191
- });
5192
- return;
5193
- }
5194
- onUpdate(end, ratio, out) {
5195
- this.target.setTheme({
5196
- common: {
5197
- opacity: 1 - ratio
5198
- }
5199
- });
5251
+ center, type: 'line' });
5200
5252
  }
5201
5253
  }
5254
+ vutils.mixin(CircleAxisGrid, CircleAxisMixin);
5202
5255
 
5203
5256
  var DataZoomActiveTag;
5204
5257
  (function (DataZoomActiveTag) {
@@ -10275,7 +10328,11 @@
10275
10328
  }
10276
10329
  Tooltip.defaultAttributes = defaultAttributes;
10277
10330
 
10278
- const version = "0.14.7";
10331
+ function VTag(params) {
10332
+ return new Tag(params ? params.attribute : {});
10333
+ }
10334
+
10335
+ const version = "0.15.0-alpha.12";
10279
10336
 
10280
10337
  exports.AbstractComponent = AbstractComponent;
10281
10338
  exports.ArcInfo = ArcInfo;
@@ -10283,6 +10340,7 @@
10283
10340
  exports.BasePlayer = BasePlayer;
10284
10341
  exports.Brush = Brush;
10285
10342
  exports.CircleAxis = CircleAxis;
10343
+ exports.CircleAxisGrid = CircleAxisGrid;
10286
10344
  exports.CircleCrosshair = CircleCrosshair;
10287
10345
  exports.ColorContinuousLegend = ColorContinuousLegend;
10288
10346
  exports.ContinuousPlayer = ContinuousPlayer;
@@ -10299,13 +10357,13 @@
10299
10357
  exports.DataZoom = DataZoom;
10300
10358
  exports.DiscreteLegend = DiscreteLegend;
10301
10359
  exports.DiscretePlayer = DiscretePlayer;
10302
- exports.Grid = Grid;
10303
10360
  exports.GroupFadeIn = GroupFadeIn;
10304
10361
  exports.GroupFadeOut = GroupFadeOut;
10305
10362
  exports.GroupTransition = GroupTransition;
10306
10363
  exports.Indicator = Indicator;
10307
10364
  exports.LabelBase = LabelBase;
10308
10365
  exports.LineAxis = LineAxis;
10366
+ exports.LineAxisGrid = LineAxisGrid;
10309
10367
  exports.LineCrosshair = LineCrosshair;
10310
10368
  exports.LineLabel = LineLabel;
10311
10369
  exports.LinkPath = LinkPath;
@@ -10326,6 +10384,7 @@
10326
10384
  exports.Tag = Tag;
10327
10385
  exports.Title = Title;
10328
10386
  exports.Tooltip = Tooltip;
10387
+ exports.VTag = VTag;
10329
10388
  exports.getHorizontalPath = getHorizontalPath;
10330
10389
  exports.getSizeHandlerPath = getSizeHandlerPath;
10331
10390
  exports.getVerticalPath = getVerticalPath;