@visactor/vchart-extension 2.1.5 → 2.1.6-alpha.1

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 (51) hide show
  1. package/build/index.js +205 -31
  2. package/build/index.min.js +1 -1
  3. package/cjs/charts/3d/arc-3d.js +1 -1
  4. package/cjs/charts/3d/enum.js +1 -1
  5. package/cjs/charts/3d/graphic-creator.js +1 -1
  6. package/cjs/charts/3d/interface.js +1 -1
  7. package/cjs/charts/3d/layout.js +1 -1
  8. package/cjs/charts/3d/plugin.js +1 -1
  9. package/cjs/charts/3d/pyramid-3d.js +1 -1
  10. package/cjs/charts/3d/rect-3d.js +1 -1
  11. package/cjs/charts/3d/util.js +1 -1
  12. package/cjs/charts/axis-3d/axis-3d-mixin.js +1 -1
  13. package/cjs/charts/axis-3d/band-axis.js +1 -1
  14. package/cjs/charts/axis-3d/index.js +1 -1
  15. package/cjs/charts/axis-3d/linear-axis.js +1 -1
  16. package/cjs/charts/bar-3d/chart-spec-transformer.js +2 -1
  17. package/cjs/charts/bar-3d/interface.js +1 -2
  18. package/cjs/charts/candlestick/candlestick-transformer.js +1 -1
  19. package/cjs/charts/candlestick/candlestick.js +1 -1
  20. package/cjs/charts/candlestick/index.js +1 -1
  21. package/cjs/charts/candlestick/interface.js +1 -1
  22. package/cjs/charts/candlestick/util.js +1 -1
  23. package/cjs/components/extension-mark-sync-state/type.js +1 -2
  24. package/cjs/components/histogram-regression-line/type.js +2 -1
  25. package/cjs/components/series-break/util.js +2 -1
  26. package/cjs/components/series-label/util.js +1 -2
  27. package/esm/charts/3d/arc-3d.js +1 -1
  28. package/esm/charts/3d/enum.js +1 -1
  29. package/esm/charts/3d/graphic-creator.js +1 -1
  30. package/esm/charts/3d/interface.js +1 -1
  31. package/esm/charts/3d/layout.js +1 -1
  32. package/esm/charts/3d/plugin.js +1 -1
  33. package/esm/charts/3d/pyramid-3d.js +1 -1
  34. package/esm/charts/3d/rect-3d.js +1 -1
  35. package/esm/charts/3d/util.js +1 -1
  36. package/esm/charts/axis-3d/axis-3d-mixin.js +1 -1
  37. package/esm/charts/axis-3d/band-axis.js +1 -1
  38. package/esm/charts/axis-3d/index.js +1 -1
  39. package/esm/charts/axis-3d/linear-axis.js +1 -1
  40. package/esm/charts/bar-3d/chart-spec-transformer.js +2 -1
  41. package/esm/charts/bar-3d/interface.js +1 -2
  42. package/esm/charts/candlestick/candlestick-transformer.js +1 -1
  43. package/esm/charts/candlestick/candlestick.js +1 -1
  44. package/esm/charts/candlestick/index.js +1 -1
  45. package/esm/charts/candlestick/interface.js +1 -1
  46. package/esm/charts/candlestick/util.js +1 -1
  47. package/esm/components/extension-mark-sync-state/type.js +1 -2
  48. package/esm/components/histogram-regression-line/type.js +2 -1
  49. package/esm/components/series-break/util.js +2 -1
  50. package/esm/components/series-label/util.js +1 -2
  51. package/package.json +8 -8
package/build/index.js CHANGED
@@ -6451,18 +6451,21 @@
6451
6451
  }
6452
6452
  }
6453
6453
 
6454
- function getScaledStroke(context, width, dpr) {
6454
+ function getScaledStrokeWithMatrix(matrix, width, dpr) {
6455
6455
  let strokeWidth = width;
6456
6456
  const {
6457
6457
  a: a,
6458
6458
  b: b,
6459
6459
  c: c,
6460
6460
  d: d
6461
- } = context.currentMatrix,
6461
+ } = matrix,
6462
6462
  scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
6463
6463
  scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
6464
6464
  return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
6465
6465
  }
