@visactor/vrender-components 0.21.0-alpha.1 → 0.21.0-alpha.10

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 (134) hide show
  1. package/cjs/axis/circle.js +3 -3
  2. package/cjs/axis/circle.js.map +1 -1
  3. package/cjs/axis/overlap/auto-hide.js +2 -2
  4. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  5. package/cjs/axis/overlap/auto-limit.js +7 -9
  6. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  7. package/cjs/axis/overlap/auto-wrap.js +21 -8
  8. package/cjs/axis/overlap/auto-wrap.js.map +1 -1
  9. package/cjs/axis/tick-data/continuous.js +3 -3
  10. package/cjs/axis/tick-data/continuous.js.map +1 -1
  11. package/cjs/axis/type.d.ts +6 -2
  12. package/cjs/axis/type.js.map +1 -1
  13. package/cjs/data-zoom/type.d.ts +1 -1
  14. package/cjs/data-zoom/type.js.map +1 -1
  15. package/cjs/index.d.ts +1 -1
  16. package/cjs/index.js +1 -1
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/indicator/index.js +1 -1
  19. package/cjs/indicator/indicator.js +1 -1
  20. package/cjs/indicator/register.js +1 -1
  21. package/cjs/indicator/type.js +1 -1
  22. package/cjs/interface.js.map +1 -1
  23. package/cjs/label/arc.js +3 -2
  24. package/cjs/label/arc.js.map +1 -1
  25. package/cjs/label/base.d.ts +4 -2
  26. package/cjs/label/base.js +48 -11
  27. package/cjs/label/base.js.map +1 -1
  28. package/cjs/label/line.js +1 -2
  29. package/cjs/label/overlap/place.d.ts +6 -1
  30. package/cjs/label/overlap/place.js +7 -5
  31. package/cjs/label/overlap/place.js.map +1 -1
  32. package/cjs/label/overlap/scaler.d.ts +6 -0
  33. package/cjs/label/overlap/scaler.js +16 -14
  34. package/cjs/label/overlap/scaler.js.map +1 -1
  35. package/cjs/label/overlap/shiftY.d.ts +9 -0
  36. package/cjs/label/overlap/shiftY.js +101 -0
  37. package/cjs/label/overlap/shiftY.js.map +1 -0
  38. package/cjs/label/register.js +1 -1
  39. package/cjs/label/symbol.js +1 -1
  40. package/cjs/label/type.d.ts +8 -1
  41. package/cjs/label/type.js +1 -1
  42. package/cjs/label/type.js.map +1 -1
  43. package/cjs/label/util.js +1 -1
  44. package/cjs/legend/base.d.ts +1 -0
  45. package/cjs/legend/base.js +7 -6
  46. package/cjs/legend/base.js.map +1 -1
  47. package/cjs/legend/color/type.d.ts +2 -2
  48. package/cjs/legend/color/type.js.map +1 -1
  49. package/cjs/legend/discrete/discrete.d.ts +8 -0
  50. package/cjs/legend/discrete/discrete.js +122 -32
  51. package/cjs/legend/discrete/discrete.js.map +1 -1
  52. package/cjs/legend/discrete/type.d.ts +16 -4
  53. package/cjs/legend/discrete/type.js.map +1 -1
  54. package/cjs/marker/type.d.ts +2 -2
  55. package/cjs/marker/type.js.map +1 -1
  56. package/cjs/player/type/discrete-player.d.ts +3 -3
  57. package/cjs/player/type/discrete-player.js.map +1 -1
  58. package/cjs/player/type/index.d.ts +2 -2
  59. package/cjs/player/type/index.js.map +1 -1
  60. package/cjs/scrollbar/index.d.ts +1 -0
  61. package/cjs/scrollbar/index.js +2 -1
  62. package/cjs/scrollbar/index.js.map +1 -1
  63. package/cjs/scrollbar/scrollbar-plugin.d.ts +18 -15
  64. package/cjs/scrollbar/scrollbar-plugin.js +109 -97
  65. package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
  66. package/cjs/timeline/type.js.map +1 -1
  67. package/dist/index.es.js +1425 -664
  68. package/es/axis/circle.js +3 -3
  69. package/es/axis/circle.js.map +1 -1
  70. package/es/axis/overlap/auto-hide.js +2 -2
  71. package/es/axis/overlap/auto-hide.js.map +1 -1
  72. package/es/axis/overlap/auto-limit.js +5 -8
  73. package/es/axis/overlap/auto-limit.js.map +1 -1
  74. package/es/axis/overlap/auto-wrap.js +20 -8
  75. package/es/axis/overlap/auto-wrap.js.map +1 -1
  76. package/es/axis/tick-data/continuous.js +3 -3
  77. package/es/axis/tick-data/continuous.js.map +1 -1
  78. package/es/axis/type.d.ts +6 -2
  79. package/es/axis/type.js.map +1 -1
  80. package/es/data-zoom/type.d.ts +1 -1
  81. package/es/data-zoom/type.js.map +1 -1
  82. package/es/index.d.ts +1 -1
  83. package/es/index.js +1 -1
  84. package/es/index.js.map +1 -1
  85. package/es/indicator/index.js +1 -1
  86. package/es/indicator/indicator.js +1 -1
  87. package/es/indicator/register.js +1 -1
  88. package/es/indicator/type.js +1 -1
  89. package/es/interface.js.map +1 -1
  90. package/es/label/arc.js +3 -2
  91. package/es/label/arc.js.map +1 -1
  92. package/es/label/base.d.ts +4 -2
  93. package/es/label/base.js +48 -8
  94. package/es/label/base.js.map +1 -1
  95. package/es/label/line.js +1 -2
  96. package/es/label/overlap/place.d.ts +6 -1
  97. package/es/label/overlap/place.js +8 -6
  98. package/es/label/overlap/place.js.map +1 -1
  99. package/es/label/overlap/scaler.d.ts +6 -0
  100. package/es/label/overlap/scaler.js +11 -10
  101. package/es/label/overlap/scaler.js.map +1 -1
  102. package/es/label/overlap/shiftY.d.ts +9 -0
  103. package/es/label/overlap/shiftY.js +94 -0
  104. package/es/label/overlap/shiftY.js.map +1 -0
  105. package/es/label/register.js +1 -1
  106. package/es/label/symbol.js +1 -1
  107. package/es/label/type.d.ts +8 -1
  108. package/es/label/type.js +1 -1
  109. package/es/label/type.js.map +1 -1
  110. package/es/label/util.js +1 -1
  111. package/es/legend/base.d.ts +1 -0
  112. package/es/legend/base.js +7 -5
  113. package/es/legend/base.js.map +1 -1
  114. package/es/legend/color/type.d.ts +2 -2
  115. package/es/legend/color/type.js.map +1 -1
  116. package/es/legend/discrete/discrete.d.ts +8 -0
  117. package/es/legend/discrete/discrete.js +122 -33
  118. package/es/legend/discrete/discrete.js.map +1 -1
  119. package/es/legend/discrete/type.d.ts +16 -4
  120. package/es/legend/discrete/type.js.map +1 -1
  121. package/es/marker/type.d.ts +2 -2
  122. package/es/marker/type.js.map +1 -1
  123. package/es/player/type/discrete-player.d.ts +3 -3
  124. package/es/player/type/discrete-player.js.map +1 -1
  125. package/es/player/type/index.d.ts +2 -2
  126. package/es/player/type/index.js.map +1 -1
  127. package/es/scrollbar/index.d.ts +1 -0
  128. package/es/scrollbar/index.js +2 -0
  129. package/es/scrollbar/index.js.map +1 -1
  130. package/es/scrollbar/scrollbar-plugin.d.ts +18 -15
  131. package/es/scrollbar/scrollbar-plugin.js +111 -94
  132. package/es/scrollbar/scrollbar-plugin.js.map +1 -1
  133. package/es/timeline/type.js.map +1 -1
  134. package/package.json +10 -9
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, 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';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isNumberClose, 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, 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 {
@@ -745,6 +745,11 @@ let DefaultGlobal = class {
745
745
  };
