@visactor/vchart 1.12.5 → 1.12.7

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 (203) hide show
  1. package/build/es5/index.js +2 -2
  2. package/build/index.js +1424 -1192
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/chart/base/base-chart.d.ts +1 -0
  6. package/cjs/chart/base/base-chart.js +17 -11
  7. package/cjs/chart/base/base-chart.js.map +1 -1
  8. package/cjs/chart/chart-meta/data.d.ts +1 -2
  9. package/cjs/chart/chart-meta/data.js +11 -11
  10. package/cjs/chart/chart-meta/data.js.map +1 -1
  11. package/cjs/chart/mosaic/mosaic.d.ts +0 -1
  12. package/cjs/chart/mosaic/mosaic.js +0 -3
  13. package/cjs/chart/mosaic/mosaic.js.map +1 -1
  14. package/cjs/chart/pie/interface.d.ts +2 -2
  15. package/cjs/chart/pie/interface.js.map +1 -1
  16. package/cjs/chart/polar/interface.d.ts +2 -0
  17. package/cjs/chart/polar/interface.js.map +1 -1
  18. package/cjs/compile/compilable-base.js +2 -1
  19. package/cjs/compile/mark/compilable-mark.d.ts +1 -1
  20. package/cjs/compile/mark/compilable-mark.js +4 -4
  21. package/cjs/compile/mark/compilable-mark.js.map +1 -1
  22. package/cjs/compile/mark/interface.d.ts +1 -0
  23. package/cjs/compile/mark/interface.js.map +1 -1
  24. package/cjs/compile/util.js +1 -2
  25. package/cjs/component/axis/base-axis.d.ts +1 -2
  26. package/cjs/component/axis/base-axis.js +0 -3
  27. package/cjs/component/axis/base-axis.js.map +1 -1
  28. package/cjs/component/axis/cartesian/axis.js +5 -3
  29. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  30. package/cjs/component/axis/polar/axis.d.ts +0 -1
  31. package/cjs/component/axis/polar/axis.js +4 -20
  32. package/cjs/component/axis/polar/axis.js.map +1 -1
  33. package/cjs/component/axis/polar/interface/spec.d.ts +3 -1
  34. package/cjs/component/axis/polar/interface/spec.js.map +1 -1
  35. package/cjs/component/base/base-component.js +1 -3
  36. package/cjs/component/base/base-component.js.map +1 -1
  37. package/cjs/component/custom-mark/custom-mark.d.ts +0 -1
  38. package/cjs/component/custom-mark/custom-mark.js +1 -12
  39. package/cjs/component/custom-mark/custom-mark.js.map +1 -1
  40. package/cjs/component/data-zoom/data-filter-base-component.js +10 -7
  41. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  42. package/cjs/component/data-zoom/util.js +11 -3
  43. package/cjs/component/data-zoom/util.js.map +1 -1
  44. package/cjs/component/label/base-label.d.ts +1 -2
  45. package/cjs/component/label/base-label.js +0 -3
  46. package/cjs/component/label/base-label.js.map +1 -1
  47. package/cjs/component/label/label.d.ts +0 -1
  48. package/cjs/component/label/label.js +2 -12
  49. package/cjs/component/label/label.js.map +1 -1
  50. package/cjs/component/label/total-label.d.ts +1 -1
  51. package/cjs/component/label/total-label.js +5 -12
  52. package/cjs/component/label/total-label.js.map +1 -1
  53. package/cjs/component/label/util.d.ts +1 -1
  54. package/cjs/component/label/util.js +12 -7
  55. package/cjs/component/label/util.js.map +1 -1
  56. package/cjs/component/legend/util.d.ts +2 -2
  57. package/cjs/constant/correlation.js +1 -2
  58. package/cjs/constant/layout.js +2 -1
  59. package/cjs/core/index.d.ts +1 -1
  60. package/cjs/core/index.js +1 -1
  61. package/cjs/core/index.js.map +1 -1
  62. package/cjs/core/vchart.d.ts +1 -1
  63. package/cjs/core/vchart.js +22 -25
  64. package/cjs/core/vchart.js.map +1 -1
  65. package/cjs/data/initialize.d.ts +1 -2
  66. package/cjs/data/initialize.js +5 -5
  67. package/cjs/data/initialize.js.map +1 -1
  68. package/cjs/plugin/chart/media-query/media-query.d.ts +1 -0
  69. package/cjs/plugin/chart/media-query/media-query.js +3 -1
  70. package/cjs/plugin/chart/media-query/media-query.js.map +1 -1
  71. package/cjs/plugin/chart/plugin-service.d.ts +2 -0
  72. package/cjs/plugin/chart/plugin-service.js +5 -0
  73. package/cjs/plugin/chart/plugin-service.js.map +1 -1
  74. package/cjs/region/region.js +2 -3
  75. package/cjs/region/region.js.map +1 -1
  76. package/cjs/series/base/base-series.d.ts +6 -5
  77. package/cjs/series/base/base-series.js +25 -15
  78. package/cjs/series/base/base-series.js.map +1 -1
  79. package/cjs/series/base/constant.js +1 -0
  80. package/cjs/series/base/constant.js.map +1 -1
  81. package/cjs/series/funnel/funnel.d.ts +1 -0
  82. package/cjs/series/funnel/funnel.js +7 -6
  83. package/cjs/series/funnel/funnel.js.map +1 -1
  84. package/cjs/series/funnel/interface.d.ts +3 -1
  85. package/cjs/series/funnel/interface.js.map +1 -1
  86. package/cjs/series/gauge/interface.d.ts +1 -1
  87. package/cjs/series/gauge/interface.js.map +1 -1
  88. package/cjs/series/polar/animation.d.ts +8 -11
  89. package/cjs/series/polar/animation.js +18 -23
  90. package/cjs/series/polar/animation.js.map +1 -1
  91. package/cjs/series/radar/animation.d.ts +0 -3
  92. package/cjs/series/radar/animation.js +4 -4
  93. package/cjs/series/radar/animation.js.map +1 -1
  94. package/cjs/series/radar/radar.js +10 -7
  95. package/cjs/series/radar/radar.js.map +1 -1
  96. package/cjs/theme/builtin/common/series/linear-progress.js +4 -1
  97. package/cjs/theme/builtin/common/series/linear-progress.js.map +1 -1
  98. package/cjs/theme/builtin/dark/color-scheme.js +2 -1
  99. package/cjs/theme/builtin/dark/color-scheme.js.map +1 -1
  100. package/cjs/theme/builtin/light/color-scheme.js +2 -1
  101. package/cjs/theme/builtin/light/color-scheme.js.map +1 -1
  102. package/cjs/typings/spec/common.d.ts +5 -2
  103. package/cjs/typings/spec/common.js.map +1 -1
  104. package/esm/chart/base/base-chart.d.ts +1 -0
  105. package/esm/chart/base/base-chart.js +18 -12
  106. package/esm/chart/base/base-chart.js.map +1 -1
  107. package/esm/chart/chart-meta/data.d.ts +1 -2
  108. package/esm/chart/chart-meta/data.js +12 -10
  109. package/esm/chart/chart-meta/data.js.map +1 -1
  110. package/esm/chart/mosaic/mosaic.d.ts +0 -1
  111. package/esm/chart/mosaic/mosaic.js +0 -3
  112. package/esm/chart/mosaic/mosaic.js.map +1 -1
  113. package/esm/chart/pie/interface.d.ts +2 -2
  114. package/esm/chart/pie/interface.js.map +1 -1
  115. package/esm/chart/polar/interface.d.ts +2 -0
  116. package/esm/chart/polar/interface.js.map +1 -1
  117. package/esm/compile/compilable-base.js +2 -1
  118. package/esm/compile/mark/compilable-mark.d.ts +1 -1
  119. package/esm/compile/mark/compilable-mark.js +5 -4
  120. package/esm/compile/mark/compilable-mark.js.map +1 -1
  121. package/esm/compile/mark/interface.d.ts +1 -0
  122. package/esm/compile/mark/interface.js.map +1 -1
  123. package/esm/compile/util.js +1 -2
  124. package/esm/component/axis/base-axis.d.ts +1 -2
  125. package/esm/component/axis/base-axis.js +0 -3
  126. package/esm/component/axis/base-axis.js.map +1 -1
  127. package/esm/component/axis/cartesian/axis.js +6 -4
  128. package/esm/component/axis/cartesian/axis.js.map +1 -1
  129. package/esm/component/axis/polar/axis.d.ts +0 -1
  130. package/esm/component/axis/polar/axis.js +4 -22
  131. package/esm/component/axis/polar/axis.js.map +1 -1
  132. package/esm/component/axis/polar/interface/spec.d.ts +3 -1
  133. package/esm/component/axis/polar/interface/spec.js.map +1 -1
  134. package/esm/component/base/base-component.js +1 -3
  135. package/esm/component/base/base-component.js.map +1 -1
  136. package/esm/component/custom-mark/custom-mark.d.ts +0 -1
  137. package/esm/component/custom-mark/custom-mark.js +0 -13
  138. package/esm/component/custom-mark/custom-mark.js.map +1 -1
  139. package/esm/component/data-zoom/data-filter-base-component.js +7 -6
  140. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  141. package/esm/component/data-zoom/util.js +11 -2
  142. package/esm/component/data-zoom/util.js.map +1 -1
  143. package/esm/component/label/base-label.d.ts +1 -2
  144. package/esm/component/label/base-label.js +0 -3
  145. package/esm/component/label/base-label.js.map +1 -1
  146. package/esm/component/label/label.d.ts +0 -1
  147. package/esm/component/label/label.js +1 -13
  148. package/esm/component/label/label.js.map +1 -1
  149. package/esm/component/label/total-label.d.ts +1 -1
  150. package/esm/component/label/total-label.js +4 -13
  151. package/esm/component/label/total-label.js.map +1 -1
  152. package/esm/component/label/util.d.ts +1 -1
  153. package/esm/component/label/util.js +12 -7
  154. package/esm/component/label/util.js.map +1 -1
  155. package/esm/component/legend/util.d.ts +2 -2
  156. package/esm/constant/correlation.js +1 -2
  157. package/esm/constant/layout.js +2 -1
  158. package/esm/core/index.d.ts +1 -1
  159. package/esm/core/index.js +1 -1
  160. package/esm/core/index.js.map +1 -1
  161. package/esm/core/vchart.d.ts +1 -1
  162. package/esm/core/vchart.js +24 -27
  163. package/esm/core/vchart.js.map +1 -1
  164. package/esm/data/initialize.d.ts +1 -2
  165. package/esm/data/initialize.js +6 -7
  166. package/esm/data/initialize.js.map +1 -1
  167. package/esm/plugin/chart/media-query/media-query.d.ts +1 -0
  168. package/esm/plugin/chart/media-query/media-query.js +3 -1
  169. package/esm/plugin/chart/media-query/media-query.js.map +1 -1
  170. package/esm/plugin/chart/plugin-service.d.ts +2 -0
  171. package/esm/plugin/chart/plugin-service.js +5 -0
  172. package/esm/plugin/chart/plugin-service.js.map +1 -1
  173. package/esm/region/region.js +2 -3
  174. package/esm/region/region.js.map +1 -1
  175. package/esm/series/base/base-series.d.ts +6 -5
  176. package/esm/series/base/base-series.js +23 -14
  177. package/esm/series/base/base-series.js.map +1 -1
  178. package/esm/series/base/constant.js +1 -0
  179. package/esm/series/base/constant.js.map +1 -1
  180. package/esm/series/funnel/funnel.d.ts +1 -0
  181. package/esm/series/funnel/funnel.js +7 -6
  182. package/esm/series/funnel/funnel.js.map +1 -1
  183. package/esm/series/funnel/interface.d.ts +3 -1
  184. package/esm/series/funnel/interface.js.map +1 -1
  185. package/esm/series/gauge/interface.d.ts +1 -1
  186. package/esm/series/gauge/interface.js.map +1 -1
  187. package/esm/series/polar/animation.d.ts +8 -11
  188. package/esm/series/polar/animation.js +17 -24
  189. package/esm/series/polar/animation.js.map +1 -1
  190. package/esm/series/radar/animation.d.ts +0 -3
  191. package/esm/series/radar/animation.js +4 -4
  192. package/esm/series/radar/animation.js.map +1 -1
  193. package/esm/series/radar/radar.js +10 -7
  194. package/esm/series/radar/radar.js.map +1 -1
  195. package/esm/theme/builtin/common/series/linear-progress.js +4 -1
  196. package/esm/theme/builtin/common/series/linear-progress.js.map +1 -1
  197. package/esm/theme/builtin/dark/color-scheme.js +2 -1
  198. package/esm/theme/builtin/dark/color-scheme.js.map +1 -1
  199. package/esm/theme/builtin/light/color-scheme.js +2 -1
  200. package/esm/theme/builtin/light/color-scheme.js.map +1 -1
  201. package/esm/typings/spec/common.d.ts +5 -2
  202. package/esm/typings/spec/common.js.map +1 -1
  203. package/package.json +18 -18
package/build/index.js CHANGED
@@ -1167,6 +1167,602 @@
1167
1167
  }
1168
1168
  }
1169
1169
 