6466
+ function getScaledStroke(context, width, dpr) {
6467
+ return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);
6468
+ }
6466
6469
  function createColor(context, c, params, offsetX = 0, offsetY = 0) {
6467
6470
  var _a, _b, _c, _d;
6468
6471
  if (!c || !0 === c) return "black";
@@ -7164,7 +7167,7 @@
7164
7167
  }
7165
7168
  class StateTransitionOrchestrator {
7166
7169
  analyzeTransition(targetAttrs, hasAnimation, options = {}) {
7167
- var _a, _b;
7170
+ var _a, _b, _c, _d;
7168
7171
  const plan = {
7169
7172
  targetAttrs: Object.assign({}, targetAttrs),
7170
7173
  animateAttrs: {},
@@ -7173,10 +7176,17 @@
7173
7176
  if (!hasAnimation) return plan;
7174
7177
  const noWorkAnimateAttr = Object.assign(Object.assign({}, null !== (_a = options.noWorkAnimateAttr) && void 0 !== _a ? _a : {}), normalizeNoAnimateAttrConfig(null === (_b = options.animateConfig) || void 0 === _b ? void 0 : _b.noAnimateAttrs)),
7175
7178
  isClear = !0 === options.isClear,
7176
- readDefaultAttribute = options.getDefaultAttribute,
7179
+ getDefaultAttribute = options.getDefaultAttribute,
7180
+ readDefaultAttribute = getDefaultAttribute,
7181
+ readStateTransitionDefaultAttribute = null !== (_c = options.getStateTransitionDefaultAttribute) && void 0 !== _c ? _c : getDefaultAttribute,
7177
7182
  shouldSkipDefaultAttribute = options.shouldSkipDefaultAttribute,
7178
- assignTransitionAttr = (key, value) => {
7179
- if (noWorkAnimateAttr[key]) plan.noAnimateAttrs[key] = value;else if (isClear && void 0 === value) {
7183
+ stateTransitionTargetAttrs = null !== (_d = options.stateTransitionTargetAttrs) && void 0 !== _d ? _d : targetAttrs,
7184
+ assignTransitionAttr = (key, value, isRemovedStateAttr = !1) => {
7185
+ if (noWorkAnimateAttr[key]) plan.noAnimateAttrs[key] = value;else if (isRemovedStateAttr && void 0 === value) {
7186
+ const defaultValue = null == readStateTransitionDefaultAttribute ? void 0 : readStateTransitionDefaultAttribute(key, stateTransitionTargetAttrs);
7187
+ if (void 0 === defaultValue && (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, stateTransitionTargetAttrs))) return;
7188
+ plan.animateAttrs[key] = defaultValue;
7189
+ } else if (isClear && void 0 === value) {
7180
7190
  if (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, targetAttrs)) return;
7181
7191
  plan.animateAttrs[key] = readDefaultAttribute(key);
7182
7192
  } else plan.animateAttrs[key] = value;
@@ -7188,7 +7198,7 @@
7188
7198
  const extraAnimateAttrs = options.extraAnimateAttrs;
7189
7199
  if (extraAnimateAttrs) for (const key in extraAnimateAttrs) {
7190
7200
  const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetAttrs, key);
7191
- !Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key]);
7201
+ !Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key], !0);
7192
7202
  }
7193
7203
  return plan;
7194
7204
  }
@@ -7220,9 +7230,11 @@
7220
7230
  noWorkAnimateAttr: graphic.getNoWorkAnimateAttr(),
7221
7231
  isClear: !0,
7222
7232
  getDefaultAttribute: graphic.getDefaultAttribute.bind(graphic),
7233
+ getStateTransitionDefaultAttribute: options.getStateTransitionDefaultAttribute,
7223
7234
  shouldSkipDefaultAttribute: null !== (_a = options.shouldSkipDefaultAttribute) && void 0 !== _a ? _a : graphic.shouldSkipStateTransitionDefaultAttribute.bind(graphic),
7224
7235
  animateConfig: options.animateConfig,
7225
- extraAnimateAttrs: options.extraAnimateAttrs
7236
+ extraAnimateAttrs: options.extraAnimateAttrs,
7237
+ stateTransitionTargetAttrs: options.stateTransitionTargetAttrs
7226
7238
  });
