@visactor/vrender-components 0.20.6-beta.0 → 0.20.6

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 (54) hide show
  1. package/cjs/axis/grid/base.d.ts +1 -0
  2. package/cjs/axis/grid/base.js +9 -3
  3. package/cjs/axis/grid/base.js.map +1 -1
  4. package/cjs/axis/grid/circle.d.ts +1 -0
  5. package/cjs/axis/grid/circle.js +4 -0
  6. package/cjs/axis/grid/circle.js.map +1 -1
  7. package/cjs/axis/grid/line.d.ts +2 -0
  8. package/cjs/axis/grid/line.js +9 -5
  9. package/cjs/axis/grid/line.js.map +1 -1
  10. package/cjs/axis/overlap/auto-hide.js +7 -13
  11. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  12. package/cjs/axis/overlap/util.js +11 -10
  13. package/cjs/axis/overlap/util.js.map +1 -1
  14. package/cjs/brush/brush.js +1 -2
  15. package/cjs/brush/type.js +2 -1
  16. package/cjs/data-zoom/config.js +2 -1
  17. package/cjs/empty-tip/empty-tip.js +1 -2
  18. package/cjs/index.d.ts +1 -1
  19. package/cjs/index.js +1 -1
  20. package/cjs/index.js.map +1 -1
  21. package/cjs/label/arc.js +1 -1
  22. package/cjs/label/arc.js.map +1 -1
  23. package/cjs/label/base.js +18 -29
  24. package/cjs/label/base.js.map +1 -1
  25. package/cjs/legend/discrete/discrete.js +3 -3
  26. package/cjs/legend/discrete/discrete.js.map +1 -1
  27. package/dist/index.es.js +174 -107
  28. package/es/axis/grid/base.d.ts +1 -0
  29. package/es/axis/grid/base.js +8 -4
  30. package/es/axis/grid/base.js.map +1 -1
  31. package/es/axis/grid/circle.d.ts +1 -0
  32. package/es/axis/grid/circle.js +4 -0
  33. package/es/axis/grid/circle.js.map +1 -1
  34. package/es/axis/grid/line.d.ts +2 -0
  35. package/es/axis/grid/line.js +9 -5
  36. package/es/axis/grid/line.js.map +1 -1
  37. package/es/axis/overlap/auto-hide.js +7 -12
  38. package/es/axis/overlap/auto-hide.js.map +1 -1
  39. package/es/axis/overlap/util.js +10 -10
  40. package/es/axis/overlap/util.js.map +1 -1
  41. package/es/brush/brush.js +1 -2
  42. package/es/brush/type.js +2 -1
  43. package/es/data-zoom/config.js +2 -1
  44. package/es/empty-tip/empty-tip.js +1 -2
  45. package/es/index.d.ts +1 -1
  46. package/es/index.js +1 -1
  47. package/es/index.js.map +1 -1
  48. package/es/label/arc.js +1 -1
  49. package/es/label/arc.js.map +1 -1
  50. package/es/label/base.js +18 -29
  51. package/es/label/base.js.map +1 -1
  52. package/es/legend/discrete/discrete.js +3 -3
  53. package/es/legend/discrete/discrete.js.map +1 -1
  54. package/package.json +6 -6
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, isNumberClose, normalizeAngle, flattenArray, cloneDeep, get, isRotateAABBIntersect, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, isNumberClose, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
2
2
  import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  class Generator {
@@ -4466,6 +4466,9 @@ class Graphic extends Node {
4466
4466
  get AABBBounds() {
4467
4467
  return this.tryUpdateAABBBounds("imprecise" === this.attribute.boundsMode);
4468
4468
  }
4469
+ get OBBBounds() {
4470
+ return this.tryUpdateOBBBounds();
4471
+ }
4469
4472
  get globalAABBBounds() {
4470
4473
  return this.tryUpdateGlobalAABBBounds();
4471
4474
  }
@@ -4478,7 +4481,7 @@ class Graphic extends Node {
4478
4481
  constructor() {
4479
4482
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4480
4483
  var _a;
4481
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
4484
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
4482
4485
  }
4483
4486
  setMode(mode) {
4484
4487
  "3d" === mode ? this.set3dMode() : this.set2dMode();
@@ -4512,13 +4515,22 @@ class Graphic extends Node {
4512
4515
  const bounds = this.doUpdateAABBBounds(full);
4513
4516
  return application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0), bounds;
4514
4517
  }
4518
+ tryUpdateOBBBounds() {
4519
+ if (this._OBBBounds || (this._OBBBounds = new OBBBounds()), this.tryUpdateAABBBounds(), this.updateOBBBoundsStamp === this.updateAABBBoundsStamp) return this._OBBBounds;
4520
+ if (this.updateOBBBoundsStamp = this.updateAABBBoundsStamp, !this.valid) return this._OBBBounds.clear(), this._OBBBounds;
4521
+ return this.doUpdateOBBBounds();
4522
+ }
4515
4523
  combindShadowAABBBounds(bounds) {
4516
4524
  if (this.shadowRoot) {
4517
4525
  const b = this.shadowRoot.AABBBounds.clone();
4518
4526
  bounds.union(b);
4519
4527
  }
4520
4528
  }
4529
+ doUpdateOBBBounds() {
4530
+ return this._OBBBounds;
4531
+ }
4521
4532
  doUpdateAABBBounds(full) {
4533
+ this.updateAABBBoundsStamp++;
4522
4534
  const graphicTheme = this.getGraphicTheme();
4523
4535
  this._AABBBounds.clear();
4524
4536
  const attribute = this.attribute,
@@ -5476,6 +5488,7 @@ class Group extends Graphic {
5476
5488
  }), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, groupTheme, !1, this), originalAABBBounds.copy(aabbBounds), originalAABBBounds;
5477
5489
  }
5478
5490
  doUpdateAABBBounds() {
5491
+ this.updateAABBBoundsStamp++;
5479
5492
  const bounds = super.doUpdateAABBBounds();
5480
5493
  return this.parent && this.parent.addChildUpdateBoundTag(), this._emitCustomEvent("AAABBBoundsChange"), bounds;
5481
5494
  }
@@ -9152,7 +9165,10 @@ class InteractiveDrawItemInterceptorContribution {
9152
9165
  }
9153
9166
  beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params) {
9154
9167
  const baseGraphic = graphic.baseGraphic;
9155
- if (!baseGraphic.stage) {
9168
+ let intree = !!baseGraphic.stage,
9169
+ _g = baseGraphic.parent;
9170
+ for (; intree && _g && _g.stage !== _g;) intree = !!_g.stage, _g = _g.parent;
9171
+ if (!intree) {
9156
9172
  const interactiveLayer = drawContext.stage.getLayer("_builtin_interactive");
9157
9173
  if (interactiveLayer) {
9158
9174
  this.getShadowRoot(interactiveLayer).removeChild(graphic);
@@ -9501,6 +9517,35 @@ class Text extends Graphic {
9501
9517
  getGraphicTheme() {
9502
9518
  return getTheme(this).text;
9503
9519
  }
9520
+ doUpdateOBBBounds() {
9521
+ const graphicTheme = this.getGraphicTheme();
9522
+ this._OBBBounds.clear();
9523
+ const attribute = this.attribute,
9524
+ {
9525
+ angle = graphicTheme.angle
9526
+ } = attribute;
9527
+ if (!angle) {
9528
+ const b = this.AABBBounds;
9529
+ return this._OBBBounds.setValue(b.x1, b.y1, b.x2, b.y2), this._OBBBounds;
9530
+ }
9531
+ this.obbText || (this.obbText = new Text({})), this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), {
9532
+ angle: 0
9533
+ }));
9534
+ const bounds1 = this.obbText.AABBBounds,
9535
+ {
9536
+ x: x,
9537
+ y: y
9538
+ } = attribute,
9539
+ boundsCenter = {
9540
+ x: (bounds1.x1 + bounds1.x2) / 2,
9541
+ y: (bounds1.y1 + bounds1.y2) / 2
9542
+ },
9543
+ center = rotatePoint(boundsCenter, angle, {
9544
+ x: x,
9545
+ y: y
9546
+ });
9547
+ return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x, center.y - boundsCenter.y), this._OBBBounds.angle = angle, this._OBBBounds;
9548
+ }
9504
9549
  updateAABBBounds(attribute, textTheme, aabbBounds) {
9505
9550
  const {
9506
9551
  text = textTheme.text
@@ -11933,13 +11978,14 @@ class Arc extends Graphic {
11933
11978
  return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
11934
11979
  }
11935
11980
  toCustomPath() {
11981
+ var _a, _b, _c, _d;
11936
11982
  const attribute = this.attribute,
11937
11983
  {
11938
11984
  startAngle: startAngle,
11939
11985
  endAngle: endAngle
11940
11986
  } = this.getParsedAngle();
11941
- let innerRadius = attribute.innerRadius - (attribute.innerPadding || 0),
11942
- outerRadius = attribute.outerRadius - (attribute.outerPadding || 0);
11987
+ let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
11988
+ outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
11943
11989
  const deltaAngle = abs(endAngle - startAngle),
11944
11990
  clockwise = endAngle > startAngle;
11945
11991
  if (outerRadius < innerRadius) {
@@ -16802,44 +16848,31 @@ class LabelBase extends AbstractComponent {
16802
16848
  const baseMark = this.getRelatedGraphic(label.attribute);
16803
16849
  const backgroundColor = baseMark.attribute.fill;
16804
16850
  const foregroundColor = label.attribute.fill;
16805
- const baseColor = backgroundColor;
16806
16851
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
16807
16852
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
16808
- if (outsideEnable) {
16809
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
16853
+ if (outsideEnable || this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds)) {
16854
+ const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
16810
16855
  fill && label.setAttributes({ fill });
16811
16856
  if (label.attribute.lineWidth === 0) {
16812
16857
  continue;
16813
16858
  }
16814
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
16859
+ const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
16815
16860
  stroke && label.setAttributes({ stroke });
16816
16861
  }
16817
- else {
16818
- const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
16819
- if (isInside) {
16820
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
16821
- fill && label.setAttributes({ fill });
16822
- if (label.attribute.lineWidth === 0) {
16823
- continue;
16824
- }
16825
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
16826
- stroke && label.setAttributes({ stroke });
16862
+ else if (label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds)) {
16863
+ if (label.attribute.lineWidth === 0) {
16864
+ continue;
16827
16865
  }
16828
- else {
16829
- if (label.attribute.lineWidth === 0) {
16830
- continue;
16831
- }
16832
- if (label.attribute.stroke) {
16833
- label.setAttributes({
16834
- fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors, mode)
16835
- });
16836
- continue;
16837
- }
16838
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
16839
- fill && label.setAttributes({ fill });
16840
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
16841
- stroke && label.setAttributes({ stroke });
16866
+ if (label.attribute.stroke) {
16867
+ label.setAttributes({
16868
+ fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors, mode)
16869
+ });
16870
+ continue;
16842
16871
  }
16872
+ const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
16873
+ fill && label.setAttributes({ fill });
16874
+ const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
16875
+ stroke && label.setAttributes({ stroke });
16843
16876
  }
16844
16877
  }
16845
16878
  }
@@ -17315,7 +17348,9 @@ class ArcLabel extends LabelBase {
17315
17348
  const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
17316
17349
  const flag = isQuadrantLeft(quadrant) ? -1 : 1;
17317
17350
  let cx = 0;
17318
- let limit = (flag > 0 ? plotLayout.x2 - pointB.x : pointB.x - plotLayout.x1) - this._line2MinLength - spaceWidth;
17351
+ let limit = (flag > 0 ? plotLayout.x2 - pointB.x + this._alignOffset : pointB.x - plotLayout.x1 - this._alignOffset) -
17352
+ this._line2MinLength -
17353
+ spaceWidth;
17319
17354
  if (labelLayoutAlign === 'labelLine') {
17320
17355
  cx = (radius + line1MinLength + this._line2MinLength) * flag + center.x;
17321
17356
  limit = (flag > 0 ? plotLayout.x2 - cx : cx - plotLayout.x1) - spaceWidth;
@@ -18772,60 +18807,6 @@ class AxisBase extends AbstractComponent {
18772
18807
  }
18773
18808
  }
18774
18809
 
18775
- function rotate(x, y, deg, originX, originY) {
18776
- return {
18777
- x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,
18778
- y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY
18779
- };
18780
- }
18781
- function genNormalBounds(item) {
18782
- const bounds = item.AABBBounds;
18783
- return {
18784
- x1: bounds.x1,
18785
- x2: bounds.x2,
18786
- y1: bounds.y1,
18787
- y2: bounds.y2,
18788
- centerX: item.attribute.x,
18789
- centerY: item.attribute.y,
18790
- angle: item.attribute.angle
18791
- };
18792
- }
18793
- function genRotateBounds(items) {
18794
- items.forEach(item => {
18795
- if (item.rotatedBounds || !item.attribute.angle) {
18796
- return;
18797
- }
18798
- const bounds = genNormalBounds(item);
18799
- const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);
18800
- const deltaX = rotatedCenter.x - bounds.centerX;
18801
- const deltaY = rotatedCenter.y - bounds.centerY;
18802
- bounds.x1 += deltaX;
18803
- bounds.x2 += deltaX;
18804
- bounds.y1 += deltaY;
18805
- bounds.y2 += deltaY;
18806
- bounds.centerX += deltaX;
18807
- bounds.centerY += deltaY;
18808
- item.rotatedBounds = bounds;
18809
- });
18810
- }
18811
- function itemIntersect(item1, item2) {
18812
- return (isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&
18813
- (item1.rotatedBounds && item2.rotatedBounds
18814
- ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)
18815
- : true));
18816
- }
18817
- const DELTA_ANGLE = Math.sin(Math.PI / 10);
18818
- function isAngleVertical(angle) {
18819
- const hasAngle = !isNil(angle) && angle !== 0;
18820
- const cos = hasAngle ? Math.cos(angle) : 1;
18821
- return hasAngle && Math.abs(cos) <= DELTA_ANGLE;
18822
- }
18823
- function isAngleHorizontal(angle) {
18824
- const hasAngle = !isNil(angle) && angle !== 0;
18825
- const sin = hasAngle ? Math.sin(angle) : 0;
18826
- return !hasAngle || Math.abs(sin) <= DELTA_ANGLE;
18827
- }
18828
-
18829
18810
  const methods$1 = {
18830
18811
  parity: function (items) {
18831
18812
  return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));
@@ -18842,13 +18823,14 @@ const methods$1 = {
18842
18823
  }
18843
18824
  };
18844
18825
  function intersect$1(textA, textB, sep) {
18845
- const a = textA.AABBBounds;
18846
- const b = textB.AABBBounds;
18847
- return (sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2) &&
18848
- (textA.rotatedBounds && textB.rotatedBounds
18849
- ? sep >
18850
- Math.max(textB.rotatedBounds.x1 - textA.rotatedBounds.x2, textA.rotatedBounds.x1 - textB.rotatedBounds.x2, textB.rotatedBounds.y1 - textA.rotatedBounds.y2, textA.rotatedBounds.y1 - textB.rotatedBounds.y2)
18851
- : true));
18826
+ let a = textA.OBBBounds;
18827
+ let b = textB.OBBBounds;
18828
+ if (a && b && !a.empty() && !b.empty()) {
18829
+ return a.intersects(b);
18830
+ }
18831
+ a = textA.AABBBounds;
18832
+ b = textB.AABBBounds;
18833
+ return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);
18852
18834
  }