1170
+ function degreeToRadian(degree) {
1171
+ return degree * (Math.PI / 180);
1172
+ }
1173
+ function radianToDegree(radian) {
1174
+ return 180 * radian / Math.PI;
1175
+ }
1176
+ const clampRadian = function () {
1177
+ let angle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1178
+ if (angle < 0) for (; angle < -tau$1;) angle += tau$1;else if (angle > 0) for (; angle > tau$1;) angle -= tau$1;
1179
+ return angle;
1180
+ };
1181
+ const clampAngleByRadian = clampRadian;
1182
+ function polarToCartesian(center, radius, angleInRadian) {
1183
+ return radius ? {
1184
+ x: center.x + radius * Math.cos(angleInRadian),
1185
+ y: center.y + radius * Math.sin(angleInRadian)
1186
+ } : {
1187
+ x: center.x,
1188
+ y: center.y
1189
+ };
1190
+ }
1191
+ function cartesianToPolar(point) {
1192
+ let center = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1193
+ x: 0,
1194
+ y: 0
1195
+ };
1196
+ let startAngle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1197
+ let endAngle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2 * Math.PI;
1198
+ const {
1199
+ x: x,
1200
+ y: y
1201
+ } = point,
1202
+ {
1203
+ x: centerX,
1204
+ y: centerY
1205
+ } = center;
1206
+ let dx = x - centerX,
1207
+ dy = y - centerY;
1208
+ const radius = Math.sqrt(dx * dx + dy * dy);
1209
+ if (0 === radius) return {
1210
+ radius: 0,
1211
+ angle: 0
1212
+ };
1213
+ dx /= radius, dy /= radius;
1214
+ let radian = Math.atan2(dy, dx);
1215
+ if (radian < startAngle) for (; radian <= startAngle;) radian += 2 * Math.PI;
1216
+ if (radian > endAngle) for (; radian >= endAngle;) radian -= 2 * Math.PI;
1217
+ return {
1218
+ radius: radius,
1219
+ angle: radian
1220
+ };
1221
+ }
1222
+ function getAngleByPoint(center, point) {
1223
+ return Math.atan2(point.y - center.y, point.x - center.x);
1224
+ }
1225
+ function normalizeAngle(angle) {
1226
+ for (; angle < 0;) angle += 2 * Math.PI;
1227
+ for (; angle >= 2 * Math.PI;) angle -= 2 * Math.PI;
1228
+ return angle;
1229
+ }
1230
+ function findBoundaryAngles(startAngle, endAngle) {
1231
+ const deltaAngle = Math.abs(endAngle - startAngle);
1232
+ if (deltaAngle >= 2 * Math.PI || 2 * Math.PI - deltaAngle < 1e-6) return [0, Math.PI / 2, Math.PI, 1.5 * Math.PI];
1233
+ const normalMin = normalizeAngle(Math.min(startAngle, endAngle)),
1234
+ normalMax = normalMin + deltaAngle,
1235
+ steps = [normalMin, normalMax];
1236
+ let directionAngle = Math.floor(normalMin / Math.PI) * Math.PI / 2;
1237
+ for (; directionAngle < normalMax;) directionAngle > normalMin && steps.push(directionAngle), directionAngle += Math.PI / 2;
1238
+ return steps;
1239
+ }
1240
+ function calculateMaxRadius(rect, center, startAngle, endAngle) {
1241
+ const {
1242
+ x: x,
1243
+ y: y
1244
+ } = center,
1245
+ steps = findBoundaryAngles(startAngle, endAngle),
1246
+ {
1247
+ width: width,
1248
+ height: height
1249
+ } = rect,
1250
+ radiusList = [];
1251
+ return steps.forEach(step => {
1252
+ const sin = Math.sin(step),
1253
+ cos = Math.cos(step);
1254
+ 1 === sin ? radiusList.push(height - y) : -1 === sin ? radiusList.push(y) : 1 === cos ? radiusList.push(width - x) : -1 === cos ? radiusList.push(x) : (sin > 0 ? radiusList.push(Math.abs((height - y) / cos)) : radiusList.push(Math.abs(y / cos)), cos > 0 ? radiusList.push(Math.abs((width - x) / sin)) : radiusList.push(Math.abs(x / sin)));
1255
+ }), Math.min.apply(null, radiusList);
1256
+ }
1257
+ function computeQuadrant(angle) {
1258
+ return (angle = normalizeAngle(angle)) > 0 && angle <= Math.PI / 2 ? 2 : angle > Math.PI / 2 && angle <= Math.PI ? 3 : angle > Math.PI && angle <= 3 * Math.PI / 2 ? 4 : 1;
1259
+ }
1260
+
1261
+ function sub(out, v1, v2) {
1262
+ out[0] = v1[0] - v2[0], out[1] = v1[1] - v2[1];
1263
+ }
1264
+ function isIntersect(left1, right1, left2, right2) {
1265
+ let min1 = left1[0],
1266
+ max1 = right1[0],
1267
+ min2 = left2[0],
1268
+ max2 = right2[0];
1269
+ return max1 < min1 && ([min1, max1] = [max1, min1]), max2 < min2 && ([max2, min2] = [min2, max2]), !(max1 < min2 || max2 < min1) && (min1 = left1[1], max1 = right1[1], min2 = left2[1], max2 = right2[1], max1 < min1 && ([min1, max1] = [max1, min1]), max2 < min2 && ([max2, min2] = [min2, max2]), !(max1 < min2 || max2 < min1));
1270
+ }
1271
+ function getIntersectPoint(left1, right1, left2, right2) {
1272
+ if (!isIntersect(left1, right1, left2, right2)) return !1;
1273
+ const dir1 = [0, 0],
1274
+ dir2 = [0, 0],
1275
+ tempVec = [0, 0];
1276
+ if (sub(dir1, right1, left1), sub(dir2, right2, left2), fuzzyEqualVec(dir1, dir2)) return !0;
1277
+ sub(tempVec, left2, left1);
1278
+ const t = crossProduct$1(tempVec, dir2) / crossProduct$1(dir1, dir2);
1279
+ return t >= 0 && t <= 1 && [left1[0] + dir1[0] * t, left1[1] + dir1[1] * t];
1280
+ }
1281
+ function getRectIntersect(bbox1, bbox2, format) {
1282
+ if (null === bbox1) return bbox2;
1283
+ if (null === bbox2) return bbox1;
1284
+ const {
1285
+ x11: x11,
1286
+ x12: x12,
1287
+ y11: y11,
1288
+ y12: y12,
1289
+ x21: x21,
1290
+ x22: x22,
1291
+ y21: y21,
1292
+ y22: y22
1293
+ } = formatTwoBBox(bbox1, bbox2, format);
1294
+ return x11 >= x22 || x12 <= x21 || y11 >= y22 || y12 <= y21 ? {
1295
+ x1: 0,
1296
+ y1: 0,
1297
+ x2: 0,
1298
+ y2: 0
1299
+ } : {
1300
+ x1: Math.max(x11, x21),
1301
+ y1: Math.max(y11, y21),
1302
+ x2: Math.min(x12, x22),
1303
+ y2: Math.min(y12, y22)
1304
+ };
1305
+ }
1306
+ var InnerBBox;
1307
+ !function (InnerBBox) {
1308
+ InnerBBox[InnerBBox.NONE = 0] = "NONE", InnerBBox[InnerBBox.BBOX1 = 1] = "BBOX1", InnerBBox[InnerBBox.BBOX2 = 2] = "BBOX2";
1309
+ }(InnerBBox || (InnerBBox = {}));
1310
+ const formatTwoBBox = (bbox1, bbox2, format) => {
1311
+ let x11 = bbox1.x1,
1312
+ x12 = bbox1.x2,
1313
+ y11 = bbox1.y1,
1314
+ y12 = bbox1.y2,
1315
+ x21 = bbox2.x1,
1316
+ x22 = bbox2.x2,
1317
+ y21 = bbox2.y1,
1318
+ y22 = bbox2.y2;
1319
+ return format && (x11 > x12 && ([x11, x12] = [x12, x11]), y11 > y12 && ([y11, y12] = [y12, y11]), x21 > x22 && ([x21, x22] = [x22, x21]), y21 > y22 && ([y21, y22] = [y22, y21])), {
1320
+ x11: x11,
1321
+ x12: x12,
1322
+ y11: y11,
1323
+ y12: y12,
1324
+ x21: x21,
1325
+ x22: x22,
1326
+ y21: y21,
1327
+ y22: y22
1328
+ };
1329
+ };
1330
+ function rectInsideAnotherRect(bbox1, bbox2, format) {
1331
+ if (!bbox1 || !bbox2) return InnerBBox.NONE;
1332
+ const {
1333
+ x11: x11,
1334
+ x12: x12,
1335
+ y11: y11,
1336
+ y12: y12,
1337
+ x21: x21,
1338
+ x22: x22,
1339
+ y21: y21,
1340
+ y22: y22
1341
+ } = formatTwoBBox(bbox1, bbox2, format);
1342
+ return x11 > x21 && x12 < x22 && y11 > y21 && y12 < y22 ? InnerBBox.BBOX1 : x21 > x11 && x22 < x12 && y21 > y11 && y22 < y12 ? InnerBBox.BBOX2 : InnerBBox.NONE;
1343
+ }
1344
+ function isRectIntersect(bbox1, bbox2, format) {
1345
+ if (bbox1 && bbox2) {
1346
+ if (!format) return !(bbox1.x1 > bbox2.x2 || bbox1.x2 < bbox2.x1 || bbox1.y1 > bbox2.y2 || bbox1.y2 < bbox2.y1);
1347
+ const {
1348
+ x11: x11,
1349
+ x12: x12,
1350
+ y11: y11,
1351
+ y12: y12,
1352
+ x21: x21,
1353
+ x22: x22,
1354
+ y21: y21,
1355
+ y22: y22
1356
+ } = formatTwoBBox(bbox1, bbox2, !0);
1357
+ return !(x11 > x22 || x12 < x21 || y11 > y22 || y12 < y21);
1358
+ }
1359
+ return !0;
1360
+ }
1361
+ function pointInRect(point, bbox, format) {
1362
+ if (!bbox) return !0;
1363
+ if (!format) return point.x >= bbox.x1 && point.x <= bbox.x2 && point.y >= bbox.y1 && point.y <= bbox.y2;
1364
+ let x11 = bbox.x1,
1365
+ x12 = bbox.x2,
1366
+ y11 = bbox.y1,
1367
+ y12 = bbox.y2;
1368
+ return x11 > x12 && ([x11, x12] = [x12, x11]), y11 > y12 && ([y11, y12] = [y12, y11]), point.x >= x11 && point.x <= x12 && point.y >= y11 && point.y <= y12;
1369
+ }
1370
+ function getProjectionRadius(checkAxis, axis) {
1371
+ return Math.abs(axis[0] * checkAxis[0] + axis[1] * checkAxis[1]);
1372
+ }
1373
+ function rotatePoint(_ref, rad) {
1374
+ let {
1375
+ x: x,
1376
+ y: y
1377
+ } = _ref;
1378
+ let origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
1379
+ x: 0,
1380
+ y: 0
1381
+ };
1382
+ return {
1383
+ x: (x - origin.x) * Math.cos(rad) - (y - origin.y) * Math.sin(rad) + origin.x,
1384
+ y: (x - origin.x) * Math.sin(rad) + (y - origin.y) * Math.cos(rad) + origin.y
1385
+ };
1386
+ }
1387
+ function getCenterPoint(box) {
1388
+ return {
1389
+ x: (box.x1 + box.x2) / 2,
1390
+ y: (box.y1 + box.y2) / 2
1391
+ };
1392
+ }
1393
+ function toRect$1(box, isDeg) {
1394
+ const deg = isDeg ? degreeToRadian(box.angle) : box.angle,
1395
+ cp = getCenterPoint(box);
1396
+ return [rotatePoint({
1397
+ x: box.x1,
1398
+ y: box.y1
1399
+ }, deg, cp), rotatePoint({
1400
+ x: box.x2,
1401
+ y: box.y1
1402
+ }, deg, cp), rotatePoint({
1403
+ x: box.x2,
1404
+ y: box.y2
1405
+ }, deg, cp), rotatePoint({
1406
+ x: box.x1,
1407
+ y: box.y2
1408
+ }, deg, cp)];
1409
+ }
1410
+ function isRotateAABBIntersect(box1, box2) {
1411
+ let isDeg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
1412
+ let ctx = arguments.length > 3 ? arguments[3] : undefined;
1413
+ const rect1 = toRect$1(box1, isDeg),
1414
+ rect2 = toRect$1(box2, isDeg),
1415
+ vector = (start, end) => [end.x - start.x, end.y - start.y];
1416
+ ctx && (ctx.save(), ctx.fillStyle = "red", ctx.globalAlpha = .6, rect1.forEach((item, index) => {
1417
+ 0 === index ? ctx.moveTo(item.x, item.y) : ctx.lineTo(item.x, item.y);
1418
+ }), ctx.fill(), ctx.restore(), ctx.save(), ctx.fillStyle = "green", ctx.globalAlpha = .6, rect2.forEach((item, index) => {
1419
+ 0 === index ? ctx.moveTo(item.x, item.y) : ctx.lineTo(item.x, item.y);
1420
+ }), ctx.fill(), ctx.restore());
1421
+ const p1 = getCenterPoint(box1),
1422
+ p2 = getCenterPoint(box2);
1423
+ ctx && ctx.fillRect(p1.x, p1.y, 2, 2), ctx && ctx.fillRect(p2.x, p2.y, 2, 2);
1424
+ const vp1p2 = vector(p1, p2),
1425
+ AB = vector(rect1[0], rect1[1]),
1426
+ BC = vector(rect1[1], rect1[2]),
1427
+ A1B1 = vector(rect2[0], rect2[1]),
1428
+ B1C1 = vector(rect2[1], rect2[2]),
1429
+ deg11 = isDeg ? degreeToRadian(box1.angle) : box1.angle;
1430
+ let deg12 = isDeg ? degreeToRadian(90 - box1.angle) : box1.angle + halfPi$2;
1431
+ const deg21 = isDeg ? degreeToRadian(box2.angle) : box2.angle;
1432
+ let deg22 = isDeg ? degreeToRadian(90 - box2.angle) : box2.angle + halfPi$2;
1433
+ deg12 > pi2 && (deg12 -= pi2), deg22 > pi2 && (deg22 -= pi2);
1434
+ const isCover = (checkAxisRadius, deg, targetAxis1, targetAxis2) => {
1435
+ const checkAxis = [Math.cos(deg), Math.sin(deg)];
1436
+ return checkAxisRadius + (getProjectionRadius(checkAxis, targetAxis1) + getProjectionRadius(checkAxis, targetAxis2)) / 2 > getProjectionRadius(checkAxis, vp1p2);
1437
+ };
1438
+ return isCover((box1.x2 - box1.x1) / 2, deg11, A1B1, B1C1) && isCover((box1.y2 - box1.y1) / 2, deg12, A1B1, B1C1) && isCover((box2.x2 - box2.x1) / 2, deg21, AB, BC) && isCover((box2.y2 - box2.y1) / 2, deg22, AB, BC);
1439
+ }
1440
+
1441
+ let x1$1, y1$1, x2, y2;
1442
+ function getAABBFromPoints(points) {
1443
+ return x1$1 = 1 / 0, y1$1 = 1 / 0, x2 = -1 / 0, y2 = -1 / 0, points.forEach(point => {
1444
+ x1$1 > point.x && (x1$1 = point.x), x2 < point.x && (x2 = point.x), y1$1 > point.y && (y1$1 = point.y), y2 < point.y && (y2 = point.y);
1445
+ }), {
1446
+ x1: x1$1,
1447
+ y1: y1$1,
1448
+ x2: x2,
1449
+ y2: y2
1450
+ };
1451
+ }
1452
+
1453
+ const EPSILON$1 = 1e-8;
1454
+ function lineIntersectPolygon(a1x, a1y, a2x, a2y, points) {
1455
+ for (let i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
1456
+ const p = points[i];
1457
+ if (isIntersect([a1x, a1y], [a2x, a2y], [p.x, p.y], [p2.x, p2.y])) return !0;
1458
+ p2 = p;
1459
+ }
1460
+ return !1;
1461
+ }
1462
+ function polygonContainPoint(points, x, y) {
1463
+ let w = 0,
1464
+ p = points[0];
1465
+ if (!p) return !1;
1466
+ for (let i = 1; i < points.length; i++) {
1467
+ const p2 = points[i];
1468
+ w += isPointInLine(p.x, p.y, p2.x, p2.y, x, y), p = p2;
1469
+ }
1470
+ const p0 = points[0];
1471
+ return isAroundEqual$1(p.x, p0.x) && isAroundEqual$1(p.y, p0.y) || (w += isPointInLine(p.x, p.y, p0.x, p0.y, x, y)), 0 !== w;
1472
+ }
1473
+ function isPointInLine(x0, y0, x1, y1, x, y) {
1474
+ if (y > y0 && y > y1 || y < y0 && y < y1) return 0;
1475
+ if (y1 === y0) return 0;
1476
+ const t = (y - y0) / (y1 - y0);
1477
+ let dir = y1 < y0 ? 1 : -1;
1478
+ 1 !== t && 0 !== t || (dir = y1 < y0 ? .5 : -.5);
1479
+ const x_ = t * (x1 - x0) + x0;
1480
+ return x_ === x ? 1 / 0 : x_ > x ? dir : 0;
1481
+ }
1482
+ function isAroundEqual$1(a, b) {
1483
+ return Math.abs(a - b) < EPSILON$1;
1484
+ }
1485
+ function polygonIntersectPolygon(pointsA, pointsB) {
1486
+ for (let i = 0; i < pointsB.length; i++) {
1487
+ if (polygonContainPoint(pointsA, pointsB[i].x, pointsB[i].y)) return !0;
1488
+ if (i > 0 && lineIntersectPolygon(pointsB[i - 1].x, pointsB[i - 1].y, pointsB[i].x, pointsB[i].y, pointsA)) return !0;
1489
+ }
1490
+ return !1;
1491
+ }
1492
+
1493
+ const eastAsianCharacterInfo = character => {
1494
+ let x = character.charCodeAt(0),
1495
+ y = 2 === character.length ? character.charCodeAt(1) : 0,
1496
+ codePoint = x;
1497
+ return 55296 <= x && x <= 56319 && 56320 <= y && y <= 57343 && (x &= 1023, y &= 1023, codePoint = x << 10 | y, codePoint += 65536), 12288 === codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 ? "F" : 8361 === codePoint || 65377 <= codePoint && codePoint <= 65470 || 65474 <= codePoint && codePoint <= 65479 || 65482 <= codePoint && codePoint <= 65487 || 65490 <= codePoint && codePoint <= 65495 || 65498 <= codePoint && codePoint <= 65500 || 65512 <= codePoint && codePoint <= 65518 ? "H" : 4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141 ? "W" : 32 <= codePoint && codePoint <= 126 || 162 <= codePoint && codePoint <= 163 || 165 <= codePoint && codePoint <= 166 || 172 === codePoint || 175 === codePoint || 10214 <= codePoint && codePoint <= 10221 || 10629 <= codePoint && codePoint <= 10630 ? "Na" : 161 === codePoint || 164 === codePoint || 167 <= codePoint && codePoint <= 168 || 170 === codePoint || 173 <= codePoint && codePoint <= 174 || 176 <= codePoint && codePoint <= 180 || 182 <= codePoint && codePoint <= 186 || 188 <= codePoint && codePoint <= 191 || 198 === codePoint || 208 === codePoint || 215 <= codePoint && codePoint <= 216 || 222 <= codePoint && codePoint <= 225 || 230 === codePoint || 232 <= codePoint && codePoint <= 234 || 236 <= codePoint && codePoint <= 237 || 240 === codePoint || 242 <= codePoint && codePoint <= 243 || 247 <= codePoint && codePoint <= 250 || 252 === codePoint || 254 === codePoint || 257 === codePoint || 273 === codePoint || 275 === codePoint || 283 === codePoint || 294 <= codePoint && codePoint <= 295 || 299 === codePoint || 305 <= codePoint && codePoint <= 307 || 312 === codePoint || 319 <= codePoint && codePoint <= 322 || 324 === codePoint || 328 <= codePoint && codePoint <= 331 || 333 === codePoint || 338 <= codePoint && codePoint <= 339 || 358 <= codePoint && codePoint <= 359 || 363 === codePoint || 462 === codePoint || 464 === codePoint || 466 === codePoint || 468 === codePoint || 470 === codePoint || 472 === codePoint || 474 === codePoint || 476 === codePoint || 593 === codePoint || 609 === codePoint || 708 === codePoint || 711 === codePoint || 713 <= codePoint && codePoint <= 715 || 717 === codePoint || 720 === codePoint || 728 <= codePoint && codePoint <= 731 || 733 === codePoint || 735 === codePoint || 768 <= codePoint && codePoint <= 879 || 913 <= codePoint && codePoint <= 929 || 931 <= codePoint && codePoint <= 937 || 945 <= codePoint && codePoint <= 961 || 963 <= codePoint && codePoint <= 969 || 1025 === codePoint || 1040 <= codePoint && codePoint <= 1103 || 1105 === codePoint || 8208 === codePoint || 8211 <= codePoint && codePoint <= 8214 || 8216 <= codePoint && codePoint <= 8217 || 8220 <= codePoint && codePoint <= 8221 || 8224 <= codePoint && codePoint <= 8226 || 8228 <= codePoint && codePoint <= 8231 || 8240 === codePoint || 8242 <= codePoint && codePoint <= 8243 || 8245 === codePoint || 8251 === codePoint || 8254 === codePoint || 8308 === codePoint || 8319 === codePoint || 8321 <= codePoint && codePoint <= 8324 || 8364 === codePoint || 8451 === codePoint || 8453 === codePoint || 8457 === codePoint || 8467 === codePoint || 8470 === codePoint || 8481 <= codePoint && codePoint <= 8482 || 8486 === codePoint || 8491 === codePoint || 8531 <= codePoint && codePoint <= 8532 || 8539 <= codePoint && codePoint <= 8542 || 8544 <= codePoint && codePoint <= 8555 || 8560 <= codePoint && codePoint <= 8569 || 8585 === codePoint || 8592 <= codePoint && codePoint <= 8601 || 8632 <= codePoint && codePoint <= 8633 || 8658 === codePoint || 8660 === codePoint || 8679 === codePoint || 8704 === codePoint || 8706 <= codePoint && codePoint <= 8707 || 8711 <= codePoint && codePoint <= 8712 || 8715 === codePoint || 8719 === codePoint || 8721 === codePoint || 8725 === codePoint || 8730 === codePoint || 8733 <= codePoint && codePoint <= 8736 || 8739 === codePoint || 8741 === codePoint || 8743 <= codePoint && codePoint <= 8748 || 8750 === codePoint || 8756 <= codePoint && codePoint <= 8759 || 8764 <= codePoint && codePoint <= 8765 || 8776 === codePoint || 8780 === codePoint || 8786 === codePoint || 8800 <= codePoint && codePoint <= 8801 || 8804 <= codePoint && codePoint <= 8807 || 8810 <= codePoint && codePoint <= 8811 || 8814 <= codePoint && codePoint <= 8815 || 8834 <= codePoint && codePoint <= 8835 || 8838 <= codePoint && codePoint <= 8839 || 8853 === codePoint || 8857 === codePoint || 8869 === codePoint || 8895 === codePoint || 8978 === codePoint || 9312 <= codePoint && codePoint <= 9449 || 9451 <= codePoint && codePoint <= 9547 || 9552 <= codePoint && codePoint <= 9587 || 9600 <= codePoint && codePoint <= 9615 || 9618 <= codePoint && codePoint <= 9621 || 9632 <= codePoint && codePoint <= 9633 || 9635 <= codePoint && codePoint <= 9641 || 9650 <= codePoint && codePoint <= 9651 || 9654 <= codePoint && codePoint <= 9655 || 9660 <= codePoint && codePoint <= 9661 || 9664 <= codePoint && codePoint <= 9665 || 9670 <= codePoint && codePoint <= 9672 || 9675 === codePoint || 9678 <= codePoint && codePoint <= 9681 || 9698 <= codePoint && codePoint <= 9701 || 9711 === codePoint || 9733 <= codePoint && codePoint <= 9734 || 9737 === codePoint || 9742 <= codePoint && codePoint <= 9743 || 9748 <= codePoint && codePoint <= 9749 || 9756 === codePoint || 9758 === codePoint || 9792 === codePoint || 9794 === codePoint || 9824 <= codePoint && codePoint <= 9825 || 9827 <= codePoint && codePoint <= 9829 || 9831 <= codePoint && codePoint <= 9834 || 9836 <= codePoint && codePoint <= 9837 || 9839 === codePoint || 9886 <= codePoint && codePoint <= 9887 || 9918 <= codePoint && codePoint <= 9919 || 9924 <= codePoint && codePoint <= 9933 || 9935 <= codePoint && codePoint <= 9953 || 9955 === codePoint || 9960 <= codePoint && codePoint <= 9983 || 10045 === codePoint || 10071 === codePoint || 10102 <= codePoint && codePoint <= 10111 || 11093 <= codePoint && codePoint <= 11097 || 12872 <= codePoint && codePoint <= 12879 || 57344 <= codePoint && codePoint <= 63743 || 65024 <= codePoint && codePoint <= 65039 || 65533 === codePoint || 127232 <= codePoint && codePoint <= 127242 || 127248 <= codePoint && codePoint <= 127277 || 127280 <= codePoint && codePoint <= 127337 || 127344 <= codePoint && codePoint <= 127386 || 917760 <= codePoint && codePoint <= 917999 || 983040 <= codePoint && codePoint <= 1048573 || 1048576 <= codePoint && codePoint <= 1114109 ? "A" : "N";
1498
+ };
1499
+
1500
+ function getContextFont(text) {
1501
+ let defaultAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1502
+ let fontSizeScale = arguments.length > 2 ? arguments[2] : undefined;
1503
+ fontSizeScale || (fontSizeScale = 1);
1504
+ const {
1505
+ fontStyle = defaultAttr.fontStyle,
1506
+ fontVariant = defaultAttr.fontVariant,
1507
+ fontWeight = defaultAttr.fontWeight,
1508
+ fontSize = defaultAttr.fontSize,
1509
+ fontFamily = defaultAttr.fontFamily
1510
+ } = text;
1511
+ return (fontStyle ? fontStyle + " " : "") + (fontVariant ? fontVariant + " " : "") + (fontWeight ? fontWeight + " " : "") + fontSize * fontSizeScale + "px " + (fontFamily || "sans-serif");
1512
+ }
1513
+
1514
+ class TextMeasure {
1515
+ constructor(option, textSpec) {
1516
+ this._numberCharSize = null, this._fullCharSize = null, this._letterCharSize = null, this._specialCharSizeMap = {}, this._canvas = null, this._context = null, this._contextSaved = !1, this._notSupportCanvas = !1, this._notSupportVRender = !1, this._userSpec = {}, this.specialCharSet = "-/: .,@%'\"~", this._option = option, this._userSpec = null != textSpec ? textSpec : {}, this.textSpec = this._initSpec(), isValid$1(option.specialCharSet) && (this.specialCharSet = option.specialCharSet), this._standardMethod = isValid$1(option.getTextBounds) ? this.fullMeasure.bind(this) : this.measureWithNaiveCanvas.bind(this);
1517
+ }
1518
+ initContext() {
1519
+ if (this._notSupportCanvas) return !1;
1520
+ if (isNil$1(this._canvas) && (isValid$1(this._option.getCanvasForMeasure) && (this._canvas = this._option.getCanvasForMeasure()), isNil$1(this._canvas) && "undefined" != typeof window && void 0 !== window.document && globalThis && isValid$1(globalThis.document) && (this._canvas = globalThis.document.createElement("canvas"))), isNil$1(this._context) && isValid$1(this._canvas)) {
1521
+ const context = this._canvas.getContext("2d");
1522
+ isValid$1(context) && (context.save(), context.font = getContextFont(this.textSpec), this._contextSaved = !0, this._context = context);
1523
+ }
1524
+ return !isNil$1(this._context) || (this._notSupportCanvas = !0, !1);
1525
+ }
1526
+ _initSpec() {
1527
+ var _a, _b, _c;
1528
+ const {
1529
+ defaultFontParams = {}
1530
+ } = this._option,
1531
+ {
1532
+ fontStyle = defaultFontParams.fontStyle,
1533
+ fontVariant = defaultFontParams.fontVariant,
1534
+ fontWeight = null !== (_a = defaultFontParams.fontWeight) && void 0 !== _a ? _a : "normal",
1535
+ fontSize = null !== (_b = defaultFontParams.fontSize) && void 0 !== _b ? _b : 12,
1536
+ fontFamily = null !== (_c = defaultFontParams.fontFamily) && void 0 !== _c ? _c : "sans-serif",
1537
+ align: align,
1538
+ textAlign = null != align ? align : "center",
1539
+ baseline: baseline,
1540
+ textBaseline = null != baseline ? baseline : "middle",
1541
+ ellipsis: ellipsis,
1542
+ limit: limit
1543
+ } = this._userSpec;
1544
+ let {
1545
+ lineHeight = fontSize
1546
+ } = this._userSpec;
1547
+ if (isString$1(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
1548
+ const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
1549
+ lineHeight = fontSize * scale;
1550
+ }
1551
+ return {
1552
+ fontStyle: fontStyle,
1553
+ fontVariant: fontVariant,
1554
+ fontFamily: fontFamily,
1555
+ fontSize: fontSize,
1556
+ fontWeight: fontWeight,
1557
+ textAlign: textAlign,
1558
+ textBaseline: textBaseline,
1559
+ ellipsis: ellipsis,
1560
+ limit: limit,
1561
+ lineHeight: lineHeight
1562
+ };
1563
+ }
1564
+ measure(text, method) {
1565
+ switch (method) {
1566
+ case "vrender":
1567
+ case "canopus":
1568
+ return this.fullMeasure(text);
1569
+ case "canvas":
1570
+ return this.measureWithNaiveCanvas(text);
1571
+ case "simple":
1572
+ return this.quickMeasureWithoutCanvas(text);
1573
+ default:
1574
+ return this.quickMeasure(text);
1575
+ }
1576
+ }
1577
+ fullMeasure(text) {
1578
+ if (isNil$1(text)) return {
1579
+ width: 0,
1580
+ height: 0
1581
+ };
1582
+ if (isNil$1(this._option.getTextBounds) || !this._notSupportVRender) return this.measureWithNaiveCanvas(text);
1583
+ const {
1584
+ fontFamily: fontFamily,
1585
+ fontSize: fontSize,
1586
+ fontWeight: fontWeight,
1587
+ textAlign: textAlign,
1588
+ textBaseline: textBaseline,
1589
+ ellipsis: ellipsis,
1590
+ limit: limit,
1591
+ lineHeight: lineHeight
1592
+ } = this.textSpec;
1593
+ let size;
1594
+ try {
1595
+ const bounds = this._option.getTextBounds({
1596
+ text: text,
1597
+ fontFamily: fontFamily,
1598
+ fontSize: fontSize,
1599
+ fontWeight: fontWeight,
1600
+ textAlign: textAlign,
1601
+ textBaseline: textBaseline,
1602
+ ellipsis: !!ellipsis,
1603
+ maxLineWidth: limit || 1 / 0,
1604
+ lineHeight: lineHeight
1605
+ });
1606
+ size = {
1607
+ width: bounds.width(),
1608
+ height: bounds.height()
1609
+ };
1610
+ } catch (e) {
1611
+ this._notSupportVRender = !0, size = this.measureWithNaiveCanvas(text);
1612
+ }
1613
+ return size;
1614
+ }
1615
+ measureWithNaiveCanvas(text) {
1616
+ return this._measureReduce(text, this._measureWithNaiveCanvas.bind(this));
1617
+ }
1618
+ _measureWithNaiveCanvas(text) {
1619
+ var _a;
1620
+ if (!this.initContext()) return this._quickMeasureWithoutCanvas(text);
1621
+ const metrics = this._context.measureText(text),
1622
+ {
1623
+ fontSize: fontSize,
1624
+ lineHeight: lineHeight
1625
+ } = this.textSpec;
1626
+ return {
1627
+ width: metrics.width,
1628
+ height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
1629
+ };
1630
+ }
1631
+ quickMeasure(text) {
1632
+ return this._measureReduce(text, this._quickMeasure.bind(this));
1633
+ }
1634
+ _quickMeasure(text) {
1635
+ const totalSize = {
1636
+ width: 0,
1637
+ height: 0
1638
+ };
1639
+ for (let i = 0; i < text.length; i++) {
1640
+ const char = text[i];
1641
+ let size = this._measureSpecialChar(char);
1642
+ isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height);
1643
+ }
1644
+ return totalSize;
1645
+ }
1646
+ quickMeasureWithoutCanvas(text) {
1647
+ return this._measureReduce(text, this._quickMeasureWithoutCanvas.bind(this));
1648
+ }
1649
+ _quickMeasureWithoutCanvas(text) {
1650
+ var _a;
1651
+ const totalSize = {
1652
+ width: 0,
1653
+ height: 0
1654
+ },
1655
+ {
1656
+ fontSize: fontSize,
1657
+ lineHeight: lineHeight
1658
+ } = this.textSpec;
1659
+ for (let i = 0; i < text.length; i++) {
1660
+ const char = text[i],
1661
+ size = ["F", "W"].includes(eastAsianCharacterInfo(char)) ? 1 : .53;
1662
+ totalSize.width += size * fontSize;
1663
+ }
1664
+ return totalSize.height = null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize, totalSize;
1665
+ }
1666
+ _measureReduce(text, processor) {
1667
+ var _a;
1668
+ const {
1669
+ fontSize: fontSize,
1670
+ lineHeight: lineHeight
1671
+ } = this.textSpec,
1672
+ defaultResult = {
1673
+ width: 0,
1674
+ height: 0
1675
+ };
1676
+ if (isNil$1(text)) return defaultResult;
1677
+ if (isArray$1(text)) {
1678
+ const textArr = text.filter(isValid$1).map(s => s.toString());
1679
+ return 0 === textArr.length ? defaultResult : 1 === textArr.length ? processor(textArr[0]) : {
1680
+ width: textArr.reduce((maxWidth, cur) => Math.max(maxWidth, processor(cur).width), 0),
1681
+ height: textArr.length * ((null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize) + 1) + 1
1682
+ };
1683
+ }
1684
+ return processor(text.toString());
1685
+ }
1686
+ _measureNumberChar() {
1687
+ if (isNil$1(this._numberCharSize)) {
1688
+ const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
1689
+ this._numberCharSize = {
1690
+ width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
1691
+ height: numberBounds.height
1692
+ };
1693
+ }
1694
+ return this._numberCharSize;
1695
+ }
1696
+ _measureFullSizeChar() {
1697
+ return isNil$1(this._fullCharSize) && (this._fullCharSize = this._standardMethod(TextMeasure.FULL_SIZE_CHAR)), this._fullCharSize;
1698
+ }
1699
+ _measureLetterChar() {
1700
+ if (isNil$1(this._letterCharSize)) {
1701
+ const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
1702
+ this._letterCharSize = {
1703
+ width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
1704
+ height: alphabetBounds.height
1705
+ };
1706
+ }
1707
+ return this._letterCharSize;
1708
+ }
1709
+ _measureSpecialChar(char) {
1710
+ return isValid$1(this._specialCharSizeMap[char]) ? this._specialCharSizeMap[char] : this.specialCharSet.includes(char) ? (this._specialCharSizeMap[char] = this._standardMethod(char), this._specialCharSizeMap[char]) : null;
1711
+ }
1712
+ release() {
1713
+ isValid$1(this._canvas) && (this._canvas = null), isValid$1(this._context) && (this._contextSaved && (this._context.restore(), this._contextSaved = !1), this._context = null);
1714
+ }
1715
+ }
1716
+ TextMeasure.ALPHABET_CHAR_SET = "abcdefghijklmnopqrstuvwxyz", TextMeasure.NUMBERS_CHAR_SET = "0123456789", TextMeasure.FULL_SIZE_CHAR = "字";
1717
+
1718
+ const calculateAnchorOfBounds = (bounds, anchorType) => {
1719
+ const {
1720
+ x1: x1,
1721
+ x2: x2,
1722
+ y1: y1,
1723
+ y2: y2
1724
+ } = bounds,
1725
+ rectWidth = Math.abs(x2 - x1),
1726
+ rectHeight = Math.abs(y2 - y1);
1727
+ let anchorX = (x1 + x2) / 2,
1728
+ anchorY = (y1 + y2) / 2,
1729
+ sx = 0,
1730
+ sy = 0;
1731
+ switch (anchorType) {
1732
+ case "top":
1733
+ case "inside-top":
1734
+ sy = -.5;
1735
+ break;
1736
+ case "bottom":
1737
+ case "inside-bottom":
1738
+ sy = .5;
1739
+ break;
1740
+ case "left":
1741
+ case "inside-left":
1742
+ sx = -.5;
1743
+ break;
1744
+ case "right":
1745
+ case "inside-right":
1746
+ sx = .5;
1747
+ break;
1748
+ case "top-right":
1749
+ sx = .5, sy = -.5;
1750
+ break;
1751
+ case "top-left":
1752
+ sx = -.5, sy = -.5;
1753
+ break;
1754
+ case "bottom-right":
1755
+ sx = .5, sy = .5;
1756
+ break;
1757
+ case "bottom-left":
1758
+ sx = -.5, sy = .5;
1759
+ }
1760
+ return anchorX += sx * rectWidth, anchorY += sy * rectHeight, {
1761
+ x: anchorX,
1762
+ y: anchorY
1763
+ };
1764
+ };
1765
+
1170
1766
  function transformBoundsWithMatrix(out, bounds, matrix) {
1171
1767
  const {
1172
1768
  x1: x1,
@@ -1305,65 +1901,22 @@
1305
1901
  }
1306
1902
  }
1307
1903
  class AABBBounds extends Bounds {}