7227
7239
  return this.applyTransition(graphic, plan, hasAnimation, options);
7228
7240
  }
@@ -7497,21 +7509,20 @@
7497
7509
  }), snapshot) : snapshot;
7498
7510
  }
7499
7511
  buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
7500
- const extraAttrs = {};
7501
- if (!previousResolvedStatePatch) return extraAttrs;
7512
+ if (!previousResolvedStatePatch) return;
7502
7513
  const snapshot = this.buildStaticAttributeSnapshot(),
7503
- staticTargetAttrs = snapshot;
7514
+ extraAttrs = {};
7504
7515
  return Object.keys(previousResolvedStatePatch).forEach(key => {
7505
7516
  const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
7506
7517
  if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
7507
7518
  const assignFallbackAttr = value => {
7508
- void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
7519
+ extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value);
7509
7520
  };
7510
- if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
7511
- const snapshotValue = snapshot[key];
7512
- assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
7513
- } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
7514
- }), extraAttrs;
7521
+ hasTargetAttr ? assignFallbackAttr(targetStateAttrs[key]) : Object.prototype.hasOwnProperty.call(snapshot, key) ? assignFallbackAttr(snapshot[key]) : assignFallbackAttr(void 0);
7522
+ }), {
7523
+ extraAttrs: extraAttrs,
7524
+ stateTransitionTargetAttrs: snapshot
7525
+ };
7515
7526
  }
7516
7527
  syncObjectToSnapshot(target, snapshot, excludedKeys) {
7517
7528
  const delta = new Map();
@@ -8227,29 +8238,37 @@
8227
8238
  resolvedStateAttrs: resolvedStateAttrs
8228
8239
  } = this.resolveGraphicStateTransition(states, !0),
8229
8240
  patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
8230
- patchChanged && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) || (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged && (hasAnimation && animateSameStatePatchChange ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8241
+ if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged)) if (hasAnimation && animateSameStatePatchChange) {
8242
+ this._syncFinalAttributeFromStaticTruth();
8243
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
8244
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
8245
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8231
8246
  type: AttributeUpdateType.STATE
8232
8247
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
8233
8248
  type: AttributeUpdateType.STATE
8234
- }), this.emitStateUpdateEvent())));
8249
+ }), this.emitStateUpdateEvent();
8235
8250
  }
8236
8251
  resolveStateAnimateConfig(animateConfig) {
8237
8252
  var _a, _b, _c;
8238
8253
  return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : DefaultStateAnimateConfig;
8239
8254
  }
8240
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
8255
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs, stateTransitionTargetAttrs) {
8241
8256
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0,
8242
8257
  transitionOptions = resolvedAnimateConfig ? {
8243
8258
  animateConfig: resolvedAnimateConfig,
8244
8259
  extraAnimateAttrs: extraAnimateAttrs,
8245
- shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
8260
+ getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
8261
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
8262
+ stateTransitionTargetAttrs: stateTransitionTargetAttrs
8246
8263
  } : void 0;
8247
8264
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, transitionOptions);
8248
8265
  const plan = this.getStateTransitionOrchestrator().analyzeTransition(attrs, hasAnimation, {
8249
8266
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
8250
8267
  animateConfig: resolvedAnimateConfig,
8251
8268
  extraAnimateAttrs: extraAnimateAttrs,
8252
- shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
8269
+ getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
8270
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
8271
+ stateTransitionTargetAttrs: stateTransitionTargetAttrs
8253
8272
  });
8254
8273
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
8255
8274
  }
@@ -8276,11 +8295,15 @@
8276
8295
  transition = this.resolveClearStatesTransition();
8277
8296
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
8278
8297
  const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
8279
- transition.changed && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0) || (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8298
+ if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), hasAnimation) {
8299
+ this._syncFinalAttributeFromStaticTruth();
8300
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
8301
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
8302
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8280
8303
  type: AttributeUpdateType.STATE
8281
8304
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
8282
8305
  type: AttributeUpdateType.STATE
8283
- }), this.emitStateUpdateEvent()));
8306
+ }), this.emitStateUpdateEvent();
8284
8307
  }