746
746
  DefaultGlobal = __decorate$P([injectable(), __param$z(0, inject(ContributionProvider)), __param$z(0, named(EnvContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGlobal);
747
747
 
748
+ var MeasureModeEnum;
749
+ !function (MeasureModeEnum) {
750
+ MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
751
+ }(MeasureModeEnum || (MeasureModeEnum = {}));
752
+
748
753
  const circleThreshold = tau - 1e-8;
749
754
  class BoundsContext {
750
755
  constructor(bounds) {
@@ -860,11 +865,12 @@ function parseSvgPath(str) {
860
865
  for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
861
866
  for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
862
867
  if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
863
- let subCommand;
868
+ let subCommand,
869
+ bestCommandChar = commandChar;
864
870
  for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
865
- subCommand = [commandChar];
871
+ subCommand = [bestCommandChar];
866
872
  for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
867
- result.push(subCommand);
873
+ result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
868
874
  }
869
875
  } else result.push(currCommandData);
870
876
  } else result.push(currCommandData);
@@ -2008,6 +2014,7 @@ const DefaultStrokeStyle = Object.assign({
2008
2014
  const DefaultTextStyle = {
2009
2015
  text: "",
2010
2016
  maxLineWidth: 1 / 0,
2017
+ maxWidth: 1 / 0,
2011
2018
  textAlign: "left",
2012
2019
  textBaseline: "alphabetic",
2013
2020
  fontSize: 16,
@@ -2031,7 +2038,8 @@ const DefaultTextStyle = {
2031
2038
  suffixPosition: "end",
2032
2039
  underlineDash: [],
2033
2040
  underlineOffset: 0,
2034
- disableAutoClipedPoptip: void 0
2041
+ disableAutoClipedPoptip: void 0,
2042
+ measureMode: MeasureModeEnum.fontBounding
2035
2043
  };
2036
2044
  const DefaultPickStyle = {
2037
2045
  pickStrokeBuffer: 0
@@ -2075,6 +2083,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
2075
2083
  zIndex: 0,
2076
2084
  layout: null,
2077
2085
  boundsPadding: 0,
2086
+ fillStrokeOrder: 0,
2078
2087
  renderStyle: "default",
2079
2088
  pickMode: "accurate",
2080
2089
  customPickShape: null,
@@ -2084,7 +2093,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
2084
2093
  globalZIndex: 1,
2085
2094
  globalCompositeOperation: "",
2086
2095
  overflow: "hidden",
2087
- shadowPickMode: "graphic"
2096
+ shadowPickMode: "graphic",
2097
+ keepStrokeScale: !1
2088
2098
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
2089
2099
  const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
2090
2100
  startAngle: 0,
@@ -2145,6 +2155,7 @@ const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, Defau
2145
2155
  });
2146
2156
  const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
2147
2157
  path: new CustomPath2D(),
2158
+ fillStrokeOrder: 1,
2148
2159
  customPath: () => {
2149
2160
  Logger.getInstance().warn("空函数");
2150
2161
  }
@@ -2350,10 +2361,32 @@ let ATextMeasure = class {
2350
2361
  configure(service, env) {
2351
2362
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
2352
2363
  }
2353
- measureTextWidth(text, options) {
2354
- if (!this.context) return this.estimate(text, options).width;
2364
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
2355
2365
  this.context.setTextStyleWithoutAlignBaseline(options);
2356
- return this.context.measureText(text).width;
2366
+ const metrics = this.context.measureText(text);
2367
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
2368
+ }
2369
+ _measureTextWithAlignBaseline(text, options, compatible) {
2370
+ this.context.setTextStyle(options);
2371
+ const metrics = this.context.measureText(text);
2372
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
2373
+ }
2374
+ compatibleMetrics(metrics, options) {
2375
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
2376
+ const {
2377
+ ascent: ascent,
2378
+ descent: descent
2379
+ } = this.measureTextBoundADscentEstimate(options);
2380
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
2381
+ }
2382
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
2383
+ const {
2384
+ left: left,
2385
+ right: right
2386
+ } = this.measureTextBoundLeftRightEstimate(options);
2387
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
2388
+ }
2389
+ return metrics;
2357
2390
  }
2358
2391
  estimate(text, _ref) {
2359
2392
  let {
@@ -2367,19 +2400,97 @@ let ATextMeasure = class {
2367
2400
  height: fontSize
2368
2401
  };
2369
2402
  }
2370
- measureTextPixelHeight(text, options) {
2403
+ measureTextWidth(text, options, textMeasure) {
2404
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
2405
+ }
2406
+ measureTextBoundsWidth(text, options, textMeasure) {
2407
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
2408
+ }
2409
+ measureTextBoundsLeftRight(text, options, textMeasure) {
2410
+ return this.context ? {
2411
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
2412
+ right: textMeasure.actualBoundingBoxRight
2413
+ } : this.measureTextBoundLeftRightEstimate(options);
2414
+ }
2415
+ measureTextPixelHeight(text, options, textMeasure) {
2371
2416
  var _a;
2372
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2373
- this.context.setTextStyleWithoutAlignBaseline(options);
2374
- const textMeasure = this.context.measureText(text);
2375
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
2417
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2376
2418
  }
2377
- measureTextBoundHieght(text, options) {
2419
+ measureTextPixelADscent(text, options, textMeasure) {
2420
+ return this.context ? {
2421
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
2422
+ descent: textMeasure.actualBoundingBoxDescent
2423
+ } : this.measureTextBoundADscentEstimate(options);
2424
+ }
2425
+ measureTextBoundHieght(text, options, textMeasure) {
2378
2426
  var _a;
2379
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2380
- this.context.setTextStyleWithoutAlignBaseline(options);
2381
- const textMeasure = this.context.measureText(text);
2382
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
2427
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2428
+ }
2429
+ measureTextBoundADscent(text, options, textMeasure) {
2430
+ return this.context ? {
2431
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
2432
+ descent: textMeasure.fontBoundingBoxDescent
2433
+ } : this.measureTextBoundADscentEstimate(options);
2434
+ }
2435
+ measureTextBoundADscentEstimate(options) {
2436
+ var _a;
2437
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2438
+ return {
2439
+ ascent: .79 * fontSize,
2440
+ descent: .21 * fontSize
2441
+ };
2442
+ }
2443
+ measureTextBoundLeftRightEstimate(options) {
2444
+ var _a;
2445
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
2446
+ {
2447
+ textAlign: textAlign
2448
+ } = options;
2449
+ return "center" === textAlign ? {
2450
+ left: fontSize / 2,
2451
+ right: fontSize / 2
2452
+ } : "right" === textAlign || "end" === textAlign ? {
2453
+ left: fontSize,
2454
+ right: 0
2455
+ } : {
2456
+ left: 0,
2457
+ right: fontSize
2458
+ };
2459
+ }
2460
+ measureTextPixelADscentAndWidth(text, options, mode) {
2461
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
2462
+ width: this.estimate(text, options).width
2463
+ });
2464
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
2465
+ if (mode === MeasureModeEnum.actualBounding) return {
2466
+ ascent: out.actualBoundingBoxAscent,
2467
+ descent: out.actualBoundingBoxDescent,
2468
+ width: out.width
2469
+ };
2470
+ if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
2471
+ width: out.width
2472
+ });
2473
+ if (mode === MeasureModeEnum.fontBounding) {
2474
+ let ascent = out.fontBoundingBoxAscent,
2475
+ descent = out.fontBoundingBoxDescent;
2476
+ if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
2477
+ const delta = out.actualBoundingBoxDescent - descent;
2478
+ descent += delta, ascent -= delta;
2479
+ } else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
2480
+ const delta = out.actualBoundingBoxAscent - ascent;
2481
+ ascent += delta, descent -= delta;
2482
+ }
2483
+ return {
2484
+ ascent: ascent,
2485
+ descent: descent,
2486
+ width: out.width
2487
+ };
2488
+ }
2489
+ return {
2490
+ ascent: out.actualBoundingBoxAscent,
2491
+ descent: out.actualBoundingBoxDescent,
2492
+ width: out.width
2493
+ };
2383
2494
  }
2384
2495
  measureText(text, options) {
2385
2496
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -2457,6 +2568,14 @@ let ATextMeasure = class {
2457
2568
  return data;
2458
2569
  }
2459
2570
  _clipTextEnd(text, options, width, leftIdx, rightIdx) {
2571
+ if (leftIdx === rightIdx) {
2572
+ Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
2573
+ const subText = text.substring(0, rightIdx + 1);
2574
+ return {
2575
+ str: subText,
2576
+ width: this.measureTextWidth(subText, options)
2577
+ };
2578
+ }
2460
2579
  const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
2461
2580
  subText = text.substring(0, middleIdx + 1),
2462
2581
  strWidth = this.measureTextWidth(subText, options);
@@ -2490,7 +2609,7 @@ let ATextMeasure = class {
2490
2609
  }
2491
2610
  _clipTextStart(text, options, width, leftIdx, rightIdx) {
2492
2611
  const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
2493
- subText = text.substring(middleIdx - 1, text.length - 1),
2612
+ subText = text.substring(middleIdx - 1, text.length),
2494
2613
  strWidth = this.measureTextWidth(subText, options);
2495
2614
  let length;
2496
2615
  if (strWidth > width) {
@@ -2498,18 +2617,18 @@ let ATextMeasure = class {
2498
2617
  str: "",
2499
2618
  width: 0
2500
2619
  };
2501
- const str = text.substring(middleIdx, text.length - 1);
2620
+ const str = text.substring(middleIdx, text.length);
2502
2621
  return length = this.measureTextWidth(str, options), length <= width ? {
2503
2622
  str: str,
2504
2623
  width: length
2505
- } : this._clipTextStart(text, options, width, middleIdx, text.length - 1);
2624
+ } : this._clipTextStart(text, options, width, middleIdx, text.length);
2506
2625
  }
2507
2626
  if (strWidth < width) {
2508
2627
  if (middleIdx <= 0) return {
2509
2628
  str: text,
2510
2629
  width: this.measureTextWidth(text, options)
2511
2630
  };
2512
- const str = text.substring(middleIdx - 2, text.length - 1);
2631
+ const str = text.substring(middleIdx - 2, text.length);
2513
2632
  return length = this.measureTextWidth(str, options), length >= width ? {
2514
2633
  str: subText,
2515
2634
  width: strWidth
@@ -2817,7 +2936,7 @@ let DefaultWindow = class {
2817
2936
  }
2818
2937
  hasSubView() {
2819
2938
  const viewBox = this._handler.getViewBox();
2820
- return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width === viewBox.width() && this.height === viewBox.height());
2939
+ return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
2821
2940
  }
2822
2941
  isVisible(bbox) {
2823
2942
  return this._handler.isVisible(bbox);
@@ -6025,9 +6144,6 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
6025
6144
  const TextRenderContribution = Symbol.for("TextRenderContribution");
6026
6145
  const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
6027
6146
 
6028
- function textDrawOffsetY(baseline, h) {
6029
- return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
6030
- }
6031
6147
  function textDrawOffsetX(textAlign, width) {
6032
6148
  return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
6033
6149
  }
@@ -7016,7 +7132,8 @@ class DefaultArcRenderContribution {
7016
7132
  x: originX = arcAttribute.x,
7017
7133
  y: originY = arcAttribute.y,
7018
7134
  scaleX = arcAttribute.scaleX,
7019
- scaleY = arcAttribute.scaleY
7135
+ scaleY = arcAttribute.scaleY,
7136
+ keepStrokeScale = arcAttribute.keepStrokeScale
7020
7137
  } = arc.attribute;
7021
7138
  let {
7022
7139
  innerRadius = arcAttribute.innerRadius,
@@ -7028,7 +7145,7 @@ class DefaultArcRenderContribution {
7028
7145
  {
7029
7146
  distance = arcAttribute[key].distance
7030
7147
  } = borderStyle,
7031
- d = getScaledStroke(context, distance, context.dpr),
7148
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7032
7149
  deltaAngle = distance / outerRadius,
7033
7150
  sign = "outerBorder" === key ? 1 : -1;
7034
7151
  if (arc.setAttributes({
@@ -7073,14 +7190,15 @@ class DefaultCircleRenderContribution {
7073
7190
  x: originX = circleAttribute.x,
7074
7191
  y: originY = circleAttribute.y,
7075
7192
  scaleX = circleAttribute.scaleX,
7076
- scaleY = circleAttribute.scaleY
7193
+ scaleY = circleAttribute.scaleY,
7194
+ keepStrokeScale = circleAttribute.keepStrokeScale
7077
7195
  } = circle.attribute,
7078
7196
  renderBorder = (borderStyle, key) => {
7079
7197
  const doStroke = !(!borderStyle || !borderStyle.stroke),
7080
7198
  {
7081
7199
  distance = circleAttribute[key].distance
7082
7200
  } = borderStyle,
7083
- d = getScaledStroke(context, distance, context.dpr),
7201
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7084
7202
  sign = "outerBorder" === key ? 1 : -1;
7085
7203
  if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
7086
7204
  const lastOpacity = circleAttribute[key].opacity;
@@ -7199,7 +7317,8 @@ class DefaultRectRenderContribution {
7199
7317
  scaleX = rectAttribute.scaleX,
7200
7318
  scaleY = rectAttribute.scaleY,
7201
7319
  x1: x1,
7202
- y1: y1
7320
+ y1: y1,
7321
+ keepStrokeScale = rectAttribute.keepStrokeScale
7203
7322
  } = rect.attribute;
7204
7323
  let {
7205
7324
  width: width,
@@ -7212,7 +7331,7 @@ class DefaultRectRenderContribution {
7212
7331
  {
7213
7332
  distance = rectAttribute[key].distance
7214
7333
  } = borderStyle,
7215
- d = getScaledStroke(context, distance, context.dpr),
7334
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7216
7335
  nextX = x + sign * d,
7217
7336
  nextY = y + sign * d,
7218
7337
  dw = 2 * d;
@@ -7369,14 +7488,15 @@ class DefaultSymbolRenderContribution {
7369
7488
  x: originX = symbolAttribute.x,
7370
7489
  y: originY = symbolAttribute.y,
7371
7490
  scaleX = symbolAttribute.scaleX,
7372
- scaleY = symbolAttribute.scaleY
7491
+ scaleY = symbolAttribute.scaleY,
7492
+ keepStrokeScale = symbolAttribute.keepStrokeScale
7373
7493
  } = symbol.attribute,
7374
7494
  renderBorder = (borderStyle, key) => {
7375
7495
  const doStroke = !(!borderStyle || !borderStyle.stroke),
7376
7496
  {
7377
7497
  distance = symbolAttribute[key].distance
7378
7498
  } = borderStyle,
7379
- d = getScaledStroke(context, distance, context.dpr),
7499
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7380
7500
  sign = "outerBorder" === key ? 1 : -1;
7381
7501
  if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
7382
7502
  const lastOpacity = symbolAttribute[key].opacity;
@@ -7497,7 +7617,8 @@ let DefaultCanvasArcRender = class extends BaseRender {
7497
7617
  fill = arcAttribute.fill,
7498
7618
  stroke = arcAttribute.stroke,
7499
7619
  x: originX = arcAttribute.x,
7500
- y: originY = arcAttribute.y
7620
+ y: originY = arcAttribute.y,
7621
+ fillStrokeOrder = arcAttribute.fillStrokeOrder
7501
7622
  } = arc.attribute,
7502
7623
  data = this.valid(arc, arcAttribute, fillCb, strokeCb);
7503
7624
  if (!data) return;
@@ -7533,7 +7654,17 @@ let DefaultCanvasArcRender = class extends BaseRender {
7533
7654
  isFullStroke: isFullStroke,
7534
7655
  stroke: arrayStroke
7535
7656
  } = parseStroke(stroke);
7536
- if ((doFill || isFullStroke) && (context.beginPath(), drawArcPath(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill())), doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()))), !isFullStroke && doStroke) {
7657
+ if (doFill || isFullStroke) {
7658
+ context.beginPath(), drawArcPath(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
7659
+ const _runFill = () => {
7660
+ doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
7661
+ },
7662
+ _runStroke = () => {
7663
+ doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()));
7664
+ };
7665
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
7666
+ }
7667
+ if (!isFullStroke && doStroke) {
7537
7668
  context.beginPath();
7538
7669
  drawArcPath(arc, context, x, y, outerRadius, innerRadius, arrayStroke);
7539
7670
  beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke());
@@ -7551,14 +7682,20 @@ let DefaultCanvasArcRender = class extends BaseRender {
7551
7682
  fill = arcAttribute.fill
7552
7683
  } = arc.attribute,
7553
7684
  startAngle = endAngle;
7554
- if (this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill) {
7555
- const color = fill;
7556
- if ("conical" === color.gradient) {
7557
- const lastColor = getConicGradientAt(0, 0, endAngle, color);
7558
- fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
7559
- }
7560
- }
7561
- doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
7685
+ this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
7686
+ const _runFill = () => {
7687
+ if (doFill) {
7688
+ const color = fill;
7689
+ if ("conical" === color.gradient) {
7690
+ const lastColor = getConicGradientAt(0, 0, endAngle, color);
7691
+ fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
7692
+ }
7693
+ }
7694
+ },
7695
+ _runStroke = () => {
7696
+ doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
7697
+ };
7698
+ _runFill(), _runStroke();
7562
7699
  }
7563
7700
  }
7564
7701
  this.afterRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), tempChangeConicalColor && (fill.startAngle += conicalOffset, fill.endAngle += conicalOffset);
@@ -7596,7 +7733,8 @@ let DefaultCanvasCircleRender = class extends BaseRender {
7596
7733
  startAngle = circleAttribute.startAngle,
7597
7734
  endAngle = circleAttribute.endAngle,
7598
7735
  x: originX = circleAttribute.x,
7599
- y: originY = circleAttribute.y
7736
+ y: originY = circleAttribute.y,
7737
+ fillStrokeOrder = circleAttribute.fillStrokeOrder
7600
7738
  } = circle.attribute,
7601
7739
  data = this.valid(circle, circleAttribute, fillCb, strokeCb);
7602
7740
  if (!data) return;
@@ -7606,7 +7744,14 @@ let DefaultCanvasCircleRender = class extends BaseRender {
7606
7744
  doFill: doFill,
7607
7745
  doStroke: doStroke
7608
7746
  } = data;
7609
- context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke())), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7747
+ context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7748
+ const _runFill = () => {
7749
+ doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill()));
7750
+ },
7751
+ _runStroke = () => {
7752
+ doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke()));
7753
+ };
7754
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7610
7755
  }
7611
7756
  draw(circle, renderService, drawContext, params) {
7612
7757
  const circleAttribute = getTheme(circle, null == params ? void 0 : params.theme).circle;
@@ -8047,7 +8192,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8047
8192
  super(), this.areaRenderContribitions = areaRenderContribitions, this.numberType = AREA_NUMBER_TYPE, this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution], this.init(areaRenderContribitions);
8048
8193
  }
8049
8194
  drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
8050
- var _a, _b, _c, _d, _e;
8195
+ var _a, _b, _c;
8051
8196
  const {
8052
8197
  points: points
8053
8198
  } = area.attribute;
@@ -8071,28 +8216,31 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8071
8216
  x: originX = 0,
8072
8217
  x: originY = 0
8073
8218
  } = area.attribute;
8074
- if (!1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
8219
+ !1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
8075
8220
  attribute: area.attribute
8076
- }), stroke) {
8077
- const {
8078
- stroke = areaAttribute && areaAttribute.stroke
8079
- } = area.attribute;
8080
- if (isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
8081
- context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
8082
- for (let i = 1; i < points.length; i++) {
8083
- const p = points[i];
8084
- context.lineTo(p.x + offsetX, p.y + offsetY, z);
8085
- }
8086
- } else if (stroke[2]) {
8087
- const endP = points[points.length - 1];
8088
- context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
8089
- for (let i = points.length - 2; i >= 0; i--) {
8090
- const p = points[i];
8091
- context.lineTo((null !== (_d = p.x1) && void 0 !== _d ? _d : p.x) + offsetX, (null !== (_e = p.y1) && void 0 !== _e ? _e : p.y) + offsetY, z);
8221
+ }), (() => {
8222
+ var _a, _b;
8223
+ if (stroke) {
8224
+ const {
8225
+ stroke = areaAttribute && areaAttribute.stroke
8226
+ } = area.attribute;
8227
+ if (isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
8228
+ context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
8229
+ for (let i = 1; i < points.length; i++) {
8230
+ const p = points[i];
8231
+ context.lineTo(p.x + offsetX, p.y + offsetY, z);
8232
+ }
8233
+ } else if (stroke[2]) {
8234
+ const endP = points[points.length - 1];
8235
+ context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
8236
+ for (let i = points.length - 2; i >= 0; i--) {
8237
+ const p = points[i];
8238
+ context.lineTo((null !== (_a = p.x1) && void 0 !== _a ? _a : p.x) + offsetX, (null !== (_b = p.y1) && void 0 !== _b ? _b : p.y) + offsetY, z);
8239
+ }
8092
8240
  }
8241
+ strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
8093
8242
  }
8094
- strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
8095
- }
8243
+ })();
8096
8244
  }
8097
8245
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
8098
8246
  var _a, _b, _c, _d, _e, _f;
@@ -8257,23 +8405,24 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8257
8405
  x: originX = 0,
8258
8406
  x: originY = 0
8259
8407
  } = attribute;
8260
- if (!1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
8408
+ return !1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
8261
8409
  attribute: attribute
8262
- }), !1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
8263
- const {
8264
- stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
8265
- } = attribute;
8266
- isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
8267
- offsetX: offsetX,
8268
- offsetY: offsetY,
8269
- offsetZ: offsetZ,
8270
- drawConnect: connect,
8271
- mode: connectedType,
8272
- zeroX: connectedX,
8273
- zeroY: connectedY
8274
- })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
8275
- }
8276
- return !1;
8410
+ }), (() => {
8411
+ if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
8412
+ const {
8413
+ stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
8414
+ } = attribute;
8415
+ isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
8416
+ offsetX: offsetX,
8417
+ offsetY: offsetY,
8418
+ offsetZ: offsetZ,
8419
+ drawConnect: connect,
8420
+ mode: connectedType,
8421
+ zeroX: connectedX,
8422
+ zeroY: connectedY
8423
+ })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
8424
+ }
8425
+ })(), !1;
8277
8426
  }
8278
8427
  };
8279
8428
  DefaultCanvasAreaRender = __decorate$D([injectable(), __param$t(0, inject(ContributionProvider)), __param$t(0, named(AreaRenderContribution)), __metadata$w("design:paramtypes", [Object])], DefaultCanvasAreaRender);
@@ -8305,7 +8454,8 @@ let DefaultCanvasPathRender = class extends BaseRender {
8305
8454
  const pathAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(path, null == params ? void 0 : params.theme).path,
8306
8455
  {
8307
8456
  x: originX = pathAttribute.x,
8308
- y: originY = pathAttribute.y
8457
+ y: originY = pathAttribute.y,
8458
+ fillStrokeOrder = pathAttribute.fillStrokeOrder
8309
8459
  } = path.attribute,
8310
8460
  z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
8311
8461
  data = this.valid(path, pathAttribute, fillCb, strokeCb);
@@ -8320,7 +8470,14 @@ let DefaultCanvasPathRender = class extends BaseRender {
8320
8470
  const path2D = null !== (_c = path.attribute.path) && void 0 !== _c ? _c : pathAttribute.path;
8321
8471
  renderCommandList(path2D.commandList, context, x, y, 1, 1, z);
8322
8472
  }
8323
- context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke())), doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill())), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8473
+ context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8474
+ const _runStroke = () => {
8475
+ doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke()));
8476
+ },
8477
+ _runFill = () => {
8478
+ doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill()));
8479
+ };
8480
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8324
8481
  }
8325
8482
  draw(path, renderService, drawContext, params) {
8326
8483
  const pathAttribute = getTheme(path, null == params ? void 0 : params.theme).path;
@@ -8364,7 +8521,8 @@ let DefaultCanvasRectRender = class extends BaseRender {
8364
8521
  x1: x1,
8365
8522
  y1: y1,
8366
8523
  x: originX = rectAttribute.x,
8367
- y: originY = rectAttribute.y
8524
+ y: originY = rectAttribute.y,
8525
+ fillStrokeOrder = rectAttribute.fillStrokeOrder
8368
8526
  } = rect.attribute;
8369
8527
  let {
8370
8528
  width: width,
@@ -8383,7 +8541,14 @@ let DefaultCanvasRectRender = class extends BaseRender {
8383
8541
  doFill: doFill,
8384
8542
  doStroke: doStroke
8385
8543
  };
8386
- context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke), doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke())), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
8544
+ context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
8545
+ const _runFill = () => {
8546
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill()));
8547
+ },
8548
+ _runStroke = () => {
8549
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke()));
8550
+ };
8551
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
8387
8552
  }
8388
8553
  draw(rect, renderService, drawContext, params) {
8389
8554
  const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
@@ -8419,7 +8584,8 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
8419
8584
  x: originX = symbolAttribute.x,
8420
8585
  y: originY = symbolAttribute.y,
8421
8586
  scaleX = symbolAttribute.scaleX,
8422
- scaleY = symbolAttribute.scaleY
8587
+ scaleY = symbolAttribute.scaleY,
8588
+ fillStrokeOrder = symbolAttribute.fillStrokeOrder
8423
8589
  } = symbol.attribute,
8424
8590
  data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
8425
8591
  if (!data) return;
@@ -8442,14 +8608,27 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
8442
8608
  const obj = Object.assign({}, a);
8443
8609
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill, obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity, obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke, a = obj;
8444
8610
  }
8445
- a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8611
+ const _runFill = () => {
8612
+ a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill()));
8613
+ },
8614
+ _runStroke = () => {
8615
+ a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8616
+ };
8617
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
8446
8618
  };
8447
8619
  if (keepDirIn3d && context.camera && context.project) {
8448
8620
  const p = context.project(x, y, z),
8449
8621
  camera = context.camera;
8450
8622
  context.camera = null, !1 === parsedPath.draw(context, isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(), context.camera = camera;
8451
8623
  } else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
8452
- context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb), doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill())), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke())), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8624
+ context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8625
+ const _runFill = () => {
8626
+ doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill()));
8627
+ },
8628
+ _runStroke = () => {
8629
+ doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8630
+ };
8631
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8453
8632
  }