1308
-
1309
- function degreeToRadian(degree) {
1310
- return degree * (Math.PI / 180);
1311
- }
1312
- function radianToDegree(radian) {
1313
- return 180 * radian / Math.PI;
1314
- }
1315
- const clampRadian$1 = function () {
1316
- let angle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1317
- if (angle < 0) for (; angle < -tau$1;) angle += tau$1;else if (angle > 0) for (; angle > tau$1;) angle -= tau$1;
1318
- return angle;
1319
- };
1320
- const clampAngleByRadian = clampRadian$1;
1321
- function polarToCartesian(center, radius, angleInRadian) {
1322
- return radius ? {
1323
- x: center.x + radius * Math.cos(angleInRadian),
1324
- y: center.y + radius * Math.sin(angleInRadian)
1325
- } : {
1326
- x: center.x,
1327
- y: center.y
1328
- };
1329
- }
1330
- function getAngleByPoint(center, point) {
1331
- return Math.atan2(point.y - center.y, point.x - center.x);
1332
- }
1333
- function normalizeAngle(angle) {
1334
- for (; angle < 0;) angle += 2 * Math.PI;
1335
- for (; angle >= 2 * Math.PI;) angle -= 2 * Math.PI;
1336
- return angle;
1337
- }
1338
- function findBoundaryAngles(startAngle, endAngle) {
1339
- const deltaAngle = Math.abs(endAngle - startAngle);
1340
- if (deltaAngle >= 2 * Math.PI || 2 * Math.PI - deltaAngle < 1e-6) return [0, Math.PI / 2, Math.PI, 1.5 * Math.PI];
1341
- const normalMin = normalizeAngle(Math.min(startAngle, endAngle)),
1342
- normalMax = normalMin + deltaAngle,
1343
- steps = [normalMin, normalMax];
1344
- let directionAngle = Math.floor(normalMin / Math.PI) * Math.PI / 2;
1345
- for (; directionAngle < normalMax;) directionAngle > normalMin && steps.push(directionAngle), directionAngle += Math.PI / 2;
1346
- return steps;
1347
- }
1348
- function calculateMaxRadius(rect, center, startAngle, endAngle) {
1349
- const {
1350
- x: x,
1351
- y: y
1352
- } = center,
1353
- steps = findBoundaryAngles(startAngle, endAngle),
1354
- {
1355
- width: width,
1356
- height: height
1357
- } = rect,
1358
- radiusList = [];
1359
- return steps.forEach(step => {
1360
- const sin = Math.sin(step),
1361
- cos = Math.cos(step);
1362
- 1 === sin ? radiusList.push(height - y) : -1 === sin ? radiusList.push(y) : 1 === cos ? radiusList.push(width - x) : -1 === cos ? radiusList.push(x) : (sin > 0 ? radiusList.push(Math.abs((height - y) / cos)) : radiusList.push(Math.abs(y / cos)), cos > 0 ? radiusList.push(Math.abs((width - x) / sin)) : radiusList.push(Math.abs(x / sin)));
1363
- }), Math.min.apply(null, radiusList);
1364
- }
1365
- function computeQuadrant(angle) {
1366
- return (angle = normalizeAngle(angle)) > 0 && angle <= Math.PI / 2 ? 2 : angle > Math.PI / 2 && angle <= Math.PI ? 3 : angle > Math.PI && angle <= 3 * Math.PI / 2 ? 4 : 1;
1904
+ class OBBBounds extends Bounds {
1905
+ constructor(bounds) {
1906
+ let angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1907
+ super(bounds), bounds && (this.angle = angle);
1908
+ }
1909
+ intersects(b) {
1910
+ return isRotateAABBIntersect(this, b);
1911
+ }
1912
+ setValue() {
1913
+ let x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1914
+ let y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1915
+ let x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1916
+ let y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1917
+ let angle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
1918
+ return super.setValue(x1, y1, x2, y2), this.angle = angle, this;
1919
+ }
1367
1920
  }
1368
1921
 
1369
1922
  class Matrix {
@@ -1904,619 +2457,114 @@
1904
2457
  }
1905
2458
  setOpacity() {
1906
2459
  let o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
1907
- return this.color.opacity = o, this;
1908
- }
1909
- getLuminance() {
1910
- return (.2126 * this.color.r + .7152 * this.color.g + .0722 * this.color.b) / 255;
1911
- }
1912
- getLuminance2() {
1913
- return (.2627 * this.color.r + .678 * this.color.g + .0593 * this.color.b) / 255;
1914
- }
1915
- getLuminance3() {
1916
- return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
1917
- }
1918
- clone() {
1919
- return new Color(this.color.toString());
1920
- }
1921
- copyGammaToLinear(color) {
1922
- let gammaFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1923
- return this.color.r = Math.pow(color.color.r, gammaFactor), this.color.g = Math.pow(color.color.g, gammaFactor), this.color.b = Math.pow(color.color.b, gammaFactor), this;
1924
- }
1925
- copyLinearToGamma(color) {
1926
- let gammaFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1927
- const safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
1928
- return this.color.r = Math.pow(color.color.r, safeInverse), this.color.g = Math.pow(color.color.g, safeInverse), this.color.b = Math.pow(color.color.b, safeInverse), this;
1929
- }
1930
- convertGammaToLinear(gammaFactor) {
1931
- return this.copyGammaToLinear(this, gammaFactor), this;
1932
- }
1933
- convertLinearToGamma(gammaFactor) {
1934
- return this.copyLinearToGamma(this, gammaFactor), this;
1935
- }
1936
- copySRGBToLinear(color) {
1937
- return this.color.r = SRGBToLinear(color.color.r), this.color.g = SRGBToLinear(color.color.g), this.color.b = SRGBToLinear(color.color.b), this;
1938
- }
1939
- copyLinearToSRGB(color) {
1940
- return this.color.r = LinearToSRGB(color.color.r), this.color.g = LinearToSRGB(color.color.g), this.color.b = LinearToSRGB(color.color.b), this;
1941
- }
1942
- convertSRGBToLinear() {
1943
- return this.copySRGBToLinear(this), this;
1944
- }
1945
- convertLinearToSRGB() {
1946
- return this.copyLinearToSRGB(this), this;
1947
- }
1948
- }
1949
- class RGB {
1950
- constructor(r, g, b, opacity) {
1951
- this.r = isNaN(+r) ? 255 : Math.max(0, Math.min(255, +r)), this.g = isNaN(+g) ? 255 : Math.max(0, Math.min(255, +g)), this.b = isNaN(+b) ? 255 : Math.max(0, Math.min(255, +b)), isValid$1(opacity) ? this.opacity = isNaN(+opacity) ? 1 : Math.max(0, Math.min(1, +opacity)) : this.opacity = 1;
1952
- }
1953
- formatHex() {
1954
- return `#${hex(this.r) + hex(this.g) + hex(this.b) + (1 === this.opacity ? "" : hex(255 * this.opacity))}`;
1955
- }
1956
- formatRgb() {
1957
- const opacity = this.opacity;
1958
- return `${1 === opacity ? "rgb(" : "rgba("}${this.r},${this.g},${this.b}${1 === opacity ? ")" : `,${opacity})`}`;
1959
- }
1960
- formatHsl() {
1961
- const opacity = this.opacity,
1962
- {
1963
- h: h,
1964
- s: s,
1965
- l: l
1966
- } = rgbToHsl(this.r, this.g, this.b);
1967
- return `${1 === opacity ? "hsl(" : "hsla("}${h},${s}%,${l}%${1 === opacity ? ")" : `,${opacity})`}`;
1968
- }
1969
- toString() {
1970
- return this.formatHex();
1971
- }
1972
- }
1973
-
1974
- function hexToRgb(str) {
1975
- let r = "",
1976
- g = "",
1977
- b = "";
1978
- const strtIndex = "#" === str[0] ? 1 : 0;
1979
- for (let i = strtIndex; i < str.length; i++) "#" !== str[i] && (i < strtIndex + 2 ? r += str[i] : i < strtIndex + 4 ? g += str[i] : i < strtIndex + 6 && (b += str[i]));
1980
- return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
1981
- }
1982
-
1983
- function rgbToHex(r, g, b) {
1984
- return Number((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
1985
- }
1986
-
1987
- function interpolateRgb$1(colorA, colorB) {
1988
- const redA = colorA.r,
1989
- redB = colorB.r,
1990
- greenA = colorA.g,
1991
- greenB = colorB.g,
1992
- blueA = colorA.b,
1993
- blueB = colorB.b,
1994
- opacityA = colorA.opacity,
1995
- opacityB = colorB.opacity;
1996
- return t => {
1997
- const r = Math.round(redA * (1 - t) + redB * t),
1998
- g = Math.round(greenA * (1 - t) + greenB * t),
1999
- b = Math.round(blueA * (1 - t) + blueB * t);
2000
- return new RGB(r, g, b, opacityA * (1 - t) + opacityB * t);
2001
- };
2002
- }
2003
-
2004
- var ColorUtil = /*#__PURE__*/Object.freeze({
2005
- __proto__: null,
2006
- Color: Color,
2007
- DEFAULT_COLORS: DEFAULT_COLORS,
2008
- RGB: RGB,
2009
- hexToRgb: hexToRgb,
2010
- hslToRgb: hslToRgb,
2011
- interpolateRgb: interpolateRgb$1,
2012
- rgbToHex: rgbToHex,
2013
- rgbToHsl: rgbToHsl
2014
- });
2015
-
2016
- function sub(out, v1, v2) {
2017
- out[0] = v1[0] - v2[0], out[1] = v1[1] - v2[1];
2018
- }
2019
- function isIntersect(left1, right1, left2, right2) {
2020
- let min1 = left1[0],
2021
- max1 = right1[0],
2022
- min2 = left2[0],
2023
- max2 = right2[0];
2024
- return max1 < min1 && ([min1, max1] = [max1, min1]), max2 < min2 && ([max2, min2] = [min2, max2]), !(max1 < min2 || max2 < min1) && (min1 = left1[1], max1 = right1[1], min2 = left2[1], max2 = right2[1], max1 < min1 && ([min1, max1] = [max1, min1]), max2 < min2 && ([max2, min2] = [min2, max2]), !(max1 < min2 || max2 < min1));
2025
- }
2026
- function getIntersectPoint(left1, right1, left2, right2) {
2027
- if (!isIntersect(left1, right1, left2, right2)) return !1;
2028
- const dir1 = [0, 0],
2029
- dir2 = [0, 0],
2030
- tempVec = [0, 0];
2031
- if (sub(dir1, right1, left1), sub(dir2, right2, left2), fuzzyEqualVec(dir1, dir2)) return !0;
2032
- sub(tempVec, left2, left1);
2033
- const t = crossProduct$1(tempVec, dir2) / crossProduct$1(dir1, dir2);
2034
- return t >= 0 && t <= 1 && [left1[0] + dir1[0] * t, left1[1] + dir1[1] * t];
2035
- }
2036
- function getRectIntersect(bbox1, bbox2, format) {
2037
- if (null === bbox1) return bbox2;
2038
- if (null === bbox2) return bbox1;
2039
- const {
2040
- x11: x11,
2041
- x12: x12,
2042
- y11: y11,
2043
- y12: y12,
2044
- x21: x21,
2045
- x22: x22,
2046
- y21: y21,
2047
- y22: y22
2048
- } = formatTwoBBox(bbox1, bbox2, format);
2049
- return x11 >= x22 || x12 <= x21 || y11 >= y22 || y12 <= y21 ? {
2050
- x1: 0,
2051
- y1: 0,
2052
- x2: 0,
2053
- y2: 0
2054
- } : {
2055
- x1: Math.max(x11, x21),
2056
- y1: Math.max(y11, y21),
2057
- x2: Math.min(x12, x22),
2058
- y2: Math.min(y12, y22)
2059
- };
2060
- }
2061
- var InnerBBox;
2062
- !function (InnerBBox) {
2063
- InnerBBox[InnerBBox.NONE = 0] = "NONE", InnerBBox[InnerBBox.BBOX1 = 1] = "BBOX1", InnerBBox[InnerBBox.BBOX2 = 2] = "BBOX2";
2064
- }(InnerBBox || (InnerBBox = {}));
2065
- const formatTwoBBox = (bbox1, bbox2, format) => {
2066
- let x11 = bbox1.x1,
2067
- x12 = bbox1.x2,
2068
- y11 = bbox1.y1,
2069
- y12 = bbox1.y2,
2070
- x21 = bbox2.x1,
2071
- x22 = bbox2.x2,
2072
- y21 = bbox2.y1,
2073
- y22 = bbox2.y2;
2074
- return format && (x11 > x12 && ([x11, x12] = [x12, x11]), y11 > y12 && ([y11, y12] = [y12, y11]), x21 > x22 && ([x21, x22] = [x22, x21]), y21 > y22 && ([y21, y22] = [y22, y21])), {
2075
- x11: x11,
2076
- x12: x12,
2077
- y11: y11,
2078
- y12: y12,
2079
- x21: x21,
2080
- x22: x22,
2081
- y21: y21,
2082
- y22: y22
2083
- };
2084
- };
2085
- function rectInsideAnotherRect(bbox1, bbox2, format) {
2086
- if (!bbox1 || !bbox2) return InnerBBox.NONE;
2087
- const {
2088
- x11: x11,
2089
- x12: x12,
2090
- y11: y11,
2091
- y12: y12,
2092
- x21: x21,
2093
- x22: x22,
2094
- y21: y21,
2095
- y22: y22
2096
- } = formatTwoBBox(bbox1, bbox2, format);
2097
- return x11 > x21 && x12 < x22 && y11 > y21 && y12 < y22 ? InnerBBox.BBOX1 : x21 > x11 && x22 < x12 && y21 > y11 && y22 < y12 ? InnerBBox.BBOX2 : InnerBBox.NONE;
2098
- }
2099
- function isRectIntersect(bbox1, bbox2, format) {
2100
- if (bbox1 && bbox2) {
2101
- if (!format) return !(bbox1.x1 > bbox2.x2 || bbox1.x2 < bbox2.x1 || bbox1.y1 > bbox2.y2 || bbox1.y2 < bbox2.y1);
2102
- const {
2103
- x11: x11,
2104
- x12: x12,
2105
- y11: y11,
2106
- y12: y12,
2107
- x21: x21,
2108
- x22: x22,
2109
- y21: y21,
2110
- y22: y22
2111
- } = formatTwoBBox(bbox1, bbox2, !0);
2112
- return !(x11 > x22 || x12 < x21 || y11 > y22 || y12 < y21);
2113
- }
2114
- return !0;
2115
- }
2116
- function pointInRect(point, bbox, format) {
2117
- if (!bbox) return !0;
2118
- if (!format) return point.x >= bbox.x1 && point.x <= bbox.x2 && point.y >= bbox.y1 && point.y <= bbox.y2;
2119
- let x11 = bbox.x1,
2120
- x12 = bbox.x2,
2121
- y11 = bbox.y1,
2122
- y12 = bbox.y2;
2123
- return x11 > x12 && ([x11, x12] = [x12, x11]), y11 > y12 && ([y11, y12] = [y12, y11]), point.x >= x11 && point.x <= x12 && point.y >= y11 && point.y <= y12;
2124
- }
2125
- function getProjectionRadius(checkAxis, axis) {
2126
- return Math.abs(axis[0] * checkAxis[0] + axis[1] * checkAxis[1]);
2127
- }
2128
- function rotate$1(_ref, deg) {
2129
- let {
2130
- x: x,
2131
- y: y
2132
- } = _ref;
2133
- let origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2134
- x: 0,
2135
- y: 0
2136
- };
2137
- return {
2138
- x: (x - origin.x) * Math.cos(deg) + (y - origin.y) * Math.sin(deg) + origin.x,
2139
- y: (x - origin.x) * Math.sin(deg) + (origin.y - y) * Math.cos(deg) + origin.y
2140
- };
2141
- }
2142
- function getCenterPoint(box) {
2143
- return {
2144
- x: (box.x1 + box.x2) / 2,
2145
- y: (box.y1 + box.y2) / 2
2146
- };
2147
- }
2148
- function toRect$1(box, isDeg) {
2149
- const deg = isDeg ? box.angle : degreeToRadian(box.angle),
2150
- cp = getCenterPoint(box);
2151
- return [rotate$1({
2152
- x: box.x1,
2153
- y: box.y1
2154
- }, deg, cp), rotate$1({
2155
- x: box.x2,
2156
- y: box.y1
2157
- }, deg, cp), rotate$1({
2158
- x: box.x2,
2159
- y: box.y2
2160
- }, deg, cp), rotate$1({
2161
- x: box.x1,
2162
- y: box.y2
2163
- }, deg, cp)];
2164
- }
2165
- function isRotateAABBIntersect(box1, box2) {
2166
- let isDeg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
2167
- let ctx = arguments.length > 3 ? arguments[3] : undefined;
2168
- const rect1 = toRect$1(box1, isDeg),
2169
- rect2 = toRect$1(box2, isDeg),
2170
- vector = (start, end) => [end.x - start.x, end.y - start.y];
2171
- ctx && (ctx.save(), ctx.fillStyle = "red", ctx.globalAlpha = .6, rect1.forEach((item, index) => {
2172
- 0 === index ? ctx.moveTo(item.x, item.y) : ctx.lineTo(item.x, item.y);
2173
- }), ctx.fill(), ctx.restore(), ctx.save(), ctx.fillStyle = "green", ctx.globalAlpha = .6, rect2.forEach((item, index) => {
2174
- 0 === index ? ctx.moveTo(item.x, item.y) : ctx.lineTo(item.x, item.y);
2175
- }), ctx.fill(), ctx.restore());
2176
- const p1 = getCenterPoint(box1),
2177
- p2 = getCenterPoint(box2);
2178
- ctx && ctx.fillRect(p1.x, p1.y, 2, 2), ctx && ctx.fillRect(p2.x, p2.y, 2, 2);
2179
- const vp1p2 = vector(p1, p2),
2180
- AB = vector(rect1[0], rect1[1]),
2181
- BC = vector(rect1[1], rect1[2]),
2182
- A1B1 = vector(rect2[0], rect2[1]),
2183
- B1C1 = vector(rect2[1], rect2[2]),
2184
- deg11 = isDeg ? box1.angle : degreeToRadian(box1.angle);
2185
- let deg12 = isDeg ? box1.angle + halfPi$2 : degreeToRadian(90 - box1.angle);
2186
- const deg21 = isDeg ? box2.angle : degreeToRadian(box2.angle);
2187
- let deg22 = isDeg ? box2.angle + halfPi$2 : degreeToRadian(90 - box2.angle);
2188
- deg12 > pi2 && (deg12 -= pi2), deg22 > pi2 && (deg22 -= pi2);
2189
- const isCover = (checkAxisRadius, deg, targetAxis1, targetAxis2) => {
2190
- const checkAxis = [Math.cos(deg), Math.sin(deg)];
2191
- return checkAxisRadius + (getProjectionRadius(checkAxis, targetAxis1) + getProjectionRadius(checkAxis, targetAxis2)) / 2 > getProjectionRadius(checkAxis, vp1p2);
2192
- };
2193
- return isCover((box1.x2 - box1.x1) / 2, deg11, A1B1, B1C1) && isCover((box1.y2 - box1.y1) / 2, deg12, A1B1, B1C1) && isCover((box2.x2 - box2.x1) / 2, deg21, AB, BC) && isCover((box2.y2 - box2.y1) / 2, deg22, AB, BC);
2194
- }
2195
-
2196
- let x1$1, y1$1, x2, y2;
2197
- function getAABBFromPoints(points) {
2198
- return x1$1 = 1 / 0, y1$1 = 1 / 0, x2 = -1 / 0, y2 = -1 / 0, points.forEach(point => {
2199
- x1$1 > point.x && (x1$1 = point.x), x2 < point.x && (x2 = point.x), y1$1 > point.y && (y1$1 = point.y), y2 < point.y && (y2 = point.y);
2200
- }), {
2201
- x1: x1$1,
2202
- y1: y1$1,
2203
- x2: x2,
2204
- y2: y2
2205
- };
2206
- }
2207
-
2208
- const EPSILON$1 = 1e-8;
2209
- function lineIntersectPolygon(a1x, a1y, a2x, a2y, points) {
2210
- for (let i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
2211
- const p = points[i];
2212
- if (isIntersect([a1x, a1y], [a2x, a2y], [p.x, p.y], [p2.x, p2.y])) return !0;
2213
- p2 = p;
2214
- }
2215
- return !1;
2216
- }
2217
- function polygonContainPoint(points, x, y) {
2218
- let w = 0,
2219
- p = points[0];
2220
- if (!p) return !1;
2221
- for (let i = 1; i < points.length; i++) {
2222
- const p2 = points[i];
2223
- w += isPointInLine(p.x, p.y, p2.x, p2.y, x, y), p = p2;
2224
- }
2225
- const p0 = points[0];
2226
- return isAroundEqual$1(p.x, p0.x) && isAroundEqual$1(p.y, p0.y) || (w += isPointInLine(p.x, p.y, p0.x, p0.y, x, y)), 0 !== w;
2227
- }
2228
- function isPointInLine(x0, y0, x1, y1, x, y) {
2229
- if (y > y0 && y > y1 || y < y0 && y < y1) return 0;
2230
- if (y1 === y0) return 0;
2231
- const t = (y - y0) / (y1 - y0);
2232
- let dir = y1 < y0 ? 1 : -1;
2233
- 1 !== t && 0 !== t || (dir = y1 < y0 ? .5 : -.5);
2234
- const x_ = t * (x1 - x0) + x0;
2235
- return x_ === x ? 1 / 0 : x_ > x ? dir : 0;
2236
- }
2237
- function isAroundEqual$1(a, b) {
2238
- return Math.abs(a - b) < EPSILON$1;
2239
- }
2240
- function polygonIntersectPolygon(pointsA, pointsB) {
2241
- for (let i = 0; i < pointsB.length; i++) {
2242
- if (polygonContainPoint(pointsA, pointsB[i].x, pointsB[i].y)) return !0;
2243
- if (i > 0 && lineIntersectPolygon(pointsB[i - 1].x, pointsB[i - 1].y, pointsB[i].x, pointsB[i].y, pointsA)) return !0;
2460
+ return this.color.opacity = o, this;
2244
2461
  }
2245
- return !1;
2246
- }
2247
-
2248
- const eastAsianCharacterInfo = character => {
2249
- let x = character.charCodeAt(0),
2250
- y = 2 === character.length ? character.charCodeAt(1) : 0,
2251
- codePoint = x;
2252
- return 55296 <= x && x <= 56319 && 56320 <= y && y <= 57343 && (x &= 1023, y &= 1023, codePoint = x << 10 | y, codePoint += 65536), 12288 === codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 ? "F" : 8361 === codePoint || 65377 <= codePoint && codePoint <= 65470 || 65474 <= codePoint && codePoint <= 65479 || 65482 <= codePoint && codePoint <= 65487 || 65490 <= codePoint && codePoint <= 65495 || 65498 <= codePoint && codePoint <= 65500 || 65512 <= codePoint && codePoint <= 65518 ? "H" : 4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141 ? "W" : 32 <= codePoint && codePoint <= 126 || 162 <= codePoint && codePoint <= 163 || 165 <= codePoint && codePoint <= 166 || 172 === codePoint || 175 === codePoint || 10214 <= codePoint && codePoint <= 10221 || 10629 <= codePoint && codePoint <= 10630 ? "Na" : 161 === codePoint || 164 === codePoint || 167 <= codePoint && codePoint <= 168 || 170 === codePoint || 173 <= codePoint && codePoint <= 174 || 176 <= codePoint && codePoint <= 180 || 182 <= codePoint && codePoint <= 186 || 188 <= codePoint && codePoint <= 191 || 198 === codePoint || 208 === codePoint || 215 <= codePoint && codePoint <= 216 || 222 <= codePoint && codePoint <= 225 || 230 === codePoint || 232 <= codePoint && codePoint <= 234 || 236 <= codePoint && codePoint <= 237 || 240 === codePoint || 242 <= codePoint && codePoint <= 243 || 247 <= codePoint && codePoint <= 250 || 252 === codePoint || 254 === codePoint || 257 === codePoint || 273 === codePoint || 275 === codePoint || 283 === codePoint || 294 <= codePoint && codePoint <= 295 || 299 === codePoint || 305 <= codePoint && codePoint <= 307 || 312 === codePoint || 319 <= codePoint && codePoint <= 322 || 324 === codePoint || 328 <= codePoint && codePoint <= 331 || 333 === codePoint || 338 <= codePoint && codePoint <= 339 || 358 <= codePoint && codePoint <= 359 || 363 === codePoint || 462 === codePoint || 464 === codePoint || 466 === codePoint || 468 === codePoint || 470 === codePoint || 472 === codePoint || 474 === codePoint || 476 === codePoint || 593 === codePoint || 609 === codePoint || 708 === codePoint || 711 === codePoint || 713 <= codePoint && codePoint <= 715 || 717 === codePoint || 720 === codePoint || 728 <= codePoint && codePoint <= 731 || 733 === codePoint || 735 === codePoint || 768 <= codePoint && codePoint <= 879 || 913 <= codePoint && codePoint <= 929 || 931 <= codePoint && codePoint <= 937 || 945 <= codePoint && codePoint <= 961 || 963 <= codePoint && codePoint <= 969 || 1025 === codePoint || 1040 <= codePoint && codePoint <= 1103 || 1105 === codePoint || 8208 === codePoint || 8211 <= codePoint && codePoint <= 8214 || 8216 <= codePoint && codePoint <= 8217 || 8220 <= codePoint && codePoint <= 8221 || 8224 <= codePoint && codePoint <= 8226 || 8228 <= codePoint && codePoint <= 8231 || 8240 === codePoint || 8242 <= codePoint && codePoint <= 8243 || 8245 === codePoint || 8251 === codePoint || 8254 === codePoint || 8308 === codePoint || 8319 === codePoint || 8321 <= codePoint && codePoint <= 8324 || 8364 === codePoint || 8451 === codePoint || 8453 === codePoint || 8457 === codePoint || 8467 === codePoint || 8470 === codePoint || 8481 <= codePoint && codePoint <= 8482 || 8486 === codePoint || 8491 === codePoint || 8531 <= codePoint && codePoint <= 8532 || 8539 <= codePoint && codePoint <= 8542 || 8544 <= codePoint && codePoint <= 8555 || 8560 <= codePoint && codePoint <= 8569 || 8585 === codePoint || 8592 <= codePoint && codePoint <= 8601 || 8632 <= codePoint && codePoint <= 8633 || 8658 === codePoint || 8660 === codePoint || 8679 === codePoint || 8704 === codePoint || 8706 <= codePoint && codePoint <= 8707 || 8711 <= codePoint && codePoint <= 8712 || 8715 === codePoint || 8719 === codePoint || 8721 === codePoint || 8725 === codePoint || 8730 === codePoint || 8733 <= codePoint && codePoint <= 8736 || 8739 === codePoint || 8741 === codePoint || 8743 <= codePoint && codePoint <= 8748 || 8750 === codePoint || 8756 <= codePoint && codePoint <= 8759 || 8764 <= codePoint && codePoint <= 8765 || 8776 === codePoint || 8780 === codePoint || 8786 === codePoint || 8800 <= codePoint && codePoint <= 8801 || 8804 <= codePoint && codePoint <= 8807 || 8810 <= codePoint && codePoint <= 8811 || 8814 <= codePoint && codePoint <= 8815 || 8834 <= codePoint && codePoint <= 8835 || 8838 <= codePoint && codePoint <= 8839 || 8853 === codePoint || 8857 === codePoint || 8869 === codePoint || 8895 === codePoint || 8978 === codePoint || 9312 <= codePoint && codePoint <= 9449 || 9451 <= codePoint && codePoint <= 9547 || 9552 <= codePoint && codePoint <= 9587 || 9600 <= codePoint && codePoint <= 9615 || 9618 <= codePoint && codePoint <= 9621 || 9632 <= codePoint && codePoint <= 9633 || 9635 <= codePoint && codePoint <= 9641 || 9650 <= codePoint && codePoint <= 9651 || 9654 <= codePoint && codePoint <= 9655 || 9660 <= codePoint && codePoint <= 9661 || 9664 <= codePoint && codePoint <= 9665 || 9670 <= codePoint && codePoint <= 9672 || 9675 === codePoint || 9678 <= codePoint && codePoint <= 9681 || 9698 <= codePoint && codePoint <= 9701 || 9711 === codePoint || 9733 <= codePoint && codePoint <= 9734 || 9737 === codePoint || 9742 <= codePoint && codePoint <= 9743 || 9748 <= codePoint && codePoint <= 9749 || 9756 === codePoint || 9758 === codePoint || 9792 === codePoint || 9794 === codePoint || 9824 <= codePoint && codePoint <= 9825 || 9827 <= codePoint && codePoint <= 9829 || 9831 <= codePoint && codePoint <= 9834 || 9836 <= codePoint && codePoint <= 9837 || 9839 === codePoint || 9886 <= codePoint && codePoint <= 9887 || 9918 <= codePoint && codePoint <= 9919 || 9924 <= codePoint && codePoint <= 9933 || 9935 <= codePoint && codePoint <= 9953 || 9955 === codePoint || 9960 <= codePoint && codePoint <= 9983 || 10045 === codePoint || 10071 === codePoint || 10102 <= codePoint && codePoint <= 10111 || 11093 <= codePoint && codePoint <= 11097 || 12872 <= codePoint && codePoint <= 12879 || 57344 <= codePoint && codePoint <= 63743 || 65024 <= codePoint && codePoint <= 65039 || 65533 === codePoint || 127232 <= codePoint && codePoint <= 127242 || 127248 <= codePoint && codePoint <= 127277 || 127280 <= codePoint && codePoint <= 127337 || 127344 <= codePoint && codePoint <= 127386 || 917760 <= codePoint && codePoint <= 917999 || 983040 <= codePoint && codePoint <= 1048573 || 1048576 <= codePoint && codePoint <= 1114109 ? "A" : "N";
2253
- };
2254
-
2255
- function getContextFont(text) {
2256
- let defaultAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2257
- let fontSizeScale = arguments.length > 2 ? arguments[2] : undefined;
2258
- fontSizeScale || (fontSizeScale = 1);
2259
- const {
2260
- fontStyle = defaultAttr.fontStyle,
2261
- fontVariant = defaultAttr.fontVariant,
2262
- fontWeight = defaultAttr.fontWeight,
2263
- fontSize = defaultAttr.fontSize,
2264
- fontFamily = defaultAttr.fontFamily
2265
- } = text;
2266
- return (fontStyle ? fontStyle + " " : "") + (fontVariant ? fontVariant + " " : "") + (fontWeight ? fontWeight + " " : "") + fontSize * fontSizeScale + "px " + (fontFamily || "sans-serif");
2267
- }
2268
-
2269
- class TextMeasure {
2270
- constructor(option, textSpec) {
2271
- this._numberCharSize = null, this._fullCharSize = null, this._letterCharSize = null, this._specialCharSizeMap = {}, this._canvas = null, this._context = null, this._contextSaved = !1, this._notSupportCanvas = !1, this._notSupportVRender = !1, this._userSpec = {}, this.specialCharSet = "-/: .,@%'\"~", this._option = option, this._userSpec = null != textSpec ? textSpec : {}, this.textSpec = this._initSpec(), isValid$1(option.specialCharSet) && (this.specialCharSet = option.specialCharSet), this._standardMethod = isValid$1(option.getTextBounds) ? this.fullMeasure.bind(this) : this.measureWithNaiveCanvas.bind(this);
2462
+ getLuminance() {
2463
+ return (.2126 * this.color.r + .7152 * this.color.g + .0722 * this.color.b) / 255;
2272
2464
  }
2273
- initContext() {
2274
- if (this._notSupportCanvas) return !1;
2275
- if (isNil$1(this._canvas) && (isValid$1(this._option.getCanvasForMeasure) && (this._canvas = this._option.getCanvasForMeasure()), isNil$1(this._canvas) && "undefined" != typeof window && void 0 !== window.document && globalThis && isValid$1(globalThis.document) && (this._canvas = globalThis.document.createElement("canvas"))), isNil$1(this._context) && isValid$1(this._canvas)) {
2276
- const context = this._canvas.getContext("2d");
2277
- isValid$1(context) && (context.save(), context.font = getContextFont(this.textSpec), this._contextSaved = !0, this._context = context);
2278
- }
2279
- return !isNil$1(this._context) || (this._notSupportCanvas = !0, !1);
2465
+ getLuminance2() {
2466
+ return (.2627 * this.color.r + .678 * this.color.g + .0593 * this.color.b) / 255;
2280
2467
  }
2281
- _initSpec() {
2282
- var _a, _b, _c;
2283
- const {
2284
- defaultFontParams = {}
2285
- } = this._option,
2286
- {
2287
- fontStyle = defaultFontParams.fontStyle,
2288
- fontVariant = defaultFontParams.fontVariant,
2289
- fontWeight = null !== (_a = defaultFontParams.fontWeight) && void 0 !== _a ? _a : "normal",
2290
- fontSize = null !== (_b = defaultFontParams.fontSize) && void 0 !== _b ? _b : 12,
2291
- fontFamily = null !== (_c = defaultFontParams.fontFamily) && void 0 !== _c ? _c : "sans-serif",
2292
- align: align,
2293
- textAlign = null != align ? align : "center",
2294
- baseline: baseline,
2295
- textBaseline = null != baseline ? baseline : "middle",
2296
- ellipsis: ellipsis,
2297
- limit: limit
2298
- } = this._userSpec;
2299
- let {
2300
- lineHeight = fontSize
2301
- } = this._userSpec;
2302
- if (isString$1(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
2303
- const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
2304
- lineHeight = fontSize * scale;
2305
- }
2306
- return {
2307
- fontStyle: fontStyle,
2308
- fontVariant: fontVariant,
2309
- fontFamily: fontFamily,
2310
- fontSize: fontSize,
2311
- fontWeight: fontWeight,
2312
- textAlign: textAlign,
2313
- textBaseline: textBaseline,
2314
- ellipsis: ellipsis,
2315
- limit: limit,
2316
- lineHeight: lineHeight
2317
- };
2468
+ getLuminance3() {
2469
+ return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
2318
2470
  }
2319
- measure(text, method) {
2320
- switch (method) {
2321
- case "vrender":
2322
- case "canopus":
2323
- return this.fullMeasure(text);
2324
- case "canvas":
2325
- return this.measureWithNaiveCanvas(text);
2326
- case "simple":
2327
- return this.quickMeasureWithoutCanvas(text);
2328
- default:
2329
- return this.quickMeasure(text);
2330
- }
2471
+ clone() {
2472
+ return new Color(this.color.toString());
2331
2473
  }
2332
- fullMeasure(text) {
2333
- if (isNil$1(text)) return {
2334
- width: 0,
2335
- height: 0
2336
- };
2337
- if (isNil$1(this._option.getTextBounds) || !this._notSupportVRender) return this.measureWithNaiveCanvas(text);
2338
- const {
2339
- fontFamily: fontFamily,
2340
- fontSize: fontSize,
2341
- fontWeight: fontWeight,
2342
- textAlign: textAlign,
2343
- textBaseline: textBaseline,
2344
- ellipsis: ellipsis,
2345
- limit: limit,
2346
- lineHeight: lineHeight
2347
- } = this.textSpec;
2348
- let size;
2349
- try {
2350
- const bounds = this._option.getTextBounds({
2351
- text: text,
2352
- fontFamily: fontFamily,
2353
- fontSize: fontSize,
2354
- fontWeight: fontWeight,
2355
- textAlign: textAlign,
2356
- textBaseline: textBaseline,
2357
- ellipsis: !!ellipsis,
2358
- maxLineWidth: limit || 1 / 0,
2359
- lineHeight: lineHeight
2360
- });
2361
- size = {
2362
- width: bounds.width(),
2363
- height: bounds.height()
2364
- };
2365
- } catch (e) {
2366
- this._notSupportVRender = !0, size = this.measureWithNaiveCanvas(text);
2367
- }
2368
- return size;
2474
+ copyGammaToLinear(color) {
2475
+ let gammaFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
2476
+ return this.color.r = Math.pow(color.color.r, gammaFactor), this.color.g = Math.pow(color.color.g, gammaFactor), this.color.b = Math.pow(color.color.b, gammaFactor), this;
2369
2477
  }
2370
- measureWithNaiveCanvas(text) {
2371
- return this._measureReduce(text, this._measureWithNaiveCanvas.bind(this));
2478
+ copyLinearToGamma(color) {
2479
+ let gammaFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
2480
+ const safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
2481
+ return this.color.r = Math.pow(color.color.r, safeInverse), this.color.g = Math.pow(color.color.g, safeInverse), this.color.b = Math.pow(color.color.b, safeInverse), this;
2372
2482
  }
2373
- _measureWithNaiveCanvas(text) {
2374
- var _a;
2375
- if (!this.initContext()) return this._quickMeasureWithoutCanvas(text);
2376
- const metrics = this._context.measureText(text),
2377
- {
2378
- fontSize: fontSize,
2379
- lineHeight: lineHeight
2380
- } = this.textSpec;
2381
- return {
2382
- width: metrics.width,
2383
- height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
2384
- };
2483
+ convertGammaToLinear(gammaFactor) {
2484
+ return this.copyGammaToLinear(this, gammaFactor), this;
2385
2485
  }
2386
- quickMeasure(text) {
2387
- return this._measureReduce(text, this._quickMeasure.bind(this));
2486
+ convertLinearToGamma(gammaFactor) {
2487
+ return this.copyLinearToGamma(this, gammaFactor), this;
2388
2488
  }
2389
- _quickMeasure(text) {
2390
- const totalSize = {
2391
- width: 0,
2392
- height: 0
2393
- };
2394
- for (let i = 0; i < text.length; i++) {
2395
- const char = text[i];
2396
- let size = this._measureSpecialChar(char);
2397
- isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height);
2398
- }
2399
- return totalSize;
2489
+ copySRGBToLinear(color) {
2490
+ return this.color.r = SRGBToLinear(color.color.r), this.color.g = SRGBToLinear(color.color.g), this.color.b = SRGBToLinear(color.color.b), this;
2400
2491
  }
2401
- quickMeasureWithoutCanvas(text) {
2402
- return this._measureReduce(text, this._quickMeasureWithoutCanvas.bind(this));
2492
+ copyLinearToSRGB(color) {
2493
+ return this.color.r = LinearToSRGB(color.color.r), this.color.g = LinearToSRGB(color.color.g), this.color.b = LinearToSRGB(color.color.b), this;
2403
2494
  }
2404
- _quickMeasureWithoutCanvas(text) {
2405
- var _a;
2406
- const totalSize = {
2407
- width: 0,
2408
- height: 0
2409
- },
2410
- {
2411
- fontSize: fontSize,
2412
- lineHeight: lineHeight
2413
- } = this.textSpec;
2414
- for (let i = 0; i < text.length; i++) {
2415
- const char = text[i],
2416
- size = ["F", "W"].includes(eastAsianCharacterInfo(char)) ? 1 : .53;
2417
- totalSize.width += size * fontSize;
2418
- }
2419
- return totalSize.height = null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize, totalSize;
2495
+ convertSRGBToLinear() {
2496
+ return this.copySRGBToLinear(this), this;
2420
2497
  }
2421
- _measureReduce(text, processor) {
2422
- var _a;
2423
- const {
2424
- fontSize: fontSize,
2425
- lineHeight: lineHeight
2426
- } = this.textSpec,
2427
- defaultResult = {
2428
- width: 0,
2429
- height: 0
2430
- };
2431
- if (isNil$1(text)) return defaultResult;
2432
- if (isArray$1(text)) {
2433
- const textArr = text.filter(isValid$1).map(s => s.toString());
2434
- return 0 === textArr.length ? defaultResult : 1 === textArr.length ? processor(textArr[0]) : {
2435
- width: textArr.reduce((maxWidth, cur) => Math.max(maxWidth, processor(cur).width), 0),
2436
- height: textArr.length * ((null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize) + 1) + 1
2437
- };
2438
- }
2439
- return processor(text.toString());
2498
+ convertLinearToSRGB() {
2499
+ return this.copyLinearToSRGB(this), this;
2440
2500
  }
2441
- _measureNumberChar() {
2442
- if (isNil$1(this._numberCharSize)) {
2443
- const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
2444
- this._numberCharSize = {
2445
- width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
2446
- height: numberBounds.height
2447
- };
2448
- }
2449
- return this._numberCharSize;
2501
+ }
2502
+ class RGB {
2503
+ constructor(r, g, b, opacity) {
2504
+ this.r = isNaN(+r) ? 255 : Math.max(0, Math.min(255, +r)), this.g = isNaN(+g) ? 255 : Math.max(0, Math.min(255, +g)), this.b = isNaN(+b) ? 255 : Math.max(0, Math.min(255, +b)), isValid$1(opacity) ? this.opacity = isNaN(+opacity) ? 1 : Math.max(0, Math.min(1, +opacity)) : this.opacity = 1;
2450
2505
  }
2451
- _measureFullSizeChar() {
2452
- return isNil$1(this._fullCharSize) && (this._fullCharSize = this._standardMethod(TextMeasure.FULL_SIZE_CHAR)), this._fullCharSize;
2506
+ formatHex() {
2507
+ return `#${hex(this.r) + hex(this.g) + hex(this.b) + (1 === this.opacity ? "" : hex(255 * this.opacity))}`;
2453
2508
  }
2454
- _measureLetterChar() {
2455
- if (isNil$1(this._letterCharSize)) {
2456
- const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
2457
- this._letterCharSize = {
2458
- width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
2459
- height: alphabetBounds.height
2460
- };
2461
- }
2462
- return this._letterCharSize;
2509
+ formatRgb() {
2510
+ const opacity = this.opacity;
2511
+ return `${1 === opacity ? "rgb(" : "rgba("}${this.r},${this.g},${this.b}${1 === opacity ? ")" : `,${opacity})`}`;
2463
2512
  }
2464
- _measureSpecialChar(char) {
2465
- return isValid$1(this._specialCharSizeMap[char]) ? this._specialCharSizeMap[char] : this.specialCharSet.includes(char) ? (this._specialCharSizeMap[char] = this._standardMethod(char), this._specialCharSizeMap[char]) : null;
2513
+ formatHsl() {
2514
+ const opacity = this.opacity,
2515
+ {
2516
+ h: h,
2517
+ s: s,
2518
+ l: l
2519
+ } = rgbToHsl(this.r, this.g, this.b);
2520
+ return `${1 === opacity ? "hsl(" : "hsla("}${h},${s}%,${l}%${1 === opacity ? ")" : `,${opacity})`}`;
2466
2521
  }
2467
- release() {
2468
- isValid$1(this._canvas) && (this._canvas = null), isValid$1(this._context) && (this._contextSaved && (this._context.restore(), this._contextSaved = !1), this._context = null);
2522
+ toString() {
2523
+ return this.formatHex();
2469
2524
  }
2470
2525
  }
2471
- TextMeasure.ALPHABET_CHAR_SET = "abcdefghijklmnopqrstuvwxyz", TextMeasure.NUMBERS_CHAR_SET = "0123456789", TextMeasure.FULL_SIZE_CHAR = "字";
2472
2526
 
2473
- const calculateAnchorOfBounds = (bounds, anchorType) => {
2474
- const {
2475
- x1: x1,
2476
- x2: x2,
2477
- y1: y1,
2478
- y2: y2
2479
- } = bounds,
2480
- rectWidth = Math.abs(x2 - x1),
2481
- rectHeight = Math.abs(y2 - y1);
2482
- let anchorX = (x1 + x2) / 2,
2483
- anchorY = (y1 + y2) / 2,
2484
- sx = 0,
2485
- sy = 0;
2486
- switch (anchorType) {
2487
- case "top":
2488
- case "inside-top":
2489
- sy = -.5;
2490
- break;
2491
- case "bottom":
2492
- case "inside-bottom":
2493
- sy = .5;
2494
- break;
2495
- case "left":
2496
- case "inside-left":
2497
- sx = -.5;
2498
- break;
2499
- case "right":
2500
- case "inside-right":
2501
- sx = .5;
2502
- break;
2503
- case "top-right":
2504
- sx = .5, sy = -.5;
2505
- break;
2506
- case "top-left":
2507
- sx = -.5, sy = -.5;
2508
- break;
2509
- case "bottom-right":
2510
- sx = .5, sy = .5;
2511
- break;
2512
- case "bottom-left":
2513
- sx = -.5, sy = .5;
2514
- }
2515
- return anchorX += sx * rectWidth, anchorY += sy * rectHeight, {
2516
- x: anchorX,
2517
- y: anchorY
2527
+ function hexToRgb(str) {
2528
+ let r = "",
2529
+ g = "",
2530
+ b = "";
2531
+ const strtIndex = "#" === str[0] ? 1 : 0;
2532
+ for (let i = strtIndex; i < str.length; i++) "#" !== str[i] && (i < strtIndex + 2 ? r += str[i] : i < strtIndex + 4 ? g += str[i] : i < strtIndex + 6 && (b += str[i]));
2533
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
2534
+ }
2535
+
2536
+ function rgbToHex(r, g, b) {
2537
+ return Number((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
2538
+ }
2539
+
2540
+ function interpolateRgb$1(colorA, colorB) {
2541
+ const redA = colorA.r,
2542
+ redB = colorB.r,
2543
+ greenA = colorA.g,
2544
+ greenB = colorB.g,
2545
+ blueA = colorA.b,
2546
+ blueB = colorB.b,
2547
+ opacityA = colorA.opacity,
2548
+ opacityB = colorB.opacity;
2549
+ return t => {
2550
+ const r = Math.round(redA * (1 - t) + redB * t),
2551
+ g = Math.round(greenA * (1 - t) + greenB * t),
2552
+ b = Math.round(blueA * (1 - t) + blueB * t);
2553
+ return new RGB(r, g, b, opacityA * (1 - t) + opacityB * t);
2518
2554
  };
2519
- };
2555
+ }
2556
+
2557
+ var ColorUtil = /*#__PURE__*/Object.freeze({
2558
+ __proto__: null,
2559
+ Color: Color,
2560
+ DEFAULT_COLORS: DEFAULT_COLORS,
2561
+ RGB: RGB,
2562
+ hexToRgb: hexToRgb,
2563
+ hslToRgb: hslToRgb,
2564
+ interpolateRgb: interpolateRgb$1,
2565
+ rgbToHex: rgbToHex,
2566
+ rgbToHsl: rgbToHsl
2567
+ });
2520
2568
 
2521
2569
  function normalizePadding$1(padding) {
2522
2570
  if (isValidNumber$1(padding)) return [padding, padding, padding, padding];
@@ -7849,7 +7897,7 @@
7849
7897
  this.bounds.add(cx + xmin, cy + ymin), this.bounds.add(cx + xmax, cy + ymax);
7850
7898
  }
7851
7899
  arcTo(x1, y1, x2, y2, radius) {
7852
- throw new Error("不支持arcTo");
7900
+ this.bounds.add(x1, y1);
7853
7901
  }
7854
7902
  bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
7855
7903
  this.bounds.add(cp1x, cp1y), this.bounds.add(cp2x, cp2y), this.bounds.add(x, y);
@@ -8058,19 +8106,25 @@
8058
8106
  }
8059
8107
  const addArcToBezierPath$1 = (bezierPath, startAngle, endAngle, cx, cy, rx, ry) => {
8060
8108
  const delta = Math.abs(endAngle - startAngle),
8061
- len = 4 * Math.tan(delta / 4) / 3,
8062
- dir = endAngle < startAngle ? -1 : 1,
8063
- c1 = Math.cos(startAngle),
8064
- s1 = Math.sin(startAngle),
8065
- c2 = Math.cos(endAngle),
8066
- s2 = Math.sin(endAngle),
8067
- x1 = c1 * rx + cx,
8068
- y1 = s1 * ry + cy,
8069
- x4 = c2 * rx + cx,
8070
- y4 = s2 * ry + cy,
8071
- hx = rx * len * dir,
8072
- hy = ry * len * dir;
8073
- bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
8109
+ count = delta > .5 * Math.PI ? Math.ceil(2 * delta / Math.PI) : 1,
8110
+ stepAngle = (endAngle - startAngle) / count;
8111
+ for (let i = 0; i < count; i++) {
8112
+ const sa = startAngle + stepAngle * i,
8113
+ ea = startAngle + stepAngle * (i + 1),
8114
+ len = 4 * Math.tan(Math.abs(stepAngle) / 4) / 3,
8115
+ dir = ea < sa ? -1 : 1,
8116
+ c1 = Math.cos(sa),
8117
+ s1 = Math.sin(sa),
8118
+ c2 = Math.cos(ea),
8119
+ s2 = Math.sin(ea),
8120
+ x1 = c1 * rx + cx,
8121
+ y1 = s1 * ry + cy,
8122
+ x4 = c2 * rx + cx,
8123
+ y4 = s2 * ry + cy,
8124
+ hx = rx * len * dir,
8125
+ hy = ry * len * dir;
8126
+ bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
8127
+ }
8074
8128
  };
8075
8129
 
8076
8130
  const commandFuncs = [(command, context, x, y, sx, sy, z) => context.arc(command[1] * sx + x, command[2] * sy + y, command[3] * (sx + sy) / 2, command[4], command[5], command[6], z), (command, context, x, y, sx, sy, z) => context.arcTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, command[5] * (sx + sy) / 2, z), (command, context, x, y, sx, sy, z) => context.bezierCurveTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, command[5] * sx + x, command[6] * sy + y, z), (command, context, x, y) => context.closePath(), (command, context, x, y, sx, sy) => context.ellipse(command[1] * sx + x, command[2] * sy + y, command[3] * sx, command[4] * sy, command[5], command[6], command[7], command[8]), (command, context, x, y, sx, sy, z) => context.lineTo(command[1] * sx + x, command[2] * sy + y, z), (command, context, x, y, sx, sy, z) => context.moveTo(command[1] * sx + x, command[2] * sy + y, z), (command, context, x, y, sx, sy, z) => context.quadraticCurveTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, z), (command, context, x, y, sx, sy, z) => context.rect(command[1] * sx + x, command[2] * sy + y, command[3] * sx, command[4] * sy, z)];
@@ -12374,8 +12428,9 @@
12374
12428
  }), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
12375
12429
  let start = 0;
12376
12430
  out.segments = this.to.segments.map((segment, index) => {
12377
- const points = this.points.slice(start, this.segmentsCache[start]);
12378
- return start += this.segmentsCache[start], Object.assign(Object.assign({}, segment), {
12431
+ const end = start + this.segmentsCache[index],
12432
+ points = this.points.slice(start, end);
12433
+ return start = end, Object.assign(Object.assign({}, segment), {
12379
12434
  points: points
12380
12435
  });
12381
12436
  });
@@ -13802,6 +13857,9 @@
13802
13857
  get AABBBounds() {
13803
13858
  return this.tryUpdateAABBBounds("imprecise" === this.attribute.boundsMode);
13804
13859
  }
13860
+ get OBBBounds() {
13861
+ return this.tryUpdateOBBBounds();
13862
+ }
13805
13863
  get globalAABBBounds() {
13806
13864
  return this.tryUpdateGlobalAABBBounds();
13807
13865
  }
@@ -13814,7 +13872,7 @@
13814
13872
  constructor() {
13815
13873
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13816
13874
  var _a;
13817
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
13875
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
13818
13876
  }
13819
13877
  setMode(mode) {
13820
13878
  "3d" === mode ? this.set3dMode() : this.set2dMode();
@@ -13848,13 +13906,22 @@
13848
13906
  const bounds = this.doUpdateAABBBounds(full);
13849
13907
  return application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0), bounds;
13850
13908
  }
13909
+ tryUpdateOBBBounds() {
13910
+ if (this._OBBBounds || (this._OBBBounds = new OBBBounds()), this.tryUpdateAABBBounds(), this.updateOBBBoundsStamp === this.updateAABBBoundsStamp) return this._OBBBounds;
13911
+ if (this.updateOBBBoundsStamp = this.updateAABBBoundsStamp, !this.valid) return this._OBBBounds.clear(), this._OBBBounds;
13912
+ return this.doUpdateOBBBounds();
13913
+ }
13851
13914
  combindShadowAABBBounds(bounds) {
13852
13915
  if (this.shadowRoot) {
13853
13916
  const b = this.shadowRoot.AABBBounds.clone();
13854
13917
  bounds.union(b);
13855
13918
  }
13856
13919
  }
13920
+ doUpdateOBBBounds() {
13921
+ return this._OBBBounds;
13922
+ }
13857
13923
  doUpdateAABBBounds(full) {
13924
+ this.updateAABBBoundsStamp++;
13858
13925
  const graphicTheme = this.getGraphicTheme();
13859
13926
  this._AABBBounds.clear();
13860
13927
  const attribute = this.attribute,
@@ -14831,6 +14898,7 @@
14831
14898
  }), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, groupTheme, !1, this), originalAABBBounds.copy(aabbBounds), originalAABBBounds;
14832
14899
  }
14833
14900
  doUpdateAABBBounds() {
14901
+ this.updateAABBBoundsStamp++;
14834
14902
  const bounds = super.doUpdateAABBBounds();
14835
14903
  return this.parent && this.parent.addChildUpdateBoundTag(), this._emitCustomEvent("AAABBBoundsChange"), bounds;
14836
14904
  }
@@ -15825,6 +15893,7 @@
15825
15893
  validCheck(attribute, theme, aabbBounds, graphic) {
15826
15894
  if (!graphic) return !0;
15827
15895
  if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
15896
+ if (graphic.shadowRoot) return !0;
15828
15897
  if (!graphic.valid) return aabbBounds.clear(), !1;
15829
15898
  const {
15830
15899
  visible = theme.visible
@@ -18654,7 +18723,10 @@
18654
18723
  }
18655
18724
  beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params) {
18656
18725
  const baseGraphic = graphic.baseGraphic;
18657
- if (!baseGraphic.stage) {
18726
+ let intree = !!baseGraphic.stage,
18727
+ _g = baseGraphic.parent;
18728
+ for (; intree && _g && _g.stage !== _g;) intree = !!_g.stage, _g = _g.parent;
18729
+ if (!intree) {
18658
18730
  const interactiveLayer = drawContext.stage.getLayer("_builtin_interactive");
18659
18731
  if (interactiveLayer) {
18660
18732
  this.getShadowRoot(interactiveLayer).removeChild(graphic);
@@ -18957,13 +19029,23 @@
18957
19029
  if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
18958
19030
  }
18959
19031
  get cliped() {
19032
+ var _a, _b;
18960
19033
  const textTheme = this.getGraphicTheme(),
18961
- attribute = this.attribute;
18962
- if (this.isMultiLine) return;
18963
- const {
18964
- maxLineWidth = textTheme.maxLineWidth
18965
- } = attribute;
18966
- return !!Number.isFinite(maxLineWidth) && (this.tryUpdateAABBBounds(), "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());
19034
+ attribute = this.attribute,
19035
+ {
19036
+ maxLineWidth = textTheme.maxLineWidth,
19037
+ text: text,
19038
+ whiteSpace = textTheme.whiteSpace
19039
+ } = attribute;
19040
+ if (!Number.isFinite(maxLineWidth)) return !1;
19041
+ if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
19042
+ let mergedText = "";
19043
+ this.cache.layoutData.lines.forEach(item => {
19044
+ mergedText += item.str;
19045
+ });
19046
+ return (Array.isArray(text) ? text.join("") : text) !== mergedText;
19047
+ }
19048
+ 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();
18967
19049
  }
18968
19050
  get multilineLayout() {
18969
19051
  if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
@@ -18993,6 +19075,35 @@
18993
19075
  getGraphicTheme() {
18994
19076
  return getTheme$1(this).text;
18995
19077
  }
19078
+ doUpdateOBBBounds() {
19079
+ const graphicTheme = this.getGraphicTheme();
19080
+ this._OBBBounds.clear();
19081
+ const attribute = this.attribute,
19082
+ {
19083
+ angle = graphicTheme.angle
19084
+ } = attribute;
19085
+ if (!angle) {
19086
+ const b = this.AABBBounds;
19087
+ return this._OBBBounds.setValue(b.x1, b.y1, b.x2, b.y2), this._OBBBounds;
19088
+ }
19089
+ this.obbText || (this.obbText = new Text({})), this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), {
19090
+ angle: 0
19091
+ }));
19092
+ const bounds1 = this.obbText.AABBBounds,
19093
+ {
19094
+ x: x,
19095
+ y: y
19096
+ } = attribute,
19097
+ boundsCenter = {
19098
+ x: (bounds1.x1 + bounds1.x2) / 2,
19099
+ y: (bounds1.y1 + bounds1.y2) / 2
19100
+ },
19101
+ center = rotatePoint(boundsCenter, angle, {
19102
+ x: x,
19103
+ y: y
19104
+ });
19105
+ return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x, center.y - boundsCenter.y), this._OBBBounds.angle = angle, this._OBBBounds;
19106
+ }
18996
19107
  updateAABBBounds(attribute, textTheme, aabbBounds) {
18997
19108
  const {
18998
19109
  text = textTheme.text
@@ -20309,7 +20420,7 @@
20309
20420
  }), aabbBounds;
20310
20421
  }
20311
20422
  doUpdateAABBBounds() {
20312
- this._AABBBounds.clear();
20423
+ this.updateAABBBoundsStamp++, this._AABBBounds.clear();
20313
20424
  const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds);
20314
20425
  return this.clearUpdateBoundTag(), bounds;
20315
20426
  }
@@ -20732,10 +20843,22 @@
20732
20843
  }
20733
20844
  draw(ctx, lastLine, x, y, drawEllipsis, drawIcon) {
20734
20845
  if (drawEllipsis && (lastLine || this.paragraphs.some(p => p.overflow))) {
20735
- let otherParagraphWidth = 0;
20846
+ let emptyOverflow = !0,
20847
+ skipEllipsis = !1;
20736
20848
  for (let i = this.paragraphs.length - 1; i >= 0; i--) {
20737
20849
  const paragraph = this.paragraphs[i];
20738
- if (paragraph.overflow) continue;
20850
+ if (paragraph.overflow) emptyOverflow = emptyOverflow && "" === paragraph.text;else if (emptyOverflow) {
20851
+ skipEllipsis = !0;
20852
+ break;
20853
+ }
20854
+ }
20855
+ let otherParagraphWidth = 0;
20856
+ if (!skipEllipsis) for (let i = this.paragraphs.length - 1; i >= 0; i--) {
20857
+ const paragraph = this.paragraphs[i];
20858
+ if (paragraph.overflow) {
20859
+ if ("" === paragraph.text) break;
20860
+ continue;
20861
+ }
20739
20862
  if (paragraph instanceof RichTextIcon) break;
20740
20863
  if ("vertical" === this.direction && "vertical" !== paragraph.direction) {
20741
20864
  paragraph.verticalEllipsis = !0;
@@ -20960,6 +21083,21 @@
20960
21083
  getFrameCache() {
20961
21084
  return this.shouldUpdateShape() && (this.doUpdateFrameCache(), this.clearUpdateShapeTag()), this._frameCache;
20962
21085
  }
21086
+ get cliped() {
21087
+ const frameCache = this.getFrameCache();
21088
+ if (frameCache.actualHeight > frameCache.height) return !0;
21089
+ const {
21090
+ disableAutoWrapLine: disableAutoWrapLine
21091
+ } = this.attribute;
21092
+ if (disableAutoWrapLine) for (let i = 0; i < frameCache.lines.length; i++) {
21093
+ const l = frameCache.lines[i];
21094
+ for (let j = 0; j < l.paragraphs.length; j++) {
21095
+ const p = l.paragraphs[j];
21096
+ if (p.overflow && "" !== p.text) return !0;
21097
+ }
21098
+ }
21099
+ return !1;
21100
+ }
20963
21101
  combinedStyleToCharacter(config) {
20964
21102
  const {
20965
21103
  fill: fill,
@@ -21445,13 +21583,14 @@
21445
21583
  return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
21446
21584
  }
21447
21585
  toCustomPath() {
21586
+ var _a, _b, _c, _d;
21448
21587
  const attribute = this.attribute,
21449
21588
  {
21450
21589
  startAngle: startAngle,
21451
21590
  endAngle: endAngle
21452
21591
  } = this.getParsedAngle();
21453
- let innerRadius = attribute.innerRadius - (attribute.innerPadding || 0),
21454
- outerRadius = attribute.outerRadius - (attribute.outerPadding || 0);
21592
+ let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
21593
+ outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
21455
21594
  const deltaAngle = abs$1(endAngle - startAngle),
21456
21595
  clockwise = endAngle > startAngle;
21457
21596
  if (outerRadius < innerRadius) {
@@ -30031,7 +30170,7 @@
30031
30170
  const {
30032
30171
  width: width,
30033
30172
  height: height
30034
- } = this._getSliderRenderBounds();
30173
+ } = this.getSliderRenderBounds();
30035
30174
  return "vertical" === direction ? (currentPos = y, delta = currentPos - this._prePos, currentScrollValue = delta / height) : (currentPos = x, delta = currentPos - this._prePos, currentScrollValue = delta / width), [currentPos, currentScrollValue];
30036
30175
  }, this._onSliderPointerMove = e => {
30037
30176
  const {
@@ -30119,7 +30258,7 @@
30119
30258
  height: height
30120
30259
  }, railStyle), "rect");
30121
30260
  this._rail = rail;
30122
- const sliderRenderBounds = this._getSliderRenderBounds(),
30261
+ const sliderRenderBounds = this.getSliderRenderBounds(),
30123
30262
  sliderPos = this._getSliderPos(clampRange$1(range, limitRange[0], limitRange[1])),
30124
30263
  sliderSize = sliderPos[1] - sliderPos[0];
30125
30264
  let sliderAttribute;
@@ -30147,7 +30286,7 @@
30147
30286
  y: containerAABBBounds.y1
30148
30287
  };
30149
30288
  }
30150
- _getSliderRenderBounds() {
30289
+ getSliderRenderBounds() {
30151
30290
  if (this._sliderRenderBounds) return this._sliderRenderBounds;
30152
30291
  const {
30153
30292
  width: width,
@@ -30174,7 +30313,7 @@
30174
30313
  const {
30175
30314
  width: width,
30176
30315
  height: height
30177
- } = this._getSliderRenderBounds();
30316
+ } = this.getSliderRenderBounds();
30178
30317
  return "horizontal" === direction ? height : width;
30179
30318
  }
30180
30319
  return 0;
@@ -30188,7 +30327,7 @@
30188
30327
  height: height,
30189
30328
  x1: x1,
30190
30329
  y1: y1
30191
- } = this._getSliderRenderBounds();
30330
+ } = this.getSliderRenderBounds();
30192
30331
  return "horizontal" === direction ? [width * range[0] + x1, width * range[1] + x1] : [height * range[0] + y1, height * range[1] + y1];
30193
30332
  }
30194
30333
  _getScrollRange() {
@@ -30203,7 +30342,7 @@
30203
30342
  height: height,
30204
30343
  x1: x1,
30205
30344
  y1: y1
30206
- } = this._getSliderRenderBounds(),
30345
+ } = this.getSliderRenderBounds(),
30207
30346
  sliderSize = this._sliderSize;
30208
30347
  return "horizontal" === direction ? clampRange$1([x1 + min * width, x1 + max * width], x1, width - sliderSize) : clampRange$1([y1 + min * height, y1 + max * height], y1, height - sliderSize);
30209
30348
  }
@@ -30379,7 +30518,7 @@
30379
30518
  }
30380
30519
  function richTextAttributeTransform(attributes) {
30381
30520
  var _a, _b;
30382
- return attributes.width = null !== (_a = attributes.width) && void 0 !== _a ? _a : 0, attributes.height = null !== (_b = attributes.height) && void 0 !== _b ? _b : 0, attributes.maxWidth = attributes.maxLineWidth, attributes.textConfig = attributes.text.text || attributes.text, attributes;
30521
+ return isValid$1(attributes.maxLineWidth) && (attributes.maxWidth = attributes.maxLineWidth, delete attributes.maxLineWidth), attributes.width = null !== (_a = attributes.width) && void 0 !== _a ? _a : 0, attributes.height = null !== (_b = attributes.height) && void 0 !== _b ? _b : 0, attributes.textConfig = attributes.text.text || attributes.text, attributes;
30383
30522
  }
30384
30523
  function htmlAttributeTransform(attributes) {
30385
30524
  const {
@@ -30496,6 +30635,8 @@
30496
30635
  zIndex: 1
30497
30636
  }, "group");
30498
30637
  let symbol,
30638
+ tagX = -parsedPadding[3],
30639
+ tagY = -parsedPadding[0],
30499
30640
  tagWidth = parsedPadding[1] + parsedPadding[3],
30500
30641
  tagHeight = parsedPadding[0] + parsedPadding[2],
30501
30642
  textX = 0,
@@ -30530,25 +30671,7 @@
30530
30671
  x: textX,
30531
30672
  y: 0
30532
30673
  });
30533
- textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext");
30534
- const {
30535
- visible: bgVisible
30536
- } = panel,
30537
- backgroundStyle = __rest$d(panel, ["visible"]);
30538
- if (visible && isBoolean$1(bgVisible)) {
30539
- const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
30540
- visible: bgVisible && !!text,
30541
- x: textShape.AABBBounds.x1 - parsedPadding[1],
30542
- y: textShape.AABBBounds.y1 - parsedPadding[0],
30543
- width: textShape.AABBBounds.width() + (parsedPadding[1] + parsedPadding[3]),
30544
- height: textShape.AABBBounds.height() + (parsedPadding[0] + parsedPadding[2])
30545
- }), "rect");
30546
- if (isEmpty(null == state ? void 0 : state.panel) || (bgRect.states = state.panel), backgroundStyle.customShape) {
30547
- const customShape = backgroundStyle.customShape;
30548
- bgRect.pathProxy = attrs => customShape(textShape.attribute, attrs, new CustomPath2D());
30549
- }
30550
- this._bgRect = bgRect;
30551
- }
30674
+ textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext"), tagWidth += textShape.AABBBounds.width(), tagHeight += textShape.AABBBounds.height(), tagX += textShape.AABBBounds.x1, tagY += textShape.AABBBounds.y1;
30552
30675
  } else {
30553
30676
  const textAttrs = Object.assign(Object.assign({
30554
30677
  text: isObject$2(text) && "type" in text && "text" === text.type ? text.text : text,
@@ -30570,11 +30693,9 @@
30570
30693
  textAlign: textAlign,
30571
30694
  textBaseline: textBaseline
30572
30695
  } = textStyle;
30573
- (isValid$1(minWidth) || isValid$1(maxWidth)) && (isValid$1(minWidth) && tagWidth < minWidth && (tagWidth = minWidth), isValid$1(maxWidth) && tagWidth > maxWidth && (tagWidth = maxWidth, textShape.setAttribute("maxLineWidth", maxWidth - parsedPadding[1] - parsedPadding[2])));
30574
- let x = 0,
30575
- y = 0,
30576
- flag = 0;
30577
- "left" === textAlign || "start" === textAlign ? flag = 1 : "right" === textAlign || "end" === textAlign ? flag = -1 : "center" === textAlign && (flag = 0), flag ? flag < 0 ? (x -= tagWidth, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth), group.setAttribute("x", -parsedPadding[1] - symbolPlaceWidth)) : flag > 0 && group.setAttribute("x", parsedPadding[3]) : (x -= tagWidth / 2, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth / 2), group.setAttribute("x", -symbolPlaceWidth / 2));
30696
+ (isValid$1(minWidth) || isValid$1(maxWidth)) && (isValid$1(minWidth) && tagWidth < minWidth && (tagWidth = minWidth), isValid$1(maxWidth) && tagWidth > maxWidth && (tagWidth = maxWidth, textShape.setAttribute("maxLineWidth", maxWidth - parsedPadding[1] - parsedPadding[2]))), tagX = 0, tagY = 0;
30697
+ let flag = 0;
30698
+ "left" === textAlign || "start" === textAlign ? flag = 1 : "right" === textAlign || "end" === textAlign ? flag = -1 : "center" === textAlign && (flag = 0), flag ? flag < 0 ? (tagX -= tagWidth, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth), group.setAttribute("x", -parsedPadding[1] - symbolPlaceWidth)) : flag > 0 && group.setAttribute("x", parsedPadding[3]) : (tagX -= tagWidth / 2, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth / 2), group.setAttribute("x", -symbolPlaceWidth / 2));
30578
30699
  const shouldRight = "right" === containerTextAlign || "end" === containerTextAlign,