8285
8308
  removeState(stateName, hasAnimation) {
8286
8309
  const transition = this.resolveRemoveStateTransition(stateName);
@@ -8321,11 +8344,15 @@
8321
8344
  effectiveStates: effectiveStates,
8322
8345
  resolvedStateAttrs: resolvedStateAttrs
8323
8346
  } = this.resolveGraphicStateTransition(states);
8324
- !transition.changed && this.sameStateNames(previousStates, transition.states) || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8347
+ if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation) {
8348
+ this._syncFinalAttributeFromStaticTruth();
8349
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
8350
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
8351
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
8325
8352
  type: AttributeUpdateType.STATE
8326
8353
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
8327
8354
  type: AttributeUpdateType.STATE
8328
- }), this.emitStateUpdateEvent()));
8355
+ }), this.emitStateUpdateEvent();
8329
8356
  }
8330
8357
  invalidateResolver() {
8331
8358
  var _a, _b;
@@ -10316,7 +10343,7 @@
10316
10343
  }
10317
10344
 
10318
10345
  var _a;
10319
- const factoryRegistryKey = Symbol.for("@visactor/vchart/factory-registry@2.1.5"),
10346
+ const factoryRegistryKey = Symbol.for("@visactor/vchart/factory-registry@2.1.4"),
10320
10347
  globalFactoryRegistry = globalThis;
10321
10348
  const factoryRegistry = null !== (_a = globalFactoryRegistry[factoryRegistryKey]) && void 0 !== _a ? _a : globalFactoryRegistry[factoryRegistryKey] = {
10322
10349
  charts: {},
@@ -10843,7 +10870,132 @@
10843
10870
  cap: 1
10844
10871
  }, NOWORK_ANIMATE_ATTR);
10845
10872
 
