@visactor/vrender-components 0.20.9-alpha.1 → 0.20.9

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 (56) hide show
  1. package/cjs/axis/line.js +3 -2
  2. package/cjs/axis/line.js.map +1 -1
  3. package/cjs/axis/overlap/auto-hide.d.ts +2 -1
  4. package/cjs/axis/overlap/auto-hide.js +26 -24
  5. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  6. package/cjs/axis/tick-data/continuous.js +29 -5
  7. package/cjs/axis/tick-data/continuous.js.map +1 -1
  8. package/cjs/axis/tick-data/util.d.ts +1 -4
  9. package/cjs/axis/tick-data/util.js +2 -13
  10. package/cjs/axis/tick-data/util.js.map +1 -1
  11. package/cjs/axis/type.d.ts +3 -1
  12. package/cjs/axis/type.js.map +1 -1
  13. package/cjs/axis/util.d.ts +3 -1
  14. package/cjs/axis/util.js +15 -2
  15. package/cjs/axis/util.js.map +1 -1
  16. package/cjs/index.d.ts +1 -1
  17. package/cjs/index.js +1 -1
  18. package/cjs/index.js.map +1 -1
  19. package/cjs/label/arc.js +1 -1
  20. package/cjs/label/arc.js.map +1 -1
  21. package/cjs/label/base.js +6 -6
  22. package/cjs/label/base.js.map +1 -1
  23. package/cjs/label/type.d.ts +1 -0
  24. package/cjs/label/type.js.map +1 -1
  25. package/cjs/legend/discrete/discrete.d.ts +1 -0
  26. package/cjs/legend/discrete/discrete.js +13 -10
  27. package/cjs/legend/discrete/discrete.js.map +1 -1
  28. package/dist/index.es.js +148 -83
  29. package/es/axis/line.js +3 -2
  30. package/es/axis/line.js.map +1 -1
  31. package/es/axis/overlap/auto-hide.d.ts +2 -1
  32. package/es/axis/overlap/auto-hide.js +22 -20
  33. package/es/axis/overlap/auto-hide.js.map +1 -1
  34. package/es/axis/tick-data/continuous.js +28 -5
  35. package/es/axis/tick-data/continuous.js.map +1 -1
  36. package/es/axis/tick-data/util.d.ts +1 -4
  37. package/es/axis/tick-data/util.js +0 -10
  38. package/es/axis/tick-data/util.js.map +1 -1
  39. package/es/axis/type.d.ts +3 -1
  40. package/es/axis/type.js.map +1 -1
  41. package/es/axis/util.d.ts +3 -1
  42. package/es/axis/util.js +12 -0
  43. package/es/axis/util.js.map +1 -1
  44. package/es/index.d.ts +1 -1
  45. package/es/index.js +1 -1
  46. package/es/index.js.map +1 -1
  47. package/es/label/arc.js +1 -1
  48. package/es/label/arc.js.map +1 -1
  49. package/es/label/base.js +6 -6
  50. package/es/label/base.js.map +1 -1
  51. package/es/label/type.d.ts +1 -0
  52. package/es/label/type.js.map +1 -1
  53. package/es/legend/discrete/discrete.d.ts +1 -0
  54. package/es/legend/discrete/discrete.js +12 -10
  55. package/es/legend/discrete/discrete.js.map +1 -1
  56. package/package.json +3 -3
package/dist/index.es.js CHANGED
@@ -2318,8 +2318,14 @@ function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter)
2318
2318
  return needTestLetter && (index = testLetter(desc, index)), index;
2319
2319
  }
2320
2320
  function testLetter(string, index) {
2321
+ let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
2321
2322
  let i = index;
2322
- for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return index;
2323
+ for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
2324
+ return i;
2325
+ }
2326
+ function testLetter2(string, index) {
2327
+ let i = index;
2328
+ for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
2323
2329
  return i;
2324
2330
  }
2325
2331
  function measureTextCanvas(text, character) {
@@ -2417,7 +2423,7 @@ let ATextMeasure = class {
2417
2423
  width: length
2418
2424
  };
2419
2425
  }