8454
8633
  draw(symbol, renderService, drawContext, params) {
8455
8634
  const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
@@ -8593,16 +8772,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
8593
8772
  verticalMode = textAttribute.verticalMode,
8594
8773
  x: originX = textAttribute.x,
8595
8774
  y: originY = textAttribute.y
8596
- } = text.attribute;
8597
- let {
8598
- textAlign = textAttribute.textAlign,
8599
- textBaseline = textAttribute.textBaseline
8600
- } = text.attribute;
8601
- if (!verticalMode && "vertical" === direction) {
8602
- const t = textAlign;
8603
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
8604
- }
8605
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
8775
+ } = text.attribute,
8776
+ lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
8606
8777
  data = this.valid(text, textAttribute, fillCb, strokeCb);
8607
8778
  if (!data) return;
8608
8779
  const {
@@ -8622,79 +8793,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
8622
8793
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
8623
8794
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
8624
8795
  }
8625
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
8796
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
8626
8797
  };
8627
- if (text.isMultiLine) {
8628
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
8629
- const {
8630
- multilineLayout: multilineLayout
8631
- } = text;
8632
- if (!multilineLayout) return void context.highPerformanceRestore();
8633
- const {
8634
- xOffset: xOffset,
8635
- yOffset: yOffset
8636
- } = multilineLayout.bbox;
8637
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8638
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
8639
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8640
- context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
8641
- width: line.width
8642
- });
8643
- })));
8644
- } else {
8645
- text.tryUpdateAABBBounds();
8646
- const cache = text.cache,
8647
- {
8648
- verticalList: verticalList
8649
- } = cache;
8650
- context.textAlign = "left", context.textBaseline = "top";
8651
- const totalHeight = lineHeight * verticalList.length;
8652
- let totalW = 0;
8653
- verticalList.forEach(verticalData => {
8654
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
8655
- totalW = max(_w, totalW);
8656
- });
8657
- let offsetY = 0,
8658
- offsetX = 0;
8659
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
8660
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
8661
- dw = totalW - currentW;
8662
- let currentOffsetY = offsetY;
8663
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
8664
- const {
8665
- text: text,
8666
- width: width,
8667
- direction: direction
8668
- } = item;
8669
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
8670
- });
8798
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
8799
+ const {
8800
+ multilineLayout: multilineLayout
8801
+ } = text;
8802
+ if (!multilineLayout) return void context.highPerformanceRestore();
8803
+ const {
8804
+ xOffset: xOffset,
8805
+ yOffset: yOffset
8806
+ } = multilineLayout.bbox;
8807
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8808
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
8809
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8810
+ context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
8811
+ width: line.width
8671
8812
  });
8672
- }
8673
- } else if ("horizontal" === direction) {
8674
- context.setTextStyle(text.attribute, textAttribute, z);
8675
- const t = text.clipedText;
8676
- let dy = 0;
8677
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
8813
+ })));
8678
8814
  } else {
8815
+ let {
8816
+ textAlign = textAttribute.textAlign,
8817
+ textBaseline = textAttribute.textBaseline
8818
+ } = text.attribute;
8819
+ if (!verticalMode) {
8820
+ const t = textAlign;
8821
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
8822
+ }
8679
8823
  text.tryUpdateAABBBounds();
8680
- const cache = text.cache;
8681
- if (cache) {
8682
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
8683
- const {
8824
+ const cache = text.cache,
8825
+ {
8684
8826
  verticalList: verticalList
8685
8827
  } = cache;
8686
- let offsetY = 0;
8687
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
8688
- let offsetX = 0;
8689
- "bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
8828
+ context.textAlign = "left", context.textBaseline = "top";
8829
+ const totalHeight = lineHeight * verticalList.length;
8830
+ let totalW = 0;
8831
+ verticalList.forEach(verticalData => {
8832
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
8833
+ totalW = max(_w, totalW);
8834
+ });
8835
+ let offsetY = 0,
8836
+ offsetX = 0;
8837
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
8838
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
8839
+ dw = totalW - currentW;
8840
+ let currentOffsetY = offsetY;
8841
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
8690
8842
  const {
8691
8843
  text: text,
8692
8844
  width: width,
8693
8845
  direction: direction
8694
8846
  } = item;
8695
- drawText(text, offsetX, offsetY, direction), offsetY += width;
8847
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
8696
8848
  });
8697
- }
8849
+ });
8698
8850
  }
8699
8851
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
8700
8852
  }
@@ -8706,12 +8858,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
8706
8858
  computed3dMatrix = !keepDirIn3d;
8707
8859
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
8708
8860
  }
8709
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
8861
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
8710
8862
  if (lineThrough + underline <= 0) return;
8711
8863
  const {
8712
8864
  textAlign = textAttribute.textAlign,
8713
- textBaseline = textAttribute.textBaseline,
8714
- fontSize = textAttribute.fontSize,
8715
8865
  fill = textAttribute.fill,
8716
8866
  opacity = textAttribute.opacity,
8717
8867
  underlineOffset = textAttribute.underlineOffset,
@@ -8721,23 +8871,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
8721
8871
  isMulti = !isNil(multiOption),
8722
8872
  w = isMulti ? multiOption.width : text.clipedWidth,
8723
8873
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
8724
- offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
8725
8874
  attribute = {
8726
8875
  lineWidth: 0,
8727
8876
  stroke: fill,
8728
8877
  opacity: opacity,
8729
8878
  strokeOpacity: fillOpacity
8730
8879
  };
8731
- let deltaY = isMulti ? -3 : 0;
8732
8880
  if (underline) {
8733
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
8734
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
8735
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
8881
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
8882
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
8883
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
8736
8884
  }
8737
- if (isMulti && (deltaY = -1), lineThrough) {
8738
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
8739
- const dy = y + offsetY + fontSize / 2 + deltaY;
8740
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
8885
+ if (lineThrough) {
8886
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
8887
+ const dy = anchorY + offsetThroughLineY;
8888
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
8741
8889
  }
8742
8890
  }
8743
8891
  };
@@ -8823,7 +8971,8 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
8823
8971
  cornerRadius = polygonAttribute.cornerRadius,
8824
8972
  x: originX = polygonAttribute.x,
8825
8973
  y: originY = polygonAttribute.y,
8826
- closePath = polygonAttribute.closePath
8974
+ closePath = polygonAttribute.closePath,
8975
+ fillStrokeOrder = polygonAttribute.fillStrokeOrder
8827
8976
  } = polygon.attribute,
8828
8977
  data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
8829
8978
  if (!data) return;
@@ -8833,7 +8982,14 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
8833
8982
  doFill: doFill,
8834
8983
  doStroke: doStroke
8835
8984
  } = data;
8836
- context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke())), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8985
+ context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8986
+ const _runFill = () => {
8987
+ doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill()));
8988
+ },
8989
+ _runStroke = () => {
8990
+ doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke()));
8991
+ };
8992
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8837
8993
  }
8838
8994
  draw(polygon, renderService, drawContext, params) {
8839
8995
  const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon;
@@ -8876,7 +9032,10 @@ let DefaultCanvasGroupRender = class {
8876
9032
  cornerRadius = groupAttribute.cornerRadius,
8877
9033
  path = groupAttribute.path,
8878
9034
  lineWidth = groupAttribute.lineWidth,
8879
- visible = groupAttribute.visible
9035
+ visible = groupAttribute.visible,
9036
+ fillStrokeOrder = groupAttribute.fillStrokeOrder,
9037
+ x: originX = groupAttribute.x,
9038
+ y: originY = groupAttribute.y
8880
9039
  } = group.attribute,
8881
9040
  fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
8882
9041
  sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
@@ -8902,7 +9061,14 @@ let DefaultCanvasGroupRender = class {
8902
9061
  };
8903
9062
  this._groupRenderContribitions.forEach(c => {
8904
9063
  c.time === BaseRenderContributionTime.beforeFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
8905
- }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute), doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, x, y, groupAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, x, y, groupAttribute), context.stroke())), this._groupRenderContribitions.forEach(c => {
9064
+ }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
9065
+ const _runFill = () => {
9066
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.fill()));
9067
+ },
9068
+ _runStroke = () => {
9069
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.stroke()));
9070
+ };
9071
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this._groupRenderContribitions.forEach(c => {
8906
9072
  c.time === BaseRenderContributionTime.afterFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb);
8907
9073
  });
8908
9074
  }
@@ -8968,6 +9134,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
8968
9134
  x: originX = imageAttribute.x,
8969
9135
  y: originY = imageAttribute.y,
8970
9136
  cornerRadius = imageAttribute.cornerRadius,
9137
+ fillStrokeOrder = imageAttribute.fillStrokeOrder,
8971
9138
  image: url
8972
9139
  } = image.attribute,
8973
9140
  data = this.valid(image, imageAttribute, fillCb);
@@ -8978,20 +9145,26 @@ let DefaultCanvasImageRender = class extends BaseRender {
8978
9145
  doFill: doFill,
8979
9146
  doStroke: doStroke
8980
9147
  } = data;
8981
- if (context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
8982
- if (!url || !image.resources) return;
8983
- const res = image.resources.get(url);
8984
- if ("success" !== res.state) return;
8985
- let needRestore = !1;
8986
- 0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
8987
- let repeat = 0;
8988
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
8989
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
8990
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
8991
- } else context.drawImage(res.data, x, y, width, height);
8992
- needRestore && context.restore();
8993
- }
8994
- doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke())), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
9148
+ context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
9149
+ const _runFill = () => {
9150
+ if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
9151
+ if (!url || !image.resources) return;
9152
+ const res = image.resources.get(url);
9153
+ if ("success" !== res.state) return;
9154
+ let needRestore = !1;
9155
+ 0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
9156
+ let repeat = 0;
9157
+ if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
9158
+ const pattern = context.createPattern(res.data, repeatStr[repeat]);
9159
+ context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
9160
+ } else context.drawImage(res.data, x, y, width, height);
9161
+ needRestore && context.restore();
9162
+ }
9163
+ },
9164
+ _runStroke = () => {
9165
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
9166
+ };
9167
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
8995
9168
  }
8996
9169
  draw(image, renderService, drawContext) {
8997
9170
  const {
@@ -9377,58 +9550,60 @@ class CanvasTextLayout {
9377
9550
  constructor(fontFamily, options, textMeasure) {
9378
9551
  this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
9379
9552
  }
9380
- LayoutBBox(bbox, textAlign, textBaseline) {
9553
+ LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
9381
9554
  if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
9382
9555
  if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
9383
9556
  bbox.xOffset = -bbox.width;
9384
9557
  }
9385
- return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
9386
- }
9387
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
9388
- const linesLayout = [],
9389
- bboxWH = [width, height],
9390
- bboxOffset = [0, 0];
9391
- for (; str.length > 0;) {
9392
- const {
9393
- str: clipText
9394
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
9395
- linesLayout.push({
9396
- str: clipText,
9397
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
9398
- }), str = str.substring(clipText.length);
9399
- }
9400
- "left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
9401
- const bbox = {
9402
- xOffset: bboxOffset[0],
9403
- yOffset: bboxOffset[1],
9404
- width: bboxWH[0],
9405
- height: bboxWH[1]
9406
- };
9407
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9558
+ if ("top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
9559
+ let percent = .79;
9560
+ if (1 === linesLayout.length) {
9561
+ const lineInfo = linesLayout[0];
9562
+ percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
9563
+ }
9564
+ bbox.yOffset = bbox.height * -percent;
9565
+ } else bbox.yOffset = -bbox.height;
9566
+ return bbox;
9408
9567
  }
9409
9568
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
9410
9569
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
9411
9570
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
9412
- let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
9413
- let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
9571
+ let params = arguments.length > 6 ? arguments[6] : undefined;
9572
+ const {
9573
+ lineWidth: lineWidth,
9574
+ suffixPosition = "end",
9575
+ measureMode = MeasureModeEnum.actualBounding
9576
+ } = null != params ? params : {};
9414
9577
  lines = lines.map(l => l.toString());
9415
9578
  const linesLayout = [],
9416
9579
  bboxWH = [0, 0];
9417
9580
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
9418
9581
  let width;
9419
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
9420
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
9421
- width: width
9422
- });
9582
+ for (let i = 0, len = lines.length; i < len; i++) {
9583
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
9584
+ width = Math.min(metrics.width, lineWidth), linesLayout.push({
9585
+ str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
9586
+ width: width,
9587
+ ascent: metrics.ascent,
9588
+ descent: metrics.descent
9589
+ });
9590
+ }
9423
9591
  bboxWH[0] = lineWidth;
9424
9592
  } else {
9425
- let width, text;
9426
- lineWidth = 0;
9427
- for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
9428
- str: text,
9429
- width: width
9430
- });
9431
- bboxWH[0] = lineWidth;
9593
+ let width,
9594
+ text,
9595
+ _lineWidth = 0;
9596
+ for (let i = 0, len = lines.length; i < len; i++) {
9597
+ text = lines[i];
9598
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
9599
+ width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
9600
+ str: text,
9601
+ width: width,
9602
+ ascent: metrics.ascent,
9603
+ descent: metrics.descent
9604
+ });
9605
+ }
9606
+ bboxWH[0] = _lineWidth;
9432
9607
  }
9433
9608
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
9434
9609
  const bbox = {
@@ -9437,7 +9612,7 @@ class CanvasTextLayout {
9437
9612
  width: bboxWH[0],
9438
9613
  height: bboxWH[1]
9439
9614
  };
9440
- return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9615
+ return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9441
9616
  }
9442
9617
  layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
9443
9618
  const origin = [0, 0],
@@ -9456,11 +9631,13 @@ class CanvasTextLayout {
9456
9631
  };
9457
9632
  }
9458
9633
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
9459
- return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
9634
+ "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
9635
+ const actualHeightWithBuf = line.ascent + line.descent + 0;
9636
+ return actualHeightWithBuf < lineHeight - 0 && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), origin[1] += lineHeight, line;
9460
9637
  }
9461
9638
  }
9462
9639
 