10846
- const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
10873
+ function getPolygonWinding(points) {
10874
+ let signedArea = 0;
10875
+ for (let i = 0; i < points.length; i++) {
10876
+ const current = points[i],
10877
+ next = points[(i + 1) % points.length];
10878
+ signedArea += current.x * next.y - next.x * current.y;
10879
+ }
10880
+ return signedArea > 0 ? 1 : -1;
10881
+ }
10882
+ function offsetPolygonPoints(points, distance, closePath = !0) {
10883
+ var _a;
10884
+ const n = null !== (_a = null == points ? void 0 : points.length) && void 0 !== _a ? _a : 0;
10885
+ if (n < 2 || closePath && n < 3 || !distance) return points;
10886
+ const sign = getPolygonWinding(points),
10887
+ edgeCount = closePath ? n : n - 1,
10888
+ lines = [];
10889
+ for (let i = 0; i < edgeCount; i++) {
10890
+ const cur = points[i],
10891
+ next = points[(i + 1) % n],
10892
+ dx = next.x - cur.x,
10893
+ dy = next.y - cur.y,
10894
+ len = Math.sqrt(dx * dx + dy * dy);
10895
+ if (!len) {
10896
+ lines.push(null);
10897
+ continue;
10898
+ }
10899
+ const offsetX = sign * dy * distance / len,
10900
+ offsetY = -sign * dx * distance / len;
10901
+ lines.push({
10902
+ x: cur.x + offsetX,
10903
+ y: cur.y + offsetY,
10904
+ dx: dx,
10905
+ dy: dy,
10906
+ len: len,
10907
+ offsetX: offsetX,
10908
+ offsetY: offsetY
10909
+ });
10910
+ }
10911
+ const prevLines = new Array(n);
10912
+ let prevLine = null;
10913
+ if (closePath) for (let i = edgeCount - 1; i >= 0; i--) if (lines[i]) {
10914
+ prevLine = lines[i];
10915
+ break;
10916
+ }
10917
+ for (let i = 0; i < n; i++) prevLines[i] = prevLine, i < edgeCount && lines[i] && (prevLine = lines[i]);
10918
+ const nextLines = new Array(n);
10919
+ let nextLine = null;
10920
+ if (closePath) for (let count = 0; count < edgeCount; count++) {
10921
+ const line = lines[(n - 1 + count) % edgeCount];
10922
+ if (line) {
10923
+ nextLine = line;
10924
+ break;
10925
+ }
10926
+ }
10927
+ for (let i = n - 1; i >= 0; i--) i < edgeCount && lines[i] && (nextLine = lines[i]), nextLines[i] = nextLine;
10928
+ const offsetPointByLine = (point, line) => ({
10929
+ x: point.x + line.offsetX,
10930
+ y: point.y + line.offsetY
10931
+ }),
10932
+ result = [];
10933
+ for (let i = 0; i < n; i++) {
10934
+ const prev = prevLines[i],
10935
+ cur = nextLines[i],
10936
+ line = prev || cur;
10937
+ if (!line) {
10938
+ result.push(points[i]);
10939
+ continue;
10940
+ }
10941
+ if (!prev || !cur) {
10942
+ result.push(offsetPointByLine(points[i], line));
10943
+ continue;
10944
+ }
10945
+ const denominator = prev.dx * cur.dy - prev.dy * cur.dx;
10946
+ if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {
10947
+ result.push(offsetPointByLine(points[i], cur));
10948
+ continue;
10949
+ }
10950
+ const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator,
10951
+ point = {
10952
+ x: prev.x + prev.dx * t,
10953
+ y: prev.y + prev.dy * t
10954
+ };
10955
+ result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));
10956
+ }
10957
+ return result;
10958
+ }
10959
+
10960
+ const getBoundsScaleMatrix = polygon => {
10961
+ var _a;
10962
+ const globalMatrix = polygon.globalTransMatrix,
10963
+ viewBoxMatrix = null === (_a = polygon.stage) || void 0 === _a ? void 0 : _a.window.getViewBoxTransform();
10964
+ return viewBoxMatrix ? {
10965
+ a: viewBoxMatrix.a * globalMatrix.a + viewBoxMatrix.c * globalMatrix.b,
10966
+ b: viewBoxMatrix.b * globalMatrix.a + viewBoxMatrix.d * globalMatrix.b,
10967
+ c: viewBoxMatrix.a * globalMatrix.c + viewBoxMatrix.c * globalMatrix.d,
10968
+ d: viewBoxMatrix.b * globalMatrix.c + viewBoxMatrix.d * globalMatrix.d
10969
+ } : globalMatrix;
10970
+ };
10971
+ const getPolygonBoundsScale = polygon => getScaledStrokeWithMatrix(getBoundsScaleMatrix(polygon), 1, 1);
10972
+ const updateBoundsOfPolygonOuterBorder = (attribute, polygonTheme, aabbBounds, polygon) => {
10973
+ const {
10974
+ outerBorder: outerBorder,
10975
+ points = polygonTheme.points,
10976
+ closePath = polygonTheme.closePath,
10977
+ shadowBlur = polygonTheme.shadowBlur,
10978
+ keepStrokeScale = polygonTheme.keepStrokeScale
10979
+ } = attribute;
10980
+ if (outerBorder && !1 !== outerBorder.visible) {
10981
+ const defaultOuterBorder = polygonTheme.outerBorder,
10982
+ {
10983
+ distance = defaultOuterBorder.distance,
10984
+ lineWidth = defaultOuterBorder.lineWidth,
10985
+ lineJoin = defaultOuterBorder.lineJoin,
10986
+ strokeBoundsBuffer = defaultOuterBorder.strokeBoundsBuffer
10987
+ } = outerBorder,
10988
+ boundsScale = getPolygonBoundsScale(polygon);
10989
+ let scaledDistance = distance;
10990
+ keepStrokeScale || (scaledDistance *= boundsScale), offsetPolygonPoints(points, scaledDistance, closePath).forEach(point => {
10991
+ aabbBounds.add(point.x, point.y);
10992
+ });
10993
+ boundStroke(aabbBounds, (shadowBlur * boundsScale + lineWidth * (keepStrokeScale ? 1 : boundsScale)) / 2, "miter" === lineJoin, strokeBoundsBuffer);
10994
+ }
10995
+ return aabbBounds;
10996
+ };
10997
+
10998
+ const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", "outerBorder", "keepStrokeScale", ...GRAPHIC_UPDATE_TAG_KEY];
10847
10999
  class Polygon extends Graphic {
10848
11000
  constructor(params) {
10849
11001
  super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
@@ -10860,6 +11012,16 @@
10860
11012
  getGraphicTheme() {
10861
11013
  return getTheme(this).polygon;
10862
11014
  }
11015
+ tryUpdateAABBBounds() {
11016
+ const {
11017
+ outerBorder: outerBorder
11018
+ } = this.attribute;
11019
+ if (outerBorder && !1 !== outerBorder.visible) {
11020
+ const boundsScale = getPolygonBoundsScale(this);
11021
+ boundsScale !== this._outerBorderBoundsScale && (this._outerBorderBoundsScale = boundsScale, this.addUpdateBoundTag());
11022
+ } else this._outerBorderBoundsScale = void 0;
11023
+ return super.tryUpdateAABBBounds();
11024
+ }
10863
11025
  updateAABBBounds(attribute, polygonTheme, aabbBounds) {
10864
11026
  this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
10865
11027
  const {
@@ -10873,7 +11035,7 @@
10873
11035
  } = attribute;
10874
11036
  return points.forEach(p => {
10875
11037
  aabbBounds.add(p.x, p.y);
10876
- }), aabbBounds;
11038
+ }), updateBoundsOfPolygonOuterBorder(attribute, polygonTheme, aabbBounds, this), aabbBounds;
10877
11039
  }