2420
- clipText(text, options, width, wordBreak) {
2426
+ clipText(text, options, width, wordBreak, keepAllBreak) {
2421
2427
  if (0 === text.length) return {
2422
2428
  str: "",
2423
2429
  width: 0
@@ -2433,8 +2439,8 @@ let ATextMeasure = class {
2433
2439
  };
2434
2440
  const data = this._clipText(text, options, width, 0, text.length - 1, "end", !1);
2435
2441
  if (wordBreak && data.str !== text) {
2436
- const index = testLetter(text, data.str.length);
2437
- index !== data.str.length && (data.str = text.substring(0, index), data.width = this.measureTextWidth(data.str, options));
2442
+ let index = testLetter(text, data.str.length, keepAllBreak);
2443
+ index !== data.str.length && (index > data.str.length && (data.wordBreaked = index, index = data.str.length), data.str = text.substring(0, index), data.width = this.measureTextWidth(data.str, options));
2438
2444
  }
2439
2445
  return data;
2440
2446
  }
@@ -5824,7 +5830,7 @@ function drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, stro
5824
5830
  const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
5825
5831
  return renderCommandList(path.commandList, context, x, y), context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes), doStroke && (strokeCb ? strokeCb(context, graphic.attribute, themeAttributes) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.stroke())), doFill && (fillCb ? fillCb(context, graphic.attribute, themeAttributes) : fVisible && (context.setCommonStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.fill())), !0;
5826
5832
  }