30579
30700
  shouldLeft = "left" === containerTextAlign || "start" === containerTextAlign;
30580
30701
  if ((containerTextAlign ? "center" === containerTextAlign : textAlwaysCenter) && flag) {
@@ -30618,25 +30739,25 @@
30618
30739
  });
30619
30740
  }
30620
30741
  }
30621
- "middle" === textBaseline ? (y -= tagHeight / 2, symbol && symbol.setAttribute("y", 0)) : "bottom" === textBaseline ? (y -= tagHeight, symbol && symbol.setAttribute("y", -textHeight / 2), group.setAttribute("y", -parsedPadding[2])) : "top" === textBaseline && (group.setAttribute("y", parsedPadding[0]), symbol && symbol.setAttribute("y", textHeight / 2));
30622
- const {
30623
- visible: bgVisible
30624
- } = panel,
30625
- backgroundStyle = __rest$d(panel, ["visible"]);
30626
- if (visible && isBoolean$1(bgVisible)) {
30627
- const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
30628
- visible: bgVisible && !!text,
30629
- x: x,
30630
- y: y,
30631
- width: tagWidth,
30632
- height: tagHeight
30633
- }), "rect");
30634
- if (isEmpty(null == state ? void 0 : state.panel) || (bgRect.states = state.panel), backgroundStyle.customShape) {
30635
- const customShape = backgroundStyle.customShape;
30636
- bgRect.pathProxy = attrs => customShape(textShape.attribute, attrs, new CustomPath2D());
30637
- }
30638
- this._bgRect = bgRect;
30742
+ "middle" === textBaseline ? (tagY -= tagHeight / 2, symbol && symbol.setAttribute("y", 0)) : "bottom" === textBaseline ? (tagY -= tagHeight, symbol && symbol.setAttribute("y", -textHeight / 2), group.setAttribute("y", -parsedPadding[2])) : "top" === textBaseline && (group.setAttribute("y", parsedPadding[0]), symbol && symbol.setAttribute("y", textHeight / 2));
30743
+ }
30744
+ const {
30745
+ visible: bgVisible
30746
+ } = panel,
30747
+ backgroundStyle = __rest$d(panel, ["visible"]);
30748
+ if (visible && isBoolean$1(bgVisible)) {
30749
+ const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
30750
+ visible: bgVisible && !!text,
30751
+ width: tagWidth,
30752
+ height: tagHeight,
30753
+ x: tagX,
30754
+ y: tagY
30755
+ }), "rect");
30756
+ if (isEmpty(null == state ? void 0 : state.panel) || (bgRect.states = state.panel), backgroundStyle.customShape) {
30757
+ const customShape = backgroundStyle.customShape;
30758
+ bgRect.pathProxy = attrs => customShape(this, attrs, new CustomPath2D());
30639
30759
  }