18853
18835
  function hasOverlap$1(items, pad) {
18854
18836
  for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
@@ -18858,8 +18840,14 @@ function hasOverlap$1(items, pad) {
18858
18840
  }
18859
18841
  }
18860
18842
  function hasBounds(item) {
18861
- const b = item.AABBBounds;
18862
- return b.width() > 1 && b.height() > 1;
18843
+ let bounds;
18844
+ if (!item.OBBBounds.empty()) {
18845
+ bounds = item.OBBBounds;
18846
+ }
18847
+ else {
18848
+ bounds = item.AABBBounds;
18849
+ }
18850
+ return bounds.width() > 1 && bounds.height() > 1;
18863
18851
  }
18864
18852
  function reset(items) {
18865
18853
  items.forEach(item => item.setAttribute('opacity', 1));
@@ -18875,7 +18863,6 @@ function autoHide(labels, config) {
18875
18863
  }
18876
18864
  let items;
18877
18865
  items = reset(source);
18878
- genRotateBounds(items);
18879
18866
  const { method = 'parity', separation: sep = 0 } = config;
18880
18867
  const reduce = isFunction(method) ? method : methods$1[method] || methods$1.parity;
18881
18868
  if (items.length >= 3 && hasOverlap$1(items, sep)) {
@@ -18906,6 +18893,61 @@ function autoHide(labels, config) {
18906
18893
  });
18907
18894
  }