5827
- function intersect$2(x0, y0, x1, y1, x2, y2, x3, y3) {
5833
+ function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
5828
5834
  const x10 = x1 - x0,
5829
5835
  y10 = y1 - y0,
5830
5836
  x32 = x3 - x2,
@@ -5893,7 +5899,7 @@ function calculateArcCornerRadius(arc, startAngle, endAngle, innerRadius, outerR
5893
5899
  yire = innerRadius * sin(innerEndAngle);
5894
5900
  let xore, yore, xirs, yirs;
5895
5901
  if ((maxInnerCornerRadius > epsilon || maxOuterCornerRadius > epsilon) && (xore = outerRadius * cos(outerEndAngle), yore = outerRadius * sin(outerEndAngle), xirs = innerRadius * cos(innerStartAngle), yirs = innerRadius * sin(innerStartAngle), deltaAngle < pi)) {
5896
- const oc = intersect$2(xors, yors, xirs, yirs, xore, yore, xire, yire);
5902
+ const oc = intersect(xors, yors, xirs, yirs, xore, yore, xire, yire);
5897
5903
  if (oc) {
5898
5904
  const ax = xors - oc[0],
5899
5905
  ay = yors - oc[1],
@@ -9613,20 +9619,22 @@ class Text extends Graphic {
9613
9619
  });
9614
9620
  break;
9615
9621
  }
9616
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-word" === wordBreak);
9617
- if ("" !== str && "" === clip.str) {
9622
+ const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
9623
+ if ("" !== str && "" === clip.str || clip.wordBreaked) {
9618
9624
  if (ellipsis) {
9619
9625
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9620
9626
  clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
9621
9627
  } else clip.str = "", clip.width = 0;
9622
9628
  needCut = !1;
9623
9629
  }
9624
- if (linesLayout.push({
9630
+ linesLayout.push({
9625
9631
  str: clip.str,
9626
9632
  width: clip.width
9627
- }), clip.str.length === str.length) ;else if (needCut) {
9628
- const newStr = str.substring(clip.str.length);
9629
- lines.splice(i + 1, 0, newStr);
9633
+ });
9634
+ let cutLength = clip.str.length;
9635
+ if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
9636
+ let newStr = str.substring(cutLength);
9637
+ "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
9630
9638
  }
9631
9639
  }
9632
9640
  let maxWidth = 0;
@@ -16831,7 +16839,7 @@ class LabelBase extends AbstractComponent {
16831
16839
  _smartInvert(labels) {
16832
16840
  var _a, _b, _c, _d, _e;
16833
16841
  const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {});
16834
- const { textType, contrastRatiosThreshold, alternativeColors, mode } = option;
16842
+ const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;
16835
16843
  const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
16836
16844
  const strokeStrategy = (_b = option.strokeStrategy) !== null && _b !== void 0 ? _b : 'base';
16837
16845
  const brightColor = (_c = option.brightColor) !== null && _c !== void 0 ? _c : '#ffffff';
@@ -16850,17 +16858,19 @@ class LabelBase extends AbstractComponent {
16850
16858
  const foregroundColor = label.attribute.fill;
16851
16859
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
16852
16860
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
16853
- if (outsideEnable || this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds)) {
16861
+ const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
16862
+ const isIntersect = !isInside && label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds);
16863
+ if (isInside || outsideEnable || (isIntersect && interactInvertType === 'inside')) {
16854
16864
  const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
16855
16865
  fill && label.setAttributes({ fill });
16856
- if (label.attribute.lineWidth === 0) {
16866
+ if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {
16857
16867
  continue;
16858
16868
  }
16859
16869
  const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
16860
16870
  stroke && label.setAttributes({ stroke });
16861
16871
  }
16862
- else if (label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds)) {
16863
- if (label.attribute.lineWidth === 0) {
16872
+ else if (isIntersect && interactInvertType !== 'none') {
16873
+ if (label.attribute.lineWidth === 0 || label.attribute.strokeOpacity === 0) {
16864
16874
  continue;
16865
16875
  }
16866
16876
  if (label.attribute.stroke) {
@@ -17348,7 +17358,8 @@ class ArcLabel extends LabelBase {
17348
17358
  const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
17349
17359
  const flag = isQuadrantLeft(quadrant) ? -1 : 1;
17350
17360
  let cx = 0;
17351
- let limit = (flag > 0 ? plotLayout.x2 - pointB.x + this._alignOffset : pointB.x - plotLayout.x1 - this._alignOffset) -
17361
+ let limit = (flag > 0 ? plotLayout.x2 - pointB.x : pointB.x - plotLayout.x1) +
17362
+ this._alignOffset -
17352
17363
  this._line2MinLength -
17353
17364
  spaceWidth;
17354
17365
  if (labelLayoutAlign === 'labelLine') {
@@ -18386,6 +18397,25 @@ function getPolygonPath(points, closed) {
18386
18397
  }
18387
18398
  return path;
18388
18399
  }
18400
+ function textIntersect(textA, textB, sep) {
18401
+ let a = textA.OBBBounds;
18402
+ let b = textB.OBBBounds;
18403
+ if (a && b && !a.empty() && !b.empty()) {
18404
+ return a.intersects(b);
18405
+ }
18406
+ a = textA.AABBBounds;
18407
+ b = textB.AABBBounds;
18408
+ return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);
18409
+ }
18410
+ function hasOverlap(items, pad) {
18411
+ for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
18412
+ b = items[i];
18413
+ if (textIntersect(a, b, pad)) {
18414
+ return true;
18415
+ }
18416
+ }
18417
+ return false;
18418
+ }
18389
18419
 
18390
18420
  const dispatchHoverState = (e, container, lastHover) => {
18391
18421
  const target = e.target;
@@ -18814,7 +18844,7 @@ const methods$1 = {
18814
18844
  greedy: function (items, sep) {
18815
18845
  let a;
18816
18846
  return items.filter((b, i) => {
18817
- if (!i || !intersect$1(a, b, sep)) {
18847
+ if (!i || !textIntersect(a, b, sep)) {
18818
18848
  a = b;
18819
18849
  return 1;
18820
18850
  }
@@ -18822,23 +18852,6 @@ const methods$1 = {
18822
18852
  });
18823
18853
  }
18824
18854
  };
18825
- function intersect$1(textA, textB, sep) {
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);
18834
- }
18835
- function hasOverlap$1(items, pad) {
18836
- for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
18837
- if (intersect$1(a, (b = items[i]), pad)) {
18838
- return true;
18839
- }
18840
- }
18841
- }
18842
18855
  function hasBounds(item) {
18843
18856
  let bounds;
18844
18857
  if (!item.OBBBounds.empty()) {
@@ -18853,6 +18866,23 @@ function reset(items) {
18853
18866
  items.forEach(item => item.setAttribute('opacity', 1));
18854
18867
  return items;
18855
18868
  }
18869
+ function forceItemVisible$1(sourceItem, items, check, comparator, inverse = false) {
18870
+ if (check && !sourceItem.attribute.opacity) {
18871
+ const remainLength = items.length;
18872
+ if (remainLength > 1) {
18873
+ sourceItem.setAttribute('opacity', 1);
18874
+ for (let i = 0; i < remainLength; i++) {
18875
+ const item = inverse ? items[remainLength - 1 - i] : items[i];
18876
+ if (comparator(item)) {
18877
+ item.setAttribute('opacity', 0);
18878
+ }
18879
+ else {
18880
+ break;
18881
+ }
18882
+ }
18883
+ }
18884
+ }
18885
+ }
18856
18886
  function autoHide(labels, config) {
18857
18887
  if (isEmpty(labels)) {
18858
18888
  return;
@@ -18865,28 +18895,22 @@ function autoHide(labels, config) {
18865
18895
  items = reset(source);
18866
18896
  const { method = 'parity', separation: sep = 0 } = config;
18867
18897
  const reduce = isFunction(method) ? method : methods$1[method] || methods$1.parity;
18868
- if (items.length >= 3 && hasOverlap$1(items, sep)) {
18898
+ if (items.length >= 3 && hasOverlap(items, sep)) {
18869
18899
  do {
18870
18900
  items = reduce(items, sep);
18871
- } while (items.length >= 3 && hasOverlap$1(items, sep));
18872
- const checkLast = items.length < 3 || config.lastVisible;
18873
- if (checkLast) {
18874
- const lastSourceItem = last(source);
18875
- if (!lastSourceItem.attribute.opacity) {
18876
- const remainLength = items.length;
18877
- if (remainLength > 1) {
18878
- lastSourceItem.setAttribute('opacity', 1);
18879
- for (let i = remainLength - 1; i >= 0; i--) {
18880
- if (intersect$1(items[i], lastSourceItem, sep)) {
18881
- items[i].setAttribute('opacity', 0);
18882
- }
18883
- else {
18884
- break;
18885
- }
18886
- }
18887
- }
18888
- }
18889
- }
18901
+ } while (items.length >= 3 && hasOverlap(items, sep));
18902
+ const shouldCheck = (length, visibility) => length < 3 || visibility;
18903
+ const checkFirst = shouldCheck(items.length, config.firstVisible);
18904
+ let checkLast = shouldCheck(items.length, config.lastVisible);
18905
+ const firstSourceItem = source[0];
18906
+ const lastSourceItem = last(source);
18907
+ if (textIntersect(firstSourceItem, lastSourceItem, sep)) {
18908
+ lastSourceItem.setAttribute('opacity', 0);
18909
+ checkLast = false;
18910
+ }
18911
+ forceItemVisible$1(firstSourceItem, items, checkFirst, (item) => textIntersect(item, firstSourceItem, sep));
18912
+ forceItemVisible$1(lastSourceItem, items, checkLast, (item) => textIntersect(item, lastSourceItem, sep) ||
18913
+ (checkFirst && item !== firstSourceItem ? textIntersect(item, firstSourceItem, sep) : false), true);
18890
18914
  }
18891
18915
  source.forEach(item => {
18892
18916
  item.setAttribute('visible', !!item.attribute.opacity);
@@ -19682,7 +19706,7 @@ class LineAxis extends AxisBase {
19682
19706
  }
19683
19707
  const { verticalLimitSize, label, orient } = this.attribute;
19684
19708
  const limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount);
19685
- const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation, lastVisible, autoWrap: autoWrap$1, overflowLimitLength } = label;
19709
+ const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation, lastVisible, firstVisible, autoWrap: autoWrap$1, overflowLimitLength } = label;
19686
19710
  if (isFunction(layoutFunc)) {
19687
19711
  layoutFunc(labelShapes, labelData, layer, this);
19688
19712
  }
@@ -19724,7 +19748,8 @@ class LineAxis extends AxisBase {
19724
19748
  orient,
19725
19749
  method: autoHideMethod,
19726
19750
  separation: autoHideSeparation,
19727
- lastVisible
19751
+ lastVisible,
19752
+ firstVisible
19728
19753
  });
19729
19754
  }
19730
19755
  }
@@ -20202,18 +20227,6 @@ const labelOverlap = (prevLabel, nextLabel, gap = 0) => {
20202
20227
  const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);
20203
20228
  return prevBounds.intersects(nextBounds);
20204
20229
  };
20205
- function intersect(a, b, sep) {
20206
- return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);
20207
- }
20208
- function hasOverlap(items, pad) {
20209
- for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
20210
- b = items[i];
20211
- if (intersect(a.AABBBounds, b.AABBBounds, pad)) {
20212
- return true;
20213
- }
20214
- }
20215
- return false;
20216
- }
20217
20230
  const MIN_TICK_GAP = 12;
20218
20231
  const calculateFlushPos = (basePosition, size, rangePosition, otherEnd) => {
20219
20232
  return rangePosition < basePosition
@@ -20324,6 +20337,30 @@ function getScaleTicks(op, scale, count, getTicks) {
20324
20337
  }
20325
20338
  return scaleTicks;
20326
20339
  }
20340
+ function forceItemVisible(sourceItem, items, check, comparator, inverse = false) {
20341
+ if (check && !items.includes(sourceItem)) {
20342
+ let remainLength = items.length;
20343
+ if (remainLength > 1) {
20344
+ if (inverse) {
20345
+ items.push(sourceItem);
20346
+ }
20347
+ else {
20348
+ items.unshift(sourceItem);
20349
+ }
20350
+ for (let i = 0; i < remainLength; i++) {
20351
+ const index = inverse ? remainLength - 1 - i : i;
20352
+ if (comparator(items[index])) {
20353
+ items.splice(index, 1);
20354
+ i--;
20355
+ remainLength--;
20356
+ }
20357
+ else {
20358
+ break;
20359
+ }
20360
+ }
20361
+ }
20362
+ }
20363
+ }
20327
20364
  const DEFAULT_CONTINUOUS_TICK_COUNT = 5;
20328
20365
  const continuousTicks = (scale, op) => {
20329
20366
  var _a, _b;
@@ -20367,17 +20404,41 @@ const continuousTicks = (scale, op) => {
20367
20404
  return scale.ticks(count, { noDecimals, customTicks });
20368
20405
  });
20369
20406
  }
20370
- if (op.sampling) {
20407
+ const domain = scale.domain();
20408
+ if (op.labelFirstVisible && domain[0] !== scaleTicks[0] && !scaleTicks.includes(domain[0])) {
20409
+ scaleTicks.unshift(domain[0]);
20410
+ }
20411
+ if (op.labelLastVisible &&
20412
+ domain[domain.length - 1] !== scaleTicks[scaleTicks.length - 1] &&
20413
+ !scaleTicks.includes(domain[domain.length - 1])) {
20414
+ scaleTicks.push(domain[domain.length - 1]);
20415
+ }
20416
+ if (op.sampling && scaleTicks.length > 1) {
20371
20417
  if (op.coordinateType === 'cartesian' || (op.coordinateType === 'polar' && op.axisOrientType === 'radius')) {
20372
20418
  const { labelGap = 4, labelFlush } = op;
20373
20419
  let items = getCartesianLabelBounds(scale, scaleTicks, op).map((bounds, i) => ({
20374
20420
  AABBBounds: bounds,
20375
20421
  value: scaleTicks[i]
20376
20422
  }));
20423
+ const source = [...items];
20424
+ const firstSourceItem = source[0];
20425
+ const lastSourceItem = last(source);
20377
20426
  const samplingMethod = breakData && breakData() ? methods.greedy : methods.parity;
20378
20427
  while (items.length >= 3 && hasOverlap(items, labelGap)) {
20379
20428
  items = samplingMethod(items, labelGap);
20380
20429
  }
20430
+ const shouldCheck = (length, visibility) => length < 3 || visibility;
20431
+ const checkFirst = shouldCheck(items.length, op.labelFirstVisible);
20432
+ let checkLast = shouldCheck(items.length, op.labelLastVisible);
20433
+ if (textIntersect(firstSourceItem, lastSourceItem, labelGap)) {
20434
+ if (items.includes(lastSourceItem) && items.length > 1) {
20435
+ items.splice(items.indexOf(lastSourceItem), 1);
20436
+ checkLast = false;
20437
+ }
20438
+ }
20439
+ forceItemVisible(firstSourceItem, items, checkFirst, (item) => textIntersect(item, firstSourceItem, labelGap));
20440
+ forceItemVisible(lastSourceItem, items, checkLast, (item) => textIntersect(item, lastSourceItem, labelGap) ||
20441
+ (checkFirst && item !== firstSourceItem ? textIntersect(item, firstSourceItem, labelGap) : false), true);
20381
20442
  const ticks = items.map(item => item.value);
20382
20443
  if (ticks.length < 3 && labelFlush) {
20383
20444
  if (ticks.length > 1) {
@@ -20399,7 +20460,7 @@ const methods = {
20399
20460
  greedy: function (items, sep) {
20400
20461
  let a;
20401
20462
  return items.filter((b, i) => {
20402
- if (!i || !intersect(a.AABBBounds, b.AABBBounds, sep)) {
20463
+ if (!i || !textIntersect(a, b, sep)) {
20403
20464
  a = b;
20404
20465
  return true;
20405
20466
  }
@@ -24619,11 +24680,11 @@ class DiscreteLegend extends LegendBase {
24619
24680
  });
24620
24681
  }
24621
24682
  else {
24622
- valueShape.setAttribute('x', valueSpace + (labelShape.AABBBounds.empty() ? 0 : labelShape.AABBBounds.x2));
24683
+ valueShape.setAttribute('x', labelSpace + (labelShape.AABBBounds.empty() ? 0 : labelShape.AABBBounds.x2));
24623
24684
  }
24624
24685
  }
24625
24686
  else {
24626
- valueShape.setAttribute('x', valueSpace + (labelShape.AABBBounds.empty() ? 0 : labelShape.AABBBounds.x2));
24687
+ valueShape.setAttribute('x', labelSpace + (labelShape.AABBBounds.empty() ? 0 : labelShape.AABBBounds.x2));
24627
24688
  }
24628
24689
  focusStartX = valueSpace + (valueShape.AABBBounds.empty() ? 0 : valueShape.AABBBounds.x2);
24629
24690
  innerGroup.add(valueShape);
@@ -24695,8 +24756,8 @@ class DiscreteLegend extends LegendBase {
24695
24756
  ? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: 12 }, compStyle), { width: compSize }))
24696
24757
  : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
24697
24758
  }
24698
- _updatePositionOfPager(contentWidth, contentHeight, renderStartY, compWidth, compHeight) {
24699
- const { maxHeight, pager } = this.attribute;
24759
+ _updatePositionOfPager(renderStartY, compWidth, compHeight) {
24760
+ const { pager } = this.attribute;
24700
24761
  const { totalPage, isHorizontal } = this._itemContext;
24701
24762
  const position = (pager && pager.position) || 'middle';
24702
24763
  this._pagerComponent.setTotal(totalPage);
@@ -24712,7 +24773,7 @@ class DiscreteLegend extends LegendBase {
24712
24773
  y = renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
24713
24774
  }
24714
24775
  this._pagerComponent.setAttributes({
24715
- x: contentWidth,
24776
+ x: compWidth - this._pagerComponent.AABBBounds.width(),
24716
24777
  y
24717
24778
  });
24718
24779
  }
@@ -24729,7 +24790,7 @@ class DiscreteLegend extends LegendBase {
24729
24790
  }
24730
24791
  this._pagerComponent.setAttributes({
24731
24792
  x,
24732
- y: maxHeight - this._pagerComponent.AABBBounds.height()
24793
+ y: compHeight - this._pagerComponent.AABBBounds.height()
24733
24794
  });
24734
24795
  }
24735
24796
  }
@@ -24777,7 +24838,6 @@ class DiscreteLegend extends LegendBase {
24777
24838
  return e.detail.current;
24778
24839
  };
24779
24840
  const onScroll = (e) => {
24780
- e.nativeEvent.preventDefault();
24781
24841
  const scrollComponent = this._pagerComponent;
24782
24842
  const preScrollRange = scrollComponent.getScrollRange();
24783
24843
  const { direction } = scrollComponent.attribute;
@@ -24811,6 +24871,7 @@ class DiscreteLegend extends LegendBase {
24811
24871
  this._pagerComponent.addEventListener('scrollUp', onPaging);
24812
24872
  if (this.attribute.pager.roamScroll) {
24813
24873
  const THROTTLE_TIME = 50;
24874
+ this.addEventListener('wheel', (e) => e.nativeEvent.preventDefault());
24814
24875
  this.addEventListener('wheel', throttle(onScroll, THROTTLE_TIME));
24815
24876
  }
24816
24877
  }
@@ -24865,7 +24926,7 @@ class DiscreteLegend extends LegendBase {
24865
24926
  this._itemContext.pages = pages;
24866
24927
  const total = Math.ceil(pages / maxRow);
24867
24928
  this._itemContext.totalPage = total;
24868
- this._updatePositionOfPager(contentWidth, contentHeight, renderStartY, compWidth, compHeight);
24929
+ this._updatePositionOfPager(renderStartY, compWidth, compHeight);
24869
24930
  }
24870
24931
  else {
24871
24932
  compWidth = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol;
@@ -24896,7 +24957,7 @@ class DiscreteLegend extends LegendBase {
24896
24957
  });
24897
24958
  const total = Math.ceil(pages / maxCol);
24898
24959
  this._itemContext.totalPage = total;
24899
- this._updatePositionOfPager(contentWidth, contentHeight, renderStartY, compWidth, compHeight);
24960
+ this._updatePositionOfPager(renderStartY, compWidth, compHeight);
24900
24961
  }
24901
24962
  if (defaultCurrent > 1) {
24902
24963
  if (isHorizontal) {
@@ -25134,6 +25195,10 @@ class DiscreteLegend extends LegendBase {
25134
25195
  }
25135
25196
  return newConfig;
25136
25197
  }
25198
+ release() {
25199
+ super.release();
25200
+ this.removeAllEventListeners();
25201
+ }
25137
25202
  }
25138
25203
  DiscreteLegend.defaultAttributes = {
25139
25204
  layout: 'horizontal',
@@ -29091,6 +29156,6 @@ EmptyTip.defaultAttributes = {
29091
29156
  }
29092
29157
  };
29093
29158
 
29094
- const version = "0.20.9-alpha.1";
29159
+ const version = "0.20.9";
29095
29160
 
29096
- 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 };
29161
+ 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, hasOverlap, 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, textIntersect, ticks, traverseGroup, version };
package/es/axis/line.js CHANGED
@@ -252,7 +252,7 @@ export class LineAxis extends AxisBase {
252
252
  }
253
253
  handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
254
254
  if (isEmpty(labelShapes)) return;
255
- const {verticalLimitSize: verticalLimitSize, label: label, orient: orient} = this.attribute, limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount), {layoutFunc: layoutFunc, autoRotate: autoRotate, autoRotateAngle: autoRotateAngle, autoLimit: autoLimit, limitEllipsis: limitEllipsis, autoHide: autoHide, autoHideMethod: autoHideMethod, autoHideSeparation: autoHideSeparation, lastVisible: lastVisible, autoWrap: autoWrap, overflowLimitLength: overflowLimitLength} = label;
255
+ const {verticalLimitSize: verticalLimitSize, label: label, orient: orient} = this.attribute, limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount), {layoutFunc: layoutFunc, autoRotate: autoRotate, autoRotateAngle: autoRotateAngle, autoLimit: autoLimit, limitEllipsis: limitEllipsis, autoHide: autoHide, autoHideMethod: autoHideMethod, autoHideSeparation: autoHideSeparation, lastVisible: lastVisible, firstVisible: firstVisible, autoWrap: autoWrap, overflowLimitLength: overflowLimitLength} = label;
256
256
  if (isFunction(layoutFunc)) layoutFunc(labelShapes, labelData, layer, this); else {
257
257
  if (autoRotate) autoRotateFunc(labelShapes, {
258
258
  labelRotateAngle: autoRotateAngle,
@@ -281,7 +281,8 @@ export class LineAxis extends AxisBase {
281
281
  orient: orient,
282
282
  method: autoHideMethod,
283
283
  separation: autoHideSeparation,
284
- lastVisible: lastVisible
284
+ lastVisible: lastVisible,
285
+ firstVisible: firstVisible
285
286
  });
286
287
  }
287
288
  }