@visactor/vchart 1.13.22 → 1.13.23-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.
package/build/index.es.js CHANGED
@@ -80487,6 +80487,41 @@ const SHAPE_TYPE = [
80487
80487
  'rect'
80488
80488
  ];
80489
80489
 
80490
+ class WordMeasureCache {
80491
+ constructor(maxSize = 1000) {
80492
+ this._map = new Map();
80493
+ this._maxSize = maxSize;
80494
+ }
80495
+ get(key) {
80496
+ const v = this._map.get(key);
80497
+ if (!v) {
80498
+ return undefined;
80499
+ }
80500
+ this._map.delete(key);
80501
+ this._map.set(key, v);
80502
+ return v;
80503
+ }
80504
+ set(key, value) {
80505
+ if (this._map.has(key)) {
80506
+ this._map.set(key, value);
80507
+ return;
80508
+ }
80509
+ if (this._map.size >= this._maxSize) {
80510
+ const oldest = this._map.keys().next().value;
80511
+ if (oldest !== undefined) {
80512
+ this._map.delete(oldest);
80513
+ }
80514
+ }
80515
+ this._map.set(key, value);
80516
+ }
80517
+ clear() {
80518
+ this._map.clear();
80519
+ }
80520
+ size() {
80521
+ return this._map.size;
80522
+ }
80523
+ }
80524
+
80490
80525
  const WORD_CLOUD_TEXT = `${PREFIX}_WORD_CLOUD_TEXT`;
80491
80526
 
80492
80527
  const wordCloudSeriesMark = Object.assign(Object.assign({}, baseSeriesMark), { ["word"]: { name: "word", type: "text" }, ["fillingWord"]: { name: "fillingWord", type: "text" }, ["wordMask"]: { name: "wordMask", type: "rect" } });
@@ -80563,11 +80598,16 @@ class BaseWordCloudSeries extends BaseSeries {
80563
80598
  !SHAPE_TYPE.includes(this._maskShape) &&
80564
80599
  !['fast', 'grid', 'cloud'].includes(this._wordCloudConfig.layoutMode);
80565
80600
  this._defaultFontFamily = this._option.getTheme().fontFamily;
80601
+ if (!this._wordMeasureCache) {
80602
+ this._wordMeasureCache = new WordMeasureCache(1000);
80603
+ }
80566
80604
  }