9463
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
9640
+ const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
9464
9641
  class Text extends Graphic {
9465
9642
  get font() {
9466
9643
  const textTheme = this.getGraphicTheme();
@@ -9469,26 +9646,22 @@ class Text extends Graphic {
9469
9646
  get clipedText() {
9470
9647
  var _a;
9471
9648
  const attribute = this.attribute,
9472
- textTheme = this.getGraphicTheme();
9473
- if (!this.isSimplify()) return;
9474
- const {
9475
- maxLineWidth = textTheme.maxLineWidth
9476
- } = attribute;
9477
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
9649
+ textTheme = this.getGraphicTheme(),
9650
+ maxWidth = this.getMaxWidth(textTheme);
9651
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
9478
9652
  }
9479
9653
  get clipedWidth() {
9480
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
9654
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
9481
9655
  }
9482
9656
  get cliped() {
9483
9657
  var _a, _b;
9484
9658
  const textTheme = this.getGraphicTheme(),
9485
9659
  attribute = this.attribute,
9486
- {
9487
- maxLineWidth = textTheme.maxLineWidth,
9488
- text: text,
9489
- whiteSpace = textTheme.whiteSpace
9490
- } = attribute;
9491
- if (!Number.isFinite(maxLineWidth)) return !1;
9660
+ maxWidth = this.getMaxWidth(textTheme);
9661
+ if (!Number.isFinite(maxWidth)) return !1;
9662
+ const {
9663
+ text: text
9664
+ } = this.attribute;
9492
9665
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
9493
9666
  let mergedText = "";
9494
9667
  this.cache.layoutData.lines.forEach(item => {
@@ -9499,10 +9672,7 @@ class Text extends Graphic {
9499
9672
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
9500
9673
  }
9501
9674
  get multilineLayout() {
9502
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
9503
- }
9504
- isSimplify() {
9505
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
9675
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
9506
9676
  }
9507
9677
  get isMultiLine() {
9508
9678
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -9575,8 +9745,72 @@ class Text extends Graphic {
9575
9745
  }
9576
9746
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
9577
9747
  }
9748
+ updateSingallineAABBBounds(text) {
9749
+ this.updateMultilineAABBBounds([text]);
9750
+ const layoutData = this.cache.layoutData;
9751
+ if (layoutData) {
9752
+ const line = layoutData.lines[0];
9753
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
9754
+ }
9755
+ return this._AABBBounds;
9756
+ }
9757
+ updateMultilineAABBBounds(text) {
9758
+ const textTheme = this.getGraphicTheme(),
9759
+ {
9760
+ direction = textTheme.direction,
9761
+ underlineOffset = textTheme.underlineOffset
9762
+ } = this.attribute,
9763
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
9764
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9765
+ }
9766
+ guessLineHeightBuf(fontSize) {
9767
+ return fontSize ? .1 * fontSize : 0;
9768
+ }
9769
+ updateHorizontalMultilineAABBBounds(text) {
9770
+ var _a;
9771
+ const textTheme = this.getGraphicTheme(),
9772
+ attribute = this.attribute,
9773
+ {
9774
+ fontFamily = textTheme.fontFamily,
9775
+ textAlign = textTheme.textAlign,
9776
+ textBaseline = textTheme.textBaseline,
9777
+ fontSize = textTheme.fontSize,
9778
+ fontWeight = textTheme.fontWeight,
9779
+ ellipsis = textTheme.ellipsis,
9780
+ maxLineWidth: maxLineWidth,
9781
+ stroke = textTheme.stroke,
9782
+ wrap = textTheme.wrap,
9783
+ measureMode = textTheme.measureMode,
9784
+ lineWidth = textTheme.lineWidth,
9785
+ whiteSpace = textTheme.whiteSpace,
9786
+ suffixPosition = textTheme.suffixPosition,
9787
+ ignoreBuf = textTheme.ignoreBuf
9788
+ } = attribute,
9789
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
9790
+ lineHeight = this.getLineHeight(attribute, textTheme) + buf;
9791
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
9792
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
9793
+ const bbox = this.cache.layoutData.bbox;
9794
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9795
+ }
9796
+ const textMeasure = application.graphicUtil.textMeasure,
9797
+ layoutData = new CanvasTextLayout(fontFamily, {
9798
+ fontSize: fontSize,
9799
+ fontWeight: fontWeight,
9800
+ fontFamily: fontFamily,
9801
+ lineHeight: lineHeight
9802
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
9803
+ lineWidth: maxLineWidth,
9804
+ suffixPosition: suffixPosition,
9805
+ measureMode: measureMode
9806
+ }),
9807
+ {
9808
+ bbox: bbox
9809
+ } = layoutData;
9810
+ return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9811
+ }
9578
9812
  updateWrapAABBBounds(text) {
9579
- var _a, _b, _c, _d;
9813
+ var _a, _b, _c;
9580
9814
  const textTheme = this.getGraphicTheme(),
9581
9815
  {
9582
9816
  fontFamily = textTheme.fontFamily,
@@ -9590,22 +9824,25 @@ class Text extends Graphic {
9590
9824
  wordBreak = textTheme.wordBreak,
9591
9825
  fontWeight = textTheme.fontWeight,
9592
9826
  ignoreBuf = textTheme.ignoreBuf,
9827
+ measureMode = textTheme.measureMode,
9593
9828
  suffixPosition = textTheme.suffixPosition,
9594
9829
  heightLimit = 0,
9595
9830
  lineClamp: lineClamp
9596
9831
  } = this.attribute,
9597
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
9598
- buf = ignoreBuf ? 0 : 2;
9599
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
9832
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
9833
+ lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
9834
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
9600
9835
  const bbox = this.cache.layoutData.bbox;
9601
9836
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9602
9837
  }
9603
9838
  const textMeasure = application.graphicUtil.textMeasure,
9604
- layoutObj = new CanvasTextLayout(fontFamily, {
9839
+ textOptions = {
9605
9840
  fontSize: fontSize,
9606
9841
  fontWeight: fontWeight,
9607
- fontFamily: fontFamily
9608
- }, textMeasure),
9842
+ fontFamily: fontFamily,
9843
+ lineHeight: lineHeight
9844
+ },
9845
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
9609
9846
  lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
9610
9847
  linesLayout = [],
9611
9848
  bboxWH = [0, 0];
@@ -9615,29 +9852,35 @@ class Text extends Graphic {
9615
9852
  const str = lines[i];
9616
9853
  let needCut = !0;
9617
9854
  if (i === lineCountLimit - 1) {
9618
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
9855
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
9856
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9619
9857
  linesLayout.push({
9620
9858
  str: clip.str,
9621
- width: clip.width
9859
+ width: clip.width,
9860
+ ascent: matrics.ascent,
9861
+ descent: matrics.descent
9622
9862
  });
9623
9863
  break;
9624
9864
  }
9625
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
9865
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
9626
9866
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
9627
9867
  if (ellipsis) {
9628
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9629
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
9868
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9869
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
9630
9870
  } else clip.str = "", clip.width = 0;
9631
9871
  needCut = !1;
9632
9872
  }
9873
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9633
9874
  linesLayout.push({
9634
9875
  str: clip.str,
9635
- width: clip.width
9876
+ width: clip.width,
9877
+ ascent: matrics.ascent,
9878
+ descent: matrics.descent
9636
9879
  });
9637
9880
  let cutLength = clip.str.length;
9638
9881
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
9639
- let newStr = str.substring(cutLength);
9640
- "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
9882
+ const newStr = str.substring(cutLength);
9883
+ lines.splice(i + 1, 0, newStr);
9641
9884
  }
9642
9885
  }
9643
9886
  let maxWidth = 0;
@@ -9650,235 +9893,44 @@ class Text extends Graphic {
9650
9893
  lineWidth = 0;
9651
9894
  for (let i = 0, len = lines.length; i < len; i++) {
9652
9895
  if (i === lineCountLimit - 1) {
9653
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9896
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
9897
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9654
9898
  linesLayout.push({
9655
9899
  str: clip.str,
9656
- width: clip.width
9900
+ width: clip.width,
9901
+ ascent: matrics.ascent,
9902
+ descent: matrics.descent
9657
9903
  }), lineWidth = Math.max(lineWidth, clip.width);
9658
9904
  break;
9659
9905
  }
9660
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
9906
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
9907
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
9908
+ linesLayout.push({
9661
9909
  str: text,
9662
- width: width
9910
+ width: width,
9911
+ ascent: matrics.ascent,
9912
+ descent: matrics.descent
9663
9913
  });
9664
9914
  }
9665
9915
  bboxWH[0] = lineWidth;
9666
9916
  }
9667
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
9917
+ bboxWH[1] = linesLayout.length * lineHeight;
9668
9918
  const bbox = {
9669
9919
  xOffset: 0,
9670
9920
  yOffset: 0,
9671
9921
  width: bboxWH[0],
9672
9922
  height: bboxWH[1]
9673
9923
  };
9674
- layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
9924
+ layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
9675
9925
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9676
9926
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9677
9927
  }
9678
- updateSingallineAABBBounds(text) {
9679
- const textTheme = this.getGraphicTheme(),
9680
- {
9681
- direction = textTheme.direction,
9682
- underlineOffset = textTheme.underlineOffset
9683
- } = this.attribute,
9684
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
9685
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9686
- }
9687
- updateMultilineAABBBounds(text) {
9688
- const textTheme = this.getGraphicTheme(),
9689
- {
9690
- direction = textTheme.direction,
9691
- underlineOffset = textTheme.underlineOffset
9692
- } = this.attribute,
9693
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
9694
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9695
- }
9696
- updateHorizontalSinglelineAABBBounds(text) {
9697
- var _a, _b;
9698
- const textTheme = this.getGraphicTheme(),
9699
- {
9700
- wrap = textTheme.wrap
9701
- } = this.attribute;
9702
- if (wrap) return this.updateWrapAABBBounds([text]);
9703
- const textMeasure = application.graphicUtil.textMeasure;
9704
- let width, str;
9705
- const attribute = this.attribute,
9706
- {
9707
- maxLineWidth = textTheme.maxLineWidth,
9708
- ellipsis = textTheme.ellipsis,
9709
- textAlign = textTheme.textAlign,
9710
- textBaseline = textTheme.textBaseline,
9711
- fontFamily = textTheme.fontFamily,
9712
- fontSize = textTheme.fontSize,
9713
- fontWeight = textTheme.fontWeight,
9714
- stroke = textTheme.stroke,
9715
- lineWidth = textTheme.lineWidth,
9716
- ignoreBuf = textTheme.ignoreBuf,
9717
- whiteSpace = textTheme.whiteSpace,
9718
- suffixPosition = textTheme.suffixPosition
9719
- } = attribute;
9720
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
9721
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
9722
- textFontSize = attribute.fontSize || textTheme.fontSize,
9723
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
9724
- if (!this.shouldUpdateShape() && this.cache) {
9725
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
9726
- const dx = textDrawOffsetX(textAlign, width),
9727
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9728
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9729
- }
9730
- if (Number.isFinite(maxLineWidth)) {
9731
- if (ellipsis) {
9732
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
9733
- data = textMeasure.clipTextWithSuffix(text.toString(), {
9734
- fontSize: fontSize,
9735
- fontWeight: fontWeight,
9736
- fontFamily: fontFamily
9737
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
9738
- str = data.str, width = data.width;
9739
- } else {
9740
- const data = textMeasure.clipText(text.toString(), {
9741
- fontSize: fontSize,
9742
- fontWeight: fontWeight,
9743
- fontFamily: fontFamily
9744
- }, maxLineWidth, !1);
9745
- str = data.str, width = data.width;
9746
- }
9747
- this.cache.clipedText = str, this.cache.clipedWidth = width;
9748
- } else width = textMeasure.measureTextWidth(text.toString(), {
9749
- fontSize: fontSize,
9750
- fontWeight: fontWeight,
9751
- fontFamily: fontFamily
9752
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
9753
- this.clearUpdateShapeTag();
9754
- const dx = textDrawOffsetX(textAlign, width);
9755
- let lh = lineHeight;
9756
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
9757
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
9758
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9759
- }
9760
- getBaselineMapAlign() {
9761
- return Text.baselineMapAlign;
9762
- }
9763
- getAlignMapBaseline() {
9764
- return Text.alignMapBaseline;
9765
- }
9766
- updateVerticalSinglelineAABBBounds(text) {
9767
- var _a, _b, _c;
9768
- const textTheme = this.getGraphicTheme(),
9769
- textMeasure = application.graphicUtil.textMeasure;
9770
- let width;
9771
- const attribute = this.attribute,
9772
- {
9773
- ignoreBuf = textTheme.ignoreBuf
9774
- } = attribute,
9775
- buf = ignoreBuf ? 0 : 2,
9776
- {
9777
- maxLineWidth = textTheme.maxLineWidth,
9778
- ellipsis = textTheme.ellipsis,
9779
- fontSize = textTheme.fontSize,
9780
- fontWeight = textTheme.fontWeight,
9781
- fontFamily = textTheme.fontFamily,
9782
- stroke = textTheme.stroke,
9783
- lineWidth = textTheme.lineWidth,
9784
- verticalMode = textTheme.verticalMode,
9785
- suffixPosition = textTheme.suffixPosition
9786
- } = attribute,
9787
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
9788
- let {
9789
- textAlign = textTheme.textAlign,
9790
- textBaseline = textTheme.textBaseline
9791
- } = attribute;
9792
- if (!verticalMode) {
9793
- const t = textAlign;
9794
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
9795
- }
9796
- if (!this.shouldUpdateShape() && this.cache) {
9797
- width = this.cache.clipedWidth;
9798
- const dx = textDrawOffsetX(textAlign, width),
9799
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9800
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9801
- }
9802
- let verticalList = [verticalLayout(text.toString())];
9803
- if (Number.isFinite(maxLineWidth)) {
9804
- if (ellipsis) {
9805
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
9806
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
9807
- fontSize: fontSize,
9808
- fontWeight: fontWeight,
9809
- fontFamily: fontFamily
9810
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
9811
- verticalList = [data.verticalList], width = data.width;
9812
- } else {
9813
- const data = textMeasure.clipTextVertical(verticalList[0], {
9814
- fontSize: fontSize,
9815
- fontWeight: fontWeight,
9816
- fontFamily: fontFamily
9817
- }, maxLineWidth, !1);
9818
- verticalList = [data.verticalList], width = data.width;
9819
- }
9820
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
9821
- } else width = 0, verticalList[0].forEach(t => {
9822
- const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
9823
- fontSize: fontSize,
9824
- fontWeight: fontWeight,
9825
- fontFamily: fontFamily
9826
- });
9827
- width += w, t.width = w;
9828
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
9829
- this.clearUpdateShapeTag();
9830
- const dx = textDrawOffsetX(textAlign, width),
9831
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9832
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9833
- }
9834
- updateHorizontalMultilineAABBBounds(text) {
9835
- var _a, _b;
9836
- const textTheme = this.getGraphicTheme(),
9837
- {
9838
- wrap = textTheme.wrap
9839
- } = this.attribute;
9840
- if (wrap) return this.updateWrapAABBBounds(text);
9841
- const attribute = this.attribute,
9842
- {
9843
- fontFamily = textTheme.fontFamily,
9844
- textAlign = textTheme.textAlign,
9845
- textBaseline = textTheme.textBaseline,
9846
- fontSize = textTheme.fontSize,
9847
- fontWeight = textTheme.fontWeight,
9848
- ellipsis = textTheme.ellipsis,
9849
- maxLineWidth: maxLineWidth,
9850
- stroke = textTheme.stroke,
9851
- lineWidth = textTheme.lineWidth,
9852
- whiteSpace = textTheme.whiteSpace,
9853
- suffixPosition = textTheme.suffixPosition
9854
- } = attribute,
9855
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
9856
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
9857
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
9858
- const bbox = this.cache.layoutData.bbox;
9859
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9860
- }
9861
- const textMeasure = application.graphicUtil.textMeasure,
9862
- layoutData = new CanvasTextLayout(fontFamily, {
9863
- fontSize: fontSize,
9864
- fontWeight: fontWeight,
9865
- fontFamily: fontFamily
9866
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
9867
- {
9868
- bbox: bbox
9869
- } = layoutData;
9870
- return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9871
- }
9872
9928
  updateVerticalMultilineAABBBounds(text) {
9873
- var _a, _b, _c;
9929
+ var _a, _b;
9874
9930
  const textTheme = this.getGraphicTheme(),
9875
9931
  textMeasure = application.graphicUtil.textMeasure;
9876
9932
  let width;
9877
9933
  const attribute = this.attribute,
9878
- {
9879
- ignoreBuf = textTheme.ignoreBuf
9880
- } = attribute,
9881
- buf = ignoreBuf ? 0 : 2,
9882
9934
  {
9883
9935
  maxLineWidth = textTheme.maxLineWidth,
9884
9936
  ellipsis = textTheme.ellipsis,
@@ -9890,14 +9942,14 @@ class Text extends Graphic {
9890
9942
  verticalMode = textTheme.verticalMode,
9891
9943
  suffixPosition = textTheme.suffixPosition
9892
9944
  } = attribute,
9893
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
9945
+ lineHeight = this.getLineHeight(attribute, textTheme);
9894
9946
  let {
9895
9947
  textAlign = textTheme.textAlign,
9896
9948
  textBaseline = textTheme.textBaseline
9897
9949
  } = attribute;
9898
9950
  if (!verticalMode) {
9899
9951
  const t = textAlign;
9900
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
9952
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
9901
9953
  }
9902
9954
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
9903
9955
  this.cache.verticalList.forEach(item => {
@@ -9945,6 +9997,15 @@ class Text extends Graphic {
9945
9997
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
9946
9998
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9947
9999
  }
10000
+ getMaxWidth(theme) {
10001
+ var _a, _b;
10002
+ const attribute = this.attribute;
10003
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
10004
+ }
10005
+ getLineHeight(attribute, textTheme) {
10006
+ var _a;
10007
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
10008
+ }
9948
10009
  needUpdateTags(keys) {
9949
10010
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
9950
10011
  return super.needUpdateTags(keys, k);
@@ -9959,6 +10020,12 @@ class Text extends Graphic {
9959
10020
  getNoWorkAnimateAttr() {
9960
10021
  return Text.NOWORK_ANIMATE_ATTR;
9961
10022
  }
10023
+ getBaselineMapAlign() {
10024
+ return Text.baselineMapAlign;
10025
+ }
10026
+ getAlignMapBaseline() {
10027
+ return Text.alignMapBaseline;
10028
+ }
9962
10029
  }
9963
10030
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
9964
10031
  ellipsis: 1,
@@ -10037,7 +10104,9 @@ class WrapText extends Text {
10037
10104
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10038
10105
  linesLayout.push({
10039
10106
  str: clip.str,
10040
- width: clip.width
10107
+ width: clip.width,
10108
+ ascent: 0,
10109
+ descent: 0
10041
10110
  });
10042
10111
  break;
10043
10112
  }
@@ -10051,7 +10120,9 @@ class WrapText extends Text {
10051
10120
  }
10052
10121
  if (linesLayout.push({
10053
10122
  str: clip.str,
10054
- width: clip.width
10123
+ width: clip.width,
10124
+ ascent: 0,
10125
+ descent: 0
10055
10126
  }), clip.str.length === str.length) ;else if (needCut) {
10056
10127
  const newStr = str.substring(clip.str.length);
10057
10128
  lines.splice(i + 1, 0, newStr);
@@ -10070,13 +10141,17 @@ class WrapText extends Text {
10070
10141
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10071
10142
  linesLayout.push({
10072
10143
  str: clip.str,
10073
- width: clip.width
10144
+ width: clip.width,
10145
+ ascent: 0,
10146
+ descent: 0
10074
10147
  }), lineWidth = Math.max(lineWidth, clip.width);
10075
10148
  break;
10076
10149
  }
10077
10150
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
10078
10151
  str: text,
10079
- width: width
10152
+ width: width,
10153
+ ascent: 0,
10154
+ descent: 0
10080
10155
  });
10081
10156
  }
10082
10157
  bboxWH[0] = lineWidth;
@@ -10120,6 +10195,9 @@ class BaseSymbol {
10120
10195
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
10121
10196
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
10122
10197
  }
10198
+ parseSize(size) {
10199
+ return isNumber(size) ? size : Math.min(size[0], size[1]);
10200
+ }
10123
10201
  }
10124
10202
 
10125
10203
  function circle(ctx, r, x, y, z) {
@@ -10130,13 +10208,13 @@ class CircleSymbol extends BaseSymbol {
10130
10208
  super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
10131
10209
  }
10132
10210
  draw(ctx, size, x, y, z) {
10133
- return circle(ctx, size / 2, x, y, z);
10211
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
10134
10212
  }
10135
10213
  drawOffset(ctx, size, x, y, offset, z) {
10136
- return circle(ctx, size / 2 + offset, x, y, z);
10214
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10137
10215
  }
10138
10216
  drawToSvgPath(size, x, y, z) {
10139
- const r = size / 2;
10217
+ const r = this.parseSize(size) / 2;
10140
10218
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
10141
10219
  }
10142
10220
  }
@@ -10153,10 +10231,10 @@ class CrossSymbol extends BaseSymbol {
10153
10231
  super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
10154
10232
  }
10155
10233
  draw(ctx, size, x, y, z) {
10156
- return cross(ctx, size / 6, x, y, z);
10234
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
10157
10235
  }
10158
10236
  drawOffset(ctx, size, x, y, offset, z) {
10159
- return crossOffset(ctx, size / 6, x, y, offset, z);
10237
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
10160
10238
  }
10161
10239
  }
10162
10240
  var cross$1 = new CrossSymbol();
@@ -10169,13 +10247,13 @@ class DiamondSymbol extends BaseSymbol {
10169
10247
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
10170
10248
  }
10171
10249
  draw(ctx, size, x, y, z) {
10172
- return diamond(ctx, size / 2, x, y, z);
10250
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10173
10251
  }
10174
10252
  drawFitDir(ctx, size, x, y, z) {
10175
- return diamond(ctx, size / 2, x, y, z);
10253
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10176
10254
  }
10177
10255
  drawOffset(ctx, size, x, y, offset, z) {
10178
- return diamond(ctx, size / 2 + offset, x, y, z);
10256
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10179
10257
  }
10180
10258
  }
10181
10259
  var diamond$1 = new DiamondSymbol();
@@ -10189,10 +10267,10 @@ class SquareSymbol extends BaseSymbol {
10189
10267
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
10190
10268
  }
10191
10269
  draw(ctx, size, x, y) {
10192
- return square(ctx, size / 2, x, y);
10270
+ return square(ctx, this.parseSize(size) / 2, x, y);
10193
10271
  }
10194
10272
  drawOffset(ctx, size, x, y, offset) {
10195
- return square(ctx, size / 2 + offset, x, y);
10273
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
10196
10274
  }
10197
10275
  }
10198
10276
  var square$1 = new SquareSymbol();
@@ -10206,10 +10284,10 @@ class TriangleUpSymbol extends BaseSymbol {
10206
10284
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
10207
10285
  }
10208
10286
  draw(ctx, size, x, y) {
10209
- return trianglUpOffset(ctx, size / 2, x, y);
10287
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
10210
10288
  }
10211
10289
  drawOffset(ctx, size, x, y, offset) {
10212
- return trianglUpOffset(ctx, size / 2, x, y, offset);
10290
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10213
10291
  }
10214
10292
  }
10215
10293
  var triangleUp = new TriangleUpSymbol();
@@ -10241,10 +10319,10 @@ class StarSymbol extends BaseSymbol {
10241
10319
  super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
10242
10320
  }
10243
10321
  draw(ctx, size, transX, transY) {
10244
- return star(ctx, size / 2, transX, transY);
10322
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
10245
10323
  }
10246
10324
  drawOffset(ctx, size, transX, transY, offset) {
10247
- return star(ctx, size / 2 + offset, transX, transY);
10325
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10248
10326
  }
10249
10327
  }
10250
10328
  var star$1 = new StarSymbol();
@@ -10262,10 +10340,10 @@ class ArrowSymbol extends BaseSymbol {
10262
10340
  super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
10263
10341
  }
10264
10342
  draw(ctx, size, transX, transY) {
10265
- return arrow(ctx, size / 2, transX, transY);
10343
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
10266
10344
  }
10267
10345
  drawOffset(ctx, size, transX, transY, offset) {
10268
- return arrow(ctx, size / 2 + offset, transX, transY);
10346
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10269
10347
  }
10270
10348
  }
10271
10349
  var arrow$1 = new ArrowSymbol();
@@ -10279,10 +10357,10 @@ class WedgeSymbol extends BaseSymbol {
10279
10357
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
10280
10358
  }
10281
10359
  draw(ctx, size, transX, transY) {
10282
- return wedge(ctx, size / 2, transX, transY);
10360
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
10283
10361
  }
10284
10362
  drawOffset(ctx, size, transX, transY, offset) {
10285
- return wedge(ctx, size / 2 + offset, transX, transY);
10363
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10286
10364
  }
10287
10365
  }
10288
10366
  var wedge$1 = new WedgeSymbol();
@@ -10295,10 +10373,10 @@ class StrokeSymbol extends BaseSymbol {
10295
10373
  super(...arguments), this.type = "stroke", this.pathStr = "";
10296
10374
  }
10297
10375
  draw(ctx, size, transX, transY) {
10298
- return stroke(ctx, size / 2, transX, transY);
10376
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
10299
10377
  }
10300
10378
  drawOffset(ctx, size, transX, transY, offset) {
10301
- return stroke(ctx, size / 2 + offset, transX, transY);
10379
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10302
10380
  }
10303
10381
  }
10304
10382
  var stroke$1 = new StrokeSymbol();
@@ -10320,10 +10398,10 @@ class WyeSymbol extends BaseSymbol {
10320
10398
  super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
10321
10399
  }
10322
10400
  draw(ctx, size, transX, transY) {
10323
- return wye(ctx, size / 2, transX, transY);
10401
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
10324
10402
  }
10325
10403
  drawOffset(ctx, size, transX, transY, offset) {
10326
- return wye(ctx, size / 2 + offset, transX, transY);
10404
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10327
10405
  }
10328
10406
  }
10329
10407
  var wye$1 = new WyeSymbol();
@@ -10336,10 +10414,10 @@ class TriangleLeftSymbol extends BaseSymbol {
10336
10414
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
10337
10415
  }
10338
10416
  draw(ctx, size, x, y) {
10339
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
10417
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
10340
10418
  }
10341
10419
  drawOffset(ctx, size, x, y, offset) {
10342
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
10420
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10343
10421
  }
10344
10422
  }