30760
+ this._bgRect = bgRect;
30640
30761
  }
30641
30762
  this._textShape = textShape, this._symbol = symbol, this.resetStates();
30642
30763
  }
@@ -31870,7 +31991,10 @@
31870
31991
  } = text.attribute;
31871
31992
  if (line.customShape) {
31872
31993
  const customShape = line.customShape;
31873
- lineGraphic.pathProxy = attrs => customShape(text.attribute, attrs, new CustomPath2D());
31994
+ lineGraphic.pathProxy = attrs => customShape({
31995
+ text: text,
31996
+ baseMark: baseMark
31997
+ }, attrs, new CustomPath2D());
31874
31998
  }
31875
31999
  return baseMark && baseMark.attribute.fill && lineGraphic.setAttribute("stroke", baseMark.attribute.fill), this.attribute.line && !isEmpty(this.attribute.line.style) && lineGraphic.setAttributes(this.attribute.line.style), this._setStatesOfLabelLine(lineGraphic), lineGraphic;
31876
32000
  }
@@ -32294,45 +32418,33 @@
32294
32418
  const baseMark = this.getRelatedGraphic(label.attribute),
32295
32419
  backgroundColor = baseMark.attribute.fill,
32296
32420
  foregroundColor = label.attribute.fill,
32297
- baseColor = backgroundColor,
32298
32421
  invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode),
32299
32422
  similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
32300
- if (outsideEnable) {
32301
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
32423
+ if (outsideEnable || this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds)) {
32424
+ const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
32302
32425
  if (fill && label.setAttributes({
32303
32426
  fill: fill
32304
32427
  }), 0 === label.attribute.lineWidth) continue;
32305
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
32428
+ const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
32306
32429
  stroke && label.setAttributes({
32307
32430
  stroke: stroke
32308
32431
  });
32309
- } else {
32310
- if (this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds)) {
32311
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
32312
- if (fill && label.setAttributes({
32313
- fill: fill
32314
- }), 0 === label.attribute.lineWidth) continue;
32315
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
32316
- stroke && label.setAttributes({
32317
- stroke: stroke
32318
- });
32319
- } else {
32320
- if (0 === label.attribute.lineWidth) continue;
32321
- if (label.attribute.stroke) {
32322
- label.setAttributes({
32323
- fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors, mode)
32324
- });
32325
- continue;
32326
- }
32327
- const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
32328
- fill && label.setAttributes({
32329
- fill: fill
32330
- });
32331
- const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
32332
- stroke && label.setAttributes({
32333
- stroke: stroke
32432
+ } else if (label.AABBBounds && baseMark.AABBBounds && baseMark.AABBBounds.intersects(label.AABBBounds)) {
32433
+ if (0 === label.attribute.lineWidth) continue;
32434
+ if (label.attribute.stroke) {
32435
+ label.setAttributes({
32436
+ fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors, mode)
32334
32437
  });
32438
+ continue;
32335
32439
  }
32440
+ const fill = smartInvertStrategy(fillStrategy, backgroundColor, invertColor, similarColor);
32441
+ fill && label.setAttributes({
32442
+ fill: fill
32443
+ });
32444
+ const stroke = smartInvertStrategy(strokeStrategy, backgroundColor, invertColor, similarColor);
32445
+ stroke && label.setAttributes({
32446
+ stroke: stroke
32447
+ });
32336
32448
  }
32337
32449
  }
32338
32450
  }
@@ -32531,7 +32643,7 @@
32531
32643
  };
32532
32644
  class ArcInfo {
32533
32645
  constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle, innerRadius, outerRadius, circleCenter) {
32534
- this.refDatum = refDatum, this.center = center, this.outerCenter = outerCenter, this.quadrant = quadrant, this.radian = radian, this.middleAngle = middleAngle, this.innerRadius = innerRadius, this.outerRadius = outerRadius, this.circleCenter = circleCenter, this.labelVisible = !0, this.labelLimit = 0;
32646
+ this.refDatum = refDatum, this.center = center, this.outerCenter = outerCenter, this.quadrant = quadrant, this.radian = radian, this.middleAngle = middleAngle, this.innerRadius = innerRadius, this.outerRadius = outerRadius, this.circleCenter = circleCenter, this.labelVisible = !0;
32535
32647
  }
32536
32648
  getLabelBounds() {
32537
32649
  return this.labelPosition && this.labelSize ? {
@@ -32567,7 +32679,7 @@
32567
32679
  };
32568
32680
  }
32569
32681
  _layout(texts) {
32570
- var _a;
32682
+ var _a, _b, _c;
32571
32683
  if (!texts || !texts.length) return;
32572
32684
  const labels = super._layout(texts),
32573
32685
  textBoundsArray = labels.map(label => this.getGraphicBounds(label)),
@@ -32596,11 +32708,10 @@
32596
32708
  x: basedArc.labelPosition.x,
32597
32709
  y: basedArc.labelPosition.y,
32598
32710
  angle: basedArc.angle,
32599
- maxLineWidth: basedArc.labelLimit,
32600
32711
  points: basedArc.pointA && basedArc.pointB && basedArc.pointC ? [basedArc.pointA, basedArc.pointB, basedArc.pointC] : void 0,
32601
32712
  line: basedArc.labelLine
32602
32713
  };
32603
- "richtext" === labels[i].type && (labelAttribute.width = basedArc.labelLimit), labels[i].setAttributes(labelAttribute);
32714
+ "richtext" === labels[i].type ? labelAttribute.width = null !== (_b = basedArc.labelLimit) && void 0 !== _b ? _b : labels[i].attribute.width : labelAttribute.maxLineWidth = null !== (_c = basedArc.labelLimit) && void 0 !== _c ? _c : labels[i].attribute.maxLineWidth, labels[i].setAttributes(labelAttribute);
32604
32715
  }
32605
32716
  }
32606
32717
  return labels;
@@ -32766,7 +32877,7 @@
32766
32877
  const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height),
32767
32878
  flag = isQuadrantLeft(quadrant) ? -1 : 1;
32768
32879
  let cx = 0,
32769
- limit = (flag > 0 ? plotLayout_x2 - pointB.x : pointB.x - plotLayout_x1) - this._line2MinLength - spaceWidth;
32880
+ limit = (flag > 0 ? plotLayout_x2 - pointB.x + this._alignOffset : pointB.x - plotLayout_x1 - this._alignOffset) - this._line2MinLength - spaceWidth;
32770
32881
  "labelLine" === labelLayoutAlign && (cx = (radius + line1MinLength + this._line2MinLength) * flag + center.x, limit = (flag > 0 ? plotLayout_x2 - cx : cx - plotLayout_x1) - spaceWidth);
32771
32882
  const text = this._getFormatLabelText(arc.refDatum, limit);
32772
32883
  arc.labelText = text;
@@ -32780,12 +32891,14 @@
32780
32891
  default:
32781
32892
  cx = pointB.x + flag * this._line2MinLength;
32782
32893
  }
32783
- labelWidth = Math.max(this._ellipsisWidth, labelWidth), arc.labelLimit = labelWidth, arc.pointC = {
32894
+ labelWidth = Math.max(this._ellipsisWidth, labelWidth);
32895
+ const needAdjustLimit = labelWidth < arc.labelSize.width - 1;
32896
+ arc.labelLimit = needAdjustLimit ? labelWidth : null, arc.pointC = {
32784
32897
  x: cx,
32785
32898
  y: labelPosition.y
32786
32899
  };
32787
32900
  const align = this._computeAlign(arc, attribute),
32788
- targetCenterOffset = getAlignOffset(align) * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
32901
+ targetCenterOffset = getAlignOffset(align) * (needAdjustLimit ? labelWidth : arc.labelSize.width);
32789
32902
  "edge" === labelLayoutAlign ? (labelPosition.x = (flag > 0 ? plotLayout_x2 : plotLayout_x1) - flag * targetCenterOffset + flag * this._alignOffset, arc.pointC.x += flag * this._alignOffset) : labelPosition.x = cx + flag * (this._alignOffset + spaceWidth + targetCenterOffset);
32790
32903
  }
32791
32904
  _computeAlign(arc, attribute) {
@@ -33485,34 +33598,10 @@
33485
33598
  zIndex: 1
33486
33599
  };
33487
33600
 
33488
- const clampRadian = function () {
33489
- let angle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
33490
- if (angle < 0) for (; angle < 0;) angle += tau$1;else if (angle > 0) for (; angle > tau$1;) angle -= tau$1;
33491
- return angle;
33492
- };
33493
- function isInRange(a, min, max) {
33494
- return !isLess(a, min, 0, 1e-6) && !isGreater(a, max, 0, 1e-6);
33495
- }
33496
- function getCircleLabelPosition(tickPosition, tickVector, text, style) {
33497
- const labelBounds = getTextBounds(Object.assign({
33498
- text: text
33499
- }, style)),
33500
- width = labelBounds.width(),
33501
- height = labelBounds.height(),
33502
- angle = clampRadian(Math.atan2(tickVector[1], tickVector[0])) - Math.PI,
33503
- PI_3_4 = 3 * Math.PI / 4,
33504
- PI_1_4 = Math.PI / 4,
33505
- PI_1_2 = Math.PI / 2,
33506
- baseX = tickPosition.x;
33507
- let dx = 0;
33508
- dx = isInRange(angle, -PI_3_4, -PI_1_4) ? ((angle + PI_3_4) / PI_1_2 - .5) * width : isInRange(angle, PI_1_4, PI_3_4) ? (.5 - (angle - PI_1_4) / PI_1_2) * width : Math.cos(angle) >= 0 ? .5 * width : .5 * -width;
33509
- const x = baseX - dx,
33510
- baseY = tickPosition.y;
33511
- let dy = 0;
33512
- dy = isInRange(angle, -PI_3_4, -PI_1_4) ? .5 * -height : isInRange(angle, PI_1_4, PI_3_4) ? .5 * height : Math.cos(angle) >= 0 ? (.5 - (PI_1_4 - angle) / PI_1_2) * height : (.5 - clampRadian(angle - PI_3_4) / PI_1_2) * height;
33601
+ function getCircleLabelPosition(tickPosition, tickVector) {
33513
33602
  return {
33514
- x: x,
33515
- y: baseY - dy
33603
+ x: tickPosition.x + tickVector[0],
33604
+ y: tickPosition.y + tickVector[1]
33516
33605
  };
33517
33606
  }
33518
33607
  function getAxisBreakSymbolAttrs() {
@@ -33555,13 +33644,13 @@
33555
33644
  baseline: baseline
33556
33645
  };
33557
33646
  }
33558
- function getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside, text, style) {
33647
+ function getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside) {
33559
33648
  const point = polarToCartesian({
33560
33649
  x: 0,
33561
33650
  y: 0
33562
33651
  }, radius, angle),
33563
33652
  labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));
33564
- return getCircleLabelPosition(labelPoint, getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside), text, style);
33653
+ return getCircleLabelPosition(labelPoint, getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside));
33565
33654
  }
33566
33655
  function getCirclePoints(center, count, radius, startAngle, endAngle) {
33567
33656
  const points = [],
@@ -33753,10 +33842,6 @@
33753
33842
  getVerticalCoord(point, offset, inside) {
33754
33843
  return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));
33755
33844
  }
33756
- getTextAlign(vector) {
33757
- let align = "center";
33758
- return isNumberClose(vector[0], 0) ? isNumberClose(vector[1], 0) ? Object.is(vector[1], -0) ? align = "start" : Object.is(vector[0], -0) && (align = "end") : align = "center" : vector[0] > 0 ? align = "start" : vector[0] < 0 && (align = "end"), align;
33759
- }
33760
33845
  getTickLineItems() {
33761
33846
  const {
33762
33847
  tick: tick
@@ -33900,49 +33985,6 @@
33900
33985
  }
33901
33986
  }
33902
33987
 
33903
- function rotate(x, y, deg, originX, originY) {
33904
- return {
33905
- x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,
33906
- y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY
33907
- };
33908
- }
33909
- function genNormalBounds(item) {
33910
- const bounds = item.AABBBounds;
33911
- return {
33912
- x1: bounds.x1,
33913
- x2: bounds.x2,
33914
- y1: bounds.y1,
33915
- y2: bounds.y2,
33916
- centerX: item.attribute.x,
33917
- centerY: item.attribute.y,
33918
- angle: item.attribute.angle
33919
- };
33920
- }
33921
- function genRotateBounds(items) {
33922
- items.forEach(item => {
33923
- if (item.rotatedBounds || !item.attribute.angle) return;
33924
- const bounds = genNormalBounds(item),
33925
- rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y),
33926
- deltaX = rotatedCenter.x - bounds.centerX,
33927
- deltaY = rotatedCenter.y - bounds.centerY;
33928
- bounds.x1 += deltaX, bounds.x2 += deltaX, bounds.y1 += deltaY, bounds.y2 += deltaY, bounds.centerX += deltaX, bounds.centerY += deltaY, item.rotatedBounds = bounds;
33929
- });
33930
- }
33931
- function itemIntersect(item1, item2) {
33932
- return isRectIntersect(item1.AABBBounds, item2.AABBBounds, !1) && (!item1.rotatedBounds || !item2.rotatedBounds || isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, !0));
33933
- }
33934
- const DELTA_ANGLE = Math.sin(Math.PI / 10);
33935
- function isAngleVertical(angle) {
33936
- const hasAngle = !isNil$1(angle) && 0 !== angle,
33937
- cos = hasAngle ? Math.cos(angle) : 1;
33938
- return hasAngle && Math.abs(cos) <= DELTA_ANGLE;
33939
- }
33940
- function isAngleHorizontal(angle) {
33941
- const hasAngle = !isNil$1(angle) && 0 !== angle,
33942
- sin = hasAngle ? Math.sin(angle) : 0;
33943
- return !hasAngle || Math.abs(sin) <= DELTA_ANGLE;
33944
- }
33945
-
33946
33988
  const methods$2 = {
33947
33989
  parity: function (items) {
33948
33990
  return items.filter((item, i) => i % 2 ? item.setAttribute("opacity", 0) : 1);
@@ -33953,16 +33995,16 @@
33953
33995
  }
33954
33996
  };
33955
33997
  function intersect$1(textA, textB, sep) {
33956
- const a = textA.AABBBounds,
33957
- b = textB.AABBBounds;
33958
- return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2) && (!textA.rotatedBounds || !textB.rotatedBounds || sep > Math.max(textB.rotatedBounds.x1 - textA.rotatedBounds.x2, textA.rotatedBounds.x1 - textB.rotatedBounds.x2, textB.rotatedBounds.y1 - textA.rotatedBounds.y2, textA.rotatedBounds.y1 - textB.rotatedBounds.y2));
33998
+ let a = textA.OBBBounds,
33999
+ b = textB.OBBBounds;
34000
+ return a && b && !a.empty() && !b.empty() ? a.intersects(b) : (a = textA.AABBBounds, b = textB.AABBBounds, sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2));
33959
34001
  }
33960
34002
  function hasOverlap$2(items, pad) {
33961
34003
  for (let b, i = 1, n = items.length, a = items[0]; i < n; a = b, ++i) if (intersect$1(a, b = items[i], pad)) return !0;
33962
34004
  }
33963
34005
  function hasBounds(item) {
33964
- const b = item.AABBBounds;
33965
- return b.width() > 1 && b.height() > 1;
34006
+ let bounds;
34007
+ return bounds = item.OBBBounds.empty() ? item.AABBBounds : item.OBBBounds, bounds.width() > 1 && bounds.height() > 1;
33966
34008
  }
33967
34009
  function reset$1(items) {
33968
34010
  return items.forEach(item => item.setAttribute("opacity", 1)), items;
@@ -33972,7 +34014,7 @@
33972
34014
  const source = labels.filter(hasBounds);
33973
34015
  if (isEmpty(source)) return;
33974
34016
  let items;
33975
- items = reset$1(source), genRotateBounds(items);
34017
+ items = reset$1(source);
33976
34018
  const {
33977
34019
  method = "parity",
33978
34020
  separation: sep = 0
@@ -33998,6 +34040,50 @@
33998
34040
  });
33999
34041
  }
34000
34042
 
34043
+ function genNormalBounds(item) {
34044
+ const bounds = item.AABBBounds;
34045
+ return {
34046
+ x1: bounds.x1,
34047
+ x2: bounds.x2,
34048
+ y1: bounds.y1,
34049
+ y2: bounds.y2,
34050
+ centerX: item.attribute.x,
34051
+ centerY: item.attribute.y,
34052
+ angle: item.attribute.angle
34053
+ };
34054
+ }
34055
+ function genRotateBounds(items) {
34056
+ items.forEach(item => {
34057
+ if (item.rotatedBounds || !item.attribute.angle) return;
34058
+ const bounds = genNormalBounds(item),
34059
+ rotatedCenter = rotatePoint({
34060
+ x: item.attribute.x,
34061
+ y: item.attribute.y
34062
+ }, bounds.angle, {
34063
+ x: bounds.centerX,
34064
+ y: bounds.centerY
34065
+ }),
34066
+ deltaX = rotatedCenter.x - bounds.centerX,
34067
+ deltaY = rotatedCenter.y - bounds.centerY;
34068
+ bounds.x1 += deltaX, bounds.x2 += deltaX, bounds.y1 += deltaY, bounds.y2 += deltaY, bounds.centerX += deltaX, bounds.centerY += deltaY, item.rotatedBounds = bounds;
34069
+ });
34070
+ }
34071
+ function itemIntersect(item1, item2) {
34072
+ var _a, _b;
34073
+ return (null === (_a = item1.OBBBounds) || void 0 === _a ? void 0 : _a.empty()) || (null === (_b = item2.OBBBounds) || void 0 === _b ? void 0 : _b.empty()) ? isRectIntersect(item1.AABBBounds, item2.AABBBounds, !1) && (!item1.rotatedBounds || !item2.rotatedBounds || isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, !0)) : item1.OBBBounds.intersects(item2.OBBBounds);
34074
+ }
34075
+ const DELTA_ANGLE = Math.sin(Math.PI / 10);
34076
+ function isAngleVertical(angle) {
34077
+ const hasAngle = !isNil$1(angle) && 0 !== angle,
34078
+ cos = hasAngle ? Math.cos(angle) : 1;
34079
+ return hasAngle && Math.abs(cos) <= DELTA_ANGLE;
34080
+ }
34081
+ function isAngleHorizontal(angle) {
34082
+ const hasAngle = !isNil$1(angle) && 0 !== angle,
34083
+ sin = hasAngle ? Math.sin(angle) : 0;
34084
+ return !hasAngle || Math.abs(sin) <= DELTA_ANGLE;
34085
+ }
34086
+
34001
34087
  function autoRotate(items, rotateConfig) {
34002
34088
  if (isEmpty(items)) return;
34003
34089
  const {
@@ -34360,6 +34446,10 @@
34360
34446
  const axisLineGroup = new Segment(lineAttrs);
34361
34447
  axisLineGroup.name = AXIS_ELEMENT_NAME.line, axisLineGroup.id = this._getNodeId("line"), container.add(axisLineGroup);
34362
34448
  }
34449
+ getTextAlign(vector) {
34450
+ let align = "center";
34451
+ return isNumberClose(vector[0], 0) ? isNumberClose(vector[1], 0) ? Object.is(vector[1], -0) ? align = "start" : Object.is(vector[0], -0) && (align = "end") : align = "center" : vector[0] > 0 ? align = "start" : vector[0] < 0 && (align = "end"), align;
34452
+ }
34363
34453
  getTitleAttribute() {
34364
34454
  var _a, _b, _c;
34365
34455
  const _d = this.attribute.title,
@@ -34684,6 +34774,70 @@
34684
34774
  }
34685
34775
  }
34686
34776
 
34777
+ function findSiblingLabels(labels, selfIndex) {
34778
+ const len = labels.length;
34779
+ return {
34780
+ prevLabel: selfIndex >= 1 ? labels[selfIndex - 1] : labels[len - 1],
34781
+ nextLabel: selfIndex < len - 1 ? labels[selfIndex + 1] : labels[0]
34782
+ };
34783
+ }
34784
+ function adjustMaxLineWidth(label, maxLineWidth, ellipsis) {
34785
+ var _a;
34786
+ label.setAttributes({
34787
+ maxLineWidth: maxLineWidth,
34788
+ ellipsis: null !== (_a = label.attribute.ellipsis) && void 0 !== _a ? _a : ellipsis
34789
+ });
34790
+ }
34791
+ function adjustMaxHeight(labels, selfIndex, bounds) {
34792
+ const siblings = [];
34793
+ if (labels.length >= 3) {
34794
+ const {
34795
+ prevLabel: prevLabel,
34796
+ nextLabel: nextLabel
34797
+ } = findSiblingLabels(labels, selfIndex);
34798
+ siblings.push(prevLabel, nextLabel);
34799
+ } else 2 === labels.length && siblings.push(labels[0 === selfIndex ? 1 : 0]);
34800
+ const label = labels[selfIndex];
34801
+ let heightLimit = Math.min(Math.abs(label.attribute.y - bounds.y1), Math.abs(label.attribute.y - bounds.y2));
34802
+ siblings.forEach(sibling => {
34803
+ heightLimit = Math.min(heightLimit, Math.abs(sibling.attribute.y - label.attribute.y));
34804
+ }), heightLimit > 0 && label.setAttributes({
34805
+ whiteSpace: "normal",
34806
+ heightLimit: heightLimit
34807
+ });
34808
+ }
34809
+ function circleAutoLimit(labels, config) {
34810
+ const {
34811
+ ellipsis: ellipsis,
34812
+ inside: inside,
34813
+ bounds: bounds,
34814
+ autoWrap: autoWrap,
34815
+ center: center
34816
+ } = config;
34817
+ inside || labels.forEach((label, index) => {
34818
+ const {
34819
+ x: x,
34820
+ y: y
34821
+ } = label.attribute,
34822
+ b = label.AABBBounds;
34823
+ if (isNumberClose(x, center.x)) {
34824
+ if (y > bounds.y2 || y < bounds.y1) return void adjustMaxLineWidth(label, 0, ellipsis);
34825
+ const boxWidth = bounds.x2 - bounds.x1;
34826
+ if (labels.length >= 3) {
34827
+ const {
34828
+ prevLabel: prevLabel,
34829
+ nextLabel: nextLabel
34830
+ } = findSiblingLabels(labels, index);
34831
+ let leftX = prevLabel.attribute.x,
34832
+ rightX = nextLabel.attribute.x;
34833
+ leftX > rightX && (leftX = nextLabel.attribute.x, rightX = prevLabel.attribute.x);
34834
+ const maxWidth = leftX === rightX ? boxWidth : x >= leftX && x <= rightX ? rightX - leftX : Math.min(Math.abs(leftX - x), Math.abs(rightX - x));
34835
+ label.AABBBounds.width() > maxWidth && adjustMaxLineWidth(label, maxWidth, ellipsis);
34836
+ } else label.AABBBounds.width() > boxWidth && adjustMaxLineWidth(label, boxWidth, ellipsis);
34837
+ } else x > center.x && b.x2 > bounds.x2 ? (adjustMaxLineWidth(label, bounds.x2 - x, ellipsis), autoWrap && adjustMaxHeight(labels, index, bounds)) : x < center.x && b.x1 < bounds.x1 && (adjustMaxLineWidth(label, x - bounds.x1, ellipsis), autoWrap && adjustMaxHeight(labels, index, bounds));
34838
+ });
34839
+ }
34840
+
34687
34841
  var __rest$4 = undefined && undefined.__rest || function (s, e) {
34688
34842
  var t = {};
34689
34843
  for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
@@ -34815,21 +34969,71 @@
34815
34969
  }
34816
34970
  return subTickLineItems;
34817
34971
  }
34818
- getTextBaseline(vector) {
34819
- let base = "middle";
34820
- return isNumberClose(vector[1], 0) ? base = "middle" : vector[1] > 0 && vector[1] > Math.abs(vector[0]) ? base = "top" : vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0]) && (base = "bottom"), base;
34821
- }
34822
34972
  beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
34823
- handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
34973
+ handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
34974
+ if (isEmpty(labelShapes)) return;
34975
+ const {
34976
+ inside: inside,
34977
+ radius: radius,
34978
+ center: center,
34979
+ width: width,
34980
+ height: height,
34981
+ label: label,
34982
+ orient: orient
34983
+ } = this.attribute,
34984
+ bounds = width && height ? {
34985
+ x1: 0,
34986
+ y1: 0,
34987
+ x2: width,
34988
+ y2: height
34989
+ } : {
34990
+ x1: center.x - radius,
34991
+ y1: center.y - radius,
34992
+ x2: center.x + radius,
34993
+ y2: center.y + radius
34994
+ },
34995
+ {
34996
+ layoutFunc: layoutFunc,
34997
+ autoLimit: autoLimit,
34998
+ limitEllipsis: limitEllipsis,
34999
+ autoHide: autoHide$1,
35000
+ autoHideMethod: autoHideMethod,
35001
+ autoHideSeparation: autoHideSeparation,
35002
+ autoWrap: autoWrap
35003
+ } = label;
35004
+ isFunction$1(layoutFunc) ? layoutFunc(labelShapes, labelData, layer, this) : ((autoLimit || autoWrap) && circleAutoLimit(labelShapes, {
35005
+ inside: inside,
35006
+ autoWrap: autoWrap,
35007
+ bounds: bounds,
35008
+ ellipsis: limitEllipsis,
35009
+ center: center
35010
+ }), autoHide$1 && autoHide(labelShapes, {
35011
+ orient: orient,
35012
+ method: autoHideMethod,
35013
+ separation: autoHideSeparation
35014
+ }));
35015
+ }
34824
35016
  afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
35017
+ getTextBaseline(vector) {
35018
+ return Math.abs(vector[1] / vector[0]) < .3 ? "middle" : vector[1] < 0 ? "bottom" : vector[1] > 0 ? "top" : "middle";
35019
+ }
34825
35020
  getLabelAlign(vector, inside, angle) {
34826
- return {
35021
+ return isNumberClose(vector[0], 0) ? {
35022
+ textAlign: "center",
35023
+ textBaseline: vector[1] > 0 ? "top" : "bottom"
35024
+ } : vector[0] < 0 ? {
35025
+ textAlign: "right",
35026
+ textBaseline: this.getTextBaseline(vector)
35027
+ } : vector[0] > 0 ? {
35028
+ textAlign: "left",
35029
+ textBaseline: this.getTextBaseline(vector)
35030
+ } : {
34827
35031
  textAlign: "center",
34828
35032
  textBaseline: "middle"
34829
35033
  };
34830
35034
  }
34831
35035
  getLabelPosition(point, vector, text, style) {
34832
- return getCircleLabelPosition(point, vector, text, style);
35036
+ return point;
34833
35037
  }
34834
35038
  }