18908
18895
 
18896
+ function genNormalBounds(item) {
18897
+ const bounds = item.AABBBounds;
18898
+ return {
18899
+ x1: bounds.x1,
18900
+ x2: bounds.x2,
18901
+ y1: bounds.y1,
18902
+ y2: bounds.y2,
18903
+ centerX: item.attribute.x,
18904
+ centerY: item.attribute.y,
18905
+ angle: item.attribute.angle
18906
+ };
18907
+ }
18908
+ function genRotateBounds(items) {
18909
+ items.forEach(item => {
18910
+ if (item.rotatedBounds || !item.attribute.angle) {
18911
+ return;
18912
+ }
18913
+ const bounds = genNormalBounds(item);
18914
+ const rotatedCenter = rotatePoint({ x: item.attribute.x, y: item.attribute.y }, bounds.angle, {
18915
+ x: bounds.centerX,
18916
+ y: bounds.centerY
18917
+ });
18918
+ const deltaX = rotatedCenter.x - bounds.centerX;
18919
+ const deltaY = rotatedCenter.y - bounds.centerY;
18920
+ bounds.x1 += deltaX;
18921
+ bounds.x2 += deltaX;
18922
+ bounds.y1 += deltaY;
18923
+ bounds.y2 += deltaY;
18924
+ bounds.centerX += deltaX;
18925
+ bounds.centerY += deltaY;
18926
+ item.rotatedBounds = bounds;
18927
+ });
18928
+ }
18929
+ function itemIntersect(item1, item2) {
18930
+ var _a, _b;
18931
+ if (!((_a = item1.OBBBounds) === null || _a === void 0 ? void 0 : _a.empty()) && !((_b = item2.OBBBounds) === null || _b === void 0 ? void 0 : _b.empty())) {
18932
+ return item1.OBBBounds.intersects(item2.OBBBounds);
18933
+ }
18934
+ return (isRectIntersect(item1.AABBBounds, item2.AABBBounds, false) &&
18935
+ (item1.rotatedBounds && item2.rotatedBounds
18936
+ ? isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true)
18937
+ : true));
18938
+ }
18939
+ const DELTA_ANGLE = Math.sin(Math.PI / 10);
18940
+ function isAngleVertical(angle) {
18941
+ const hasAngle = !isNil(angle) && angle !== 0;
18942
+ const cos = hasAngle ? Math.cos(angle) : 1;
18943
+ return hasAngle && Math.abs(cos) <= DELTA_ANGLE;
18944
+ }
18945
+ function isAngleHorizontal(angle) {
18946
+ const hasAngle = !isNil(angle) && angle !== 0;
18947
+ const sin = hasAngle ? Math.sin(angle) : 0;
18948
+ return !hasAngle || Math.abs(sin) <= DELTA_ANGLE;
18949
+ }
18950
+
18909
18951
  function autoRotate(items, rotateConfig) {
18910
18952
  if (isEmpty(items)) {
18911
18953
  return;
@@ -20854,8 +20896,25 @@ class BaseGrid extends AbstractComponent {
20854
20896
  ? alternateColor
20855
20897
  : [alternateColor, 'transparent'];
20856
20898
  const getColor = (index) => colors[index % colors.length];
20857
- for (let index = 0; index < items.length - 1; index++) {
20858
- const [prev, curr] = [items[index].points, items[index + 1].points];
20899
+ const originalItems = this.attribute.items;
20900
+ const firstItem = originalItems[0];
20901
+ const lastItem = originalItems[originalItems.length - 1];
20902
+ const noZero = !isNumberClose(firstItem.value, 0) && !isNumberClose(lastItem.value, 0);
20903
+ const noOne = !isNumberClose(firstItem.value, 1) && !isNumberClose(lastItem.value, 1);
20904
+ const allPoints = [];
20905
+ const isDesc = firstItem.value > lastItem.value;
20906
+ if ((isDesc && noOne) || (!isDesc && noZero)) {
20907
+ allPoints.push(this.getGridPointsByValue(isDesc ? 1 : 0));
20908
+ }
20909
+ items.forEach((item) => {
20910
+ allPoints.push(item.points);
20911
+ });
20912
+ if ((isDesc && noZero) || (!isDesc && noOne)) {
20913
+ allPoints.push(this.getGridPointsByValue(isDesc ? 0 : 1));
20914
+ }
20915
+ for (let index = 0; index < allPoints.length - 1; index++) {
20916
+ const prev = allPoints[index];
20917
+ const curr = allPoints[index + 1];
20859
20918
  const path = getRegionPath(prev, curr, gridAttrs);
20860
20919
  const shape = graphicCreator.path({
20861
20920
  path,
@@ -20941,6 +21000,10 @@ class LineAxisGrid extends BaseGrid {
20941
21000
  }
20942
21001
  return gridPoints;
20943
21002
  }
21003
+ getGridPointsByValue(value) {
21004
+ const basePoint = this.getTickCoord(value);
21005
+ return this._getGridPoint(this.attribute.type, basePoint);
21006
+ }
20944
21007
  getGridAttribute(isSubGrid) {
20945
21008
  const { type: gridType, alignWithLabel = true } = this.attribute;
20946
21009
  const tickSegment = this._parseTickSegment();
@@ -20969,7 +21032,7 @@ class LineAxisGrid extends BaseGrid {
20969
21032
  else {
20970
21033
  gridAttribute = merge({}, this.attribute, this.attribute.subGrid);
20971
21034
  const subGridItems = [];
20972
- const { count: subCount = 4 } = this.attribute.subGrid || {};
21035
+ const { count: subCount = 4 } = gridAttribute;
20973
21036
  const tickLineCount = this.data.length;
20974
21037
  if (tickLineCount >= 2) {
20975
21038
  const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);
@@ -20978,23 +21041,22 @@ class LineAxisGrid extends BaseGrid {
20978
21041
  const next = points[i + 1];
20979
21042
  subGridItems.push({
20980
21043
  id: `sub-${i}-0`,
20981
- points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
21044
+ points: this.getGridPointsByValue(pre.value),
20982
21045
  datum: {}
20983
21046
  });
20984
21047
  for (let j = 0; j < subCount; j++) {
20985
21048
  const percent = (j + 1) / (subCount + 1);
20986
21049
  const value = (1 - percent) * pre.value + percent * next.value;
20987
- const point = this.getTickCoord(value);
20988
21050
  subGridItems.push({
20989
21051
  id: `sub-${i}-${j + 1}`,
20990
- points: this._getGridPoint(gridType, point),
21052
+ points: this.getGridPointsByValue(value),
20991
21053
  datum: {}
20992
21054
  });
20993
21055
  }
20994
21056
  if (i === points.length - 2) {
20995
21057
  subGridItems.push({
20996
21058
  id: `sub-${i}-${subCount + 1}`,
20997
- points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
21059
+ points: this.getGridPointsByValue(next.value),
20998
21060
  datum: {}
20999
21061
  });
21000
21062
  }
@@ -21012,6 +21074,11 @@ class CircleAxisGrid extends BaseGrid {
21012
21074
  constructor(attributes, options) {
21013
21075
  super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, BaseGrid.defaultAttributes, attributes), options);
21014
21076
  }
21077
+ getGridPointsByValue(value) {
21078
+ const basePoint = this.getTickCoord(value);
21079
+ const { radius, innerRadius = 0 } = this.attribute;
21080
+ return [basePoint, this.getVerticalCoord(basePoint, radius - innerRadius, true)];
21081
+ }
21015
21082
  getGridAttribute(isSubGrid) {
21016
21083
  let gridAttribute;
21017
21084
  let items = [];
@@ -24517,7 +24584,7 @@ class DiscreteLegend extends LegendBase {
24517
24584
  let focusSpace = 0;
24518
24585
  if (focus) {
24519
24586
  const focusSize = get(focusIconStyle, 'size', DEFAULT_SHAPE_SIZE);
24520
- focusShape = graphicCreator.symbol(Object.assign(Object.assign({ x: 0, y: -focusSize / 2 - 1, strokeBoundsBuffer: 0 }, focusIconStyle), { visible: true, pickMode: 'imprecise', boundsPadding: parsedPadding }));
24587
+ focusShape = graphicCreator.symbol(Object.assign(Object.assign({ x: 0, y: -focusSize / 2 - 1, strokeBoundsBuffer: 0, boundsPadding: parsedPadding }, focusIconStyle), { visible: true, pickMode: 'imprecise' }));
24521
24588
  this._appendDataToShape(focusShape, LEGEND_ELEMENT_NAME.focus, item, itemGroup);
24522
24589
  focusSpace = focusSize;
24523
24590
  }
@@ -29002,6 +29069,6 @@ EmptyTip.defaultAttributes = {
29002
29069
  }
29003
29070
  };
29004
29071
 
29005
- const version = "0.20.6-beta.0";
29072
+ const version = "0.20.6";
29006
29073
 
29007
29074
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
@@ -19,6 +19,7 @@ export declare abstract class BaseGrid<T extends GridBaseAttributes> extends Abs
19
19
  abstract isInValidValue(value: number): boolean;
20
20
  abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];
21
21
  protected abstract getGridAttribute(isSubGrid: boolean): T;
22
+ protected abstract getGridPointsByValue(value: number): Point[];
22
23
  protected render(): void;
23
24
  protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point;
24
25
  private _transformItems;
@@ -1,4 +1,4 @@
1
- import { isFunction, isArray, merge, PointService, abs, pi } from "@visactor/vutils";
1
+ import { isFunction, isArray, merge, PointService, abs, pi, isNumberClose } from "@visactor/vutils";
2
2
 
3
3
  import { graphicCreator } from "@visactor/vrender-core";
4
4
 
@@ -104,9 +104,13 @@ export class BaseGrid extends AbstractComponent {
104
104
  }, isFunction(style) ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index)) : style));
105
105
  shape.name = `${name}-line`, shape.id = this._getNodeId(`${name}-path-${id}`), container.add(shape);
106
106
  })), items.length > 1 && alternateColor) {
107
- const colors = isArray(alternateColor) ? alternateColor : [ alternateColor, "transparent" ], getColor = index => colors[index % colors.length];
108
- for (let index = 0; index < items.length - 1; index++) {
109
- const [prev, curr] = [ items[index].points, items[index + 1].points ], path = getRegionPath(prev, curr, gridAttrs), shape = graphicCreator.path({
107
+ const colors = isArray(alternateColor) ? alternateColor : [ alternateColor, "transparent" ], getColor = index => colors[index % colors.length], originalItems = this.attribute.items, firstItem = originalItems[0], lastItem = originalItems[originalItems.length - 1], noZero = !isNumberClose(firstItem.value, 0) && !isNumberClose(lastItem.value, 0), noOne = !isNumberClose(firstItem.value, 1) && !isNumberClose(lastItem.value, 1), allPoints = [], isDesc = firstItem.value > lastItem.value;
108
+ (isDesc && noOne || !isDesc && noZero) && allPoints.push(this.getGridPointsByValue(isDesc ? 1 : 0)),
109
+ items.forEach((item => {
110
+ allPoints.push(item.points);
111
+ })), (isDesc && noZero || !isDesc && noOne) && allPoints.push(this.getGridPointsByValue(isDesc ? 0 : 1));
112
+ for (let index = 0; index < allPoints.length - 1; index++) {
113
+ const path = getRegionPath(allPoints[index], allPoints[index + 1], gridAttrs), shape = graphicCreator.path({
110
114
  path: path,
111
115
  fill: getColor(index)
112
116
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/grid/base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAErE,SAAS,UAAU,CAAC,MAAa,EAAE,MAAe,EAAE,OAAgB,EAAE,MAAe;IACnF,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,MAAM,GAAG,YAAY,CAA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ACvC,IAAI,aAAa,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAyB,EAAE,EAAE;gBAC9C,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;gBAC3B,IAAI,CAAC,cAAc,EAAE;oBAEnB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,GAAG,CAAC,CAAC;oBAC3C,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;wBAC9B,OAAO;qBACR;oBACD,SAAS,GAAG,KAAK,CAAC;iBACnB;gBACD,MAAM,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,SAAS;iBACjB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;;AA9MM,0BAAiB,GAAgC;IACtD,KAAK,EAAE;QACL,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getPolygonPath, getVerticalCoord } from '../util';\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getPolygonPath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getPolygonPath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n\n // const regions: any[] = [];\n for (let index = 0; index < items.length - 1; index++) {\n const [prev, curr] = [items[index].points, items[index + 1].points];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n protected _parseTickSegment() {\n let tickSegment = 1;\n const count = this.data.length;\n if (count >= 2) {\n tickSegment = this.data[1].value - this.data[0].value;\n }\n\n return tickSegment;\n }\n\n protected _getPointsOfSubGrid(tickSegment: number, alignWithLabel: boolean) {\n const tickLineCount = this.data.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n const points: { value: number }[] = [];\n if (tickLineCount >= 2) {\n this.data.forEach((item: TransformedAxisItem) => {\n let tickValue = item.value;\n if (!alignWithLabel) {\n // tickLine 不同 tick 对齐时需要调整 point\n const value = item.value - tickSegment / 2;\n if (this.isInValidValue(value)) {\n return;\n }\n tickValue = value;\n }\n points.push({\n value: tickValue\n });\n });\n }\n\n return points;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/grid/base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAA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AM,EAAE,MAAM;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi, isNumberClose } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getPolygonPath, getVerticalCoord } from '../util';\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n protected abstract getGridPointsByValue(value: number): Point[];\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getPolygonPath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getPolygonPath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n const originalItems = this.attribute.items;\n const firstItem = originalItems[0];\n const lastItem = originalItems[originalItems.length - 1];\n const noZero = !isNumberClose(firstItem.value, 0) && !isNumberClose(lastItem.value, 0);\n const noOne = !isNumberClose(firstItem.value, 1) && !isNumberClose(lastItem.value, 1);\n const allPoints = [];\n const isDesc = firstItem.value > lastItem.value;\n\n if ((isDesc && noOne) || (!isDesc && noZero)) {\n allPoints.push(this.getGridPointsByValue(isDesc ? 1 : 0));\n }\n items.forEach((item: any) => {\n allPoints.push(item.points as Point[]);\n });\n\n if ((isDesc && noZero) || (!isDesc && noOne)) {\n allPoints.push(this.getGridPointsByValue(isDesc ? 0 : 1));\n }\n\n for (let index = 0; index < allPoints.length - 1; index++) {\n const prev = allPoints[index];\n const curr = allPoints[index + 1];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n protected _parseTickSegment() {\n let tickSegment = 1;\n const count = this.data.length;\n if (count >= 2) {\n tickSegment = this.data[1].value - this.data[0].value;\n }\n\n return tickSegment;\n }\n\n protected _getPointsOfSubGrid(tickSegment: number, alignWithLabel: boolean) {\n const tickLineCount = this.data.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n const points: { value: number }[] = [];\n if (tickLineCount >= 2) {\n this.data.forEach((item: TransformedAxisItem) => {\n let tickValue = item.value;\n if (!alignWithLabel) {\n // tickLine 不同 tick 对齐时需要调整 point\n const value = item.value - tickSegment / 2;\n if (this.isInValidValue(value)) {\n return;\n }\n tickValue = value;\n }\n points.push({\n value: tickValue\n });\n });\n }\n\n return points;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
@@ -6,5 +6,6 @@ export interface CircleAxisGrid extends Pick<CircleAxisMixin, 'isInValidValue' |
6
6
  }
7
7
  export declare class CircleAxisGrid extends BaseGrid<CircleAxisGridAttributes> {
8
8
  constructor(attributes: CircleAxisGridAttributes, options?: ComponentOptions);
9
+ protected getGridPointsByValue(value: number): import("../..").Point[];
9
10
  protected getGridAttribute(isSubGrid: boolean): any;
10
11
  }
@@ -24,6 +24,10 @@ export class CircleAxisGrid extends BaseGrid {
24
24
  constructor(attributes, options) {
25
25
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, BaseGrid.defaultAttributes, attributes), options);
26
26
  }
27
+ getGridPointsByValue(value) {
28
+ const basePoint = this.getTickCoord(value), {radius: radius, innerRadius: innerRadius = 0} = this.attribute;
29
+ return [ basePoint, this.getVerticalCoord(basePoint, radius - innerRadius, !0) ];
30
+ }
27
31
  getGridAttribute(isSubGrid) {
28
32
  let gridAttribute, items = [];
29
33
  const _a = this.attribute, {radius: radius, innerRadius: innerRadius = 0, startAngle: startAngle = POLAR_START_ANGLE, endAngle: endAngle = POLAR_END_ANGLE, center: center, subGrid: subGrid} = _a, grid = __rest(_a, [ "radius", "innerRadius", "startAngle", "endAngle", "center", "subGrid" ]), {alignWithLabel: alignWithLabel = !0} = grid || {}, length = radius - innerRadius, tickSegment = this._parseTickSegment();