10345
10423
  var triangleLeft = new TriangleLeftSymbol();
@@ -10353,10 +10431,10 @@ class TriangleRightSymbol extends BaseSymbol {
10353
10431
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
10354
10432
  }
10355
10433
  draw(ctx, size, x, y) {
10356
- return trianglRightOffset(ctx, size / 2, x, y);
10434
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
10357
10435
  }
10358
10436
  drawOffset(ctx, size, x, y, offset) {
10359
- return trianglRightOffset(ctx, size / 2, x, y, offset);
10437
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10360
10438
  }
10361
10439
  }
10362
10440
  var triangleRight = new TriangleRightSymbol();
@@ -10370,10 +10448,10 @@ class TriangleDownSymbol extends BaseSymbol {
10370
10448
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
10371
10449
  }
10372
10450
  draw(ctx, size, x, y) {
10373
- return trianglDownOffset(ctx, size / 2, x, y);
10451
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
10374
10452
  }
10375
10453
  drawOffset(ctx, size, x, y, offset) {
10376
- return trianglDownOffset(ctx, size / 2, x, y, offset);
10454
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10377
10455
  }
10378
10456
  }
10379
10457
  var triangleDown = new TriangleDownSymbol();
@@ -10388,10 +10466,10 @@ class ThinTriangleSymbol extends BaseSymbol {
10388
10466
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
10389
10467
  }
10390
10468
  draw(ctx, size, x, y) {
10391
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
10469
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
10392
10470
  }
10393
10471
  drawOffset(ctx, size, x, y, offset) {
10394
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
10472
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
10395
10473
  }
10396
10474
  }
10397
10475
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -10405,10 +10483,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
10405
10483
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
10406
10484
  }
10407
10485
  draw(ctx, size, transX, transY) {
10408
- return arrow2Left(ctx, size / 4, transX, transY);
10486
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
10409
10487
  }
10410
10488
  drawOffset(ctx, size, transX, transY, offset) {
10411
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
10489
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10412
10490
  }
10413
10491
  }
10414
10492
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -10422,10 +10500,10 @@ class Arrow2RightSymbol extends BaseSymbol {
10422
10500
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
10423
10501
  }
10424
10502
  draw(ctx, size, transX, transY) {
10425
- return arrow2Right(ctx, size / 4, transX, transY);
10503
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
10426
10504
  }
10427
10505
  drawOffset(ctx, size, transX, transY, offset) {
10428
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
10506
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10429
10507
  }
10430
10508
  }
10431
10509
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -10439,10 +10517,10 @@ class Arrow2UpSymbol extends BaseSymbol {
10439
10517
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
10440
10518
  }
10441
10519
  draw(ctx, size, transX, transY) {
10442
- return arrow2Up(ctx, size / 4, transX, transY);
10520
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
10443
10521
  }
10444
10522
  drawOffset(ctx, size, transX, transY, offset) {
10445
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
10523
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10446
10524
  }
10447
10525
  }
10448
10526
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -10456,10 +10534,10 @@ class Arrow2DownSymbol extends BaseSymbol {
10456
10534
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
10457
10535
  }
10458
10536
  draw(ctx, size, transX, transY) {
10459
- return arrow2Down(ctx, size / 4, transX, transY);
10537
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
10460
10538
  }
10461
10539
  drawOffset(ctx, size, transX, transY, offset) {
10462
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
10540
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10463
10541
  }
10464
10542
  }
10465
10543
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -10472,13 +10550,13 @@ class LineVSymbol extends BaseSymbol {
10472
10550
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
10473
10551
  }
10474
10552
  draw(ctx, size, x, y, z) {
10475
- return lineV(ctx, size / 2, x, y);
10553
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
10476
10554
  }
10477
10555
  drawOffset(ctx, size, x, y, offset, z) {
10478
- return lineV(ctx, size / 2 + offset, x, y);
10556
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
10479
10557
  }
10480
10558
  drawToSvgPath(size, x, y, z) {
10481
- const r = size / 2;
10559
+ const r = this.parseSize(size) / 2;
10482
10560
  return `M ${x}, ${y - r} L ${x},${y + r}`;
10483
10561
  }
10484
10562
  }
@@ -10492,13 +10570,13 @@ class LineHSymbol extends BaseSymbol {
10492
10570
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
10493
10571
  }
10494
10572
  draw(ctx, size, x, y, z) {
10495
- return lineH(ctx, size / 2, x, y);
10573
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
10496
10574
  }
10497
10575
  drawOffset(ctx, size, x, y, offset, z) {
10498
- return lineH(ctx, size / 2 + offset, x, y);
10576
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
10499
10577
  }
10500
10578
  drawToSvgPath(size, x, y, z) {
10501
- const r = size / 2;
10579
+ const r = this.parseSize(size) / 2;
10502
10580
  return `M ${x - r}, ${y} L ${x + r},${y}`;
10503
10581
  }
10504
10582
  }
@@ -10512,13 +10590,13 @@ class CloseSymbol extends BaseSymbol {
10512
10590
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
10513
10591
  }
10514
10592
  draw(ctx, size, x, y, z) {
10515
- return close(ctx, size / 2, x, y);
10593
+ return close(ctx, this.parseSize(size) / 2, x, y);
10516
10594
  }
10517
10595
  drawOffset(ctx, size, x, y, offset, z) {
10518
- return close(ctx, size / 2 + offset, x, y);
10596
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
10519
10597
  }
10520
10598
  drawToSvgPath(size, x, y, z) {
10521
- const r = size / 2;
10599
+ const r = this.parseSize(size) / 2;
10522
10600
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
10523
10601
  }
10524
10602
  }
@@ -10552,15 +10630,18 @@ class CustomSymbolClass {
10552
10630
  this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
10553
10631
  }
10554
10632
  drawOffset(ctx, size, x, y, offset, z, cb) {
10555
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10633
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10556
10634
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
10557
10635
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
10558
10636
  }
10559
10637
  draw(ctx, size, x, y, z, cb) {
10560
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
10638
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
10639
+ }
10640
+ parseSize(size) {
10641
+ return isNumber(size) ? size : Math.min(size[0], size[1]);
10561
10642
  }