34835
35039
  CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME, mixin(CircleAxis, CircleAxisMixin);
@@ -36173,32 +36377,33 @@
36173
36377
  } = op,
36174
36378
  radius = null == getRadius ? void 0 : getRadius(),
36175
36379
  labelAngle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0,
36176
- textMeasure = initTextMeasure$1(labelStyle),
36177
- labelBoundsList = domain.map(v => {
36178
- var _a, _b;
36179
- const str = labelFormatter ? labelFormatter(v) : `${v}`,
36180
- {
36181
- width: width,
36182
- height: height
36183
- } = textMeasure.quickMeasure(str),
36184
- textWidth = Math.max(width, MIN_TICK_GAP),
36185
- textHeight = Math.max(height, MIN_TICK_GAP),
36186
- angle = scale.scale(v);
36187
- let textX = 0,
36188
- textY = 0;
36189
- const orient_align = null !== (_a = labelStyle.textAlign) && void 0 !== _a ? _a : "center",
36190
- orient_baseline = null !== (_b = labelStyle.textBaseline) && void 0 !== _b ? _b : "middle",
36191
- {
36192
- x: x,
36193
- y: y
36194
- } = getPolarAngleLabelPosition(angle, {
36195
- x: 0,
36196
- y: 0
36197
- }, radius, labelOffset, inside, str, labelStyle);
36198
- textX = x + ("right" === orient_align ? -textWidth : "center" === orient_align ? -textWidth / 2 : 0), textY = y + ("bottom" === orient_baseline ? -textHeight : "middle" === orient_baseline ? -textHeight / 2 : 0);
36199
- return new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight).rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);
36200
- });
36201
- return labelBoundsList;
36380
+ textMeasure = initTextMeasure$1(labelStyle);
36381
+ return domain.map(v => {
36382
+ const str = labelFormatter ? labelFormatter(v) : `${v}`,
36383
+ {
36384
+ width: width,
36385
+ height: height
36386
+ } = textMeasure.quickMeasure(str),
36387
+ textWidth = Math.max(width, MIN_TICK_GAP),
36388
+ textHeight = Math.max(height, MIN_TICK_GAP),
36389
+ angle = scale.scale(v),
36390
+ center = {
36391
+ x: 0,
36392
+ y: 0
36393
+ };
36394
+ let textX = 0,
36395
+ textY = 0;
36396
+ const orient = {
36397
+ align: labelStyle.textAlign,
36398
+ baseline: labelStyle.textBaseline
36399
+ },
36400
+ {
36401
+ x: x,
36402
+ y: y
36403
+ } = getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside);
36404
+ orient.align || (isNumberClose(x, center.x) ? orient.baseline || (orient.baseline = y > center.y ? "top" : "bottom") : x > center.x ? orient.align = "left" : x < center.x && (orient.align = "right")), textX = x + ("right" === orient.align ? -textWidth : "left" === orient.align ? 0 : -textWidth / 2), textY = y + ("bottom" === orient.baseline ? -textHeight : "top" === orient.baseline ? 0 : -textHeight / 2);
36405
+ return new AABBBounds().set(textX, textY, textX + textWidth, textY + textHeight).rotate(labelAngle, textX + textWidth / 2, textY + textHeight / 2);
36406
+ });
36202
36407
  };
36203
36408
  const polarAngleAxisDiscreteTicks = (scale, op) => {
36204
36409
  const {
@@ -36389,10 +36594,19 @@
36389
36594
  shape.name = `${name}-line`, shape.id = this._getNodeId(`${name}-path-${id}`), container.add(shape);
36390
36595
  }), items.length > 1 && alternateColor) {
36391
36596
  const colors = isArray$1(alternateColor) ? alternateColor : [alternateColor, "transparent"],
36392
- getColor = index => colors[index % colors.length];
36393
- for (let index = 0; index < items.length - 1; index++) {
36394
- const [prev, curr] = [items[index].points, items[index + 1].points],
36395
- path = getRegionPath(prev, curr, gridAttrs),
36597
+ getColor = index => colors[index % colors.length],
36598
+ originalItems = this.attribute.items,
36599
+ firstItem = originalItems[0],
36600
+ lastItem = originalItems[originalItems.length - 1],
36601
+ noZero = !isNumberClose(firstItem.value, 0) && !isNumberClose(lastItem.value, 0),
36602
+ noOne = !isNumberClose(firstItem.value, 1) && !isNumberClose(lastItem.value, 1),
36603
+ allPoints = [],
36604
+ isDesc = firstItem.value > lastItem.value;
36605
+ (isDesc && noOne || !isDesc && noZero) && allPoints.push(this.getGridPointsByValue(isDesc ? 1 : 0)), items.forEach(item => {
36606
+ allPoints.push(item.points);
36607
+ }), (isDesc && noZero || !isDesc && noOne) && allPoints.push(this.getGridPointsByValue(isDesc ? 0 : 1));
36608
+ for (let index = 0; index < allPoints.length - 1; index++) {
36609
+ const path = getRegionPath(allPoints[index], allPoints[index + 1], gridAttrs),
36396
36610
  shape = graphicCreator.path({
36397
36611
  path: path,
36398
36612
  fill: getColor(index)
@@ -36469,6 +36683,10 @@
36469
36683
  }
36470
36684
  return gridPoints;
36471
36685
  }
36686
+ getGridPointsByValue(value) {
36687
+ const basePoint = this.getTickCoord(value);
36688
+ return this._getGridPoint(this.attribute.type, basePoint);
36689
+ }
36472
36690
  getGridAttribute(isSubGrid) {
36473
36691
  const {
36474
36692
  type: gridType,
@@ -36482,7 +36700,7 @@
36482
36700
  const subGridItems = [],
36483
36701
  {
36484
36702
  count: subCount = 4
36485
- } = this.attribute.subGrid || {};
36703
+ } = gridAttribute;
36486
36704
  if (this.data.length >= 2) {
36487
36705
  const points = this._getPointsOfSubGrid(tickSegment, alignWithLabel);
36488
36706
  for (let i = 0; i < points.length - 1; i++) {
@@ -36490,22 +36708,21 @@
36490
36708
  next = points[i + 1];
36491
36709
  subGridItems.push({
36492
36710
  id: `sub-${i}-0`,
36493
- points: this._getGridPoint(gridType, this.getTickCoord(pre.value)),
36711
+ points: this.getGridPointsByValue(pre.value),
36494
36712
  datum: {}
36495
36713
  });
36496
36714
  for (let j = 0; j < subCount; j++) {
36497
36715
  const percent = (j + 1) / (subCount + 1),
36498
- value = (1 - percent) * pre.value + percent * next.value,
36499
- point = this.getTickCoord(value);
36716
+ value = (1 - percent) * pre.value + percent * next.value;
36500
36717
  subGridItems.push({
36501
36718
  id: `sub-${i}-${j + 1}`,
36502
- points: this._getGridPoint(gridType, point),
36719
+ points: this.getGridPointsByValue(value),
36503
36720
  datum: {}
36504
36721
  });
36505
36722
  }
36506
36723
  i === points.length - 2 && subGridItems.push({
36507
36724
  id: `sub-${i}-${subCount + 1}`,
36508
- points: this._getGridPoint(gridType, this.getTickCoord(next.value)),
36725
+ points: this.getGridPointsByValue(next.value),
36509
36726
  datum: {}
36510
36727
  });
36511
36728
  }
@@ -36551,6 +36768,14 @@
36551
36768
  constructor(attributes, options) {
36552
36769
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge$2({}, BaseGrid.defaultAttributes, attributes), options);
36553
36770
  }
36771
+ getGridPointsByValue(value) {
36772
+ const basePoint = this.getTickCoord(value),
36773
+ {
36774
+ radius: radius,
36775
+ innerRadius = 0
36776
+ } = this.attribute;
36777
+ return [basePoint, this.getVerticalCoord(basePoint, radius - innerRadius, !0)];
36778
+ }
36554
36779
  getGridAttribute(isSubGrid) {
36555
36780
  let gridAttribute,
36556
36781
  items = [];
@@ -36958,6 +37183,7 @@
36958
37183
  return !1;
36959
37184
  }
36960
37185
  setTextAttr(startTextBounds, endTextBounds) {
37186
+ var _a, _b, _c, _d, _e, _f, _g, _h;
36961
37187
  const {
36962
37188
  startTextStyle: startTextStyle,
36963
37189
  endTextStyle: endTextStyle
@@ -36997,10 +37223,10 @@
36997
37223
  y: position.y + height / 2
36998
37224
  }, startTextAlignStyle = {
36999
37225
  textAlign: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "left" : "right",
37000
- textBaseline: "middle"
37226
+ textBaseline: null !== (_b = null === (_a = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _a ? void 0 : _a.textBaseline) && void 0 !== _b ? _b : "middle"
37001
37227
  }, endTextAlignStyle = {
37002
37228
  textAlign: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "right" : "left",
37003
- textBaseline: "middle"
37229
+ textBaseline: null !== (_d = null === (_c = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _c ? void 0 : _c.textBaseline) && void 0 !== _d ? _d : "middle"
37004
37230
  }) : (startTextPosition = {
37005
37231
  x: position.x + width / 2,
37006
37232
  y: position.y + start * height
@@ -37008,10 +37234,10 @@
37008
37234
  x: position.x + width / 2,
37009
37235
  y: position.y + end * height
37010
37236
  }, startTextAlignStyle = {
37011
- textAlign: "center",
37237
+ textAlign: null !== (_f = null === (_e = null == restStartTextStyle ? void 0 : restStartTextStyle.textStyle) || void 0 === _e ? void 0 : _e.textAlign) && void 0 !== _f ? _f : "center",
37012
37238
  textBaseline: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "top" : "bottom"
37013
37239
  }, endTextAlignStyle = {
37014
- textAlign: "center",
37240
+ textAlign: null !== (_h = null === (_g = null == restEndTextStyle ? void 0 : restEndTextStyle.textStyle) || void 0 === _g ? void 0 : _g.textAlign) && void 0 !== _h ? _h : "center",
37015
37241
  textBaseline: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "bottom" : "top"
37016
37242
  }), this._startText = this.maybeAddLabel(this._container, merge$2({}, restStartTextStyle, {
37017
37243
  text: startTextValue,
@@ -39732,11 +39958,11 @@
39732
39958
  focusShape = graphicCreator.symbol(Object.assign(Object.assign({
39733
39959
  x: 0,
39734
39960
  y: -focusSize / 2 - 1,
39735
- strokeBoundsBuffer: 0
39961
+ strokeBoundsBuffer: 0,
39962
+ boundsPadding: parsedPadding
39736
39963
  }, focusIconStyle), {
39737
39964
  visible: !0,
39738
- pickMode: "imprecise",
39739
- boundsPadding: parsedPadding
39965
+ pickMode: "imprecise"
39740
39966
  })), this._appendDataToShape(focusShape, LEGEND_ELEMENT_NAME.focus, item, itemGroup), focusSpace = focusSize;
39741
39967
  }
39742
39968
  const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label,
@@ -39891,6 +40117,20 @@
39891
40117
  let newPage = value[0] * this._itemContext.totalPage;
39892
40118
  return pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1, newPage;
39893
40119
  } : e => e.detail.current,
40120
+ onScroll = e => {
40121
+ e.preventDefault();
40122
+ const scrollComponent = this._pagerComponent,
40123
+ preScrollRange = scrollComponent.getScrollRange(),
40124
+ {
40125
+ direction: direction
40126
+ } = scrollComponent.attribute,
40127
+ {
40128
+ width: width,
40129
+ height: height
40130
+ } = scrollComponent.getSliderRenderBounds(),
40131
+ currentScrollValue = "vertical" === direction ? e.deltaY / height : e.deltaX / width;
40132
+ scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], !0);
40133
+ },
39894
40134
  onPaging = e => {
39895
40135
  const newPage = pageParser(e);
39896
40136
  if (newPage !== this._itemContext.currentPage) {
@@ -39904,7 +40144,12 @@
39904
40144
  }, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
39905
40145
  }
39906
40146
  };
39907
- this._itemContext.isScrollbar ? (this._pagerComponent.addEventListener("scrollDrag", onPaging), this._pagerComponent.addEventListener("scrollUp", onPaging)) : (this._pagerComponent.addEventListener("toPrev", onPaging), this._pagerComponent.addEventListener("toNext", onPaging));
40147
+ if (this._itemContext.isScrollbar) {
40148
+ if (this._pagerComponent.addEventListener("scrollDrag", onPaging), this._pagerComponent.addEventListener("scrollUp", onPaging), this.attribute.pager.roamScroll) {
40149
+ const THROTTLE_TIME = 50;
40150
+ this.addEventListener("wheel", throttle(onScroll, THROTTLE_TIME));
40151
+ }
40152
+ } else this._pagerComponent.addEventListener("toPrev", onPaging), this._pagerComponent.addEventListener("toNext", onPaging);
39908
40153
  }
39909
40154
  _renderPager() {
39910
40155
  const renderStartY = this._title ? this._title.AABBBounds.height() + get$1(this.attribute, "title.space", 8) : 0,
@@ -43515,7 +43760,8 @@
43515
43760
  discreteLegendPagerTextColor: 'rgb(51, 51, 51)',
43516
43761
  discreteLegendPagerHandlerColor: 'rgb(47, 69, 84)',
43517
43762
  discreteLegendPagerHandlerDisableColor: 'rgb(170, 170, 170)',
43518
- emptyCircleColor: '#e3e5e8'
43763
+ emptyCircleColor: '#e3e5e8',
43764
+ linearProgressTrackColor: '#E7EBED'
43519
43765
  }
43520
43766
  }
43521
43767
  };
@@ -43726,7 +43972,7 @@
43726
43972
  },
43727
43973
  track: {
43728
43974
  style: {
43729
- fill: '#E7EBED',
43975
+ fill: { type: 'palette', key: 'linearProgressTrackColor' },
43730
43976
  fillOpacity: 1
43731
43977
  }
43732
43978
  }
@@ -45235,7 +45481,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
45235
45481
  discreteLegendPagerTextColor: '#BBBDC3',
45236
45482
  discreteLegendPagerHandlerColor: '#BBBDC3',
45237
45483
  discreteLegendPagerHandlerDisableColor: '#55595F',
45238
- emptyCircleColor: '#bbbdc3'
45484
+ emptyCircleColor: '#bbbdc3',
45485
+ linearProgressTrackColor: '#404349'
45239
45486
  }
45240
45487
  }
45241
45488
  };
@@ -48432,12 +48679,22 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48432
48679
  const NAME_PREFIX = "@";
48433
48680
  const ID_PREFIX = "#";
48434
48681
 
48435
- function getExtendedEvents(view, event, item, type, source) {
48682
+ function getExtendedEvents(view, event, type, source) {
48683
+ var _a, _b;
48436
48684
  if (source === EVENT_SOURCE_WINDOW) {
48437
48685
  const e = event.changedTouches ? event.changedTouches[0] : event;
48438
48686
  point(e);
48439
48687
  }
48440
- return event.element = item, event;
48688
+ let element = null === (_a = event.target) || void 0 === _a ? void 0 : _a[BridgeElementKey];
48689
+ if (!element && source === EVENT_SOURCE_VIEW) {
48690
+ let target = event.target;
48691
+ const rootGraphic = null === (_b = view.rootMark) || void 0 === _b ? void 0 : _b.graphicItem;
48692
+ for (; (null == target ? void 0 : target.parent) && target.parent !== rootGraphic;) if (target = target.parent, target[BridgeElementKey]) {
48693
+ element = target[BridgeElementKey];
48694
+ break;
48695
+ }
48696
+ }
48697
+ return event.element = element, event;
48441
48698
  }
48442
48699
 
48443
48700
  class Signal extends GrammarBase {
@@ -48723,19 +48980,27 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48723
48980
  }), this.differ.updateToCurrent(), this.needClear = !1);
48724
48981
  }
48725
48982
  evaluateMainTasks(data, parameters) {
48726
- var _a;
48983
+ var _a, _b;
48727
48984
  if (this.needSkipBeforeLayout() && this.view.getLayoutState() === LayoutState.before) return this;
48728
48985
  const stage = null === (_a = this.view.renderer) || void 0 === _a ? void 0 : _a.stage();
48729
48986
  this.init(stage, parameters);
48730
- const transformData = this.evaluateTransform(this._getTransformsBeforeJoin(), null != data ? data : DefaultMarkData, parameters);
48731
- let inputData = (null == transformData ? void 0 : transformData.progressive) ? data : transformData;
48732
- return this.evaluateGroup(inputData), this.renderContext = this.parseRenderContext(inputData, parameters), this.renderContext.progressive ? (this.differ.reset(), this.elementMap.clear(), this.evaluateProgressive()) : ((null == transformData ? void 0 : transformData.progressive) && (this.renderContext.parameters = parameters, this.renderContext.beforeTransformProgressive = transformData.progressive, inputData = transformData.progressive.output()), this.emit(HOOK_EVENT.BEFORE_MARK_JOIN), this.evaluateJoin(inputData), this.emit(HOOK_EVENT.AFTER_MARK_JOIN), this.emit(HOOK_EVENT.BEFORE_MARK_STATE), this.evaluateState(this.elements, this.spec.state, parameters), this.emit(HOOK_EVENT.AFTER_MARK_STATE), this.emit(HOOK_EVENT.BEFORE_MARK_ENCODE), this.evaluateEncode(this.elements, this._getEncoders(), parameters), this.emit(HOOK_EVENT.AFTER_MARK_ENCODE)), this.emit(HOOK_EVENT.BEFORE_MARK_UPDATE), this.update(this.spec), this.emit(HOOK_EVENT.AFTER_MARK_UPDATE), this;
48987
+ const transformData = this.evaluateTransform(this._getTransformsBeforeJoin(), null != data ? data : DefaultMarkData, parameters),
48988
+ progressiveTransform = null == transformData ? void 0 : transformData.progressive;
48989
+ if (progressiveTransform ? this.renderContext = {
48990
+ large: !1
48991
+ } : (this.evaluateGroup(transformData), this.renderContext = this.parseRenderContext(transformData, parameters)), null === (_b = this.renderContext) || void 0 === _b ? void 0 : _b.progressive) this.differ.reset(), this.elementMap.clear(), this.evaluateProgressive();else {
48992
+ let inputData = null;
48993
+ if (progressiveTransform) {
48994
+ if (this.renderContext.parameters = parameters, this.renderContext.beforeTransformProgressive = transformData.progressive, inputData = transformData.progressive.output(), transformData.progressive.canAnimate && transformData.progressive.unfinished()) return this.update(this.spec), this;
48995
+ } else inputData = transformData;
48996
+ this.emit(HOOK_EVENT.BEFORE_MARK_JOIN), this.evaluateJoin(inputData), this.emit(HOOK_EVENT.AFTER_MARK_JOIN), this.emit(HOOK_EVENT.BEFORE_MARK_STATE), this.evaluateState(this.elements, this.spec.state, parameters), this.emit(HOOK_EVENT.AFTER_MARK_STATE), this.emit(HOOK_EVENT.BEFORE_MARK_ENCODE), this.evaluateEncode(this.elements, this._getEncoders(), parameters), this.emit(HOOK_EVENT.AFTER_MARK_ENCODE);
48997
+ }
48998
+ return this.update(this.spec), this;
48733
48999
  }
48734
49000
  evaluateGroup(data) {
48735
49001
  if (this.markType === GrammarMarkType.group) return;
48736
- const res = groupData(null != data ? data : DefaultMarkData, this.spec.groupBy, this.spec.groupSort),
48737
- groupKeys = res.keys;
48738
- this._groupKeys = groupKeys, this._groupEncodeResult = null, this.differ.setCurrentData(res);
49002
+ const res = groupData(null != data ? data : DefaultMarkData, this.spec.groupBy, this.spec.groupSort);
49003
+ this._groupEncodeResult = null, this._groupedData = res;
48739
49004
  }
48740
49005
  _getTransformsAfterEncodeItems() {
48741
49006
  return this.transforms && this.transforms.filter(entry => "afterEncodeItems" === entry.markPhase);
@@ -48861,12 +49126,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48861
49126
  init(stage, parameters) {
48862
49127
  var _b, _c, _d, _e, _f;
48863
49128
  if (this._delegateEvent || (this._delegateEvent = (event, type) => {
48864
- var _a;
48865
- const activeElement = null === (_a = event.target) || void 0 === _a ? void 0 : _a[BridgeElementKey];
48866
- if ((null == activeElement ? void 0 : activeElement.mark) === this) {
48867
- const extendedEvt = getExtendedEvents(this.view, event, activeElement, type, EVENT_SOURCE_VIEW);
48868
- this.emitGrammarEvent(type, extendedEvt, activeElement);
48869
- }
49129
+ const extendedEvt = getExtendedEvents(this.view, event, type, EVENT_SOURCE_VIEW),
49130
+ activeElement = event.element;
49131
+ (null == activeElement ? void 0 : activeElement.mark) === this && this.emitGrammarEvent(type, extendedEvt, activeElement);
48870
49132
  }, this.initEvent()), null === (_b = this.initAnimate) || void 0 === _b || _b.call(this, this.spec), !this.group) {
48871
49133
  const group = getGrammarOutput(this.spec.group, parameters);
48872
49134
  this.group = group, group && group.appendChild(this);
@@ -48887,7 +49149,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48887
49149
  }
48888
49150
  update(spec) {
48889
49151
  var _b;
48890
- if (this._context = this.spec.context, this.isUpdated = !0, this.renderContext.progressive || null === (_b = this.updateAnimate) || void 0 === _b || _b.call(this, spec), this.markType !== GrammarMarkType.group) {
49152
+ if (this.emit(HOOK_EVENT.BEFORE_MARK_UPDATE), this._context = this.spec.context, this.isUpdated = !0, this.renderContext.progressive || null === (_b = this.updateAnimate) || void 0 === _b || _b.call(this, spec), this.markType !== GrammarMarkType.group) {
48891
49153
  if (isNil$1(spec.zIndex) || this.graphicItem.setAttribute("zIndex", spec.zIndex), isNil$1(spec.clip) || this.graphicItem.setAttribute("clip", spec.clip), !isNil$1(spec.clipPath)) {
48892
49154
  const paths = isArray$1(spec.clipPath) ? spec.clipPath : spec.clipPath(this.elements);
48893
49155
  paths && paths.length ? this.graphicItem.setAttribute("path", paths) : this.graphicItem.setAttributes({
@@ -48901,6 +49163,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48901
49163
  } else this.elementMap.forEach(element => {
48902
49164
  element.updateGraphicItem();
48903
49165
  });
49166
+ this.emit(HOOK_EVENT.AFTER_MARK_UPDATE);
48904
49167
  }
48905
49168
  createElement() {
48906
49169
  return new Element$1(this);
@@ -48935,7 +49198,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48935
49198
  enterElements.delete(element);
48936
49199
  });
48937
49200
  const currentData = null != data ? data : DefaultMarkData;
48938
- isCollectionMark || this.differ.setCurrentData(groupData(currentData, datum => `${groupKeyGetter(datum)}-${keyGetter(datum)}`, void 0)), this.differ.doDiff(), enterElements.forEach(element => {
49201
+ isCollectionMark ? this.differ.setCurrentData(this._groupedData) : this.differ.setCurrentData(groupData(currentData, datum => `${groupKeyGetter(datum)}-${keyGetter(datum)}`, void 0)), this.differ.doDiff(), enterElements.forEach(element => {
48939
49202
  this.elementMap.delete(isCollectionMark ? element.groupKey : `${element.groupKey}-${element.key}`), element.remove(), element.release();
48940
49203
  }), this.elements = elements, sort && this.elements.length >= 2 && this.elements.sort((elementA, elementB) => sort(elementA.getDatum(), elementB.getDatum()));
48941
49204
  }
@@ -48945,9 +49208,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48945
49208
  });
48946
49209
  }
48947
49210
  evaluateGroupEncode(elements, groupEncode, parameters) {
48948
- if (!this._groupKeys || !groupEncode) return;
49211
+ if (!this._groupedData || !groupEncode) return;
48949
49212
  const res = {};
48950
- return this._groupKeys.forEach(key => {
49213
+ return this._groupedData.keys.forEach(key => {
48951
49214
  const el = elements.find(el => el.groupKey === key);
48952
49215
  el && (res[key] = invokeEncoder(groupEncode, el.items && el.items[0] && el.items[0].datum, el, parameters));
48953
49216
  }), this._groupEncodeResult = res, res;
@@ -48992,8 +49255,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
48992
49255
  if (graphicItem) {
48993
49256
  if (null === (_a = this.renderContext) || void 0 === _a ? void 0 : _a.progressive) {
48994
49257
  let group;
48995
- if (this._groupKeys) {
48996
- const index = this._groupKeys.indexOf(groupKey);
49258
+ if (this._groupedData) {
49259
+ const index = this._groupedData.keys.indexOf(groupKey);
48997
49260
  index >= 0 && (group = this.graphicParent.getChildAt(index));
48998
49261
  } else group = this.graphicParent.at(0);
48999
49262
  this.isCollectionMark() ? (graphicItem.incremental = 1, group.appendChild(graphicItem)) : group.incrementalAppendChild(graphicItem);
@@ -49005,7 +49268,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49005
49268
  const enableProgressive = this.markType !== GrammarMarkType.group && this.spec.progressiveStep > 0 && this.spec.progressiveThreshold > 0 && this.spec.progressiveStep < this.spec.progressiveThreshold,
49006
49269
  large = this.spec.large && this.spec.largeThreshold > 0 && data.length >= this.spec.largeThreshold;
49007
49270
  if (enableProgressive) {
49008
- const groupedData = this.differ.getCurrentData();
49271
+ const groupedData = this._groupedData;
49009
49272
  return groupedData && groupedData.keys && groupedData.keys.some(key => groupedData.data.get(key).length > this.spec.progressiveThreshold) ? {
49010
49273
  large: large,
49011
49274
  parameters: parameters,
@@ -49046,7 +49309,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49046
49309
  const currentIndex = this.renderContext.progressive.currentIndex,
49047
49310
  keyGetter = parseField(null !== (_c = null !== (_a = this.spec.key) && void 0 !== _a ? _a : null === (_b = this.grammarSource) || void 0 === _b ? void 0 : _b.getDataIDKey()) && void 0 !== _c ? _c : () => DefaultKey),
49048
49311
  elements = [];
49049
- if (this.isCollectionMark()) return this._groupKeys.forEach((key, index) => {
49312
+ if (this.isCollectionMark()) return this._groupedData.keys.forEach((key, index) => {
49050
49313
  const data = this.renderContext.progressive.groupedData.get(key),
49051
49314
  groupStep = this.renderContext.progressive.step,
49052
49315
  dataSlice = data.slice(currentIndex * groupStep, (currentIndex + 1) * groupStep);
@@ -49059,7 +49322,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49059
49322
  }
49060
49323
  }), elements;
49061
49324
  const groupElements = {};
49062
- return this._groupKeys.forEach(key => {
49325
+ return this._groupedData.keys.forEach(key => {
49063
49326
  const data = this.renderContext.progressive.groupedData.get(key),
49064
49327
  groupStep = this.renderContext.progressive.step,
49065
49328
  dataSlice = data.slice(currentIndex * groupStep, (currentIndex + 1) * groupStep),
@@ -49089,8 +49352,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49089
49352
  evaluateProgressive() {
49090
49353
  var _a, _b, _c;
49091
49354
  if (null === (_a = this.renderContext) || void 0 === _a ? void 0 : _a.beforeTransformProgressive) {
49092
- this.renderContext.beforeTransformProgressive.progressiveRun();
49093
- const output = this.renderContext.beforeTransformProgressive.output();
49355
+ const transform = this.renderContext.beforeTransformProgressive;
49356
+ transform.progressiveRun();
49357
+ const output = transform.output();
49358
+ if (transform.canAnimate) {
49359
+ if (transform.unfinished()) return;
49360
+ this.evaluateGroup(output);
49361
+ }
49094
49362
  return this.emit(HOOK_EVENT.BEFORE_MARK_JOIN), this.evaluateJoin(output), this.emit(HOOK_EVENT.AFTER_MARK_JOIN), this.emit(HOOK_EVENT.BEFORE_MARK_STATE), this.evaluateState(this.elements, this.spec.state, this.renderContext.parameters), this.emit(HOOK_EVENT.AFTER_MARK_STATE), this.emit(HOOK_EVENT.BEFORE_MARK_ENCODE), this.evaluateEncode(this.elements, this._getEncoders(), this.renderContext.parameters), void this.emit(HOOK_EVENT.AFTER_MARK_ENCODE);
49095
49363
  }
49096
49364
  if (!(null === (_b = this.renderContext) || void 0 === _b ? void 0 : _b.progressive)) return;
@@ -49098,7 +49366,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49098
49366
  this.emit(HOOK_EVENT.BEFORE_MARK_JOIN);
49099
49367
  const result = this.evaluateJoinProgressive(),
49100
49368
  elements = Array.isArray(result) ? result : result.elements;
49101
- if (this.emit(HOOK_EVENT.AFTER_MARK_JOIN), 0 === this.renderContext.progressive.currentIndex ? (this.graphicParent.removeAllChild(), this._groupKeys.forEach(key => {
49369
+ if (this.emit(HOOK_EVENT.AFTER_MARK_JOIN), 0 === this.renderContext.progressive.currentIndex ? (this.graphicParent.removeAllChild(), this._groupedData.keys.forEach(key => {
49102
49370
  const graphicItem = createGraphicItem(this, GrammarMarkType.group, {
49103
49371
  pickable: !1,
49104
49372
  zIndex: this.spec.zIndex
@@ -49172,10 +49440,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
49172
49440
  }
49173
49441
  prepareRelease() {
49174
49442
  var _a;
49175
- null === (_a = this.animate) || void 0 === _a || _a.stop(), this.elementMap.forEach(element => element.diffState = DiffState.exit), this._finalParameters = this.parameters();
49443
+ this.differ.setCurrentData(null), null === (_a = this.animate) || void 0 === _a || _a.stop(), this.elementMap.forEach(element => element.diffState = DiffState.exit), this._finalParameters = this.parameters();
49176
49444
  }
49177
49445
  release() {
49178
- this.releaseEvent(), this.elements.forEach(element => element.release()), this.elementMap.clear(), this._finalParameters = null, this.animate && this.animate.release(), this.graphicItem && removeGraphicItem(this.graphicItem), this.detachAll(), super.release();
49446
+ this.releaseEvent(), this.elements.forEach(element => element.release()), this.differ = null, this.elements = [], this.elementMap.clear(), this._finalParameters = null, this.animate && this.animate.release(), this.graphicItem && removeGraphicItem(this.graphicItem), this.detachAll(), super.release();
49179
49447
  }
49180
49448
  }
49181
49449
 
@@ -50243,10 +50511,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
50243
50511
  const size = _this._getContainerSize();
50244
50512
  size && _this.resize(size.width, size.height);
50245
50513
  }, 100), this.delegateEvent = (event, type) => {
50246
- var _a;
50247
- const activeElement = null === (_a = event.target) || void 0 === _a ? void 0 : _a[BridgeElementKey],
50248
- extendedEvt = getExtendedEvents(this, event, activeElement, type, EVENT_SOURCE_VIEW);
50249
- this.emit(type, extendedEvt, activeElement);
50514
+ const extendedEvt = getExtendedEvents(this, event, type, EVENT_SOURCE_VIEW);
50515
+ this.emit(type, extendedEvt, event.element);
50250
50516
  }, this.handleProgressiveFrame = () => {
50251
50517
  this._progressiveMarks.length && this._progressiveMarks.forEach(mark => {
50252
50518
  mark.isDoingProgressive() && mark.evaluateProgressive();
@@ -50630,7 +50896,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
50630
50896
  var _b;
50631
50897
  const matched = 1 === diff.prev.length && 1 === diff.next.length && diff.prev[0].markType === diff.next[0].markType,
50632
50898
  enableMarkMorphConfig = diff.prev.every(mark => mark.getMorphConfig().morph) && diff.next.every(mark => mark.getMorphConfig().morph);
50633
- runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll ? null === (_b = this.addMorphMarks) || void 0 === _b || _b.call(this, {
50899
+ this.morph && (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) ? null === (_b = this.addMorphMarks) || void 0 === _b || _b.call(this, {
50634
50900
  prev: diff.prev,
50635
50901
  next: diff.next
50636
50902
  }) : matched && runningConfig.reuse && (diff.next[0].reuse(diff.prev[0]), diff.prev[0].detachAll(), diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0]));
@@ -50723,7 +50989,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
50723
50989
  resize(width, height) {
50724
50990
  let render = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
50725
50991
  let needDataflow = !1;
50726
- return width !== this.width() && (needDataflow = !0, this.updateSignal(SIGNAL_WIDTH, width)), height !== this.height() && (needDataflow = !0, this.updateSignal(SIGNAL_HEIGHT, height)), needDataflow && (render ? this.evaluate() : this._dataflow.evaluate()), this;
50992
+ return width !== this.width() && (needDataflow = !0, this.updateSignal(SIGNAL_WIDTH, width)), height !== this.height() && (needDataflow = !0, this.updateSignal(SIGNAL_HEIGHT, height)), needDataflow && (render ? this.evaluate({
50993
+ morph: !1
50994
+ }) : this._dataflow.evaluate()), this;
50727
50995
  }
50728
50996
  _resizeRenderer() {
50729
50997
  const width = this.width(),
@@ -55547,8 +55815,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
55547
55815
  });
55548
55816
  return viewData;
55549
55817
  }
55550
- function dataToDataView(data, dataSet, sourceDataViews = [], ctx = {}) {
55551
- var _a, _b, _c;
55818
+ function dataToDataView(data, dataSet, sourceDataViews = []) {
55819
+ var _a;
55552
55820
  if (data instanceof DataView) {
55553
55821
  return data;
55554
55822
  }
@@ -55570,7 +55838,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
55570
55838
  if (typeof fromDataId === 'string') {
55571
55839
  const fromDataView = sourceDataViews.find(dv => dv.name === fromDataId);
55572
55840
  if (!fromDataView) {
55573
- ((_a = ctx.onError) !== null && _a !== void 0 ? _a : error$1)(`no data matches fromDataId ${fromDataId}`);
55841
+ warn(`no data matches fromDataId ${fromDataId}`);
55574
55842
  return null;
55575
55843
  }
55576
55844
  dataView.parse([fromDataView], {
@@ -55583,7 +55851,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
55583
55851
  else if (typeof fromDataIndex === 'number') {
55584
55852
  const fromDataView = sourceDataViews[fromDataIndex];
55585
55853
  if (!fromDataView) {
55586
- ((_b = ctx.onError) !== null && _b !== void 0 ? _b : error$1)(`no data matches fromDataIndex ${fromDataIndex}`);
55854
+ warn(`no data matches fromDataIndex ${fromDataIndex}`);
55587
55855
  return null;
55588
55856
  }
55589
55857
  dataView.parse([fromDataView], {
@@ -55597,7 +55865,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
55597
55865
  dataView.parse(values, parser);
55598
55866
  }
55599
55867
  else if (isString$1(values) && (!parser || ['csv', 'dsv', 'tsv'].includes(parser.type))) {
55600
- dataView.parse(values, (_c = parser) !== null && _c !== void 0 ? _c : { type: 'csv' });
55868
+ dataView.parse(values, (_a = parser) !== null && _a !== void 0 ? _a : { type: 'csv' });
55601
55869
  }
55602
55870
  else {
55603
55871
  dataView.parse([]);
@@ -57821,12 +58089,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
57821
58089
  compileMarks(group) {
57822
58090
  this.getMarks().forEach(m => {
57823
58091
  var _a;
57824
- m.compile({ group });
57825
- (_a = m.getProduct()) === null || _a === void 0 ? void 0 : _a.configure({
57826
- context: {
57827
- model: this
57828
- }
57829
- }).layout((group, children, parentLayoutBounds, options) => {
58092
+ m.compile({ group, context: { model: this } });
58093
+ (_a = m.getProduct()) === null || _a === void 0 ? void 0 : _a.layout((group, children, parentLayoutBounds, options) => {
57830
58094
  });
57831
58095
  });
57832
58096
  }
@@ -59034,7 +59298,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59034
59298
  this.compileState();
59035
59299
  this.compileEncode();
59036
59300
  this.compileAnimation();
59037
- this.compileContext();
59301
+ this.compileContext(option === null || option === void 0 ? void 0 : option.context);
59038
59302
  this.compileTransform();
59039
59303
  }
59040
59304
  _initProduct(group) {
@@ -59149,16 +59413,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59149
59413
  }
59150
59414
  }
59151
59415
  }
59152
- compileContext() {
59416
+ compileContext(extraContext) {
59153
59417
  const config = {
59154
59418
  interactive: this.getInteractive(),
59155
59419
  zIndex: this.getZIndex(),
59156
- context: {
59157
- markId: this.id,
59158
- modelId: this.model.id,
59159
- markUserId: this._userId,
59160
- modelUserId: this.model.userId
59161
- },
59420
+ context: Object.assign({ markId: this.id, modelId: this.model.id, markUserId: this._userId, modelUserId: this.model.userId }, extraContext),
59162
59421
  skipTheme: this.getSkipTheme(),
59163
59422
  support3d: this.getSupport3d(),
59164
59423
  enableSegments: !!this._enableSegments,
@@ -59833,6 +60092,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59833
60092
  plugin.onAfterChartSpecTransform && plugin.onAfterChartSpecTransform(this, chartSpec, actionSource);
59834
60093
  });
59835
60094
  }
60095
+ onAfterModelSpecTransform(chartSpec, chartSpecInfo, actionSource) {
60096
+ this._plugins.forEach(plugin => {
60097
+ plugin.onAfterModelSpecTransform &&
60098
+ plugin.onAfterModelSpecTransform(this, chartSpec, chartSpecInfo, actionSource);
60099
+ });
60100
+ }
59836
60101
  onBeforeInitChart(chartSpec, actionSource) {
59837
60102
  this._plugins.forEach(plugin => {
59838
60103
  plugin.onBeforeInitChart && plugin.onBeforeInitChart(this, chartSpec, actionSource);
@@ -59921,7 +60186,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59921
60186
  return this._dataSet;
59922
60187
  }
59923
60188
  constructor(spec, options) {
59924
- var _a, _b, _c, _d, _e, _f;
60189
+ var _a, _b, _c, _d, _e, _f, _g, _h;
59925
60190
  this.id = createID();
59926
60191
  this._userEvents = [];
59927
60192
  this._autoSize = true;
@@ -59936,9 +60201,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59936
60201
  };
59937
60202
  this._observer = null;
59938
60203
  this._context = {};
59939
- this._onResize = debounce((...args) => {
59940
- this._doResize();
59941
- }, 100);
60204
+ this._doResize = () => {
60205
+ const { width, height } = this.getCurrentSize();
60206
+ if (this._currentSize.width !== width || this._currentSize.height !== height) {
60207
+ this._currentSize = { width, height };
60208
+ this.resizeSync(width, height);
60209
+ }
60210
+ };
59942
60211
  this._renderSync = (option = {}) => {
59943
60212
  var _a;
59944
60213
  const self = this;
@@ -59953,6 +60222,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59953
60222
  var _a, _b;
59954
60223
  const lastSpec = this._spec;
59955
60224
  const result = {
60225
+ changeBackground: false,
59956
60226
  reTransformSpec: false,
59957
60227
  change: false,
59958
60228
  reMake: false,
@@ -59980,14 +60250,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59980
60250
  result.changeTheme = true;
59981
60251
  return result;
59982
60252
  }
59983
- this._initChartSpec(this._spec, 'render');
60253
+ this._initChartSpec(this._spec, 'updateSpec');
59984
60254
  const res = mergeUpdateResult(this._chart.updateSpec(this._spec), result);
59985
60255
  return userUpdateOptions
59986
60256
  ? Object.assign(Object.assign({}, res), userUpdateOptions) : res;
59987
60257
  };
59988
60258
  this._option = merge$2(this._option, { animation: spec.animation !== false }, options);
59989
60259
  this._onError = (_a = this._option) === null || _a === void 0 ? void 0 : _a.onError;
59990
- const _g = this._option, { dom, renderCanvas, mode, stage, poptip } = _g, restOptions = __rest$e(_g, ["dom", "renderCanvas", "mode", "stage", "poptip"]);
60260
+ const _j = this._option, { dom, renderCanvas, mode, stage, poptip } = _j, restOptions = __rest$e(_j, ["dom", "renderCanvas", "mode", "stage", "poptip"]);
59991
60261
  const isTrueBrowseEnv = isTrueBrowser(mode);
59992
60262
  if (isTrueBrowseEnv) {
59993
60263
  registerBrowserEnv();
@@ -60028,6 +60298,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60028
60298
  this._bindVGrammarViewEvent();
60029
60299
  this._initChartPlugin();
60030
60300
  InstanceManager.registerInstance(this);
60301
+ (_h = (_g = this._option.performanceHook) === null || _g === void 0 ? void 0 : _g.afterCreateVChart) === null || _h === void 0 ? void 0 : _h.call(_g, this);
60031
60302
  }
60032
60303
  _setNewSpec(spec, forceMerge) {
60033
60304
  if (!spec) {
@@ -60118,13 +60389,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60118
60389
  });
60119
60390
  }
60120
60391
  _bindResizeEvent() {
60121
- var _a;
60392
+ var _a, _b;
60122
60393
  if (this._autoSize) {
60394
+ this._onResize = throttle(this._doResize, (_a = this._option.resizeDelay) !== null && _a !== void 0 ? _a : 100);
60123
60395
  if (this._container) {
60124
60396
  const ResizeObserverWindow = window.ResizeObserver;
60125
60397
  if (ResizeObserverWindow) {
60126
60398
  this._observer = new ResizeObserverWindow(this._onResize);
60127
- (_a = this._observer) === null || _a === void 0 ? void 0 : _a.observe(this._container);
60399
+ (_b = this._observer) === null || _b === void 0 ? void 0 : _b.observe(this._container);
60128
60400
  }
60129
60401
  }
60130
60402
  window.addEventListener('resize', this._onResize);
@@ -60151,13 +60423,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60151
60423
  height: (_d = (_c = this._currentSize) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : DEFAULT_CHART_HEIGHT
60152
60424
  });
60153
60425
  }
60154
- _doResize() {
60155
- const { width, height } = this.getCurrentSize();
60156
- if (this._currentSize.width !== width || this._currentSize.height !== height) {
60157
- this._currentSize = { width, height };
60158
- this.resizeSync(width, height);
60159
- }
60160
- }
60161
60426
  _initDataSet(dataSet) {
60162
60427
  if (dataSet instanceof DataSet) {
60163
60428
  this._dataSet = dataSet;
@@ -60200,7 +60465,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60200
60465
  return this._beforeRender(option);
60201
60466
  }
60202
60467
  _reCompile(updateResult, morphConfig) {
60203
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
60468
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
60204
60469
  if (updateResult.reMake) {
60205
60470
  this._releaseData();
60206
60471
  this._initDataSet();
@@ -60229,8 +60494,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60229
60494
  (_h = this._compiler) === null || _h === void 0 ? void 0 : _h.setBackground(this._getBackground());
60230
60495
  }
60231
60496
  if (updateResult.reCompile) {
60232
- (_j = this._compiler) === null || _j === void 0 ? void 0 : _j.clear({ chart: this._chart, vChart: this }, !this._option.animation || !this._spec.animation);
60233
- (_k = this._compiler) === null || _k === void 0 ? void 0 : _k.compile({ chart: this._chart, vChart: this }, {});
60497
+ (_j = this._compiler) === null || _j === void 0 ? void 0 : _j.clear({ chart: this._chart, vChart: this }, ((_k = this._option) === null || _k === void 0 ? void 0 : _k.animation) === false || ((_l = this._spec) === null || _l === void 0 ? void 0 : _l.animation) === false);
60498
+ (_m = this._compiler) === null || _m === void 0 ? void 0 : _m.compile({ chart: this._chart, vChart: this }, {});
60234
60499
  }
60235
60500
  if (updateResult.reSize) {
60236
60501
  const { width, height } = this.getCurrentSize();
@@ -60252,9 +60517,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60252
60517
  this._initChartSpec(this._spec, 'render');
60253
60518
  }
60254
60519
  this._chartPluginApply('onBeforeInitChart', this._spec, actionSource);
60255
- (_b = (_a = this._option.performanceHook) === null || _a === void 0 ? void 0 : _a.beforeInitializeChart) === null || _b === void 0 ? void 0 : _b.call(_a);
60520
+ (_b = (_a = this._option.performanceHook) === null || _a === void 0 ? void 0 : _a.beforeInitializeChart) === null || _b === void 0 ? void 0 : _b.call(_a, this);
60256
60521
  this._initChart(this._spec);
60257
- (_d = (_c = this._option.performanceHook) === null || _c === void 0 ? void 0 : _c.afterInitializeChart) === null || _d === void 0 ? void 0 : _d.call(_c);
60522
+ (_d = (_c = this._option.performanceHook) === null || _c === void 0 ? void 0 : _c.afterInitializeChart) === null || _d === void 0 ? void 0 : _d.call(_c, this);
60258
60523
  if (!this._chart || !this._compiler) {
60259
60524
  return false;
60260
60525
  }
@@ -60414,7 +60679,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60414
60679
  const prevData = array(this._spec.data);
60415
60680
  const list = array(data);
60416
60681
  list.forEach(d => {
60417
- var _a;
60418
60682
  const { id, values, parser, fields } = d;
60419
60683
  const preDV = prevData.find(dv => dv.name === id);
60420
60684
  if (preDV) {
@@ -60429,9 +60693,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
60429
60693
  }
60430
60694
  }
60431
60695
  else {
60432
- const dataView = dataToDataView(d, this._dataSet, prevData, {
60433
- onError: (_a = this._option) === null || _a === void 0 ? void 0 : _a.onError
60434
- });
60696
+ const dataView = dataToDataView(d, this._dataSet, prevData);
60435
60697
  if (isArray$1(this._spec.data)) {
60436
60698
  this._spec.data.push(dataView);
60437
60699
  }
@@ -61145,7 +61407,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
61145
61407
  };
61146
61408
  registerVChartCore();
61147
61409
 
61148
- const version = "1.12.5";
61410
+ const version = "1.12.7";
61149
61411
 
61150
61412
  const addVChartProperty = (data, op) => {
61151
61413
  const context = op.beforeCall();
@@ -61541,6 +61803,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
61541
61803
  data: true
61542
61804
  };
61543
61805
  const defaultSeriesCompileCheckKeys = {
61806
+ invalidType: true,
61544
61807
  animation: true,
61545
61808
  animationAppear: true,
61546
61809
  animationEnter: true,
@@ -62271,14 +62534,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
62271
62534
  }
62272
62535
  }
62273
62536
  initData() {
62274
- var _a, _b, _c, _d;
62537
+ var _a, _b, _c;
62275
62538
  const d = (_a = this._spec.data) !== null && _a !== void 0 ? _a : this._option.getSeriesData(this._spec.dataId, this._spec.dataIndex);
62276
62539
  if (d) {
62277
- this._rawData = dataToDataView(d, this._dataSet, this._option.sourceDataList, {
62278
- onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError
62279
- });
62540
+ this._rawData = dataToDataView(d, this._dataSet, this._option.sourceDataList);
62280
62541
  }
62281
- (_d = (_c = this._rawData) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.addListener('change', this.rawDataUpdate.bind(this));
62542
+ (_c = (_b = this._rawData) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.addListener('change', this.rawDataUpdate.bind(this));
62282
62543
  this._addDataIndexAndKey();
62283
62544
  if (this._rawData) {
62284
62545
  if (this.getStack()) {
@@ -62794,8 +63055,34 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
62794
63055
  initTooltip() {
62795
63056
  this._tooltipHelper = new BaseSeriesTooltipHelper(this);
62796
63057
  }
63058
+ _compareExtensionMarksSpec(newMarks, prevMarks, compareResult) {
63059
+ if (newMarks.length !== prevMarks.length ||
63060
+ prevMarks.some((prev, index) => {
63061
+ return prev.type !== newMarks[index].type || prev.id !== newMarks[index].id;
63062
+ })) {
63063
+ compareResult.reMake = true;
63064
+ }
63065
+ else if (prevMarks.some((prev, index) => {
63066
+ return prev.visible !== newMarks[index].visible;
63067
+ })) {
63068
+ compareResult.reCompile = true;
63069
+ }
63070
+ }
63071
+ _compareLabelSpec(newLabels, prevLabels, compareResult) {
63072
+ if (newLabels.length !== prevLabels.length ||
63073
+ prevLabels.some((prev, index) => {
63074
+ return prev.labelLayout !== newLabels[index].labelLayout;
63075
+ })) {
63076
+ compareResult.reMake = true;
63077
+ }
63078
+ else if (!compareResult.reCompile &&
63079
+ prevLabels.some((prev, index) => {
63080
+ return !isEqual(prev, newLabels[index]);
63081
+ })) {
63082
+ compareResult.reCompile = true;
63083
+ }
63084
+ }
62797
63085
  _compareSpec(spec, prevSpec, ignoreCheckKeys) {
62798
- var _a, _b;
62799
63086
  const result = super._compareSpec(spec, prevSpec);
62800
63087
  const currentKeys = Object.keys(prevSpec || {}).sort();
62801
63088
  const nextKeys = Object.keys(spec || {}).sort();
@@ -62803,36 +63090,30 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
62803
63090
  result.reMake = true;
62804
63091
  return result;
62805
63092
  }
62806
- ignoreCheckKeys = Object.assign(Object.assign(Object.assign({}, defaultSeriesIgnoreCheckKeys), defaultSeriesCompileCheckKeys), ignoreCheckKeys);
62807
- ignoreCheckKeys.invalidType = true;
62808
- if (spec.invalidType !== prevSpec.invalidType) {
62809
- result.reCompile = true;
62810
- }
62811
- ignoreCheckKeys.extensionMark = true;
62812
- if (array(spec.extensionMark).length !== array(prevSpec.extensionMark).length ||
62813
- ((_a = prevSpec.extensionMark) === null || _a === void 0 ? void 0 : _a.some((mark, index) => mark.type !== spec.extensionMark[index].type || mark.id !== spec.extensionMark[index].id))) {
62814
- result.reMake = true;
62815
- }
63093
+ const ignores = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultSeriesIgnoreCheckKeys), defaultSeriesCompileCheckKeys), ignoreCheckKeys), { extensionMark: true, label: true, totalLabel: true });
63094
+ this._compareExtensionMarksSpec(array(spec.extensionMark), array(prevSpec.extensionMark), result);
63095
+ !result.reMake && this._compareLabelSpec(array(spec.label), array(prevSpec.label), result);
63096
+ !result.reMake &&
63097
+ this._compareLabelSpec(array(spec.totalLabel), array(prevSpec.totalLabel), result);
62816
63098
  if (result.reMake) {
62817
63099
  return result;
62818
63100
  }
62819
- if ((_b = prevSpec.extensionMark) === null || _b === void 0 ? void 0 : _b.some((mark, index) => mark.visible !== spec.extensionMark[index].visible)) {
63101
+ if (!result.reCompile &&
63102
+ this._marks.getMarks().some(m => {
63103
+ var _a, _b;
63104
+ ignores[m.name] = true;
63105
+ return ((_a = prevSpec[m.name]) === null || _a === void 0 ? void 0 : _a.visible) !== ((_b = spec[m.name]) === null || _b === void 0 ? void 0 : _b.visible);
63106
+ })) {
62820
63107
  result.reCompile = true;
62821
63108
  }
62822
- if (this._marks.getMarks().some(m => {
62823
- var _a, _b;
62824
- ignoreCheckKeys[m.name] = true;
62825
- return ((_a = prevSpec[m.name]) === null || _a === void 0 ? void 0 : _a.visible) !== ((_b = spec[m.name]) === null || _b === void 0 ? void 0 : _b.visible);
62826
- })) {
63109
+ if (!result.reCompile &&
63110
+ currentKeys.some((k) => {
63111
+ return defaultSeriesCompileCheckKeys[k] && !isEqual(spec[k], prevSpec[k]);
63112
+ })) {
62827
63113
  result.reCompile = true;
62828
63114
  }
62829
63115
  if (currentKeys.some((k) => {
62830
- return defaultSeriesCompileCheckKeys[k] && !isEqual(spec[k], prevSpec[k]);
62831
- })) {
62832
- result.reCompile = true;
62833
- }
62834
- if (currentKeys.some((k) => {
62835
- return !ignoreCheckKeys[k] && !isEqual(spec[k], prevSpec[k]);
63116
+ return !ignores[k] && !isEqual(spec[k], prevSpec[k]);
62836
63117
  })) {
62837
63118
  result.reMake = true;
62838
63119
  return result;
@@ -64714,13 +64995,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
64714
64995
  }
64715
64996
  compileMarks(group) {
64716
64997
  this.getMarks().forEach(m => {
64717
- var _a;
64718
- m.compile({ group });
64719
- (_a = m.getProduct()) === null || _a === void 0 ? void 0 : _a.configure({
64720
- context: {
64721
- model: this
64722
- }
64723
- });
64998
+ m.compile({ group, context: { model: this } });
64724
64999
  });
64725
65000
  }
64726
65001
  reAppendComponents() {
@@ -65015,11 +65290,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
65015
65290
  });
65016
65291
  return result;
65017
65292
  }
65018
- _delegateAxisContainerEvent(component) {
65019
- if (component.listenerCount('*') === 0) {
65020
- component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
65021
- }
65022
- }
65023
65293
  _getAxisAttributes() {
65024
65294
  const spec = this._spec;
65025
65295
  const axisAttrs = {
@@ -65614,7 +65884,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
65614
65884
  this.pluginService && plugin.onDidLayoutVertical && plugin.onDidLayoutVertical(this.pluginService, this);
65615
65885
  });
65616
65886
  }
65617
- this._delegateAxisContainerEvent(product.getGroupGraphicItem());
65618
65887
  if (this._unitText) {
65619
65888
  const { x, y } = this.getLayoutStartPoint();
65620
65889
  const pos = isXAxis(this._orient)
@@ -65729,12 +65998,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
65729
65998
  const attrs = this._getUpdateAttribute(true);
65730
65999
  const axisComponent = product.getGroupGraphicItem();
65731
66000
  const spec = mergeSpec(Object.assign({}, this.getLayoutStartPoint()), this._axisStyle, attrs, { line: { visible: false } });
65732
- const updateBounds = axisComponent.getBoundsWithoutRender(spec);
66001
+ let updateBounds = axisComponent.getBoundsWithoutRender(spec);
66002
+ if (updateBounds.empty()) {
66003
+ updateBounds = new Bounds().set(spec.x, spec.y, spec.x, spec.y);
66004
+ }
65733
66005
  hasBounds = true;
65734
66006
  this._latestBounds = updateBounds;
65735
- if (isFinite(updateBounds.width())) {
65736
- result = this._appendAxisUnit(updateBounds, isX);
65737
- }
66007
+ result = this._appendAxisUnit(updateBounds, isX);
65738
66008
  }
65739
66009
  if (!hasBounds) {
65740
66010
  this._latestBounds = product.getBounds();
@@ -67062,16 +67332,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67062
67332
  get dataList() {
67063
67333
  return this._dataArr;
67064
67334
  }
67065
- constructor(dataSet, onError) {
67335
+ constructor(dataSet) {
67066
67336
  this._dataArr = [];
67067
- this._onError = onError;
67068
67337
  this._dataSet = dataSet;
67069
67338
  }
67070
67339
  parseData(dataSpec) {
67071
67340
  this._dataArr = [];
67072
67341
  const list = array(dataSpec);
67073
67342
  for (let i = 0; i < list.length; i++) {
67074
- this._dataArr.push(dataToDataView(list[i], this._dataSet, this._dataArr, { onError: this._onError }));
67343
+ this._dataArr.push(dataToDataView(list[i], this._dataSet, this._dataArr));
67075
67344
  }
67076
67345
  }
67077
67346
  updateData(dataSpec, fullUp = false, forceMerge = true) {
@@ -67100,7 +67369,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67100
67369
  });
67101
67370
  }
67102
67371
  getSeriesData(id, index) {
67103
- var _a, _b;
67104
67372
  if (!this._dataArr.length) {
67105
67373
  return null;
67106
67374
  }
@@ -67111,15 +67379,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67111
67379
  if (metchData[0]) {
67112
67380
  return metchData[0];
67113
67381
  }
67114
- (_a = this._onError) === null || _a === void 0 ? void 0 : _a.call(this, `no data matches dataId ${id}!`);
67115
- return null;
67382
+ warn(`no data matches dataId ${id}!`);
67116
67383
  }
67117
67384
  if (typeof index === 'number') {
67118
67385
  if (this._dataArr[index]) {
67119
67386
  return this._dataArr[index];
67120
67387
  }
67121
- (_b = this._onError) === null || _b === void 0 ? void 0 : _b.call(this, `no data matches dataIndex ${index}!`);
67122
- return null;
67388
+ warn(`no data matches dataIndex ${index}!`);
67123
67389
  }
67124
67390
  return this._dataArr[0];
67125
67391
  }
@@ -67479,7 +67745,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67479
67745
  return this._chartData;
67480
67746
  }
67481
67747
  constructor(spec, option) {
67482
- var _a, _b, _c, _d;
67748
+ var _a, _b, _c;
67483
67749
  super(option);
67484
67750
  this.type = 'chart';
67485
67751
  this.id = createID();
@@ -67609,8 +67875,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67609
67875
  this._paddingSpec = normalizeLayoutPaddingSpec((_a = spec.padding) !== null && _a !== void 0 ? _a : option.getTheme().padding);
67610
67876
  this._event = new Event$1(option.eventDispatcher, option.mode);
67611
67877
  this._dataSet = option.dataSet;
67612
- this._chartData = new ChartData(this._dataSet, (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError);
67613
- this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_c = this._option) === null || _c === void 0 ? void 0 : _c.onError, disableTriggerEvent: ((_d = this._option) === null || _d === void 0 ? void 0 : _d.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData) });
67878
+ this._chartData = new ChartData(this._dataSet);
67879
+ this._modelOption = Object.assign(Object.assign({}, option), { mode: this._option.mode, map: this._idMap, getChartLayoutRect: () => this._layoutRect, getChartViewRect: () => this._viewRect, getChart: () => this, globalScale: this._globalScale, onError: (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError, disableTriggerEvent: ((_c = this._option) === null || _c === void 0 ? void 0 : _c.disableTriggerEvent) === true, getSeriesData: this._chartData.getSeriesData.bind(this._chartData) });
67614
67880
  this._spec = spec;
67615
67881
  }
67616
67882
  created() {
@@ -67936,6 +68202,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67936
68202
  this._globalScale.getScale('color').range(colorSpec.range);
67937
68203
  }
67938
68204
  }
68205
+ _getSpecKeys(spec) {
68206
+ const ignoreKeys = { width: true, height: true };
68207
+ return Object.keys(spec)
68208
+ .filter(key => !ignoreKeys[key])
68209
+ .sort();
68210
+ }
67939
68211
  updateSpec(spec) {
67940
68212
  const result = {
67941
68213
  change: false,
@@ -67949,9 +68221,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
67949
68221
  result.reMake = true;
67950
68222
  return result;
67951
68223
  }
67952
- const currentKeys = Object.keys(this._spec).sort();
67953
- const nextKeys = Object.keys(spec).sort();
67954
- if (JSON.stringify(currentKeys) !== JSON.stringify(nextKeys)) {
68224
+ const currentKeys = this._getSpecKeys(this._spec);
68225
+ const nextKeys = this._getSpecKeys(spec);
68226
+ if (!isEqual(currentKeys, nextKeys)) {
67955
68227
  result.reMake = true;
67956
68228
  return result;
67957
68229
  }
@@ -68050,10 +68322,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
68050
68322
  }
68051
68323
  }
68052
68324
  }
68325
+ const isVisible = (compSpec) => compSpec && compSpec.visible !== false;
68053
68326
  Object.keys(checkVisibleComponents).forEach(type => {
68054
68327
  if (checkVisibleComponents[type]) {
68055
68328
  const compSpec = this._spec[type];
68056
- const switchToVisible = isArray$1(compSpec) ? compSpec.some(entry => entry === null || entry === void 0 ? void 0 : entry.visible) : compSpec === null || compSpec === void 0 ? void 0 : compSpec.visible;
68329
+ const switchToVisible = isArray$1(compSpec) ? compSpec.some(isVisible) : isVisible(compSpec);
68057
68330
  if (switchToVisible) {
68058
68331
  result.reMake = true;
68059
68332
  }
@@ -68143,13 +68416,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
68143
68416
  if (!this._backgroundMark) {
68144
68417
  return;
68145
68418
  }
68146
- this._backgroundMark.compile();
68147
- (_a = this._backgroundMark
68148
- .getProduct()) === null || _a === void 0 ? void 0 : _a.configure({
68149
- context: {
68150
- model: this
68151
- }
68152
- }).layout(() => {
68419
+ this._backgroundMark.compile({ context: { model: this } });
68420
+ (_a = this._backgroundMark.getProduct()) === null || _a === void 0 ? void 0 : _a.layout(() => {
68153
68421
  });
68154
68422
  }
68155
68423
  compileRegions() {
@@ -72324,15 +72592,20 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72324
72592
  ? (_c = series.getXAxisHelper()) === null || _c === void 0 ? void 0 : _c.isInverse()
72325
72593
  : (_d = series.getYAxisHelper()) === null || _d === void 0 ? void 0 : _d.isInverse();
72326
72594
  let position = originPosition;
72327
- if (isString$1(originPosition) && originPosition === 'outside') {
72328
- position = (data) => {
72329
- const { data: datum } = data;
72595
+ position = (datum) => {
72596
+ var _a;
72597
+ const { data } = datum;
72598
+ const labelPosition = (_a = (typeof labelSpec.position === 'function'
72599
+ ? labelSpec.position(data)
72600
+ : labelSpec.position)) !== null && _a !== void 0 ? _a : 'outside';
72601
+ if (labelPosition === 'outside') {
72330
72602
  const dataField = series.getMeasureField()[0];
72331
72603
  const positionMap = { vertical: ['top', 'bottom'], horizontal: ['right', 'left'] };
72332
- const index = ((datum === null || datum === void 0 ? void 0 : datum[dataField]) >= 0 && isInverse) || ((datum === null || datum === void 0 ? void 0 : datum[dataField]) < 0 && !isInverse) ? 1 : 0;
72604
+ const index = ((data === null || data === void 0 ? void 0 : data[dataField]) >= 0 && isInverse) || ((data === null || data === void 0 ? void 0 : data[dataField]) < 0 && !isInverse) ? 1 : 0;
72333
72605
  return positionMap[direction][index];
72334
- };
72335
- }
72606
+ }
72607
+ return labelPosition;
72608
+ };
72336
72609
  let overlap;
72337
72610
  if (labelSpec.overlap === false) {
72338
72611
  overlap = false;
@@ -75173,17 +75446,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75173
75446
  var _a;
75174
75447
  return Object.assign(Object.assign({}, super._tickTransformOption()), { noDecimal: (_a = this._tick) === null || _a === void 0 ? void 0 : _a.noDecimals, startAngle: this.startAngle, labelOffset: getAxisLabelOffset(this._spec), getRadius: () => this.getOuterRadius(), inside: this._spec.inside });
75175
75448
  }
75176
- afterCompile() {
75177
- var _a;
75178
- const product = (_a = this._axisMark) === null || _a === void 0 ? void 0 : _a.getProduct();
75179
- if (product) {
75180
- product.addEventListener(HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
75181
- if (this._isLayout === false) {
75182
- this._delegateAxisContainerEvent(product.getGroupGraphicItem());
75183
- }
75184
- });
75185
- }
75186
- }
75187
75449
  updateScaleRange() {
75188
75450
  const prevRange = this._scale.range();
75189
75451
  let newRange;
@@ -75269,29 +75531,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75269
75531
  return polarToCartesian(center, point.radius, point.angle);
75270
75532
  }
75271
75533
  pointToCoord(point) {
75272
- const { x: centerX, y: centerY } = this.getCenter();
75273
- let dx = point.x - centerX;
75274
- let dy = point.y - centerY;
75534
+ const center = this.getCenter();
75275
75535
  const startAngle = this._startAngle;
75276
75536
  const endAngle = this._endAngle;
75277
- const radius = Math.sqrt(dx * dx + dy * dy);
75278
- dx /= radius;
75279
- dy /= radius;
75280
- let radian = Math.atan2(dy, dx);
75281
- if (radian < startAngle) {
75282
- while (radian <= startAngle) {
75283
- radian += Math.PI * 2;
75284
- }
75285
- }
75286
- if (radian > endAngle) {
75287
- while (radian >= endAngle) {
75288
- radian -= Math.PI * 2;
75289
- }
75290
- }
75291
- return {
75292
- radius,
75293
- angle: radian
75294
- };
75537
+ return cartesianToPolar(point, center, startAngle, endAngle);
75295
75538
  }
75296
75539
  getOuterRadius() {
75297
75540
  return this.computeLayoutOuterRadius();
@@ -75343,7 +75586,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75343
75586
  innerRadius, startAngle: this._startAngle, endAngle: this._endAngle, sides: ((_c = (_b = (_a = this._getRelatedAxis(this._option.radiusAxisIndex)) === null || _a === void 0 ? void 0 : _a.getSpec()) === null || _b === void 0 ? void 0 : _b.grid) === null || _c === void 0 ? void 0 : _c.smooth)
75344
75587
  ? undefined
75345
75588
  : this.getScale().domain().length });
75346
- const attrs = Object.assign(Object.assign({}, commonAttrs), { title: {
75589
+ const attrs = Object.assign(Object.assign(Object.assign({}, commonAttrs), this.getRefLayoutRect()), { title: {
75347
75590
  text: this._spec.title.text || this._dataFieldText
75348
75591
  }, items, orient: 'angle' });
75349
75592
  if (this._spec.grid.visible) {
@@ -75648,23 +75891,21 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75648
75891
  class PolarPointUpdate extends ACustomAnimate {
75649
75892
  constructor(from, to, duration, easing, params) {
75650
75893
  super(from, to, duration, easing, params);
75651
- const pointToCoord = this.params.pointToCoord;
75652
- const coordToPoint = this.params.coordToPoint;
75653
- if (!isFunction$1(pointToCoord) || !isFunction$1(coordToPoint)) {
75894
+ this._center = to.center;
75895
+ this._prevCenter = from.center;
75896
+ if (!this._center || !this._prevCenter) {
75654
75897
  this.valid = false;
75655
75898
  }
75656
- this._pointToCoord = pointToCoord;
75657
- this._coordToPoint = coordToPoint;
75658
75899
  }
75659
75900
  getEndProps() {
75660
75901
  if (this.valid === false) {
75661
75902
  return {};
75662
75903
  }
75663
- return this._coordToPoint({ angle: this._toAngle, radius: this._toRadius });
75904
+ return polarToCartesian(this._center, this._toRadius, this._toAngle);
75664
75905
  }
75665
75906
  onBind() {
75666
- const { angle: fromAngle, radius: fromRadius } = this._pointToCoord(this.from);
75667
- const { angle: toAngle, radius: toRadius } = this._pointToCoord(this.to);
75907
+ const { angle: fromAngle, radius: fromRadius } = cartesianToPolar(this.from, this._prevCenter);
75908
+ const { angle: toAngle, radius: toRadius } = cartesianToPolar(this.to, this._center);
75668
75909
  if (!isValidNumber$1(toAngle * toRadius)) {
75669
75910
  this.valid = false;
75670
75911
  }
@@ -75686,12 +75927,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75686
75927
  const { x, y } = this.getEndProps();
75687
75928
  out.x = x;
75688
75929
  out.y = y;
75930
+ out.center = this._center;
75689
75931
  }
75690
75932
  else {
75691
- const { x, y } = this._coordToPoint({
75692
- angle: this._fromAngle + (this._toAngle - this._fromAngle) * ratio,
75693
- radius: this._fromRadius + (this._toRadius - this._fromRadius) * ratio
75694
- });
75933
+ const { x, y } = polarToCartesian({
75934
+ x: this._prevCenter.x + (this._center.x - this._prevCenter.x) * ratio,
75935
+ y: this._prevCenter.y + (this._center.y - this._prevCenter.y) * ratio
75936
+ }, this._fromRadius + (this._toRadius - this._fromRadius) * ratio, this._fromAngle + (this._toAngle - this._fromAngle) * ratio);
75695
75937
  out.x = x;
75696
75938
  out.y = y;
75697
75939
  }
@@ -75700,14 +75942,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75700
75942
  class PolarTagPointsUpdate extends TagPointsUpdate {
75701
75943
  constructor(from, to, duration, easing, params) {
75702
75944
  super(from, to, duration, easing, params);
75703
- const pointToCoord = this.params.pointToCoord;
75704
- const coordToPoint = this.params.coordToPoint;
75705
- this._pointToCoord = pointToCoord;
75706
- this._coordToPoint = coordToPoint;
75945
+ this._center = to.center;
75946
+ this._prevCenter = from.center;
75707
75947
  }
75708
75948
  onUpdate(end, ratio, out) {
75709
75949
  this.points = this.points.map((point, index) => {
75710
75950
  const newPoint = this.polarPointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
75951
+ if (end) {
75952
+ out.center = this._center;
75953
+ }
75711
75954
  newPoint.context = point.context;
75712
75955
  return newPoint;
75713
75956
  });
@@ -75717,8 +75960,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75717
75960
  if (!isValidPoint(pointA) && !isValidPoint(pointB)) {
75718
75961
  return pointB;
75719
75962
  }
75720
- const polarPointA = this._pointToCoord(pointA);
75721
- const polarPointB = this._pointToCoord(pointB);
75963
+ const polarPointA = cartesianToPolar(pointA, this._prevCenter);
75964
+ const polarPointB = cartesianToPolar(pointB, this._center);
75722
75965
  let angleA = normalizeAngle(polarPointA.angle);
75723
75966
  let angleB = normalizeAngle(polarPointB.angle);
75724
75967
  if (!isValidNumber$1(angleA) && isValidNumber$1(angleB)) {
@@ -75729,7 +75972,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75729
75972
  }
75730
75973
  const angle = angleA + (angleB - angleA) * ratio;
75731
75974
  const radius = polarPointA.radius + (polarPointB.radius - polarPointA.radius) * ratio;
75732
- return this._coordToPoint({ angle, radius });
75975
+ return polarToCartesian({
75976
+ x: this._prevCenter.x + (this._center.x - this._prevCenter.x) * ratio,
75977
+ y: this._prevCenter.y + (this._center.y - this._prevCenter.y) * ratio
75978
+ }, radius, angle);
75733
75979
  }
75734
75980
  polarPointInterpolation(pointA, pointB, ratio) {
75735
75981
  const { x, y } = this._interpolationSinglePoint(pointA, pointB, ratio);
@@ -75820,10 +76066,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75820
76066
  disappear: preset === 'clipIn' ? undefined : radarPresetAnimation(params, preset, 'out'),
75821
76067
  update: [
75822
76068
  {
75823
- options: { excludeChannels: ['points', 'defined'] }
76069
+ options: { excludeChannels: ['points', 'defined', 'center'] }
75824
76070
  },
75825
76071
  {
75826
- channel: ['points'],
76072
+ channel: ['points', 'center'],
75827
76073
  custom: PolarTagPointsUpdate,
75828
76074
  customParameters: params,
75829
76075
  duration: DEFAULT_ANIMATION_CONFIG.update.duration,
@@ -75839,10 +76085,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75839
76085
  disappear: preset === 'clipIn' ? undefined : radarSymbolPresetAnimation(params, preset, 'out'),
75840
76086
  update: [
75841
76087
  {
75842
- options: { excludeChannels: ['x', 'y'] }
76088
+ options: { excludeChannels: ['x', 'y', 'center'] }
75843
76089
  },
75844
76090
  {
75845
- channel: ['x', 'y'],
76091
+ channel: ['x', 'y', 'center'],
75846
76092
  custom: PolarPointUpdate,
75847
76093
  customParameters: params,
75848
76094
  duration: DEFAULT_ANIMATION_CONFIG.update.duration,
@@ -75892,6 +76138,16 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75892
76138
  this.initAreaMarkStyle();
75893
76139
  this.initLineMarkStyle();
75894
76140
  this.initSymbolMarkStyle();
76141
+ [this._lineMark, this._symbolMark, this._areaMark].forEach(mark => {
76142
+ if (mark) {
76143
+ this.setMarkStyle(mark, {
76144
+ center: () => {
76145
+ var _a;
76146
+ return (_a = this.angleAxisHelper) === null || _a === void 0 ? void 0 : _a.center();
76147
+ }
76148
+ });
76149
+ }
76150
+ });
75895
76151
  }
75896
76152
  initAreaMark(progressive, isSeriesMark) {
75897
76153
  var _a, _b;
@@ -75963,9 +76219,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
75963
76219
  const rect = this.getLayoutRect();
75964
76220
  return Math.min(rect.width, rect.height);
75965
76221
  },
75966
- startAngle: isValid$1(this._spec.startAngle) ? degreeToRadian(this._spec.startAngle) : POLAR_START_RADIAN,
75967
- pointToCoord: (point) => { var _a; return (_a = this.angleAxisHelper) === null || _a === void 0 ? void 0 : _a.pointToCoord(point); },
75968
- coordToPoint: (coord) => this.angleAxisHelper.coordToPoint(coord)
76222
+ startAngle: isValid$1(this._spec.startAngle) ? degreeToRadian(this._spec.startAngle) : POLAR_START_RADIAN
75969
76223
  };
75970
76224
  const appearPreset = ((_c = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.animationAppear) === null || _b === void 0 ? void 0 : _b.preset) !== null && _c !== void 0 ? _c : 'clipIn');
75971
76225
  if (appearPreset === 'clipIn') {
@@ -79939,12 +80193,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
79939
80193
  return this._valueField;
79940
80194
  }
79941
80195
  setAttrFromSpec() {
79942
- var _a, _b;
80196
+ var _a, _b, _c, _d, _e;
79943
80197
  super.setAttrFromSpec();
79944
80198
  this.setCategoryField(this._spec.categoryField);
79945
80199
  this.setValueField(this._spec.valueField);
79946
80200
  this._funnelOrient = (_a = this._spec.funnelOrient) !== null && _a !== void 0 ? _a : 'top';
79947
80201
  this._shape = (_b = this._spec.shape) !== null && _b !== void 0 ? _b : 'trapezoid';
80202
+ this._minLabelLineWidth = (_e = (_d = (_c = this._spec.outerLabel) === null || _c === void 0 ? void 0 : _c.line) === null || _d === void 0 ? void 0 : _d.minLength) !== null && _e !== void 0 ? _e : FUNNEL_LABEL_LINE_LENGTH;
79948
80203
  if (this._isHorizontal()) {
79949
80204
  this._funnelAlign = ['top', 'bottom'].includes(this._spec.funnelAlign) ? this._spec.funnelAlign : 'center';
79950
80205
  }
@@ -80452,7 +80707,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
80452
80707
  return type === 'text' && ((_a = attribute.data) === null || _a === void 0 ? void 0 : _a[categoryField]) === datum[categoryField];
80453
80708
  }, true)) === null || _c === void 0 ? void 0 : _c.AABBBounds;
80454
80709
  const funnelLabelWidth = funnelLabelBounds ? funnelLabelBounds.x2 - funnelLabelBounds.x1 : 0;
80455
- const outerLineSpace = this._funnelOuterLabelMark.line ? FUNNEL_LABEL_LINE_LENGTH : 0;
80710
+ const outerLineSpace = this._funnelOuterLabelMark.line ? this._minLabelLineWidth : 0;
80456
80711
  let space = this.getLayoutRect().width - Math.max(shapeMiddleWidth, funnelLabelWidth);
80457
80712
  if (this._funnelAlign === 'center') {
80458
80713
  space /= 2;
@@ -80480,14 +80735,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
80480
80735
  y1 = this._getPolygonCenter(points).y - shapeMiddleHeight / 2 - spaceWidth;
80481
80736
  y2 = outerLabelSpec.alignLabel !== false ? (outerLabelMarkBounds === null || outerLabelMarkBounds === void 0 ? void 0 : outerLabelMarkBounds.y2) + spaceWidth : y1 - spaceWidth;
80482
80737
  x1 = this._getPolygonCenter(points).x;
80483
- y1 - y2 < FUNNEL_LABEL_LINE_LENGTH && (y2 = y1 - FUNNEL_LABEL_LINE_LENGTH);
80738
+ y1 - y2 < this._minLabelLineWidth && (y2 = y1 - this._minLabelLineWidth);
80484
80739
  x2 = x1;
80485
80740
  }
80486
80741
  else {
80487
80742
  y1 = this._getPolygonCenter(points).y + shapeMiddleHeight / 2 + spaceWidth;
80488
80743
  y2 = outerLabelSpec.alignLabel !== false ? (outerLabelMarkBounds === null || outerLabelMarkBounds === void 0 ? void 0 : outerLabelMarkBounds.y1) - spaceWidth : y1 + spaceWidth;
80489
80744
  x1 = this._getPolygonCenter(points).x;
80490
- y2 - y1 < FUNNEL_LABEL_LINE_LENGTH && (y2 = y1 + FUNNEL_LABEL_LINE_LENGTH);
80745
+ y2 - y1 < this._minLabelLineWidth && (y2 = y1 + this._minLabelLineWidth);
80491
80746
  x2 = x1;
80492
80747
  }
80493
80748
  return { x1, x2, y1, y2 };
@@ -80500,14 +80755,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
80500
80755
  x1 = this._getPolygonCenter(points).x + Math.max(labelWidth / 2, shapeMiddleWidth / 2) + spaceWidth;
80501
80756
  x2 = outerLabelSpec.alignLabel !== false ? (outerLabelMarkBounds === null || outerLabelMarkBounds === void 0 ? void 0 : outerLabelMarkBounds.x1) - spaceWidth : x1 + spaceWidth;
80502
80757
  y1 = this._getPolygonCenter(points).y;
80503
- x2 - x1 < FUNNEL_LABEL_LINE_LENGTH && (x2 = x1 + FUNNEL_LABEL_LINE_LENGTH);
80758
+ x2 - x1 < this._minLabelLineWidth && (x2 = x1 + this._minLabelLineWidth);
80504
80759
  y2 = y1;
80505
80760
  }
80506
80761
  else {
80507
80762
  x1 = this._getPolygonCenter(points).x - Math.max(labelWidth / 2, shapeMiddleWidth / 2) - spaceWidth;
80508
80763
  x2 = outerLabelSpec.alignLabel !== false ? (outerLabelMarkBounds === null || outerLabelMarkBounds === void 0 ? void 0 : outerLabelMarkBounds.x2) + spaceWidth : x1 - spaceWidth;
80509
80764
  y1 = this._getPolygonCenter(points).y;
80510
- x1 - x2 < FUNNEL_LABEL_LINE_LENGTH && (x2 = x1 - FUNNEL_LABEL_LINE_LENGTH);
80765
+ x1 - x2 < this._minLabelLineWidth && (x2 = x1 - this._minLabelLineWidth);
80511
80766
  y2 = y1;
80512
80767
  }
80513
80768
  return { x1, x2, y1, y2 };
@@ -92355,11 +92610,27 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
92355
92610
  });
92356
92611
  let filter = null;
92357
92612
  if (isContinuous()) {
92358
- filter = (d) => d[datumField] >= newDomain[0] && d[datumField] <= last(newDomain);
92613
+ filter = (d) => {
92614
+ let flag = false;
92615
+ array(datumField).every(field => {
92616
+ if (d[field] >= newDomain[0] && d[field] <= last(newDomain)) {
92617
+ flag = true;
92618
+ }
92619
+ return;
92620
+ });
92621
+ return flag;
92622
+ };
92359
92623
  }
92360
92624
  else {
92361
92625
  filter = (d) => {
92362
- return domainMap[d[datumField] + ''] || domainMap[d[datumField]];
92626
+ let flag = false;
92627
+ array(datumField).every(field => {
92628
+ if (domainMap[d[field] + ''] || domainMap[d[field]]) {
92629
+ flag = true;
92630
+ }
92631
+ return;
92632
+ });
92633
+ return flag;
92363
92634
  };
92364
92635
  }
92365
92636
  return data.filter(filter);
@@ -92769,18 +93040,28 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
92769
93040
  : yAxisHelper;
92770
93041
  const valueAxisHelper = stateAxisHelper === xAxisHelper ? yAxisHelper : xAxisHelper;
92771
93042
  const isValidateValueAxis = isContinuous(valueAxisHelper.getScale(0).type);
93043
+ const isValidateStateAxis = isContinuous(stateAxisHelper.getScale(0).type);
92772
93044
  dataCollection.push(s.getRawData());
92773
93045
  const seriesSpec = s.getSpec();
92774
- const xFields = array(seriesSpec.xField);
92775
- const yFields = array(seriesSpec.yField);
92776
- const xField = s.coordinate === 'cartesian' ? xFields[0] : (_a = seriesSpec.angleField) !== null && _a !== void 0 ? _a : seriesSpec.categoryField;
92777
- const yField = s.coordinate === 'cartesian' ? yFields[0] : (_b = seriesSpec.radiusField) !== null && _b !== void 0 ? _b : seriesSpec.valueField;
93046
+ const xField = s.coordinate === 'cartesian'
93047
+ ? array(seriesSpec.xField)
93048
+ : array((_a = seriesSpec.angleField) !== null && _a !== void 0 ? _a : seriesSpec.categoryField);
93049
+ const yField = s.coordinate === 'cartesian'
93050
+ ? array(seriesSpec.yField)
93051
+ : array((_b = seriesSpec.radiusField) !== null && _b !== void 0 ? _b : seriesSpec.valueField);
92778
93052
  originalStateFields[s.id] =
92779
- s.type === 'link' ? 'from_xField' : stateAxisHelper === xAxisHelper ? xField : yField;
92780
- stateFields.push(originalStateFields[s.id]);
93053
+ s.type === 'link' ? ['from_xField'] : stateAxisHelper === xAxisHelper ? xField : yField;
93054
+ if (isValidateStateAxis) {
93055
+ stateFields.push(originalStateFields[s.id]);
93056
+ }
93057
+ else {
93058
+ stateFields.push(originalStateFields[s.id][0]);
93059
+ }
92781
93060
  if (this._valueField) {
92782
- const valueField = s.type === 'link' ? 'from_yField' : valueAxisHelper === xAxisHelper ? xField : yField;
92783
- valueFields.push(isValidateValueAxis ? valueField : null);
93061
+ const valueField = s.type === 'link' ? ['from_yField'] : valueAxisHelper === xAxisHelper ? xField : yField;
93062
+ if (isValidateValueAxis) {
93063
+ valueFields.push(...valueField);
93064
+ }
92784
93065
  }
92785
93066
  }, {
92786
93067
  userId: this._seriesUserId,
@@ -96043,11 +96324,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96043
96324
  _getNeedClearVRenderComponents() {
96044
96325
  return [];
96045
96326
  }
96046
- _delegateLabelEvent(component) {
96047
- if (component.listenerCount('*') === 0) {
96048
- component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
96049
- }
96050
- }
96051
96327
  }
96052
96328
  BaseLabelComponent.type = ComponentTypeEnum.label;
96053
96329
 
@@ -96158,18 +96434,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96158
96434
  this.event.off(HOOK_EVENT.AFTER_MARK_RENDER_END, enableAnimation);
96159
96435
  };
96160
96436
  }
96161
- afterCompile() {
96162
- this._labelComponentMap.forEach((info, component) => {
96163
- const product = component.getProduct();
96164
- if (product) {
96165
- product.addEventListener(HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
96166
- if (this._isLayout === false) {
96167
- this._delegateLabelEvent(product.getGroupGraphicItem());
96168
- }
96169
- });
96170
- }
96171
- });
96172
- }
96173
96437
  _initTextMark() {
96174
96438
  if (!this._labelInfoMap) {
96175
96439
  this._labelInfoMap = new Map();
@@ -96344,7 +96608,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96344
96608
  }
96345
96609
  compileMarks() {
96346
96610
  this.getMarks().forEach(m => {
96347
- var _a;
96348
96611
  const labelInfo = this._labelComponentMap.get(m)();
96349
96612
  let group;
96350
96613
  if (isArray$1(labelInfo)) {
@@ -96353,13 +96616,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96353
96616
  else {
96354
96617
  group = labelInfo.series.getRegion().getGroupMark().getProduct();
96355
96618
  }
96356
- m.compile({ group });
96357
- (_a = m.getProduct()) === null || _a === void 0 ? void 0 : _a.configure({
96358
- context: {
96359
- model: this,
96360
- labelInfo
96361
- }
96362
- });
96619
+ m.compile({ group, context: { model: this, labelInfo } });
96363
96620
  });
96364
96621
  }
96365
96622
  getVRenderComponents() {
@@ -96418,6 +96675,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96418
96675
  this._initTextMark();
96419
96676
  this._initLabelComponent();
96420
96677
  }
96678
+ reInit(spec) {
96679
+ super.reInit(spec);
96680
+ this._initTextMark();
96681
+ }
96421
96682
  _initTextMark() {
96422
96683
  var _a;
96423
96684
  const series = this._getSeries();
@@ -96453,18 +96714,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96453
96714
  this._marks.addMark(component);
96454
96715
  }
96455
96716
  }
96456
- afterCompile() {
96457
- this._marks.forEach((componentMark, index) => {
96458
- const product = componentMark.getProduct();
96459
- if (product) {
96460
- product.addEventListener(HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
96461
- if (this._isLayout === false) {
96462
- this._delegateLabelEvent(product.getGroupGraphicItem());
96463
- }
96464
- });
96465
- }
96466
- });
96467
- }
96468
96717
  updateLayoutAttribute() {
96469
96718
  super.updateLayoutAttribute();
96470
96719
  const series = this._getSeries();
@@ -96506,14 +96755,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
96506
96755
  }
96507
96756
  compileMarks() {
96508
96757
  this.getMarks().forEach(m => {
96509
- var _a;
96510
96758
  const group = this._regions[0].getGroupMark().getProduct();
96511
- m.compile({ group });
96512
- (_a = m.getProduct()) === null || _a === void 0 ? void 0 : _a.configure({
96513
- context: {
96514
- model: this
96515
- }
96516
- });
96759
+ m.compile({ group, context: { model: this } });
96517
96760
  });
96518
96761
  }
96519
96762
  getVRenderComponents() {
@@ -97483,21 +97726,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
97483
97726
  }
97484
97727
  onRender(ctx) {
97485
97728
  }
97486
- afterCompile() {
97487
- this.getMarks().forEach(mark => {
97488
- const product = mark.getProduct();
97489
- if (product) {
97490
- product.addEventListener(HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
97491
- if (this._isLayout === false) {
97492
- const component = product.getGroupGraphicItem();
97493
- if ((component === null || component === void 0 ? void 0 : component.listenerCount('*')) === 0) {
97494
- component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
97495
- }
97496
- }
97497
- });
97498
- }
97499
- });
97500
- }
97501
97729
  _getMarkAttributeContext() {
97502
97730
  return {
97503
97731
  vchart: this._option.globalInstance,
@@ -100900,9 +101128,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
100900
101128
  });
100901
101129
  };
100902
101130
  }
100903
- afterCompile() {
100904
- super.afterCompile();
100905
- }
100906
101131
  _beforeInit() {
100907
101132
  if (this._dataSet) {
100908
101133
  registerDataSetInstanceTransform(this._dataSet, 'stackSplit', stackSplit);
@@ -101147,6 +101372,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
101147
101372
  this._reInit(false, false);
101148
101373
  }
101149
101374
  }
101375
+ onAfterModelSpecTransform(service, chartSpec, chartInfo, actionSource) {
101376
+ if (!this._initialized) {
101377
+ return;
101378
+ }
101379
+ if (actionSource === 'updateSpec') {
101380
+ this.onBeforeInitChart(service, chartSpec, 'setCurrentTheme');
101381
+ }
101382
+ }
101150
101383
  onBeforeInitChart(service, chartSpec, actionSource) {
101151
101384
  if (!this._initialized) {
101152
101385
  return;
@@ -101159,7 +101392,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
101159
101392
  resetMediaQuery = false;
101160
101393
  checkMediaQuery = true;
101161
101394
  break;
101162
- case 'updateSpec':
101163
101395
  case 'setCurrentTheme':
101164
101396
  resetMediaQuery = true;
101165
101397
  checkMediaQuery = false;