80567
80605
  initData() {
80568
80606
  var _a, _b;
80569
80607
  super.initData();
80570
80608
  (_b = (_a = this.getViewData()) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.addListener('change', () => {
80609
+ var _a;
80610
+ (_a = this._wordMeasureCache) === null || _a === void 0 ? void 0 : _a.clear();
80571
80611
  this._dataChange = true;
80572
80612
  this.compile();
80573
80613
  });
@@ -80736,7 +80776,7 @@ class BaseWordCloudSeries extends BaseSeries {
80736
80776
  var _a, _b, _c, _d, _e, _f;
80737
80777
  const fillingWordStyleSpec = (_b = (_a = this._spec.fillingWord) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
80738
80778
  const wordCloudShapeConfig = (_c = this._wordCloudShapeConfig) !== null && _c !== void 0 ? _c : {};
80739
- return Object.assign(Object.assign(Object.assign({}, wordCloudShapeConfig), this._getCommonTransformOptions()), { rotateList: this._rotateAngles, fillingRotateList: wordCloudShapeConfig.fillingRotateAngles, fillingFontFamily: isValid$1(wordCloudShapeConfig.fillingFontFamilyField)
80779
+ return Object.assign(Object.assign(Object.assign({}, wordCloudShapeConfig), this._getCommonTransformOptions()), { measureCache: this._wordMeasureCache, rotateList: this._rotateAngles, fillingRotateList: wordCloudShapeConfig.fillingRotateAngles, fillingFontFamily: isValid$1(wordCloudShapeConfig.fillingFontFamilyField)
80740
80780
  ? { field: wordCloudShapeConfig.fillingFontFamilyField }
80741
80781
  : (_d = fillingWordStyleSpec.fontFamily) !== null && _d !== void 0 ? _d : this._defaultFontFamily, fillingPadding: (_f = (_e = this._spec.fillingWord) === null || _e === void 0 ? void 0 : _e.padding) !== null && _f !== void 0 ? _f : DEFAULT_FONT_PADDING, fillingFontStyle: isValid$1(wordCloudShapeConfig.fillingFontStyleField)
80742
80782
  ? { field: wordCloudShapeConfig.fillingFontStyleField }
@@ -80785,6 +80825,7 @@ class BaseWordCloudSeries extends BaseSeries {
80785
80825
  return [this._wordMark];
80786
80826
  }
80787
80827
  reInit() {
80828
+ var _a;
80788
80829
  super.reInit();
80789
80830
  if (this._keyWordColorCallback) {
80790
80831
  this._keyWordColorCallback = null;
@@ -80792,6 +80833,13 @@ class BaseWordCloudSeries extends BaseSeries {
80792
80833
  if (this._fillingColorCallback) {
80793
80834
  this._fillingColorCallback = null;
80794
80835
  }
80836
+ (_a = this._wordMeasureCache) === null || _a === void 0 ? void 0 : _a.clear();
80837
+ }
80838
+ release() {
80839
+ var _a;
80840
+ super.release();
80841
+ (_a = this._wordMeasureCache) === null || _a === void 0 ? void 0 : _a.clear();
80842
+ this._wordMeasureCache = undefined;
80795
80843
  }
80796
80844
  }
80797
80845
  BaseWordCloudSeries.mark = wordCloudSeriesMark;
@@ -81718,6 +81766,30 @@ var WORDCLOUD_SHAPE_HOOK_EVENT;
81718
81766
  !function (WORDCLOUD_SHAPE_HOOK_EVENT) {
81719
81767
  WORDCLOUD_SHAPE_HOOK_EVENT.BEFORE_WORDCLOUD_SHAPE_LAYOUT = "beforeWordcloudShapeLayout", WORDCLOUD_SHAPE_HOOK_EVENT.AFTER_WORDCLOUD_SHAPE_LAYOUT = "afterWordcloudShapeLayout", WORDCLOUD_SHAPE_HOOK_EVENT.AFTER_WORDCLOUD_SHAPE_DRAW = "afterWordcloudShapeDraw";
81720
81768
  }(WORDCLOUD_SHAPE_HOOK_EVENT || (WORDCLOUD_SHAPE_HOOK_EVENT = {}));
81769
+ class MapWordMeasureCache {
81770
+ constructor(maxSize = 1e3) {
81771
+ this._map = new Map(), this._maxSize = maxSize;
81772
+ }
81773
+ get(key) {
81774
+ const value = this._map.get(key);
81775
+ if (void 0 !== value) return this._map.delete(key), this._map.set(key, value), value;
81776
+ }
81777
+ set(key, value) {
81778
+ if (this._map.has(key)) this._map.set(key, value);else {
81779
+ if (this._map.size >= this._maxSize) {
81780
+ const firstKey = this._map.keys().next().value;
81781
+ void 0 !== firstKey && this._map.delete(firstKey);
81782
+ }
81783
+ this._map.set(key, value);
81784
+ }
81785
+ }
81786
+ clear() {
81787
+ this._map.clear();
81788
+ }
81789
+ size() {
81790
+ return this._map.size;
81791
+ }
81792
+ }
81721
81793
  const colorListEqual = (arr0, arr1) => {
81722
81794
  if (1 === arr1.length && "#537EF5" === arr1[0]) return !0;
81723
81795
  if (!Array.isArray(arr0) || !Array.isArray(arr1) || arr0.length !== arr1.length) return !1;
@@ -81957,7 +82029,7 @@ function layout(words, layoutConfig, segmentationOutput) {
81957
82029
  ratio: ratio
81958
82030
  } = region;
81959
82031
  for (let i = 0; i < regionWords.length; i++) {
81960
- measureSprite(canvas, ctx, words, i);
82032
+ measureSprite(canvas, ctx, words, i, layoutConfig.measureCache);
81961
82033
  const word = regionWords[i];
81962
82034
  word.x = center[0], word.y = center[1], word.hasText && word.sprite && place$1(board, word, maxR, ratio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
81963
82035
  }
@@ -81967,7 +82039,7 @@ function layout(words, layoutConfig, segmentationOutput) {
81967
82039
  if (0 === failedWords.length) break;
81968
82040
  for (let i = 0; i < failedWords.length; i++) {
81969
82041
  const word = failedWords[i];
81970
- measureSprite(canvas, ctx, failedWords, i), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
82042
+ measureSprite(canvas, ctx, failedWords, i, layoutConfig.measureCache), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
81971
82043
  }
81972
82044
  }
81973
82045
  layoutConfig.board = board;
@@ -82013,7 +82085,7 @@ function layoutGlobalShrink(words, layoutConfig, segmentationOutput) {
82013
82085
  } = region;
82014
82086
  let restartTag = !1;
82015
82087
  for (let i = 0; i < regionWords.length; i++) {
82016
- measureSprite(canvas, ctx, words, i);
82088
+ measureSprite(canvas, ctx, words, i, layoutConfig.measureCache);
82017
82089
  const word = regionWords[i];
82018
82090
  if (word.x = center[0], word.y = center[1], !word.skip && word.hasText && word.sprite && place$1(board, word, maxR, ratio, size, boardSize, stepFactor)) word.hasPlaced = !0;else {
82019
82091
  if (!word.skip && word.weight > weightStd && globalShinkFactor > globalShinkLimit) {
@@ -82038,7 +82110,7 @@ function layoutGlobalShrink(words, layoutConfig, segmentationOutput) {
82038
82110
  if (0 === failedWords.length) break;
82039
82111
  for (let i = 0; i < failedWords.length; i++) {
82040
82112
  const word = failedWords[i];
82041
- measureSprite(canvas, ctx, failedWords, i), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
82113
+ measureSprite(canvas, ctx, failedWords, i, layoutConfig.measureCache), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
82042
82114
  }
82043
82115
  }
82044
82116
  layoutConfig.board = board;
@@ -82083,7 +82155,7 @@ function layoutSelfEnlarge(words, layoutConfig, segmentationOutput) {
82083
82155
  } = region;
82084
82156
  let restartTag = !1;
82085
82157
  for (let i = 0; i < regionWords.length; i++) {
82086
- measureSprite(canvas, ctx, words, i);
82158
+ measureSprite(canvas, ctx, words, i, layoutConfig.measureCache);
82087
82159
  const word = regionWords[i];
82088
82160
  if (word.x = center[0], word.y = center[1], word.hasText && word.sprite && place$1(board, word, maxR, ratio, size, boardSize, stepFactor)) {
82089
82161
  if (word.hasPlaced = !0, word.weight >= weightStd && importantWordSuccessedNum++, importantWordSuccessedNum >= importantCount && !layoutFinish) {
@@ -82109,7 +82181,7 @@ function layoutSelfEnlarge(words, layoutConfig, segmentationOutput) {
82109
82181
  if (0 === failedWords.length) break;
82110
82182
  for (let i = 0; i < failedWords.length; i++) {
82111
82183
  const word = failedWords[i];
82112
- measureSprite(canvas, ctx, failedWords, i), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
82184
+ measureSprite(canvas, ctx, failedWords, i, layoutConfig.measureCache), word.x = shapeCenter[0], word.y = shapeCenter[1], word.hasText && place$1(board, word, shapeMaxR, shapeRatio, size, boardSize, stepFactor) && (word.hasPlaced = !0);
82113
82185
  }
82114
82186
  }
82115
82187
  layoutConfig.board = board;
@@ -82188,8 +82260,13 @@ function archimedeanSpiral(ratio) {
82188
82260
  return [ratio * (t *= .1) * Math.cos(t), t * Math.sin(t)];
82189
82261
  };
82190
82262
  }
82191
- function measureSprite(canvas, ctx, words, wi) {
82192
- if (words[wi].sprite || 0 === words[wi].fontSize) return;
82263
+ function measureSprite(canvas, ctx, words, wi, cache) {
82264
+ const targetWord = words[wi];
82265
+ if (targetWord.sprite || 0 === targetWord.fontSize) return;
82266
+ if (cache) {
82267
+ const cached = cache.get(getWordMeasureKey(targetWord));
82268
+ if (cached) return targetWord.sprite = cached.sprite, targetWord.bounds = cached.bounds, targetWord.wordSize = cached.wordSize, void (targetWord.hasText = !0);
82269
+ }
82193
82270
  const cw = 2048,
82194
82271
  radians = Math.PI / 180,
82195
82272
  n = words.length;
@@ -82252,14 +82329,25 @@ function measureSprite(canvas, ctx, words, wi) {
82252
82329
  }
82253
82330
  seen && (j < dTop && (dTop = j), j > dBottom && (dBottom = j));
82254
82331
  }
82255
- word.bounds = {
82332
+ if (word.bounds = {
82256
82333
  dTop: (wordSize[1] >> 1) - dTop,
82257
82334
  dBottom: dBottom - (wordSize[1] >> 1),
82258
82335
  dLeft: (wordSize[0] >> 1) - dLeft,
82259
82336
  dRight: dRight - (wordSize[0] >> 1)
82260
- }, word.sprite = sprite, delete word.LT;
82337
+ }, word.sprite = sprite, cache) {
82338
+ const key = getWordMeasureKey(word);
82339
+ cache.set(key, {
82340
+ sprite: sprite,
82341
+ bounds: word.bounds,
82342
+ wordSize: wordSize
82343
+ });
82344
+ }
82345
+ delete word.LT;
82261
82346
  }
82262
82347
  }
82348
+ function getWordMeasureKey(word) {
82349
+ return String(word.text) + "|" + String(word.fontFamily) + "|" + String(word.fontStyle) + "|" + String(word.fontWeight) + "|" + String(word.fontSize) + "|" + String(word.rotate) + "|" + String(word.padding);
82350
+ }
82263
82351
  function initBoardWithShape(segmentationOutput) {
82264
82352
  const {
82265
82353
  segmentation: {
@@ -82356,7 +82444,7 @@ function filling(words, layoutConfig, segmentationOutput) {
82356
82444
  } = shapeBounds,
82357
82445
  [startX, startY] = [x1 + ~~(randomGenerator() * fillingXStep * 2), y1 + ~~(randomGenerator() * fillingYStep * 2)];
82358
82446
  for (let y = startY; y <= y2; y += fillingYStep) for (let x = startX; x <= x2; x += fillingXStep) {
82359
- measureSprite(canvas, ctx, fillingWords, wi);
82447
+ measureSprite(canvas, ctx, fillingWords, wi, layoutConfig.measureCache);
82360
82448
  const word = fillingWords[wi];
82361
82449
  word.x = x, word.y = y;
82362
82450
  const {
@@ -82473,7 +82561,7 @@ class Layout {
82473
82561
  return this.progressiveResult;
82474
82562
  }
82475
82563
  doLayout() {
82476
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
82564
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
82477
82565
  const segmentationInput = this.segmentationInput,
82478
82566
  segmentationOutput = segmentation(segmentationInput);
82479
82567
  if (!segmentationOutput.segmentation.regions.length) return;
@@ -82500,35 +82588,36 @@ class Layout {
82500
82588
  const layoutConfig = {
82501
82589
  size: options.size,
82502
82590
  ratio: options.ratio || .8,
82591
+ measureCache: null !== (_a = options.measureCache) && void 0 !== _a ? _a : new MapWordMeasureCache(),
82503
82592
  shapeUrl: options.shape,
82504
82593
  random: void 0 === options.random || options.random,
82505
- textLayoutTimes: null !== (_a = options.textLayoutTimes) && void 0 !== _a ? _a : 3,
82594
+ textLayoutTimes: null !== (_b = options.textLayoutTimes) && void 0 !== _b ? _b : 3,
82506
82595
  removeWhiteBorder: options.removeWhiteBorder,
82507
- layoutMode: null !== (_b = options.layoutMode) && void 0 !== _b ? _b : "default",
82508
- fontSizeShrinkFactor: null !== (_c = options.fontSizeShrinkFactor) && void 0 !== _c ? _c : .8,
82509
- stepFactor: null !== (_d = options.stepFactor) && void 0 !== _d ? _d : 1,
82510
- importantWordCount: null !== (_e = options.importantWordCount) && void 0 !== _e ? _e : 10,
82596
+ layoutMode: null !== (_c = options.layoutMode) && void 0 !== _c ? _c : "default",
82597
+ fontSizeShrinkFactor: null !== (_d = options.fontSizeShrinkFactor) && void 0 !== _d ? _d : .8,
82598
+ stepFactor: null !== (_e = options.stepFactor) && void 0 !== _e ? _e : 1,
82599
+ importantWordCount: null !== (_f = options.importantWordCount) && void 0 !== _f ? _f : 10,
82511
82600
  globalShinkLimit: options.globalShinkLimit || .2,
82512
- fontSizeEnlargeFactor: null !== (_f = options.fontSizeEnlargeFactor) && void 0 !== _f ? _f : 1.5,
82513
- fillingRatio: null !== (_g = options.fillingRatio) && void 0 !== _g ? _g : .7,
82514
- fillingTimes: null !== (_h = options.fillingTimes) && void 0 !== _h ? _h : 4,
82515
- fillingXStep: options.fillingXRatioStep ? Math.max(Math.floor(options.size[0] * options.fillingXRatioStep), 1) : null !== (_j = options.fillingXStep) && void 0 !== _j ? _j : 4,
82516
- fillingYStep: options.fillingYRatioStep ? Math.max(Math.floor(options.size[1] * options.fillingYRatioStep), 1) : null !== (_k = options.fillingYStep) && void 0 !== _k ? _k : 4,
82601
+ fontSizeEnlargeFactor: null !== (_g = options.fontSizeEnlargeFactor) && void 0 !== _g ? _g : 1.5,
82602
+ fillingRatio: null !== (_h = options.fillingRatio) && void 0 !== _h ? _h : .7,
82603
+ fillingTimes: null !== (_j = options.fillingTimes) && void 0 !== _j ? _j : 4,
82604
+ fillingXStep: options.fillingXRatioStep ? Math.max(Math.floor(options.size[0] * options.fillingXRatioStep), 1) : null !== (_k = options.fillingXStep) && void 0 !== _k ? _k : 4,
82605
+ fillingYStep: options.fillingYRatioStep ? Math.max(Math.floor(options.size[1] * options.fillingYRatioStep), 1) : null !== (_l = options.fillingYStep) && void 0 !== _l ? _l : 4,
82517
82606
  fillingInitialFontSize: options.fillingInitialFontSize,
82518
82607
  fillingDeltaFontSize: options.fillingDeltaFontSize,
82519
- fillingInitialOpacity: null !== (_l = options.fillingInitialOpacity) && void 0 !== _l ? _l : .8,
82520
- fillingDeltaOpacity: null !== (_m = options.fillingDeltaOpacity) && void 0 !== _m ? _m : .05,
82608
+ fillingInitialOpacity: null !== (_m = options.fillingInitialOpacity) && void 0 !== _m ? _m : .8,
82609
+ fillingDeltaOpacity: null !== (_o = options.fillingDeltaOpacity) && void 0 !== _o ? _o : .05,
82521
82610
  getFillingFontFamily: field(options.fillingFontFamily || "sans-serif"),
82522
82611
  getFillingFontStyle: field(options.fillingFontStyle || "normal"),
82523
82612
  getFillingFontWeight: field(options.fillingFontWeight || "normal"),
82524
- getFillingPadding: field(null !== (_o = options.fillingPadding) && void 0 !== _o ? _o : .4),
82525
- fillingRotateList: null !== (_p = options.fillingRotateList) && void 0 !== _p ? _p : [0, 90],
82526
- fillingDeltaFontSizeFactor: null !== (_q = options.fillingDeltaFontSizeFactor) && void 0 !== _q ? _q : .2,
82613
+ getFillingPadding: field(null !== (_p = options.fillingPadding) && void 0 !== _p ? _p : .4),
82614
+ fillingRotateList: null !== (_q = options.fillingRotateList) && void 0 !== _q ? _q : [0, 90],
82615
+ fillingDeltaFontSizeFactor: null !== (_r = options.fillingDeltaFontSizeFactor) && void 0 !== _r ? _r : .2,
82527
82616
  fillingColorList: options.fillingColorList || ["#537EF5"],
82528
82617
  sameColorList: !1,
82529
- minInitFontSize: null !== (_r = options.minInitFontSize) && void 0 !== _r ? _r : 10,
82530
- minFontSize: null !== (_s = options.minFontSize) && void 0 !== _s ? _s : 4,
82531
- minFillFontSize: null !== (_t = options.minFillFontSize) && void 0 !== _t ? _t : 2
82618
+ minInitFontSize: null !== (_s = options.minInitFontSize) && void 0 !== _s ? _s : 10,
82619
+ minFontSize: null !== (_t = options.minFontSize) && void 0 !== _t ? _t : 4,
82620
+ minFillFontSize: null !== (_u = options.minFillFontSize) && void 0 !== _u ? _u : 2
82532
82621
  },
82533
82622
  sameColorList = colorListEqual(wordsConfig.colorList, layoutConfig.fillingColorList);
82534
82623
  layoutConfig.sameColorList = sameColorList, initColorScale(data, wordsConfig, layoutConfig, options), initFillingWordsFontSize(data, wordsConfig, layoutConfig, segmentationOutput);
@@ -82575,8 +82664,8 @@ class Layout {
82575
82664
  successedWords: successedWords,
82576
82665
  failedWords: failedWords
82577
82666
  } = cloud(words, layoutConfig, segmentationOutput),
82578
- textKey = null !== (_v = null === (_u = options.text) || void 0 === _u ? void 0 : _u.field) && void 0 !== _v ? _v : "textKey",
82579
- dataIndexKey = null !== (_w = options.dataIndexKey) && void 0 !== _w ? _w : "defaultDataIndexKey",
82667
+ textKey = null !== (_w = null === (_v = options.text) || void 0 === _v ? void 0 : _v.field) && void 0 !== _w ? _w : "textKey",
82668
+ dataIndexKey = null !== (_x = options.dataIndexKey) && void 0 !== _x ? _x : "defaultDataIndexKey",
82580
82669
  as = options.as ? Object.assign(Object.assign({}, OUTPUT), options.as) : OUTPUT;
82581
82670
  let w, t;
82582
82671
  const modKeywords = [];
@@ -82591,7 +82680,7 @@ class Layout {
82591
82680
  successedWords: successedWords,
82592
82681
  failedWords: failedWords
82593
82682
  });
82594
- const stage = null === (_x = this.view.renderer) || void 0 === _x ? void 0 : _x.stage();
82683
+ const stage = null === (_y = this.view.renderer) || void 0 === _y ? void 0 : _y.stage();
82595
82684
  stage && stage.hooks.afterRender.tap(WORDCLOUD_SHAPE_HOOK_EVENT.AFTER_WORDCLOUD_SHAPE_DRAW, () => {
82596
82685
  this.view.emit(WORDCLOUD_SHAPE_HOOK_EVENT.AFTER_WORDCLOUD_SHAPE_DRAW, {
82597
82686
  successedWords: successedWords,
@@ -104214,10 +104303,6 @@ class ScrollPlugin extends BasePlugin {
104214
104303
  };
104215
104304
  this.onWheel = (e) => {
104216
104305
  var _a, _b;
104217
- if (this._spec.preventDefault !== false) {
104218
- e.preventDefault();
104219
- e.stopPropagation();
104220
- }
104221
104306
  const scrollX = e.deltaX;
104222
104307
  const scrollY = e.deltaY;
104223
104308
  const rootMark = this.getRootMark();
@@ -104227,6 +104312,7 @@ class ScrollPlugin extends BasePlugin {
104227
104312
  const { percent: yPercent, y } = (_a = this._computeFinalScrollY(rootMark.attribute.y - scrollY)) !== null && _a !== void 0 ? _a : {};
104228
104313
  const { percent: xPercent, x } = (_b = this._computeFinalScrollX(rootMark.attribute.x - scrollX)) !== null && _b !== void 0 ? _b : {};
104229
104314
  const eventResult = {};
104315
+ const isScroll = isValidNumber$1(x) || isValidNumber$1(y);
104230
104316
  if (isValidNumber$1(x)) {
104231
104317
  this._updateScrollX(rootMark, x, xPercent);
104232
104318
  eventResult.x = x;
@@ -104235,6 +104321,12 @@ class ScrollPlugin extends BasePlugin {
104235
104321
  this._updateScrollY(rootMark, y, yPercent);
104236
104322
  eventResult.y = y;
104237
104323
  }
104324
+ if (isScroll) {
104325
+ if (this._spec.preventDefault !== false) {
104326
+ e.preventDefault();
104327
+ e.stopPropagation();
104328
+ }
104329
+ }
104238
104330
  this._event.emit('chartScroll', eventResult);
104239
104331
  };
104240
104332
  }
@@ -104291,6 +104383,7 @@ class ScrollPlugin extends BasePlugin {
104291
104383
  }
104292
104384
  _computeFinalScrollY(y) {
104293
104385
  var _a;
104386
+ y = Math.max(this._scrollLimit.y.min, Math.min(y, this._scrollLimit.y.max));
104294
104387
  if (this._lastScrollY === y) {
104295
104388
  return null;
104296
104389
  }
@@ -104298,15 +104391,15 @@ class ScrollPlugin extends BasePlugin {
104298
104391
  if (((_a = this._spec.y) === null || _a === void 0 ? void 0 : _a.enable) === false) {
104299
104392
  return null;
104300
104393
  }
104301
- const finalY = Math.max(this._scrollLimit.y.min, Math.min(y, this._scrollLimit.y.max));
104302
- const percent = Math.abs(finalY / this._scrollLimit.y.size);
104394
+ const percent = Math.abs(y / this._scrollLimit.y.size);
104303
104395
  return {
104304
- y: finalY,
104396
+ y,
104305
104397
  percent
104306
104398
  };
104307
104399
  }
104308
104400
  _computeFinalScrollX(x) {
104309
104401
  var _a;
104402
+ x = Math.max(this._scrollLimit.x.min, Math.min(x, this._scrollLimit.x.max));
104310
104403
  if (this._lastScrollX === x) {
104311
104404
  return null;
104312
104405
  }
@@ -104314,10 +104407,9 @@ class ScrollPlugin extends BasePlugin {
104314
104407
  if (((_a = this._spec.x) === null || _a === void 0 ? void 0 : _a.enable) === false) {
104315
104408
  return null;
104316
104409
  }
104317
- const finalX = Math.max(this._scrollLimit.x.min, Math.min(x, this._scrollLimit.x.max));
104318
- const percent = Math.abs(finalX / this._scrollLimit.x.size);
104410
+ const percent = Math.abs(x / this._scrollLimit.x.size);
104319
104411
  return {
104320
- x: finalX,
104412
+ x,
104321
104413
  percent
104322
104414
  };
104323
104415
  }