10562
10643
  bounds(size, bounds) {
10563
- if (this.isSvg) {
10644
+ if (size = this.parseSize(size), this.isSvg) {
10564
10645
  if (!this.svgCache) return;
10565
10646
  return bounds.clear(), void this.svgCache.forEach(_ref => {
10566
10647
  let {
@@ -11064,7 +11145,11 @@ class Paragraph {
11064
11145
  case "sub":
11065
11146
  baseline += this.descent / 2;
11066
11147
  }
11067
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
11148
+ "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
11149
+ const {
11150
+ lineWidth = 1
11151
+ } = this.character;
11152
+ this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
11068
11153
  }
11069
11154
  getWidthWithEllips(direction) {
11070
11155
  let text = this.text;
@@ -12925,27 +13010,9 @@ function simplifyRadialDist(points, sqTolerance) {
12925
13010
  for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
12926
13011
  return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
12927
13012
  }
12928
- function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
12929
- let maxSqDist = sqTolerance,
12930
- nextIdx = startIdx;
12931
- const startX = points[startIdx].x,
12932
- startY = points[startIdx].y,
12933
- vecX2 = points[endIdx].x - startX,
12934
- vecY2 = points[endIdx].y - startY,
12935
- sqLength = vecX2 * vecX2 + vecY2 * vecY2;
12936
- let area, sqArea, sqDistance, vecX1, vecY1;
12937
- for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
12938
- maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
12939
- }
12940
- function simplifyDouglasPeucker(points, sqTolerance) {
12941
- const lastIdx = points.length - 1,
12942
- simplified = [points[0]];
12943
- return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
12944
- }
12945
13013
  function flatten_simplify(points, tolerance, highestQuality) {
12946
13014
  if (points.length <= 10) return points;
12947
- const sqTolerance = void 0 !== tolerance ? tolerance * tolerance : 1;
12948
- return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
13015
+ return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
12949
13016
  }
12950
13017
 
12951
13018
  let loadArcModule = !1;
@@ -13269,8 +13336,9 @@ class PickerBase {
13269
13336
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
13270
13337
  if (picked) return !0;
13271
13338
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
13272
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13273
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13339
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13340
+ keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13341
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13274
13342
  }), pickContext.highPerformanceRestore(), picked;
13275
13343
  }
13276
13344
  }
@@ -13492,8 +13560,9 @@ class RectPickerBase {
13492
13560
  if (!onlyTranslate || rect.shadowRoot || isNumber(cornerRadius, !0) && 0 !== cornerRadius || isArray(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
13493
13561
  if (picked) return !0;
13494
13562
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
13495
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13496
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13563
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13564
+ keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13565
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13497
13566
  });else {
13498
13567
  const {
13499
13568
  fill = rectAttribute.fill,
@@ -13672,8 +13741,9 @@ class BaseLinePicker extends BaseRender {
13672
13741
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
13673
13742
  if (picked) return !0;
13674
13743
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
13675
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13676
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13744
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13745
+ keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13746
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13677
13747
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
13678
13748
  }
13679
13749
  }
@@ -13808,8 +13878,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
13808
13878
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
13809
13879
  if (picked) return !0;
13810
13880
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
13811
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13812
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13881
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13882
+ keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13883
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13813
13884
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
13814
13885
  }
13815
13886
  };
@@ -14456,6 +14527,288 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
14456
14527
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
14457
14528
  };
14458
14529
 
14530
+ var ScrollBarPlugin_1;
14531
+ let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
14532
+ constructor() {
14533
+ this.name = 'scrollbar';
14534
+ this.activeEvent = 'onRegister';
14535
+ this._uid = Generator.GenAutoIncrementId();
14536
+ this.key = this.name + this._uid;
14537
+ this.scroll = (e) => {
14538
+ var _a, _b;
14539
+ const graphic = e.target;
14540
+ const data = this.getScrollContainer(graphic);
14541
+ if (!data && !this.scrollContainer) {
14542
+ return;
14543
+ }
14544
+ if (!data && this.scrollContainer) {
14545
+ if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
14546
+ return;
14547
+ }
14548
+ const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
14549
+ if (!newScrollContainer) {
14550
+ this.clearScrollbar(this.scrollContainer.g, 'all');
14551
+ return;
14552
+ }
14553
+ if (this.scrollContainer.showH && !newScrollContainer.showH) {
14554
+ this.clearScrollbar(this.scrollContainer.g, 'horizontal');
14555
+ }
14556
+ if (this.scrollContainer.showV && !newScrollContainer.showV) {
14557
+ this.clearScrollbar(this.scrollContainer.g, 'vertical');
14558
+ }
14559
+ this.scrollContainer = newScrollContainer;
14560
+ }
14561
+ else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
14562
+ this.clearScrollbar(this.scrollContainer.g, 'all');
14563
+ }
14564
+ this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
14565
+ const scrollContainer = data.g;
14566
+ const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
14567
+ let newScrollX = scrollX;
14568
+ let newScrollY = scrollY;
14569
+ let { showH, showV } = data;
14570
+ this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
14571
+ if (showH && showH) {
14572
+ if (abs(e.deltaX) > abs(e.deltaY)) {
14573
+ showH = showH && true;
14574
+ showV = showV && false;
14575
+ }
14576
+ else {
14577
+ showH = showH && false;
14578
+ showV = showV && true;
14579
+ }
14580
+ }
14581
+ const childrenBounds = this.childrenBounds;
14582
+ childrenBounds.clear();
14583
+ childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
14584
+ const scrollWidth = childrenBounds.width();
14585
+ const scrollHeight = childrenBounds.height();
14586
+ if (showH) {
14587
+ newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
14588
+ }
14589
+ else {
14590
+ newScrollX = -scrollX;
14591
+ }
14592
+ if (showV) {
14593
+ newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
14594
+ }
14595
+ else {
14596
+ newScrollY = -scrollY;
14597
+ }
14598
+ childrenBounds.translate(-newScrollX, -newScrollY);
14599
+ this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
14600
+ scrollContainer.setAttributes({
14601
+ scrollX: -newScrollX,
14602
+ scrollY: -newScrollY
14603
+ });
14604
+ };
14605
+ this.handleScrollBarChange = (params) => {
14606
+ if (!this.scrollContainer ||
14607
+ !this.scrollContainerBounds ||
14608
+ !this.childrenBounds ||
14609
+ !params ||
14610
+ !params.target ||
14611
+ !params.detail ||
14612
+ !params.detail.value) {
14613
+ return;
14614
+ }
14615
+ const scrollbar = params.target;
14616
+ const newRange = params.detail.value;
14617
+ if (scrollbar.attribute.direction === 'horizontal') {
14618
+ const scrollWidth = this.childrenBounds.width();
14619
+ this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
14620
+ }
14621
+ else {
14622
+ const scrollHeight = this.childrenBounds.height();
14623
+ this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
14624
+ }
14625
+ };
14626
+ }
14627
+ activate(context) {
14628
+ this.pluginService = context;
14629
+ const { stage } = this.pluginService;
14630
+ this.childrenBounds = new AABBBounds();
14631
+ stage.addEventListener('wheel', this.scroll);
14632
+ this.params = ScrollBarPlugin_1.defaultParams;
14633
+ }
14634
+ initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
14635
+ scrollContainer.addEventListener('pointerover', () => {
14636
+ scrollbar.setAttribute('visibleAll', true);
14637
+ });
14638
+ scrollContainer.addEventListener('pointermove', () => {
14639
+ scrollbar.setAttribute('visibleAll', true);
14640
+ });
14641
+ scrollContainer.addEventListener('pointerout', () => {
14642
+ scrollbar.setAttribute('visibleAll', false);
14643
+ });
14644
+ scrollbar.addEventListener('pointerover', () => {
14645
+ scrollbar.setAttribute('visibleAll', true);
14646
+ });
14647
+ scrollbar.addEventListener('pointerout', () => {
14648
+ scrollbar.setAttribute('visibleAll', true);
14649
+ });
14650
+ scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
14651
+ scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
14652
+ }
14653
+ addOrUpdateScroll(showH, showV, container, scrollContainer) {
14654
+ if (showH) {
14655
+ const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
14656
+ if (!isUpdate) {
14657
+ this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
14658
+ }
14659
+ }
14660
+ else {
14661
+ this.clearScrollbar(scrollContainer, 'horizontal');
14662
+ }
14663
+ if (showV) {
14664
+ const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
14665
+ if (!isUpdate) {
14666
+ this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
14667
+ }
14668
+ }
14669
+ else {
14670
+ this.clearScrollbar(scrollContainer, 'vertical');
14671
+ }
14672
+ }
14673
+ getDirection(isHorozntal) {
14674
+ return isHorozntal ? 'horizontal' : 'vertical';
14675
+ }
14676
+ addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
14677
+ var _a;
14678
+ const direction = this.getDirection(isHorozntal);
14679
+ const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
14680
+ const scrollbars = container.children.filter((g) => g.name === name);
14681
+ let isUpdate = true;
14682
+ let scrollBar = scrollbars[0];
14683
+ const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
14684
+ const attrs = {
14685
+ x: 0,
14686
+ y: 0,
14687
+ direction,
14688
+ zIndex: zIndex + 1,
14689
+ visibleAll: true,
14690
+ padding: [2, 0],
14691
+ railStyle: {
14692
+ fill: 'rgba(0, 0, 0, .1)'
14693
+ },
14694
+ range: [0, 0.05]
14695
+ };
14696
+ if (isHorozntal) {
14697
+ attrs.width = this.scrollContainerBounds.width();
14698
+ attrs.height = 12;
14699
+ }
14700
+ else {
14701
+ attrs.height = this.scrollContainerBounds.height();
14702
+ attrs.width = 12;
14703
+ }
14704
+ if (!scrollBar) {
14705
+ isUpdate = false;
14706
+ scrollBar = new ScrollBar(attrs);
14707
+ scrollBar.name = name;
14708
+ container.add(scrollBar);
14709
+ scrollBar.isScrollBar = true;
14710
+ }
14711
+ else if (scrollbars.length > 1) {
14712
+ scrollbars.forEach((child, index) => {
14713
+ var _a;
14714
+ if (index) {
14715
+ (_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
14716
+ }
14717
+ });
14718
+ }
14719
+ const childrenBounds = this.childrenBounds;
14720
+ if (isHorozntal) {
14721
+ const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
14722
+ const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
14723
+ attrs.x = x + dx;
14724
+ attrs.y = y + dy + height - this.scrollContainerBounds.height();
14725
+ attrs.range = [-start, -start + ratio];
14726
+ }
14727
+ else {
14728
+ const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
14729
+ const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
14730
+ attrs.x = x + dx + width - this.scrollContainerBounds.width();
14731
+ attrs.y = y + dy;
14732
+ attrs.range = [-start, -start + ratio];
14733
+ }
14734
+ scrollBar.setAttributes(attrs);
14735
+ return {
14736
+ scrollBar,
14737
+ isUpdate
14738
+ };
14739
+ }
14740
+ clearScrollbar(scrollContainer, type) {
14741
+ if (!scrollContainer.parent) {
14742
+ return;
14743
+ }
14744
+ const scrollbarBars = scrollContainer.parent.children.filter((child) => {
14745
+ return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
14746
+ });
14747
+ scrollbarBars.forEach((child) => {
14748
+ child.parent.removeChild(child);
14749
+ });
14750
+ }
14751
+ formatScrollContainer(g) {
14752
+ if (!g || g.type !== 'group' || !g.attribute) {
14753
+ return null;
14754
+ }
14755
+ const { overflow, width, height } = g.attribute;
14756
+ if (!overflow || overflow === 'hidden') {
14757
+ return null;
14758
+ }
14759
+ let showH = false;
14760
+ let showV = false;
14761
+ if (overflow === 'scroll') {
14762
+ showH = true;
14763
+ showV = true;
14764
+ }
14765
+ else {
14766
+ showH = overflow === 'scroll-x';
14767
+ showV = !showH;
14768
+ }
14769
+ if (!g.AABBBounds.empty()) {
14770
+ if (showH) {
14771
+ showH = width < g.AABBBounds.width();
14772
+ }
14773
+ if (showV) {
14774
+ showV = height < g.AABBBounds.height();
14775
+ }
14776
+ }
14777
+ return showH || showV ? { g: g, showH, showV } : null;
14778
+ }
14779
+ getScrollContainer(graphic) {
14780
+ let g = graphic;
14781
+ while (g) {
14782
+ const res = this.formatScrollContainer(g);
14783
+ if (res) {
14784
+ return res;
14785
+ }
14786
+ g = g.parent;
14787
+ }
14788
+ return null;
14789
+ }
14790
+ deactivate(context) {
14791
+ const { stage } = this.pluginService;
14792
+ stage.removeEventListener('wheel', this.scroll);
14793
+ }
14794
+ };
14795
+ ScrollBarPlugin.defaultParams = {
14796
+ timeout: 500
14797
+ };
14798
+ ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
14799
+ injectable()
14800
+ ], ScrollBarPlugin);
14801
+
14802
+ const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
14803
+ if (!isBound(ScrollBarPlugin)) {
14804
+ bind(ScrollBarPlugin).toSelf();
14805
+ bind(AutoEnablePlugins).toService(ScrollBarPlugin);
14806
+ }
14807
+ });
14808
+ function loadScrollbar() {
14809
+ container.load(scrollbarModule);
14810
+ }
14811
+
14459
14812
  function traverseGroup(group, cb) {
14460
14813
  group.forEachChildren(node => {
14461
14814
  const stopped = cb(node);
@@ -15807,19 +16160,22 @@ function bitmapTool(width, height, padding = { top: 0, left: 0, right: 0, bottom
15807
16160
  scale.height = height;
15808
16161
  return scale;
15809
16162
  }
15810
- function boundToRange($, bound, clamp$1 = false) {
15811
- if (clamp$1) {
15812
- const { x1, x2, y1, y2 } = bound;
15813
- const _x1 = clamp(x1, 0, $.width);
15814
- const _x2 = clamp(x2, 0, $.width);
15815
- const _y1 = clamp(y1, 0, $.height);
15816
- const _y2 = clamp(y2, 0, $.height);
15817
- return {
15818
- x1: $.x(_x1),
15819
- x2: $.x(_x2),
15820
- y1: $.y(_y1),
15821
- y2: $.y(_y2)
15822
- };
16163
+ function clampRangeByBitmap($, range) {
16164
+ const { x1, x2, y1, y2 } = range;
16165
+ const _x1 = clamp(x1, 0, $.width);
16166
+ const _x2 = clamp(x2, 0, $.width);
16167
+ const _y1 = clamp(y1, 0, $.height);
16168
+ const _y2 = clamp(y2, 0, $.height);
16169
+ return {
16170
+ x1: $.x(_x1),
16171
+ x2: $.x(_x2),
16172
+ y1: $.y(_y1),
16173
+ y2: $.y(_y2)
16174
+ };
16175
+ }
16176
+ function boundToRange($, bound, clamp = false) {
16177
+ if (clamp) {
16178
+ return clampRangeByBitmap($, bound);
15823
16179
  }
15824
16180
  return {
15825
16181
  x1: $.x(bound.x1),
@@ -15840,10 +16196,13 @@ function canPlace($, bitmap, bound, checkBound = true, pad = 0) {
15840
16196
  };
15841
16197
  }
15842
16198
  range = boundToRange($, range);
15843
- const outOfBounds = checkBound && bitmap.outOfBounds(range);
15844
- if (outOfBounds) {
16199
+ const outOfBounds = bitmap.outOfBounds(range);
16200
+ if (checkBound && outOfBounds) {
15845
16201
  return false;
15846
16202
  }
16203
+ if (outOfBounds) {
16204
+ range = clampRangeByBitmap($, range);
16205
+ }
15847
16206
  return !bitmap.getRange(range);
15848
16207
  }
15849
16208
  function placeToCandidates($, bitmap, text, candidates = [], clampForce = true, pad = 0) {
@@ -15907,24 +16266,29 @@ function defaultLabelPosition(type) {
15907
16266
  return DefaultPositions;
15908
16267
  }
15909
16268
  }
15910
- function clampText(text, width, height) {
16269
+ function clampText(text, width, height, padding = {}) {
15911
16270
  const { x1, x2, y1, y2 } = text.AABBBounds;
16271
+ const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
15912
16272
  const minX = Math.min(x1, x2);
15913
16273
  const maxX = Math.max(x1, x2);
15914
16274
  const minY = Math.min(y1, y2);
15915
16275
  const maxY = Math.max(y1, y2);
16276
+ const minXWithPadding = 0 - left;
16277
+ const maxXWithPadding = width + right;
16278
+ const minYWithPadding = 0 - top;
16279
+ const maxYWithPadding = height + bottom;
15916
16280
  let dx = 0;
15917
16281
  let dy = 0;
15918
- if (minX < 0 && maxX - minX <= width) {
16282
+ if (minX < minXWithPadding && maxX - minX <= width) {
15919
16283
  dx = -minX;
15920
16284
  }
15921
- else if (maxX > width && minX - (maxX - width) >= 0) {
16285
+ else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
15922
16286
  dx = width - maxX;
15923
16287
  }
15924
- if (minY < 0 && maxY - minY <= height) {
16288
+ if (minY < minYWithPadding && maxY - minY <= height) {
15925
16289
  dy = -minY;
15926
16290
  }
15927
- else if (maxY > height && minY - (maxY - height) >= 0) {
16291
+ else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
15928
16292
  dy = height - maxY;
15929
16293
  }
15930
16294
  return { dx, dy };
@@ -16224,6 +16588,151 @@ function loadLabelComponent() {
16224
16588
  registerLine();
16225
16589
  }
16226
16590
 
16591
+ const isIntersect = (top, bottom) => {
16592
+ return Math.ceil(top) > Math.floor(bottom);
16593
+ };
16594
+ const isXIntersect = ([a, b], [c, d]) => {
16595
+ return d > a && b > c;
16596
+ };
16597
+ function getIntersectionLength(range1, range2) {
16598
+ const [start1, end1] = range1;
16599
+ const [start2, end2] = range2;
16600
+ const start = Math.max(start1, start2);
16601
+ const end = Math.min(end1, end2);
16602
+ return Math.max(0, end - start);
16603
+ }
16604
+ function shiftY(texts, option) {
16605
+ const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
16606
+ const n = texts.length;
16607
+ if (n <= 1) {
16608
+ return texts;
16609
+ }
16610
+ const xMap = new Map();
16611
+ const textInformation = new Map();
16612
+ const getY1Initial = (text) => textInformation.get(text).y1Initial;
16613
+ const getHeight = (text) => textInformation.get(text).height;
16614
+ const getY1 = (text) => textInformation.get(text).y1;
16615
+ const getY = (text) => textInformation.get(text).y;
16616
+ const getX = (text) => textInformation.get(text).x;
16617
+ const getX1 = (text) => textInformation.get(text).x1;
16618
+ const getX2 = (text) => textInformation.get(text).x2;
16619
+ const setY1 = (text, y) => {
16620
+ textInformation.get(text).y1 = y;
16621
+ };
16622
+ function adjustPositionInOneGroup(texts) {
16623
+ if (texts.length === 1) {
16624
+ return;
16625
+ }
16626
+ for (let i = texts.length - 1; i > 0; i--) {
16627
+ const curText = texts[i];
16628
+ const upperText = texts[i - 1];
16629
+ const lowerText = texts[i + 1];
16630
+ if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
16631
+ const { y } = labelling(curText);
16632
+ if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
16633
+ if (y + getHeight(curText) / 2 <= maxY) {
16634
+ setY1(curText, getY1(curText) + y - getY(curText));
16635
+ }
16636
+ }
16637
+ }
16638
+ }
16639
+ }
16640
+ texts.sort((a, b) => a.attribute.x - b.attribute.x);
16641
+ for (const text of texts) {
16642
+ const { y1, y2, x1, x2 } = text.AABBBounds;
16643
+ const { x, y } = text.attribute;
16644
+ textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
16645
+ let hasRange = false;
16646
+ for (const [range, xGroupTexts] of xMap) {
16647
+ const { start, end } = range;
16648
+ if (x1 >= start && x2 <= end) {
16649
+ xGroupTexts.push(text);
16650
+ hasRange = true;
16651
+ }
16652
+ else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
16653
+ const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16654
+ xGroupTexts.push(text);
16655
+ xMap.set(newRange, xGroupTexts);
16656
+ xMap.delete(range);
16657
+ hasRange = true;
16658
+ }
16659
+ else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
16660
+ const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16661
+ xGroupTexts.push(text);
16662
+ xMap.set(newRange, xGroupTexts);
16663
+ xMap.delete(range);
16664
+ hasRange = true;
16665
+ }
16666
+ if (hasRange) {
16667
+ break;
16668
+ }
16669
+ }
16670
+ if (!hasRange) {
16671
+ xMap.set({ start: x1, end: x2 }, [text]);
16672
+ }
16673
+ }
16674
+ for (const xTexts of xMap.values()) {
16675
+ xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
16676
+ adjustPositionInOneGroup(xTexts);
16677
+ }
16678
+ for (let iter = 0; iter < maxIterations; iter++) {
16679
+ texts.sort((a, b) => getY1(a) - getY1(b));
16680
+ let error = 0;
16681
+ for (let i = 0; i < n - 1; i++) {
16682
+ const curText = texts[i];
16683
+ let j = i + 1;
16684
+ let nextText;
16685
+ while ((nextText = texts[j]) &&
16686
+ !isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16687
+ j += 1;
16688
+ }
16689
+ if (nextText) {
16690
+ const y1 = getY1(curText);
16691
+ const h0 = getHeight(curText);
16692
+ const nextY1 = getY1(nextText);
16693
+ const delta = nextY1 - (y1 + h0);
16694
+ if (delta < padding) {
16695
+ const newDelta = (padding - delta) / 2;
16696
+ error = Math.max(error, newDelta);
16697
+ if (y1 + newDelta + getHeight(nextText) > maxY) {
16698
+ setY1(curText, y1 - (padding - delta));
16699
+ }
16700
+ else if (y1 - newDelta < 0) {
16701
+ setY1(nextText, nextY1 + (padding - delta));
16702
+ }
16703
+ else {
16704
+ setY1(curText, y1 - newDelta);
16705
+ setY1(nextText, nextY1 + newDelta);
16706
+ }
16707
+ }
16708
+ }
16709
+ }
16710
+ if (error < maxError) {
16711
+ break;
16712
+ }
16713
+ }
16714
+ for (const text of texts) {
16715
+ const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
16716
+ text.setAttribute('y', finalY);
16717
+ }
16718
+ const result = [];
16719
+ texts.sort((a, b) => a.attribute.x - b.attribute.x);
16720
+ let start = 0;
16721
+ let end = texts.length - 1;
16722
+ while (start <= end) {
16723
+ if (start === end) {
16724
+ result.push(texts[start]);
16725
+ }
16726
+ else {
16727
+ result.push(texts[start]);
16728
+ result.push(texts[end]);
16729
+ }
16730
+ start++;
16731
+ end--;
16732
+ }
16733
+ return result;
16734
+ }
16735
+
16227
16736
  loadLabelComponent();
16228
16737
  class LabelBase extends AbstractComponent {
16229
16738
  setBitmap(bitmap) {
@@ -16537,12 +17046,11 @@ class LabelBase extends AbstractComponent {
16537
17046
  return texts;
16538
17047
  }
16539
17048
  _overlapping(labels) {
16540
- var _a, _b, _c, _d;
17049
+ var _a, _b, _c;
16541
17050
  if (labels.length === 0) {
16542
17051
  return [];
16543
17052
  }
16544
17053
  const option = (isObject(this.attribute.overlap) ? this.attribute.overlap : {});
16545
- const result = [];
16546
17054
  const baseMarkGroup = this.getBaseMarkGroup();
16547
17055
  const size = (_a = option.size) !== null && _a !== void 0 ? _a : {
16548
17056
  width: (_b = baseMarkGroup === null || baseMarkGroup === void 0 ? void 0 : baseMarkGroup.AABBBounds.width()) !== null && _b !== void 0 ? _b : 0,
@@ -16551,12 +17059,62 @@ class LabelBase extends AbstractComponent {
16551
17059
  if (size.width === 0 || size.height === 0) {
16552
17060
  return labels;
16553
17061
  }
16554
- const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
17062
+ const { strategy, priority } = option;
16555
17063
  const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
16556
17064
  const bitmap = this._bitmap || bmpTool.bitmap();
17065
+ if (priority) {
17066
+ labels = labels.sort((a, b) => priority(b.attribute.data) - priority(a.attribute.data));
17067
+ }
17068
+ if ((strategy === null || strategy === void 0 ? void 0 : strategy.type) === 'shiftY') {
17069
+ return this._overlapGlobal(labels, option, bmpTool, bitmap);
17070
+ }
17071
+ return this._overlapByStrategy(labels, option, bmpTool, bitmap);
17072
+ }
17073
+ _overlapGlobal(labels, option, bmpTool, bitmap) {
17074
+ let result = labels.filter(label => label.attribute.visible && label.attribute.opacity !== 0);
17075
+ const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;
17076
+ if (clampForce) {
17077
+ for (let i = 0; i < result.length; i++) {
17078
+ const text = labels[i];
17079
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
17080
+ if (dx !== 0 || dy !== 0) {
17081
+ text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
17082
+ text._isClamped = true;
17083
+ }
17084
+ }
17085
+ }
17086
+ result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
17087
+ const baseMark = this.getRelatedGraphic(text.attribute);
17088
+ const graphicBound = this._isCollectionBase
17089
+ ? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
17090
+ : this.getGraphicBounds(baseMark, text);
17091
+ return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
17092
+ } }));
17093
+ for (let i = 0; i < result.length; i++) {
17094
+ const text = result[i];
17095
+ const bounds = text.AABBBounds;
17096
+ const range = boundToRange(bmpTool, bounds, true);
17097
+ if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
17098
+ bitmap.setRange(range);
17099
+ }
17100
+ else {
17101
+ if (hideOnHit) {
17102
+ text.setAttributes({ visible: false });
17103
+ }
17104
+ else {
17105
+ bitmap.setRange(range);
17106
+ }
17107
+ }
17108
+ }
17109
+ return result;
17110
+ }
17111
+ _overlapByStrategy(labels, option, bmpTool, bitmap) {
17112
+ var _a;
17113
+ const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
17114
+ const result = [];
16557
17115
  const checkBounds = strategy.some(s => s.type === 'bound');
16558
17116
  if (avoidBaseMark) {
16559
- (_d = this._baseMarks) === null || _d === void 0 ? void 0 : _d.forEach(mark => {
17117
+ (_a = this._baseMarks) === null || _a === void 0 ? void 0 : _a.forEach(mark => {
16560
17118
  mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));
16561
17119
  });
16562
17120
  }
@@ -16573,7 +17131,7 @@ class LabelBase extends AbstractComponent {
16573
17131
  });
16574
17132
  }
16575
17133
  for (let i = 0; i < labels.length; i++) {
16576
- if (labels[i].visible === false) {
17134
+ if (labels[i].attribute.visible === false) {
16577
17135
  continue;
16578
17136
  }
16579
17137
  const text = labels[i];
@@ -16609,7 +17167,7 @@ class LabelBase extends AbstractComponent {
16609
17167
  }
16610
17168
  }
16611
17169
  if (!hasPlace && clampForce) {
16612
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
17170
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
16613
17171
  if (dx === 0 && dy === 0) {
16614
17172
  if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
16615
17173
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
@@ -16840,7 +17398,7 @@ class LabelBase extends AbstractComponent {
16840
17398
  return listener;
16841
17399
  }
16842
17400
  _smartInvert(labels) {
16843
- var _a, _b, _c, _d, _e;
17401
+ var _a, _b, _c, _d, _e, _f, _g;
16844
17402
  const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {});
16845
17403
  const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;
16846
17404
  const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
@@ -16857,8 +17415,15 @@ class LabelBase extends AbstractComponent {
16857
17415
  continue;
16858
17416
  }
16859
17417
  const baseMark = this.getRelatedGraphic(label.attribute);
16860
- const backgroundColor = baseMark.attribute.fill;
16861
- const foregroundColor = label.attribute.fill;
17418
+ let backgroundColor = baseMark.attribute.fill;
17419
+ let foregroundColor = label.attribute.fill;
17420
+ if (isObject(backgroundColor) && backgroundColor.gradient) {
17421
+ const firstStopColor = (_g = (_f = backgroundColor.stops) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.color;
17422
+ if (firstStopColor) {
17423
+ backgroundColor = firstStopColor;
17424
+ foregroundColor = firstStopColor;
17425
+ }
17426
+ }
16862
17427
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
16863
17428
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
16864
17429
  const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
@@ -17086,6 +17651,9 @@ class ArcLabel extends LabelBase {
17086
17651
  this._alignOffset = 0;
17087
17652
  }
17088
17653
  _overlapping(labels) {
17654
+ if (['inside', 'inside-center'].includes(this.attribute.position)) {
17655
+ return super._overlapping(labels);
17656
+ }
17089
17657
  return labels;
17090
17658
  }
17091
17659
  labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
@@ -18902,12 +19470,14 @@ function autoHide(labels, config) {
18902
19470
  do {
18903
19471
  items = reduce(items, sep);
18904
19472
  } while (items.length >= 3 && hasOverlap(items, sep));
18905
- const shouldCheck = (length, visibility) => length < 3 || visibility;
18906
- const checkFirst = shouldCheck(items.length, config.firstVisible);
19473
+ const shouldCheck = (length, visibility, checkLength = true) => {
19474
+ return checkLength ? length < 3 || visibility : visibility;
19475
+ };
19476
+ const checkFirst = shouldCheck(items.length, config.firstVisible, false);
18907
19477
  let checkLast = shouldCheck(items.length, config.lastVisible);
18908
19478
  const firstSourceItem = source[0];
18909
19479
  const lastSourceItem = last(source);
18910
- if (textIntersect(firstSourceItem, lastSourceItem, sep)) {
19480
+ if (textIntersect(firstSourceItem, lastSourceItem, sep) && checkFirst && checkLast) {
18911
19481
  lastSourceItem.setAttribute('opacity', 0);
18912
19482
  checkLast = false;
18913
19483
  }
@@ -19105,15 +19675,24 @@ function autoLimit(labels, config) {
19105
19675
  return;
19106
19676
  }
19107
19677
  const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);
19678
+ const firstLabel = labels[0];
19679
+ const angle = firstLabel.attribute.angle;
19680
+ const hasAngle = !isNil(angle);
19681
+ const cos = hasAngle ? Math.cos(angle) : 1;
19682
+ const sin = hasAngle ? Math.sin(angle) : 0;
19683
+ const isHorizontal = isAngleHorizontal(angle);
19684
+ const isVertical = isAngleVertical(angle);
19685
+ const isX = orient === 'top' || orient === 'bottom';
19686
+ const direction = firstLabel.attribute.direction;
19687
+ const THRESHOLD = 2;
19688
+ const checkBox = !isHorizontal &&
19689
+ !isVertical &&
19690
+ isX &&
19691
+ (labels.length < 2 ||
19692
+ labels.some(label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= THRESHOLD)) &&
19693
+ firstLabel.AABBBounds.width() > Math.abs(limitLength / sin);
19108
19694
  labels.forEach(label => {
19109
19695
  var _a;
19110
- const angle = label.attribute.angle;
19111
- const hasAngle = !isNil(angle);
19112
- const cos = hasAngle ? Math.cos(angle) : 1;
19113
- const sin = hasAngle ? Math.sin(angle) : 0;
19114
- const isHorizontal = isAngleHorizontal(angle);
19115
- const isVertical = isAngleVertical(angle);
19116
- const isX = orient === 'top' || orient === 'bottom';
19117
19696
  if (isX) {
19118
19697
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
19119
19698
  return;
@@ -19122,7 +19701,6 @@ function autoLimit(labels, config) {
19122
19701
  return;
19123
19702
  }
19124
19703
  }
19125
- const direction = label.attribute.direction;
19126
19704
  if (!isX) {
19127
19705
  if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {
19128
19706
  return;
@@ -19142,12 +19720,18 @@ function autoLimit(labels, config) {
19142
19720
  const { x1, x2 } = label.AABBBounds;
19143
19721
  const tan = sin / cos;
19144
19722
  const verticalSizeLimit = Math.abs(limitLength / sin);
19145
- if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {
19146
- const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right;
19723
+ if (checkBox &&
19724
+ tan > 0 &&
19725
+ x1 <= axisLength + overflowLimitLength.right &&
19726
+ limitLength / tan + x1 > axisLength + overflowLimitLength.right) {
19727
+ const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos);
19147
19728
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
19148
19729
  }
19149
- else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {
19150
- const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left;
19730
+ else if (checkBox &&
19731
+ tan < 0 &&
19732
+ x2 >= -overflowLimitLength.left &&
19733
+ limitLength / tan + x2 < -overflowLimitLength.left) {
19734
+ const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos);
19151
19735
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
19152
19736
  }
19153
19737
  else {
@@ -19181,24 +19765,37 @@ function autoWrap(labels, config) {
19181
19765
  if (isEmpty(labels) || !isValidNumber(limitLength)) {
19182
19766
  return;
19183
19767
  }
19184
- const verticalLimitLength = axisLength / labels.length;
19185
- labels.forEach(label => {
19186
- var _a;
19187
- const angle = label.attribute.angle;
19188
- const isHorizontal = isAngleHorizontal(angle);
19189
- const isVertical = isAngleVertical(angle);
19190
- const isX = orient === 'top' || orient === 'bottom';
19768
+ const firstLabel = labels[0];
19769
+ const angle = firstLabel.attribute.angle;
19770
+ const isHorizontal = isAngleHorizontal(angle);
19771
+ const isVertical = isAngleVertical(angle);
19772
+ const isX = orient === 'top' || orient === 'bottom';
19773
+ let verticalLimitLength = axisLength / labels.length;
19774
+ labels.forEach((label, index) => {
19775
+ var _a, _b, _c, _d, _e;
19191
19776
  if (isX) {
19192
19777
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
19193
19778
  return;
19194
19779
  }
19195
- if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {
19196
- return;
19780
+ if (isHorizontal) {
19781
+ const curLabelX = label.attribute.x;
19782
+ const nextLabelX = (_a = labels[index + 1]) === null || _a === void 0 ? void 0 : _a.attribute.x;
19783
+ const lastLabelX = (_b = labels[index - 1]) === null || _b === void 0 ? void 0 : _b.attribute.x;
19784
+ const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);
19785
+ if (isValidNumber(minGap)) {
19786
+ verticalLimitLength = min(verticalLimitLength, minGap);
19787
+ }
19197
19788
  }
19198
19789
  }
19199
19790
  else {
19200
- if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {
19201
- return;
19791
+ if (isVertical) {
19792
+ const curLabelY = label.attribute.y;
19793
+ const nextLabelY = (_c = labels[index + 1]) === null || _c === void 0 ? void 0 : _c.attribute.y;
19794
+ const lastLabelY = (_d = labels[index - 1]) === null || _d === void 0 ? void 0 : _d.attribute.y;
19795
+ const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);
19796
+ if (isValidNumber(minGap)) {
19797
+ verticalLimitLength = min(verticalLimitLength, minGap);
19798
+ }
19202
19799
  }
19203
19800
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {
19204
19801
  return;
@@ -19228,12 +19825,27 @@ function autoWrap(labels, config) {
19228
19825
  }
19229
19826
  label.setAttributes({
19230
19827
  maxLineWidth: limitLabelLength,
19231
- ellipsis: (_a = label.attribute.ellipsis) !== null && _a !== void 0 ? _a : ellipsis,
19828
+ ellipsis: (_e = label.attribute.ellipsis) !== null && _e !== void 0 ? _e : ellipsis,
19232
19829
  whiteSpace: 'normal',
19233
19830
  heightLimit
19234
19831
  });
19235
19832
  });
19236
19833
  }
19834
+ function getLabelMinGap(current, next, prev) {
19835
+ let minGap;
19836
+ if (isValidNumber(next)) {
19837
+ minGap = Math.abs(next - current);
19838
+ }
19839
+ if (isValidNumber(prev)) {
19840
+ if (isValidNumber(minGap)) {
19841
+ minGap = Math.min(Math.abs(current - prev), minGap);
19842
+ }
19843
+ else {
19844
+ minGap = Math.abs(current - prev);
19845
+ }
19846
+ }
19847
+ return minGap;
19848
+ }
19237
19849
 
19238
19850
  function alignAxisLabels(labels, start, containerSize, orient, align) {
19239
19851
  if (orient === 'left' || orient === 'right') {
@@ -20056,13 +20668,13 @@ class CircleAxis extends AxisBase {
20056
20668
  if (isEmpty(labelShapes)) {
20057
20669
  return;
20058
20670
  }
20059
- const { inside, radius, center, width, height, label, orient } = this.attribute;
20060
- const bounds = width && height
20671
+ const { inside, radius, center, size, label, orient } = this.attribute;
20672
+ const bounds = size
20061
20673
  ? {
20062
20674
  x1: 0,
20063
20675
  y1: 0,
20064
- x2: width,
20065
- y2: height
20676
+ x2: size.width,
20677
+ y2: size.height
20066
20678
  }
20067
20679
  : {
20068
20680
  x1: center.x - radius,
@@ -20430,11 +21042,10 @@ const continuousTicks = (scale, op) => {
20430
21042
  while (items.length >= 3 && hasOverlap(items, labelGap)) {
20431
21043
  items = samplingMethod(items, labelGap);
20432
21044
  }
20433
- const shouldCheck = (length, visibility) => length < 3 || visibility;
20434
- const checkFirst = shouldCheck(items.length, op.labelFirstVisible);
20435
- let checkLast = shouldCheck(items.length, op.labelLastVisible);
21045
+ const checkFirst = op.labelFirstVisible;
21046
+ let checkLast = op.labelLastVisible;
20436
21047
  if (textIntersect(firstSourceItem, lastSourceItem, labelGap)) {
20437
- if (items.includes(lastSourceItem) && items.length > 1) {
21048
+ if (items.includes(lastSourceItem) && items.length > 1 && checkFirst && checkLast) {
20438
21049
  items.splice(items.indexOf(lastSourceItem), 1);
20439
21050
  checkLast = false;
20440
21051
  }
@@ -24171,10 +24782,10 @@ class LegendBase extends AbstractComponent {
24171
24782
  render() {
24172
24783
  this.removeAllChild(true);
24173
24784
  const { interactive = true, title, padding = 0 } = this.attribute;
24174
- const parsedPadding = normalizePadding(padding);
24785
+ this._parsedPadding = normalizePadding(padding);
24175
24786
  const innerView = graphicCreator.group({
24176
- x: parsedPadding[3],
24177
- y: parsedPadding[0],
24787
+ x: this._parsedPadding[3],
24788
+ y: this._parsedPadding[0],
24178
24789
  pickable: interactive,
24179
24790
  childrenPickable: interactive
24180
24791
  });
@@ -24190,8 +24801,8 @@ class LegendBase extends AbstractComponent {
24190
24801
  this._bindEvents();
24191
24802
  }
24192
24803
  const viewBounds = this._innerView.AABBBounds;
24193
- this.attribute.width = viewBounds.width() + parsedPadding[1] + parsedPadding[3];
24194
- this.attribute.height = viewBounds.height() + parsedPadding[0] + parsedPadding[2];
24804
+ this.attribute.width = viewBounds.width() + this._parsedPadding[1] + this._parsedPadding[3];
24805
+ this.attribute.height = viewBounds.height() + this._parsedPadding[0] + this._parsedPadding[2];
24195
24806
  }
24196
24807
  _renderTitle(title) {
24197
24808
  const { text = '', textStyle, padding = 0, background, minWidth, maxWidth, shape } = title;
@@ -24276,6 +24887,7 @@ class DiscreteLegend extends LegendBase {
24276
24887
  this._itemHeightByUser = undefined;
24277
24888
  this._itemHeight = 0;
24278
24889
  this._itemMaxWidth = 0;
24890
+ this._contentMaxHeight = 0;
24279
24891
  this._onHover = (e) => {
24280
24892
  const target = e.target;
24281
24893
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
@@ -24380,11 +24992,12 @@ class DiscreteLegend extends LegendBase {
24380
24992
  });
24381
24993
  }
24382
24994
  _renderItems() {
24383
- const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth, maxHeight, defaultSelected, lazyload, autoPage } = this.attribute;
24995
+ const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth, defaultSelected, lazyload, autoPage } = this.attribute;
24384
24996
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = itemAttrs;
24385
24997
  const itemsContainer = this._itemsContainer;
24386
24998
  const { items: legendItems, isHorizontal, startIndex, isScrollbar } = this._itemContext;
24387
24999
  const maxPages = isScrollbar ? 1 : isHorizontal ? maxRow : maxCol;
25000
+ const maxHeight = this._contentMaxHeight;
24388
25001
  let { doWrap, maxWidthInCol, startX, startY, pages } = this._itemContext;
24389
25002
  let item;
24390
25003
  let lastItemWidth = 0;
@@ -24481,7 +25094,7 @@ class DiscreteLegend extends LegendBase {
24481
25094
  return this._itemContext;
24482
25095
  }
24483
25096
  _renderContent() {
24484
- const { item = {}, items, reversed, maxWidth } = this.attribute;
25097
+ const { item = {}, items, reversed, maxWidth, maxHeight } = this.attribute;
24485
25098
  if (item.visible === false || isEmpty(items)) {
24486
25099
  return;
24487
25100
  }
@@ -24489,6 +25102,7 @@ class DiscreteLegend extends LegendBase {
24489
25102
  if (reversed) {
24490
25103
  legendItems = items === null || items === void 0 ? void 0 : items.reverse();
24491
25104
  }
25105
+ this._contentMaxHeight = Math.max(0, maxHeight - this._parsedPadding[0] - this._parsedPadding[2]);
24492
25106
  const itemsContainer = graphicCreator.group({
24493
25107
  x: 0,
24494
25108
  y: 0
@@ -24526,7 +25140,8 @@ class DiscreteLegend extends LegendBase {
24526
25140
  items: legendItems,
24527
25141
  isHorizontal,
24528
25142
  totalPage: Infinity,
24529
- isScrollbar: pager && pager.type === 'scrollbar'
25143
+ isScrollbar: pager && pager.type === 'scrollbar',
25144
+ clipContainer: undefined
24530
25145
  };
24531
25146
  this._itemContext = this._renderItems();
24532
25147
  let pagerRendered = false;
@@ -24547,11 +25162,21 @@ class DiscreteLegend extends LegendBase {
24547
25162
  }
24548
25163
  const { hover = true, select = true } = this.attribute;
24549
25164
  if (hover) {
24550
- this._itemsContainer.addEventListener('pointermove', this._onHover);
24551
- this._itemsContainer.addEventListener('pointerleave', this._onUnHover);
25165
+ let trigger = 'pointermove';
25166
+ let triggerOff = 'pointerleave';
25167
+ if (isObject(hover)) {
25168
+ hover.trigger && (trigger = hover.trigger);
25169
+ hover.triggerOff && (triggerOff = hover.triggerOff);
25170
+ }
25171
+ this._itemsContainer.addEventListener(trigger, this._onHover);
25172
+ this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
24552
25173
  }
24553
25174
  if (select) {
24554
- this._itemsContainer.addEventListener('pointerdown', this._onClick);
25175
+ let trigger = 'pointerdown';
25176
+ if (isObject(select) && select.trigger) {
25177
+ trigger = select.trigger;
25178
+ }
25179
+ this._itemsContainer.addEventListener(trigger, this._onClick);
24555
25180
  }
24556
25181
  }
24557
25182
  _autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
@@ -24756,8 +25381,8 @@ class DiscreteLegend extends LegendBase {
24756
25381
  _createScrollbar(compStyle, compSize) {
24757
25382
  const { disableTriggerEvent } = this.attribute;
24758
25383
  return this._itemContext.isHorizontal
24759
- ? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: 12 }, compStyle), { width: compSize }))
24760
- : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
25384
+ ? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: compStyle.visible === false ? 0 : 12 }, compStyle), { width: compSize }))
25385
+ : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: compStyle.visible === false ? 0 : 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
24761
25386
  }
24762
25387
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
24763
25388
  const { pager } = this.attribute;
@@ -24797,9 +25422,26 @@ class DiscreteLegend extends LegendBase {
24797
25422
  });
24798
25423
  }
24799
25424
  }
25425
+ _computeScrollbarDelta() {
25426
+ const { isHorizontal, clipContainer } = this._itemContext;
25427
+ const itemContainerBounds = this._itemsContainer.AABBBounds;
25428
+ const clipContainerBounds = clipContainer.AABBBounds;
25429
+ let delta;
25430
+ let innerViewSize;
25431
+ if (isHorizontal) {
25432
+ innerViewSize = clipContainerBounds.width();
25433
+ delta = innerViewSize / itemContainerBounds.width();
25434
+ }
25435
+ else {
25436
+ innerViewSize = clipContainerBounds.height();
25437
+ delta = innerViewSize / itemContainerBounds.height();
25438
+ }
25439
+ return delta;
25440
+ }
24800
25441
  _updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
24801
- const { currentPage, totalPage, isHorizontal } = this._itemContext;
24802
- this._pagerComponent.setScrollRange([(currentPage - 1) / totalPage, currentPage / totalPage]);
25442
+ const { isHorizontal, currentPage, totalPage } = this._itemContext;
25443
+ const start = (currentPage - 1) / totalPage;
25444
+ this._pagerComponent.setScrollRange([start, start + this._computeScrollbarDelta()]);
24803
25445
  if (isHorizontal) {
24804
25446
  this._pagerComponent.setAttributes({
24805
25447
  x: 0,
@@ -24827,13 +25469,7 @@ class DiscreteLegend extends LegendBase {
24827
25469
  newPage = this._itemContext.totalPage;
24828
25470
  }
24829
25471
  else {
24830
- newPage = value[0] * this._itemContext.totalPage;
24831
- if (pager.scrollByPosition) {
24832
- newPage = newPage + 1;
24833
- }
24834
- else {
24835
- newPage = Math.floor(newPage) + 1;
24836
- }
25472
+ newPage = value[0] * this._itemContext.totalPage + 1;
24837
25473
  }
24838
25474
  return newPage;
24839
25475
  }
@@ -24847,6 +25483,7 @@ class DiscreteLegend extends LegendBase {
24847
25483
  const { width, height } = scrollComponent.getSliderRenderBounds();
24848
25484
  const currentScrollValue = direction === 'vertical' ? e.deltaY / height : e.deltaX / width;
24849
25485
  scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);
25486
+ this.updateScrollMask();
24850
25487
  };
24851
25488
  const onPaging = (e) => {
24852
25489
  const newPage = pageParser(e);
@@ -24858,15 +25495,39 @@ class DiscreteLegend extends LegendBase {
24858
25495
  this._renderItems();
24859
25496
  const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
24860
25497
  this._itemContext.totalPage = newTotalPage;
24861
- this._pagerComponent.setScrollRange([(newPage - 1) / newTotalPage, newPage / newTotalPage]);
25498
+ if (this._itemContext.isScrollbar && this._pagerComponent) {
25499
+ const newDelta = this._computeScrollbarDelta();
25500
+ const [start] = this._pagerComponent.getScrollRange();
25501
+ this._pagerComponent.setScrollRange([start, start + newDelta]);
25502
+ }
24862
25503
  }
24863
- if (animation) {
24864
- this._itemsContainer
24865
- .animate()
24866
- .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
25504
+ if (!this._itemContext.isScrollbar) {
25505
+ if (animation) {
25506
+ this._itemsContainer
25507
+ .animate()
25508
+ .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
25509
+ }
25510
+ else {
25511
+ this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
25512
+ }
24867
25513
  }
24868
25514
  else {
24869
- this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
25515
+ const [start] = this._pagerComponent.getScrollRange();
25516
+ let containerSize;
25517
+ if (this._itemContext.isHorizontal) {
25518
+ containerSize = this._itemsContainer.AABBBounds.width();
25519
+ }
25520
+ else {
25521
+ containerSize = this._itemsContainer.AABBBounds.height();
25522
+ }
25523
+ const startOffset = containerSize * start;
25524
+ this.updateScrollMask();
25525
+ if (animation) {
25526
+ this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
25527
+ }
25528
+ else {
25529
+ this._itemsContainer.setAttribute(channel, -startOffset);
25530
+ }
24870
25531
  }
24871
25532
  };
24872
25533
  if (this._itemContext.isScrollbar) {
@@ -24885,11 +25546,12 @@ class DiscreteLegend extends LegendBase {
24885
25546
  }
24886
25547
  _renderPager() {
24887
25548
  const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
24888
- const { maxWidth, maxHeight, maxCol = 1, maxRow = 2, item = {}, pager = {} } = this.attribute;
25549
+ const { maxWidth, maxCol = 1, maxRow = 2, item = {}, pager = {} } = this.attribute;
24889
25550
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
24890
25551
  const itemsContainer = this._itemsContainer;
24891
25552
  const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
24892
25553
  const { isHorizontal } = this._itemContext;
25554
+ const maxHeight = this._contentMaxHeight;
24893
25555
  let comp;
24894
25556
  let compWidth = 0;
24895
25557
  let compHeight = 0;
@@ -24980,57 +25642,76 @@ class DiscreteLegend extends LegendBase {
24980
25642
  });
24981
25643
  clipGroup.add(itemsContainer);
24982
25644
  this._innerView.add(clipGroup);
25645
+ this._itemContext.clipContainer = clipGroup;
24983
25646
  this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? 'y' : 'x');
24984
25647
  return true;
24985
25648
  }
24986
25649
  _renderScrollbar() {
25650
+ var _a;
24987
25651
  const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
24988
- const { maxWidth, maxHeight, item = {}, pager = {} } = this.attribute;
25652
+ const { maxWidth, item = {}, pager = {} } = this.attribute;
24989
25653
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
24990
25654
  const itemsContainer = this._itemsContainer;
24991
25655
  const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
24992
25656
  const { isHorizontal } = this._itemContext;
25657
+ const maxHeight = this._contentMaxHeight;
24993
25658
  let comp;
24994
- let compSize = 0;
24995
25659
  let contentWidth = 0;
24996
25660
  let contentHeight = 0;
24997
25661
  let startY = 0;
24998
25662
  let pages = 1;
24999
25663
  if (isHorizontal) {
25000
- compSize = maxWidth;
25001
25664
  contentWidth = maxWidth;
25002
25665
  contentHeight = this._itemHeight;
25003
- comp = this._createScrollbar(compStyle, compSize);
25666
+ comp = this._createScrollbar(compStyle, contentWidth);
25004
25667
  this._pagerComponent = comp;
25005
25668
  this._innerView.add(comp);
25006
- this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25007
25669
  }
25008
25670
  else {
25009
- compSize = maxHeight;
25010
- comp = this._createScrollbar(compStyle, compSize);
25011
- this._pagerComponent = comp;
25012
- this._innerView.add(comp);
25013
25671
  contentHeight = maxHeight - renderStartY;
25014
25672
  contentWidth = this._itemMaxWidth;
25673
+ comp = this._createScrollbar(compStyle, contentHeight);
25674
+ this._pagerComponent = comp;
25675
+ this._innerView.add(comp);
25015
25676
  if (contentHeight <= 0) {
25016
25677
  this._innerView.removeChild(comp);
25017
25678
  return false;
25018
25679
  }
25019
- itemsContainer.getChildren().forEach((item, index) => {
25020
- const { height } = item.attribute;
25021
- pages = Math.floor((startY + height) / contentHeight) + 1;
25022
- startY += spaceRow + height;
25023
- });
25680
+ const items = itemsContainer.getChildren();
25681
+ const itemsHeightArr = items.map((item) => item.attribute.height);
25682
+ if (itemsHeightArr.length === 1 || itemsHeightArr.every(entry => entry === itemsHeightArr[0])) {
25683
+ const itemHeight = itemsHeightArr[0];
25684
+ const maxContentHeight = contentHeight;
25685
+ const pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight));
25686
+ contentHeight = pageItemsCount * (spaceRow + itemHeight);
25687
+ pages = Math.ceil(items.length / pageItemsCount);
25688
+ }
25689
+ else {
25690
+ items.forEach((item, index) => {
25691
+ const { height } = item.attribute;
25692
+ const prePages = pages;
25693
+ const preStartY = startY;
25694
+ pages = Math.floor((startY + height) / contentHeight) + 1;
25695
+ startY += spaceRow + height;
25696
+ if (prePages !== pages &&
25697
+ index === itemsContainer.getChildren().length - 1 &&
25698
+ startY - contentHeight >= (1 / 3) * height) {
25699
+ contentHeight = preStartY + height;
25700
+ pages -= 1;
25701
+ }
25702
+ });
25703
+ }
25024
25704
  this._itemContext.totalPage = pages;
25025
25705
  this._itemContext.pages = pages;
25026
- this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25027
25706
  }
25028
25707
  if (defaultCurrent > 1) {
25029
25708
  if (isHorizontal) {
25030
- itemsContainer.setAttribute('x', -(defaultCurrent - 1) * (contentWidth + spaceCol));
25709
+ const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
25710
+ itemsContainer.setAttribute('x', -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
25031
25711
  }
25032
25712
  else {
25033
- itemsContainer.setAttribute('y', -(defaultCurrent - 1) * (contentHeight + spaceRow));
25713
+ const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
25714
+ itemsContainer.setAttribute('y', -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
25034
25715
  }
25035
25716
  }
25036
25717
  const clipGroup = graphicCreator.group({
@@ -25043,9 +25724,89 @@ class DiscreteLegend extends LegendBase {
25043
25724
  });
25044
25725
  clipGroup.add(itemsContainer);
25045
25726
  this._innerView.add(clipGroup);
25727
+ this._itemContext.clipContainer = clipGroup;
25728
+ this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25729
+ if ((_a = pager.scrollMask) === null || _a === void 0 ? void 0 : _a.visible) {
25730
+ this.renderScrollMask(clipGroup);
25731
+ }
25046
25732
  this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? 'x' : 'y');
25047
25733
  return true;
25048
25734
  }
25735
+ renderScrollMask(clipGroup) {
25736
+ const { scrollMask = {} } = this.attribute
25737
+ .pager;
25738
+ const { visible = true, gradientLength = 16, gradientStops } = scrollMask;
25739
+ if (!visible || !gradientStops) {
25740
+ return;
25741
+ }
25742
+ const width = clipGroup.AABBBounds.width();
25743
+ const height = clipGroup.AABBBounds.height();
25744
+ const totalLength = this._itemContext.isHorizontal ? width : height;
25745
+ const startStops = gradientStops.map(stop => {
25746
+ return {
25747
+ offset: (gradientLength * stop.offset) / totalLength,
25748
+ color: stop.color
25749
+ };
25750
+ });
25751
+ const endStops = gradientStops.map(stop => {
25752
+ return {
25753
+ offset: (totalLength - gradientLength * stop.offset) / totalLength,
25754
+ color: stop.color
25755
+ };
25756
+ });
25757
+ const mask = graphicCreator.rect({
25758
+ x: 0,
25759
+ y: 0,
25760
+ width,
25761
+ height
25762
+ });
25763
+ this._scrollMask = mask;
25764
+ this._scrollMaskContext = { startStops, endStops };
25765
+ this.updateScrollMask();
25766
+ clipGroup.add(mask);
25767
+ }
25768
+ updateScrollMask() {
25769
+ if (!this._scrollMask || !this._pagerComponent) {
25770
+ return;
25771
+ }
25772
+ if (!this._itemContext.isScrollbar) {
25773
+ return;
25774
+ }
25775
+ const [start, end] = this._pagerComponent.getScrollRange();
25776
+ const stops = [];
25777
+ if (!isNumberClose(clamp(end, 0, 1), 1)) {
25778
+ stops.push(...this._scrollMaskContext.endStops);
25779
+ }
25780
+ if (!isNumberClose(clamp(start, 0, 1), 0)) {
25781
+ stops.push(...this._scrollMaskContext.startStops);
25782
+ }
25783
+ if (stops.length) {
25784
+ if (this._itemContext.isHorizontal) {
25785
+ this._scrollMask.setAttributes({
25786
+ fill: {
25787
+ gradient: 'linear',
25788
+ x0: 0,
25789
+ y0: 0,
25790
+ x1: 1,
25791
+ y1: 0,
25792
+ stops
25793
+ }
25794
+ });
25795
+ }
25796
+ else {
25797
+ this._scrollMask.setAttributes({
25798
+ fill: {
25799
+ gradient: 'linear',
25800
+ x0: 0,
25801
+ y0: 0,
25802
+ x1: 0,
25803
+ y1: 1,
25804
+ stops
25805
+ }
25806
+ });
25807
+ }
25808
+ }
25809
+ }
25049
25810
  _renderPagerComponent() {
25050
25811
  if (this._itemContext.isScrollbar) {
25051
25812
  this._renderScrollbar();
@@ -29159,6 +29920,6 @@ EmptyTip.defaultAttributes = {
29159
29920
  }
29160
29921
  };
29161
29922
 
29162
- const version = "0.21.0-alpha.1";
29923
+ const version = "0.21.0-alpha.10";
29163
29924
 
29164
- 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 };
29925
+ 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, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };