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

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 (70) hide show
  1. package/cjs/axis/index.d.ts +1 -0
  2. package/cjs/axis/index.js +2 -1
  3. package/cjs/axis/index.js.map +1 -1
  4. package/cjs/axis/tick-data/continuous.d.ts +4 -0
  5. package/cjs/axis/tick-data/continuous.js +61 -0
  6. package/cjs/axis/tick-data/continuous.js.map +1 -0
  7. package/cjs/axis/tick-data/discrete/linear.d.ts +6 -0
  8. package/cjs/axis/tick-data/discrete/linear.js +101 -0
  9. package/cjs/axis/tick-data/discrete/linear.js.map +1 -0
  10. package/cjs/axis/tick-data/discrete/polar-angle.d.ts +3 -0
  11. package/cjs/axis/tick-data/discrete/polar-angle.js +53 -0
  12. package/cjs/axis/tick-data/discrete/polar-angle.js.map +1 -0
  13. package/cjs/axis/tick-data/index.d.ts +5 -0
  14. package/cjs/axis/tick-data/index.js +26 -0
  15. package/cjs/axis/tick-data/index.js.map +1 -0
  16. package/cjs/axis/tick-data/util.d.ts +13 -0
  17. package/cjs/axis/tick-data/util.js +91 -0
  18. package/cjs/axis/tick-data/util.js.map +1 -0
  19. package/cjs/axis/type.d.ts +41 -1
  20. package/cjs/axis/type.js.map +1 -1
  21. package/cjs/axis/util.d.ts +11 -0
  22. package/cjs/axis/util.js +21 -2
  23. package/cjs/axis/util.js.map +1 -1
  24. package/cjs/constant.d.ts +2 -2
  25. package/cjs/constant.js +2 -2
  26. package/cjs/constant.js.map +1 -1
  27. package/cjs/index.d.ts +1 -1
  28. package/cjs/index.js +1 -1
  29. package/cjs/index.js.map +1 -1
  30. package/cjs/tag/tag.js +3 -3
  31. package/cjs/tag/tag.js.map +1 -1
  32. package/cjs/util/text.d.ts +1 -1
  33. package/cjs/util/text.js +3 -3
  34. package/cjs/util/text.js.map +1 -1
  35. package/dist/index.es.js +530 -27
  36. package/es/axis/index.d.ts +1 -0
  37. package/es/axis/index.js +2 -0
  38. package/es/axis/index.js.map +1 -1
  39. package/es/axis/tick-data/continuous.d.ts +4 -0
  40. package/es/axis/tick-data/continuous.js +56 -0
  41. package/es/axis/tick-data/continuous.js.map +1 -0
  42. package/es/axis/tick-data/discrete/linear.d.ts +6 -0
  43. package/es/axis/tick-data/discrete/linear.js +90 -0
  44. package/es/axis/tick-data/discrete/linear.js.map +1 -0
  45. package/es/axis/tick-data/discrete/polar-angle.d.ts +3 -0
  46. package/es/axis/tick-data/discrete/polar-angle.js +45 -0
  47. package/es/axis/tick-data/discrete/polar-angle.js.map +1 -0
  48. package/es/axis/tick-data/index.d.ts +5 -0
  49. package/es/axis/tick-data/index.js +21 -0
  50. package/es/axis/tick-data/index.js.map +1 -0
  51. package/es/axis/tick-data/util.d.ts +13 -0
  52. package/es/axis/tick-data/util.js +80 -0
  53. package/es/axis/tick-data/util.js.map +1 -0
  54. package/es/axis/type.d.ts +41 -1
  55. package/es/axis/type.js.map +1 -1
  56. package/es/axis/util.d.ts +11 -0
  57. package/es/axis/util.js +19 -1
  58. package/es/axis/util.js.map +1 -1
  59. package/es/constant.d.ts +2 -2
  60. package/es/constant.js +2 -2
  61. package/es/constant.js.map +1 -1
  62. package/es/index.d.ts +1 -1
  63. package/es/index.js +1 -1
  64. package/es/index.js.map +1 -1
  65. package/es/tag/tag.js +3 -3
  66. package/es/tag/tag.js.map +1 -1
  67. package/es/util/text.d.ts +1 -1
  68. package/es/util/text.js +3 -3
  69. package/es/util/text.js.map +1 -1
  70. package/package.json +6 -6
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, Matrix, Logger, pi2, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, isArray, cos, sin, pi, pointAt, isNumber, getDecimalPlaces, isNil, Color, has, normalTransform, isValidUrl, isBase64, epsilon, acos, sqrt, LRU, clampAngleByRadian, asin, transformBoundsWithMatrix, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, isEmpty, isValid, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian as polarToCartesian$1, array, isValidNumber, calculateAnchorOfBounds, isGreater, isLess, isNumberClose, flattenArray, cloneDeep, get, isRotateAABBIntersect, last, mixin, isEqual, interpolateString, minInArray, polygonContainPoint } from '@visactor/vutils';
2
- import { LinearScale } from '@visactor/vscale';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, Matrix, Logger, pi2, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, isArray, cos, sin, pi, pointAt, isNumber, getDecimalPlaces, isNil, Color, has, normalTransform, isValidUrl, isBase64, epsilon, acos, sqrt, LRU, clampAngleByRadian, asin, transformBoundsWithMatrix, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, isEmpty, isValid, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian as polarToCartesian$1, array, isValidNumber, calculateAnchorOfBounds, isGreater, isLess, isNumberClose, flattenArray, normalizeAngle as normalizeAngle$1, cloneDeep, get, isRotateAABBIntersect, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
2
+ import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  function _toPrimitive(t, r) {
5
5
  if ("object" != typeof t || !t) return t;
@@ -6004,7 +6004,7 @@ function drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, stro
6004
6004
  const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
6005
6005
  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;
6006
6006
  }