10878
11040
  _interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
10879
11041
  "points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
@@ -13118,7 +13280,8 @@
13118
13280
  const DrawContribution = Symbol.for("DrawContribution");
13119
13281
 
13120
13282
  const DrawItemInterceptor = Symbol.for("DrawItemInterceptor");
13121
- const tempDirtyBounds = new vutils.AABBBounds(),
13283
+ const INTERACTIVE_POST_MATRIX = "_interactivePostMatrix",
13284
+ tempDirtyBounds = new vutils.AABBBounds(),
13122
13285
  tempBackupDirtyBounds = new vutils.AABBBounds();
13123
13286
  class ShadowRootDrawItemInterceptorContribution {
13124
13287
  constructor() {
@@ -13182,12 +13345,23 @@
13182
13345
  beforeDrawItem(graphic, renderService, drawContext, drawContribution, params) {
13183
13346
  return !this.processing && (graphic.baseGraphic ? this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params) : this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params));
13184
13347
  }
13348
+ resolveInteractivePostMatrix(graphic, interactiveGraphic) {
13349
+ const parent = graphic.parent;
13350
+ if (!parent) return graphic.attribute.postMatrix;
13351
+ let matrix = interactiveGraphic[INTERACTIVE_POST_MATRIX];
13352
+ matrix || (matrix = new vutils.Matrix(), interactiveGraphic[INTERACTIVE_POST_MATRIX] = matrix);
13353
+ const ancestorMatrix = parent.globalTransMatrix;
13354
+ matrix.setValue(ancestorMatrix.a, ancestorMatrix.b, ancestorMatrix.c, ancestorMatrix.d, ancestorMatrix.e, ancestorMatrix.f);
13355
+ const ownPostMatrix = graphic.attribute.postMatrix;
13356
+ return ownPostMatrix && matrix.multiply(ownPostMatrix.a, ownPostMatrix.b, ownPostMatrix.c, ownPostMatrix.d, ownPostMatrix.e, ownPostMatrix.f), matrix;
13357
+ }
13185
13358
  beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params) {
13186
13359
  let interactiveGraphic = graphic.interactiveGraphic;
13187
13360
  if (graphic.attribute.globalZIndex) {
13188
13361
  interactiveGraphic || (interactiveGraphic = graphic.clone(), graphic.interactiveGraphic = interactiveGraphic, interactiveGraphic.baseGraphic = graphic), interactiveGraphic.setAttributes({
13189
13362
  globalZIndex: 0,
13190
- zIndex: graphic.attribute.globalZIndex
13363
+ zIndex: graphic.attribute.globalZIndex,
13364
+ postMatrix: this.resolveInteractivePostMatrix(graphic, interactiveGraphic)
13191
13365
  }, !1, {
13192
13366
  skipUpdateCallback: !0
13193
13367
  }), drawContext.stage.tryInitInteractiveLayer();