6007
- function intersect$1(x0, y0, x1, y1, x2, y2, x3, y3) {
6007
+ function intersect$2(x0, y0, x1, y1, x2, y2, x3, y3) {
6008
6008
  const x10 = x1 - x0,
6009
6009
  y10 = y1 - y0,
6010
6010
  x32 = x3 - x2,
@@ -6083,7 +6083,7 @@ function drawArcPath(arc, context, cx, cy, outerRadius, innerRadius, partStroke)
6083
6083
  yire = innerRadius * sin(innerEndAngle);
6084
6084
  let xore, yore, xirs, yirs;
6085
6085
  if ((maxInnerCornerRadius > epsilon || maxOuterCornerRadius > epsilon) && (xore = outerRadius * cos(outerEndAngle), yore = outerRadius * sin(outerEndAngle), xirs = innerRadius * cos(innerStartAngle), yirs = innerRadius * sin(innerStartAngle), deltaAngle < pi)) {
6086
- const oc = intersect$1(xors, yors, xirs, yirs, xore, yore, xire, yire);
6086
+ const oc = intersect$2(xors, yors, xirs, yirs, xore, yore, xire, yire);
6087
6087
  if (oc) {
6088
6088
  const ax = xors - oc[0],
6089
6089
  ay = yors - oc[1],
@@ -10863,7 +10863,7 @@ let DefaultCanvasArcRender = class DefaultCanvasArcRender extends BaseRender {
10863
10863
  yire = innerRadius * sin(innerEndAngle);
10864
10864
  let xore, yore, xirs, yirs;
10865
10865
  if ((maxInnerCornerRadius > epsilon || maxOuterCornerRadius > epsilon) && (xore = outerRadius * cos(outerEndAngle), yore = outerRadius * sin(outerEndAngle), xirs = innerRadius * cos(innerStartAngle), yirs = innerRadius * sin(innerStartAngle), deltaAngle < pi)) {
10866
- const oc = intersect$1(xors, yors, xirs, yirs, xore, yore, xire, yire);
10866
+ const oc = intersect$2(xors, yors, xirs, yirs, xore, yore, xire, yire);
10867
10867
  if (oc) {
10868
10868
  const ax = xors - oc[0],
10869
10869
  ay = yors - oc[1],
@@ -15155,8 +15155,8 @@ function loadScrollbarComponent() {
15155
15155
 
15156
15156
  const POLAR_START_ANGLE = -0.5 * Math.PI;
15157
15157
  const POLAR_END_ANGLE = 1.5 * Math.PI;
15158
- const DEFAULT_TEXT_FONT_FAMILY = 'PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol';
15159
- const DEFAULT_TEXT_FONT_SIZE = 11;
15158
+ const DEFAULT_TEXT_FONT_FAMILY = 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol';
15159
+ const DEFAULT_TEXT_FONT_SIZE = 14;
15160
15160
  var StateValue;
15161
15161
  (function (StateValue) {
15162
15162
  StateValue["selected"] = "selected";
@@ -15708,11 +15708,8 @@ function angleTo(v1, v2, direct) {
15708
15708
  return Math.PI * 2 - ang;
15709
15709
  }
15710
15710
 
15711
- const initTextMeasure = (textSpec, option, useNaiveCanvas) => {
15712
- return new TextMeasure(Object.assign({ defaultFontParams: {
15713
- fontFamily: DEFAULT_TEXT_FONT_FAMILY,
15714
- fontSize: DEFAULT_TEXT_FONT_SIZE
15715
- }, getTextBounds: useNaiveCanvas ? undefined : getTextBounds, specialCharSet: '-/: .,@%\'"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
15711
+ const initTextMeasure = (textSpec, option, useNaiveCanvas, defaultFontParams) => {
15712
+ return new TextMeasure(Object.assign({ defaultFontParams: Object.assign({ fontFamily: DEFAULT_TEXT_FONT_FAMILY, fontSize: DEFAULT_TEXT_FONT_SIZE }, defaultFontParams), getTextBounds: useNaiveCanvas ? undefined : getTextBounds, specialCharSet: '-/: .,@%\'"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
15716
15713
  };
15717
15714
  function measureTextSize(text, textSpec, defaultTextTheme = {}) {
15718
15715
  if (!text) {
@@ -15910,14 +15907,14 @@ class Tag extends AbstractComponent {
15910
15907
  const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
15911
15908
  const tsWidth = textWidth + symbolPlaceWidth;
15912
15909
  const textX = flag === 1
15913
- ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth
15914
- : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth);
15910
+ ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
15911
+ : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
15915
15912
  textShape.setAttributes({
15916
15913
  x: textX,
15917
- textAlign: 'left'
15914
+ textAlign: 'center'
15918
15915
  });
15919
15916
  if (symbol) {
15920
- const symbolX = textX - symbolPlaceWidth + maxSize / 2;
15917
+ const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
15921
15918
  symbol.setAttributes({
15922
15919
  x: symbolX
15923
15920
  });
@@ -19278,6 +19275,36 @@ function getCircleVerticalVector(offset, point, center, inside = false, axisInsi
19278
19275
  const vector = [point.x - center.x, point.y - center.y];
19279
19276
  return scale(vector, ((inside ? -1 : 1) * (axisInside ? -1 : 1) * offset) / length(vector));
19280
19277
  }
19278
+ function angleLabelOrientAttribute(angle) {
19279
+ let align = 'center';
19280
+ let baseline = 'middle';
19281
+ angle = normalizeAngle$1(angle);
19282
+ if (angle >= Math.PI * (5 / 3) || angle <= Math.PI * (1 / 3)) {
19283
+ align = 'left';
19284
+ }
19285
+ else if (angle >= Math.PI * (2 / 3) && angle <= Math.PI * (4 / 3)) {
19286
+ align = 'right';
19287
+ }
19288
+ else {
19289
+ align = 'center';
19290
+ }
19291
+ if (angle >= Math.PI * (7 / 6) && angle <= Math.PI * (11 / 6)) {
19292
+ baseline = 'bottom';
19293
+ }
19294
+ else if (angle >= Math.PI * (1 / 6) && angle <= Math.PI * (5 / 6)) {
19295
+ baseline = 'top';
19296
+ }
19297
+ else {
19298
+ baseline = 'middle';
19299
+ }
19300
+ return { align, baseline };
19301
+ }
19302
+ function getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside, text, style) {
19303
+ const point = polarToCartesian$1({ x: 0, y: 0 }, radius, angle);
19304
+ const labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));
19305
+ const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);
19306
+ return getCircleLabelPosition(labelPoint, vector, text, style);
19307
+ }
19281
19308
 
19282
19309
  const dispatchHoverState = (e, container, lastHover) => {
19283
19310
  const target = e.target;
@@ -19760,14 +19787,14 @@ function itemIntersect(item1, item2) {
19760
19787
  : true));
19761
19788
  }
19762
19789
 
19763
- const methods = {
19790
+ const methods$1 = {
19764
19791
  parity: function (items) {
19765
19792
  return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));
19766
19793
  },
19767
19794
  greedy: function (items, sep) {
19768
19795
  let a;
19769
19796
  return items.filter((b, i) => {
19770
- if (!i || !intersect(a, b, sep)) {
19797
+ if (!i || !intersect$1(a, b, sep)) {
19771
19798
  a = b;
19772
19799
  return 1;
19773
19800
  }
@@ -19775,7 +19802,7 @@ const methods = {
19775
19802
  });
19776
19803
  }
19777
19804
  };
19778
- function intersect(textA, textB, sep) {
19805
+ function intersect$1(textA, textB, sep) {
19779
19806
  const a = textA.AABBBounds;
19780
19807
  const b = textB.AABBBounds;
19781
19808
  return (sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2) &&
@@ -19784,9 +19811,9 @@ function intersect(textA, textB, sep) {
19784
19811
  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)
19785
19812
  : true));
19786
19813
  }
19787
- function hasOverlap(items, pad) {
19814
+ function hasOverlap$1(items, pad) {
19788
19815
  for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
19789
- if (intersect(a, (b = items[i]), pad)) {
19816
+ if (intersect$1(a, (b = items[i]), pad)) {
19790
19817
  return true;
19791
19818
  }
19792
19819
  }
@@ -19811,11 +19838,11 @@ function autoHide(labels, config) {
19811
19838
  items = reset(source);
19812
19839
  genRotateBounds(items);
19813
19840
  const { method = 'parity', separation: sep = 0 } = config;
19814
- const reduce = isFunction(method) ? method : methods[method] || methods.parity;
19815
- if (items.length >= 3 && hasOverlap(items, sep)) {
19841
+ const reduce = isFunction(method) ? method : methods$1[method] || methods$1.parity;
19842
+ if (items.length >= 3 && hasOverlap$1(items, sep)) {
19816
19843
  do {
19817
19844
  items = reduce(items, sep);
19818
- } while (items.length >= 3 && hasOverlap(items, sep));
19845
+ } while (items.length >= 3 && hasOverlap$1(items, sep));
19819
19846
  const checkLast = items.length < 3 || config.lastVisible;
19820
19847
  if (checkLast) {
19821
19848
  const lastSourceItem = last(source);
@@ -19824,7 +19851,7 @@ function autoHide(labels, config) {
19824
19851
  if (remainLength > 1) {
19825
19852
  lastSourceItem.setAttribute('opacity', 1);
19826
19853
  for (let i = remainLength - 1; i >= 0; i--) {
19827
- if (intersect(items[i], lastSourceItem, sep)) {
19854
+ if (intersect$1(items[i], lastSourceItem, sep)) {
19828
19855
  items[i].setAttribute('opacity', 0);
19829
19856
  }
19830
19857
  else {
@@ -20871,6 +20898,482 @@ class GroupFadeOut extends ACustomAnimate {
20871
20898
  }
20872
20899
  }
20873
20900
 
20901
+ const convertDomainToTickData = (domain) => {
20902
+ const ticks = domain.map((t, index) => {
20903
+ return {
20904
+ index,
20905
+ value: t
20906
+ };
20907
+ });
20908
+ return ticks;
20909
+ };
20910
+ const labelOverlap = (prevLabel, nextLabel, gap = 0) => {
20911
+ const prevBounds = new AABBBounds(prevLabel).expand(gap / 2);
20912
+ const nextBounds = new AABBBounds(nextLabel).expand(gap / 2);
20913
+ return prevBounds.intersects(nextBounds);
20914
+ };
20915
+ function intersect(a, b, sep) {
20916
+ return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);
20917
+ }
20918
+ function hasOverlap(items, pad) {
20919
+ for (let i = 1, n = items.length, a = items[0], b; i < n; a = b, ++i) {
20920
+ b = items[i];
20921
+ if (intersect(a.AABBBounds, b.AABBBounds, pad)) {
20922
+ return true;
20923
+ }
20924
+ }
20925
+ return false;
20926
+ }
20927
+ const MIN_TICK_GAP = 12;
20928
+ const calculateFlushPos = (basePosition, size, rangePosition, otherEnd) => {
20929
+ return rangePosition < basePosition
20930
+ ? Math.max(basePosition - size / 2, rangePosition)
20931
+ : rangePosition > basePosition
20932
+ ? Math.min(basePosition - size / 2, rangePosition - size)
20933
+ : rangePosition < otherEnd
20934
+ ? rangePosition
20935
+ : rangePosition - size;
20936
+ };
20937
+ const getCartesianLabelBounds = (scale, domain, op) => {
20938
+ var _a;
20939
+ const { labelStyle, axisOrientType, labelFlush, labelFormatter, startAngle = 0 } = op;
20940
+ let labelAngle = (_a = labelStyle.angle) !== null && _a !== void 0 ? _a : 0;
20941
+ if (labelStyle.direction === 'vertical') {
20942
+ labelAngle += degreeToRadian(90);
20943
+ }
20944
+ const isHorizontal = ['bottom', 'top'].includes(axisOrientType);
20945
+ const isVertical = ['left', 'right'].includes(axisOrientType);
20946
+ let scaleX = 1;
20947
+ let scaleY = 0;
20948
+ if (isHorizontal) ;
20949
+ else if (isVertical) {
20950
+ scaleX = 0;
20951
+ scaleY = 1;
20952
+ }
20953
+ else if (startAngle) {
20954
+ scaleX = Math.cos(startAngle);
20955
+ scaleY = -Math.sin(startAngle);
20956
+ }
20957
+ const textMeasure = initTextMeasure(labelStyle);
20958
+ const range = scale.range();
20959
+ const labelBoundsList = domain.map((v, i) => {
20960
+ var _a, _b;
20961
+ const str = labelFormatter ? labelFormatter(v) : `${v}`;
20962
+ const { width, height } = textMeasure.quickMeasure(str);
20963
+ const textWidth = Math.max(width, MIN_TICK_GAP);
20964
+ const textHeight = Math.max(height, MIN_TICK_GAP);
20965
+ const pos = scale.scale(v);
20966
+ const baseTextX = scaleX * pos;
20967
+ const baseTextY = scaleY * pos;
20968
+ let textX = baseTextX;
20969
+ let textY = baseTextY;
20970
+ let align;
20971
+ if (labelFlush && isHorizontal && i === 0) {
20972
+ textX = calculateFlushPos(baseTextX, textWidth, range[0], range[range.length - 1]);
20973
+ }
20974
+ else if (labelFlush && isHorizontal && i === domain.length - 1) {
20975
+ textX = calculateFlushPos(baseTextX, textWidth, range[range.length - 1], range[0]);
20976
+ }
20977
+ else {
20978
+ align = (_a = labelStyle.textAlign) !== null && _a !== void 0 ? _a : 'center';
20979
+ }
20980
+ if (align === 'right') {
20981
+ textX -= textWidth;
20982
+ }
20983
+ else if (align === 'center') {
20984
+ textX -= textWidth / 2;
20985
+ }
20986
+ let baseline;
20987
+ if (labelFlush && isVertical && i === 0) {
20988
+ textY = calculateFlushPos(baseTextY, textHeight, range[0], range[range.length - 1]);
20989
+ }
20990
+ else if (labelFlush && isVertical && i === domain.length - 1) {
20991
+ textY = calculateFlushPos(baseTextY, textHeight, range[range.length - 1], range[0]);
20992
+ }
20993
+ else {
20994
+ baseline = (_b = labelStyle.textBaseline) !== null && _b !== void 0 ? _b : 'middle';
20995
+ }
20996
+ if (baseline === 'bottom') {
20997
+ textY -= textHeight;
20998
+ }
20999
+ else if (baseline === 'middle') {
21000
+ textY -= textHeight / 2;
21001
+ }
21002
+ const bounds = new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight);
21003
+ if (labelAngle) {
21004
+ bounds.rotate(labelAngle, baseTextX, baseTextY);
21005
+ }
21006
+ return bounds;
21007
+ });
21008
+ return labelBoundsList;
21009
+ };
21010
+ const getPolarAngleLabelBounds = (scale, domain, op) => {
21011
+ var _a;
21012
+ const { labelStyle, getRadius, labelOffset, labelFormatter, inside } = op;
21013
+ const radius = getRadius === null || getRadius === void 0 ? void 0 : getRadius();
21014
+ const labelAngle = (_a = labelStyle.angle) !== null && _a !== void 0 ? _a : 0;
21015
+ const textMeasure = initTextMeasure(labelStyle);
21016
+ const labelBoundsList = domain.map((v) => {
21017
+ var _a, _b;
21018
+ const str = labelFormatter ? labelFormatter(v) : `${v}`;
21019
+ const { width, height } = textMeasure.quickMeasure(str);
21020
+ const textWidth = Math.max(width, MIN_TICK_GAP);
21021
+ const textHeight = Math.max(height, MIN_TICK_GAP);
21022
+ const angle = scale.scale(v);
21023
+ let textX = 0;
21024
+ let textY = 0;
21025
+ const orient = {
21026
+ align: (_a = labelStyle.textAlign) !== null && _a !== void 0 ? _a : 'center',
21027
+ baseline: (_b = labelStyle.textBaseline) !== null && _b !== void 0 ? _b : 'middle'
21028
+ };
21029
+ const { x, y } = getPolarAngleLabelPosition(angle, { x: 0, y: 0 }, radius, labelOffset, inside, str, labelStyle);
21030
+ textX = x + (orient.align === 'right' ? -textWidth : orient.align === 'center' ? -textWidth / 2 : 0);
21031
+ textY = y + (orient.baseline === 'bottom' ? -textHeight : orient.baseline === 'middle' ? -textHeight / 2 : 0);
21032
+ const bounds = new AABBBounds()
21033
+ .set(textX, textY, textX + textWidth, textY + textHeight)
21034
+ .rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);
21035
+ return bounds;
21036
+ });
21037
+ return labelBoundsList;
21038
+ };
21039
+ const isAxisHorizontal = (axisOrientType) => {
21040
+ return ['bottom', 'top', 'z'].includes(axisOrientType);
21041
+ };
21042
+
21043
+ const DEFAULT_CONTINUOUS_TICK_COUNT = 5;
21044
+ const continuousTicks = (scale, op) => {
21045
+ if (!isContinuous(scale.type)) {
21046
+ return convertDomainToTickData(scale.domain());
21047
+ }
21048
+ const range = scale.range();
21049
+ const rangeSize = Math.abs(range[range.length - 1] - range[0]);
21050
+ if (rangeSize < 2) {
21051
+ return convertDomainToTickData([scale.domain()[0]]);
21052
+ }
21053
+ const { tickCount, forceTickCount, tickStep, noDecimals = false, labelStyle } = op;
21054
+ let scaleTicks;
21055
+ if (isValid(tickStep)) {
21056
+ scaleTicks = scale.stepTicks(tickStep);
21057
+ }
21058
+ else if (isValid(forceTickCount)) {
21059
+ scaleTicks = scale.forceTicks(forceTickCount);
21060
+ }
21061
+ else if (op.tickMode === 'd3') {
21062
+ const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount;
21063
+ scaleTicks = scale.d3Ticks(count !== null && count !== void 0 ? count : DEFAULT_CONTINUOUS_TICK_COUNT, { noDecimals });
21064
+ }
21065
+ else {
21066
+ const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount;
21067
+ scaleTicks = scale.ticks(count !== null && count !== void 0 ? count : DEFAULT_CONTINUOUS_TICK_COUNT, { noDecimals });
21068
+ }
21069
+ if (op.sampling) {
21070
+ if (op.coordinateType === 'cartesian' || (op.coordinateType === 'polar' && op.axisOrientType === 'radius')) {
21071
+ const { labelGap = 4, labelFlush } = op;
21072
+ let items = getCartesianLabelBounds(scale, scaleTicks, op).map((bounds, i) => ({
21073
+ AABBBounds: bounds,
21074
+ value: scaleTicks[i]
21075
+ }));
21076
+ while (items.length >= 3 && hasOverlap(items, labelGap)) {
21077
+ items = methods.parity(items);
21078
+ }
21079
+ const ticks = items.map(item => item.value);
21080
+ if (ticks.length < 3 && labelFlush) {
21081
+ if (ticks.length > 1) {
21082
+ ticks.pop();
21083
+ }
21084
+ if (last(ticks) !== last(scaleTicks)) {
21085
+ ticks.push(last(scaleTicks));
21086
+ }
21087
+ }
21088
+ scaleTicks = ticks;
21089
+ }
21090
+ }
21091
+ return convertDomainToTickData(scaleTicks);
21092
+ };
21093
+ const methods = {
21094
+ parity: function (items) {
21095
+ return items.filter((item, i) => i % 2 === 0);
21096
+ },
21097
+ greedy: function (items, sep) {
21098
+ let a;
21099
+ return items.filter((b, i) => {
21100
+ if (!i || !intersect(a.AABBBounds, b.AABBBounds, sep)) {
21101
+ a = b;
21102
+ return true;
21103
+ }
21104
+ return false;
21105
+ });
21106
+ }
21107
+ };
21108
+
21109
+ const getOneDimensionalLabelBounds = (scale, domain, op, isHorizontal) => {
21110
+ const labelBoundsList = getCartesianLabelBounds(scale, domain, op);
21111
+ return labelBoundsList.map(bounds => {
21112
+ if (isHorizontal) {
21113
+ return [bounds.x1, bounds.x2, bounds.width()];
21114
+ }
21115
+ return [bounds.y1, bounds.y2, bounds.height()];
21116
+ });
21117
+ };
21118
+ const boundsOverlap = (prevBounds, nextBounds, gap = 0) => {
21119
+ return Math.max(prevBounds[0], nextBounds[0]) - gap / 2 <= Math.min(prevBounds[1], nextBounds[1]) + gap / 2;
21120
+ };
21121
+ const boundsDistance = (prevBounds, nextBounds) => {
21122
+ if (prevBounds[1] < nextBounds[0]) {
21123
+ return nextBounds[0] - prevBounds[1];
21124
+ }
21125
+ else if (nextBounds[1] < prevBounds[0]) {
21126
+ return prevBounds[0] - nextBounds[1];
21127
+ }
21128
+ return 0;
21129
+ };
21130
+ const linearDiscreteTicks = (scale, op) => {
21131
+ var _a;
21132
+ const domain = scale.domain();
21133
+ if (!domain.length) {
21134
+ return [];
21135
+ }
21136
+ const { tickCount, forceTickCount, tickStep, labelGap = 4, axisOrientType, labelStyle } = op;
21137
+ const isHorizontal = isAxisHorizontal(axisOrientType);
21138
+ const range = scale.range();
21139
+ const rangeSize = scale.calculateWholeRangeSize();
21140
+ if (rangeSize < 2) {
21141
+ if (op.labelLastVisible) {
21142
+ return convertDomainToTickData([domain[domain.length - 1]]);
21143
+ }
21144
+ return convertDomainToTickData([domain[0]]);
21145
+ }
21146
+ let scaleTicks;
21147
+ if (isValid(tickStep)) {
21148
+ scaleTicks = scale.stepTicks(tickStep);
21149
+ }
21150
+ else if (isValid(forceTickCount)) {
21151
+ scaleTicks = scale.forceTicks(forceTickCount);
21152
+ }
21153
+ else if (isValid(tickCount)) {
21154
+ const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount;
21155
+ scaleTicks = scale.ticks(count);
21156
+ }
21157
+ else if (op.sampling) {
21158
+ const fontSize = ((_a = op.labelStyle.fontSize) !== null && _a !== void 0 ? _a : 12) + 2;
21159
+ const rangeStart = minInArray(range);
21160
+ const rangeEnd = maxInArray(range);
21161
+ if (domain.length <= rangeSize / fontSize) {
21162
+ const incrementUnit = (rangeEnd - rangeStart) / domain.length;
21163
+ const labelBoundsList = getOneDimensionalLabelBounds(scale, domain, op, isHorizontal);
21164
+ const minBoundsLength = Math.min(...labelBoundsList.map(bounds => bounds[2]));
21165
+ const stepResult = getStep$1(domain, labelBoundsList, labelGap, op.labelLastVisible, Math.floor(minBoundsLength / incrementUnit), false);
21166
+ scaleTicks = scale.stepTicks(stepResult.step);
21167
+ if (op.labelLastVisible) {
21168
+ if (stepResult.delCount) {
21169
+ scaleTicks = scaleTicks.slice(0, scaleTicks.length - stepResult.delCount);
21170
+ }
21171
+ scaleTicks.push(domain[domain.length - 1]);
21172
+ }
21173
+ }
21174
+ else {
21175
+ const tempDomain = [domain[0], domain[Math.floor(domain.length / 2)], domain[domain.length - 1]];
21176
+ const tempList = getOneDimensionalLabelBounds(scale, tempDomain, op, isHorizontal);
21177
+ let maxBounds = null;
21178
+ tempList.forEach(current => {
21179
+ if (!maxBounds) {
21180
+ maxBounds = current;
21181
+ return;
21182
+ }
21183
+ if (maxBounds[2] < current[2]) {
21184
+ maxBounds = current;
21185
+ }
21186
+ });
21187
+ const step = rangeEnd - rangeStart - labelGap > 0
21188
+ ? Math.ceil((domain.length * (labelGap + maxBounds[2])) / (rangeEnd - rangeStart - labelGap))
21189
+ : domain.length - 1;
21190
+ scaleTicks = scale.stepTicks(step);
21191
+ if (op.labelLastVisible &&
21192
+ (!scaleTicks.length || scaleTicks[scaleTicks.length - 1] !== domain[domain.length - 1])) {
21193
+ if (scaleTicks.length &&
21194
+ Math.abs(scale.scale(scaleTicks[scaleTicks.length - 1]) - scale.scale(domain[domain.length - 1])) <
21195
+ maxBounds[2]) {
21196
+ scaleTicks = scaleTicks.slice(0, -1);
21197
+ }
21198
+ scaleTicks.push(domain[domain.length - 1]);
21199
+ }
21200
+ }
21201
+ }
21202
+ else {
21203
+ scaleTicks = scale.domain();
21204
+ }
21205
+ return convertDomainToTickData(scaleTicks);
21206
+ };
21207
+ const getStep$1 = (domain, labelBoundsList, labelGap, labelLastVisible, defaultStep, areAllBoundsSame) => {
21208
+ let resultDelCount = 0;
21209
+ let resultStep = 0;
21210
+ let resultTickCount = -1;
21211
+ let minDiff = Number.MAX_VALUE;
21212
+ const validateStep = (step) => {
21213
+ let success = true;
21214
+ let ptr = 0;
21215
+ do {
21216
+ if (ptr + step < domain.length && boundsOverlap(labelBoundsList[ptr], labelBoundsList[ptr + step], labelGap)) {
21217
+ success = false;
21218
+ }
21219
+ ptr += step;
21220
+ } while (success && ptr < domain.length);
21221
+ return success;
21222
+ };
21223
+ const minValidStep = binaryFuzzySearchInNumberRange(defaultStep, domain.length, step => validateStep(step) ? 1 : -1);
21224
+ let step = minValidStep;
21225
+ do {
21226
+ if (step > minValidStep && !areAllBoundsSame) {
21227
+ if (!validateStep(step)) {
21228
+ step++;
21229
+ continue;
21230
+ }
21231
+ }
21232
+ if (labelLastVisible) {
21233
+ const lastIndex = domain.length - 1;
21234
+ let delCount = 0;
21235
+ let ptr;
21236
+ if (domain.length % step > 0) {
21237
+ ptr = domain.length - (domain.length % step) + step;
21238
+ }
21239
+ else {
21240
+ ptr = domain.length;
21241
+ }
21242
+ do {
21243
+ ptr -= step;
21244
+ if (ptr === lastIndex || boundsOverlap(labelBoundsList[ptr], labelBoundsList[lastIndex], labelGap)) {
21245
+ delCount++;
21246
+ }
21247
+ else {
21248
+ break;
21249
+ }
21250
+ } while (ptr > 0);
21251
+ if (ptr === lastIndex) {
21252
+ resultStep = step;
21253
+ resultDelCount = delCount;
21254
+ break;
21255
+ }
21256
+ else {
21257
+ const tickCount = Math.floor(domain.length / step) - delCount + 1;
21258
+ if (tickCount < resultTickCount) {
21259
+ break;
21260
+ }
21261
+ else {
21262
+ resultTickCount = tickCount;
21263
+ const distance1 = boundsDistance(labelBoundsList[ptr], labelBoundsList[lastIndex]);
21264
+ const distance2 = ptr - step >= 0 ? boundsDistance(labelBoundsList[ptr - step], labelBoundsList[ptr]) : distance1;
21265
+ const diff = Math.abs(distance1 - distance2);
21266
+ if (diff < minDiff) {
21267
+ minDiff = diff;
21268
+ resultStep = step;
21269
+ resultDelCount = delCount;
21270
+ }
21271
+ if (distance1 <= distance2) {
21272
+ break;
21273
+ }
21274
+ }
21275
+ }
21276
+ }
21277
+ else {
21278
+ resultStep = step;
21279
+ break;
21280
+ }
21281
+ step++;
21282
+ } while (step <= domain.length);
21283
+ return {
21284
+ step: resultStep,
21285
+ delCount: resultDelCount
21286
+ };
21287
+ };
21288
+
21289
+ const polarAngleAxisDiscreteTicks = (scale, op) => {
21290
+ const { tickCount, forceTickCount, tickStep, getRadius, labelOffset, labelGap = 0, labelStyle } = op;
21291
+ const radius = getRadius === null || getRadius === void 0 ? void 0 : getRadius();
21292
+ if (!radius) {
21293
+ return convertDomainToTickData(scale.domain());
21294
+ }
21295
+ let scaleTicks;
21296
+ if (isValid(tickStep)) {
21297
+ scaleTicks = scale.stepTicks(tickStep);
21298
+ }
21299
+ else if (isValid(forceTickCount)) {
21300
+ scaleTicks = scale.forceTicks(forceTickCount);
21301
+ }
21302
+ else if (isValid(tickCount)) {
21303
+ const range = scale.range();
21304
+ const rangeSize = Math.abs(range[range.length - 1] - range[0]);
21305
+ const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount;
21306
+ scaleTicks = scale.ticks(count);
21307
+ }
21308
+ else if (op.sampling) {
21309
+ const domain = scale.domain();
21310
+ const range = scale.range();
21311
+ const labelBoundsList = getPolarAngleLabelBounds(scale, domain, op);
21312
+ const rangeStart = minInArray(range);
21313
+ const rangeEnd = maxInArray(range);
21314
+ const axisLength = Math.abs(rangeEnd - rangeStart) * (radius + labelOffset);
21315
+ const incrementUnit = axisLength / domain.length;
21316
+ const { step, delCount } = getStep(domain, labelBoundsList, labelGap, Math.floor(labelBoundsList.reduce((min, curBounds) => {
21317
+ return Math.min(min, curBounds.width(), curBounds.height());
21318
+ }, Number.MAX_VALUE) / incrementUnit));
21319
+ scaleTicks = scale.stepTicks(step);
21320
+ scaleTicks = scaleTicks.slice(0, scaleTicks.length - delCount);
21321
+ }
21322
+ else {
21323
+ scaleTicks = scale.domain();
21324
+ }
21325
+ return convertDomainToTickData(scaleTicks);
21326
+ };
21327
+ const getStep = (domain, labelBoundsList, labelGap, defaultStep) => {
21328
+ let step = defaultStep;
21329
+ do {
21330
+ let success = true;
21331
+ step++;
21332
+ let ptr = 0;
21333
+ do {
21334
+ if (ptr + step < domain.length && labelOverlap(labelBoundsList[ptr], labelBoundsList[ptr + step], labelGap)) {
21335
+ success = false;
21336
+ }
21337
+ ptr += step;
21338
+ } while (success && ptr < domain.length);
21339
+ if (success) {
21340
+ break;
21341
+ }
21342
+ } while (step <= domain.length);
21343
+ let delCount = 0;
21344
+ if (domain.length > 2) {
21345
+ let ptr = domain.length - (domain.length % step);
21346
+ if (ptr >= domain.length) {
21347
+ ptr -= step;
21348
+ }
21349
+ while (ptr > 0 && labelOverlap(labelBoundsList[0], labelBoundsList[ptr])) {
21350
+ delCount++;
21351
+ ptr -= step;
21352
+ }
21353
+ }
21354
+ return {
21355
+ step,
21356
+ delCount
21357
+ };
21358
+ };
21359
+
21360
+ const ticks = (scale, op) => {
21361
+ if (isContinuous(scale.type)) {
21362
+ return continuousTicks(scale, op);
21363
+ }
21364
+ else if (isDiscrete(scale.type)) {
21365
+ if (op.coordinateType === 'cartesian') {
21366
+ return linearDiscreteTicks(scale, op);
21367
+ }
21368
+ else if (op.coordinateType === 'polar') {
21369
+ if (op.axisOrientType === 'angle') {
21370
+ return polarAngleAxisDiscreteTicks(scale, op);
21371
+ }
21372
+ }
21373
+ }
21374
+ return convertDomainToTickData(scale.domain());
21375
+ };
21376
+
20874
21377
  function getLinePath(points, closed) {
20875
21378
  let path = '';
20876
21379
  if (points.length === 0) {
@@ -28848,6 +29351,6 @@ Radio.defaultAttributes = {
28848
29351
  }
28849
29352
  };
28850
29353
 
28851
- const version = "0.19.5-alpha.1";
29354
+ const version = "0.19.5";
28852
29355
 
28853
- export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, 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, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, angle, angleTo, clampRadian, contrastAccessibilityChecker, createTextGraphicByType, deltaXYToAngle, direction, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getSizeHandlerPath, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxisCartes, isPostiveXAxisPolar, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, traverseGroup, version };
29356
+ export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, 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, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Title, Tooltip, VTag, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxisCartes, isPostiveXAxisPolar, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
@@ -4,3 +4,4 @@ export * from './type';
4
4
  export * from './animate';
5
5
  export * from './constant';
6
6
  export * from './util';
7
+ export * from './tick-data';