@visactor/vchart 2.1.0-alpha.3 → 2.1.0-alpha.4

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
@@ -72657,6 +72657,7 @@ class AxisComponent extends BaseComponent {
72657
72657
  }
72658
72658
  }
72659
72659
  _compareSpec(spec, prevSpec) {
72660
+ var _a, _b;
72660
72661
  const result = super._compareSpec(spec, prevSpec);
72661
72662
  if (result.reMake) {
72662
72663
  return result;
@@ -72667,10 +72668,10 @@ class AxisComponent extends BaseComponent {
72667
72668
  result.reMake = true;
72668
72669
  return result;
72669
72670
  }
72670
- result.reMake = ['grid', 'subGrid', 'tick', 'subTick', 'label', 'domainLine', 'title'].some(k => {
72671
- var _a, _b;
72672
- return ((_a = prevSpec === null || prevSpec === void 0 ? void 0 : prevSpec[k]) === null || _a === void 0 ? void 0 : _a.visible) !== ((_b = spec === null || spec === void 0 ? void 0 : spec[k]) === null || _b === void 0 ? void 0 : _b.visible);
72673
- });
72671
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.grid) === null || _a === void 0 ? void 0 : _a.visible) === true && ((_b = prevSpec === null || prevSpec === void 0 ? void 0 : prevSpec.grid) === null || _b === void 0 ? void 0 : _b.visible) !== true && !this._gridMark) {
72672
+ result.reMake = true;
72673
+ return result;
72674
+ }
72674
72675
  if (specChanged && !result.reMake && this._isComponentOnlySpecChange(spec, prevSpec)) {
72675
72676
  result.effects = Object.assign(Object.assign({}, result.effects), { component: true, layout: true, render: true });
72676
72677
  }
@@ -75957,6 +75958,21 @@ const MARKER_COMPONENT_SPEC_KEYS = {
75957
75958
  [ComponentTypeEnum.markLine]: true,
75958
75959
  [ComponentTypeEnum.markArea]: true
75959
75960
  };
75961
+ const MARKER_ADDITION_REMAKE_SPEC_KEYS = {
75962
+ autoRange: true,
75963
+ regionId: true,
75964
+ regionIndex: true,
75965
+ seriesId: true,
75966
+ seriesIndex: true,
75967
+ relativeSeriesId: true,
75968
+ relativeSeriesIndex: true,
75969
+ startRelativeSeriesId: true,
75970
+ startRelativeSeriesIndex: true,
75971
+ endRelativeSeriesId: true,
75972
+ endRelativeSeriesIndex: true,
75973
+ specifiedDataSeriesId: true,
75974
+ specifiedDataSeriesIndex: true
75975
+ };
75960
75976
  class BaseChart extends CompilableBase {
75961
75977
  getSpec() {
75962
75978
  return this._spec;
@@ -76131,6 +76147,12 @@ class BaseChart extends CompilableBase {
76131
76147
  this.getComponentsByType = (type) => {
76132
76148
  return this._components.filter(c => c.type === type);
76133
76149
  };
76150
+ this._isMarkerAdditionSpecSafeWithoutRemake = (spec) => {
76151
+ if (!spec || typeof spec !== 'object' || spec.visible === false) {
76152
+ return false;
76153
+ }
76154
+ return !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some(key => !isNil$1(spec[key]));
76155
+ };
76134
76156
  this._paddingSpec = normalizeLayoutPaddingSpec((_a = spec.padding) !== null && _a !== void 0 ? _a : option.getTheme('padding'));
76135
76157
  this._event = new Event$1(option.eventDispatcher, option.mode);
76136
76158
  this._dataSet = option.dataSet;
@@ -76530,7 +76552,7 @@ class BaseChart extends CompilableBase {
76530
76552
  .sort();
76531
76553
  }
76532
76554
  updateSpec(spec) {
76533
- var _a;
76555
+ var _a, _b;
76534
76556
  const result = {
76535
76557
  change: false,
76536
76558
  reMake: false,
@@ -76556,7 +76578,7 @@ class BaseChart extends CompilableBase {
76556
76578
  const nextSpec = spec[key];
76557
76579
  if (isArray$1(currentSpec) &&
76558
76580
  currentSpec.length !== array(nextSpec).length &&
76559
- !this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) {
76581
+ !this._canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) {
76560
76582
  result.reMake = true;
76561
76583
  this.setLayoutTag(true, null, false);
76562
76584
  return result;
@@ -76591,6 +76613,9 @@ class BaseChart extends CompilableBase {
76591
76613
  this.setLayoutTag(true, null, false);
76592
76614
  return result;
76593
76615
  }
76616
+ if (!onlyComponentSpecsChanged && ((_a = result.effects) === null || _a === void 0 ? void 0 : _a.localOnly)) {
76617
+ delete result.effects.localOnly;
76618
+ }
76594
76619
  if (isUpdateSpecResultLocalOnly(result)) {
76595
76620
  return result;
76596
76621
  }
@@ -76600,7 +76625,7 @@ class BaseChart extends CompilableBase {
76600
76625
  componentUpdateResult.componentOnlyUpdatedComponents.forEach(component => {
76601
76626
  component.reInit(component.getSpec());
76602
76627
  });
76603
- if ((_a = result.effects) === null || _a === void 0 ? void 0 : _a.layout) {
76628
+ if ((_b = result.effects) === null || _b === void 0 ? void 0 : _b.layout) {
76604
76629
  this.setLayoutTag(true, null, false);
76605
76630
  }
76606
76631
  return result;
@@ -76613,7 +76638,9 @@ class BaseChart extends CompilableBase {
76613
76638
  this.reInit();
76614
76639
  if (!onlySeriesSpecsChanged || !this._canSkipChartDataStages(result)) {
76615
76640
  this.updateDataSpec();
76616
- this.updateGlobalScaleDomain();
76641
+ this.reDataFlow();
76642
+ this._reRunStackDataFlow();
76643
+ this.getAllModels().forEach(model => model.onDataUpdate());
76617
76644
  }
76618
76645
  return result;
76619
76646
  }
@@ -76696,6 +76723,9 @@ class BaseChart extends CompilableBase {
76696
76723
  mergeUpdateResult(result, componentResult);
76697
76724
  }
76698
76725
  });
76726
+ if (!result.reMake) {
76727
+ this._createMissingMarkerComponentsForSpecs(result, componentCache);
76728
+ }
76699
76729
  for (const key in componentCache) {
76700
76730
  if (Object.prototype.hasOwnProperty.call(componentCache, key)) {
76701
76731
  const element = componentCache[key];
@@ -76726,6 +76756,19 @@ class BaseChart extends CompilableBase {
76726
76756
  hasNonComponentOnlyUpdate
76727
76757
  };
76728
76758
  }
76759
+ _canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76760
+ return (this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) ||
76761
+ this._canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec));
76762
+ }
76763
+ _canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76764
+ if (!MARKER_COMPONENT_SPEC_KEYS[key] || !isArray$1(currentSpec) || !isArray$1(nextSpec)) {
76765
+ return false;
76766
+ }
76767
+ if (nextSpec.length <= currentSpec.length) {
76768
+ return false;
76769
+ }
76770
+ return nextSpec.slice(currentSpec.length).every(this._isMarkerAdditionSpecSafeWithoutRemake);
76771
+ }
76729
76772
  _canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76730
76773
  return (MARKER_COMPONENT_SPEC_KEYS[key] &&
76731
76774
  isArray$1(currentSpec) &&
@@ -76745,6 +76788,9 @@ class BaseChart extends CompilableBase {
76745
76788
  return hasMarkerRemoval && onlyMarkerRemoval;
76746
76789
  }
76747
76790
  _isComponentSpecKey(key) {
76791
+ if (MARKER_COMPONENT_SPEC_KEYS[key]) {
76792
+ return true;
76793
+ }
76748
76794
  return this._components.some(component => {
76749
76795
  return (component.specKey || component.type) === key;
76750
76796
  });
@@ -76804,6 +76850,57 @@ class BaseChart extends CompilableBase {
76804
76850
  !result.changeTheme &&
76805
76851
  !result.changeBackground);
76806
76852
  }
76853
+ _reRunStackDataFlow() {
76854
+ var _a, _b;
76855
+ if (!this._series.some(series => { var _a; return (_a = series.getStack) === null || _a === void 0 ? void 0 : _a.call(series); })) {
76856
+ return;
76857
+ }
76858
+ (_b = (_a = this._stack) === null || _a === void 0 ? void 0 : _a.stackAll) === null || _b === void 0 ? void 0 : _b.call(_a);
76859
+ this._series.forEach(series => {
76860
+ if (series.getViewDataFilter()) {
76861
+ series.reTransformViewData();
76862
+ }
76863
+ });
76864
+ }
76865
+ _getModelSpecIndex(specInfo) {
76866
+ var _a;
76867
+ const specPath = (_a = specInfo.specPath) !== null && _a !== void 0 ? _a : [];
76868
+ const specIndex = specPath[specPath.length - 1];
76869
+ return typeof specIndex === 'number' ? specIndex : 0;
76870
+ }
76871
+ _hasComponentForSpecInfo(key, specInfo) {
76872
+ const specIndex = this._getModelSpecIndex(specInfo);
76873
+ return this._components.some(component => {
76874
+ return (component.specKey || component.type) === key && component.getSpecIndex() === specIndex;
76875
+ });
76876
+ }
76877
+ _createMissingMarkerComponentsForSpecs(result, componentCache) {
76878
+ var _a;
76879
+ let createdCount = 0;
76880
+ (_a = this._specTransformer) === null || _a === void 0 ? void 0 : _a.forEachComponentInSpec(this._spec, (constructor, specInfo) => {
76881
+ if (result.reMake) {
76882
+ return;
76883
+ }
76884
+ const compSpecKey = constructor.specKey || constructor.type;
76885
+ if (!MARKER_COMPONENT_SPEC_KEYS[compSpecKey] || this._hasComponentForSpecInfo(compSpecKey, specInfo)) {
76886
+ return;
76887
+ }
76888
+ if (!this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec)) {
76889
+ result.reMake = true;
76890
+ return;
76891
+ }
76892
+ this._createComponent(constructor, specInfo);
76893
+ if (componentCache[compSpecKey]) {
76894
+ componentCache[compSpecKey].componentCount++;
76895
+ }
76896
+ createdCount++;
76897
+ }, this._option.getSpecInfo());
76898
+ if (!createdCount) {
76899
+ return;
76900
+ }
76901
+ result.change = true;
76902
+ result.effects = Object.assign(Object.assign({}, result.effects), { component: true, layout: true, render: true });
76903
+ }
76807
76904
  _removeMarkerComponentsForEmptySpecs(result) {
76808
76905
  const removedComponents = this._components.filter(component => {
76809
76906
  var _a;
package/build/index.js CHANGED
@@ -72663,6 +72663,7 @@
72663
72663
  }
72664
72664
  }
72665
72665
  _compareSpec(spec, prevSpec) {
72666
+ var _a, _b;
72666
72667
  const result = super._compareSpec(spec, prevSpec);
72667
72668
  if (result.reMake) {
72668
72669
  return result;
@@ -72673,10 +72674,10 @@
72673
72674
  result.reMake = true;
72674
72675
  return result;
72675
72676
  }
72676
- result.reMake = ['grid', 'subGrid', 'tick', 'subTick', 'label', 'domainLine', 'title'].some(k => {
72677
- var _a, _b;
72678
- return ((_a = prevSpec === null || prevSpec === void 0 ? void 0 : prevSpec[k]) === null || _a === void 0 ? void 0 : _a.visible) !== ((_b = spec === null || spec === void 0 ? void 0 : spec[k]) === null || _b === void 0 ? void 0 : _b.visible);
72679
- });
72677
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.grid) === null || _a === void 0 ? void 0 : _a.visible) === true && ((_b = prevSpec === null || prevSpec === void 0 ? void 0 : prevSpec.grid) === null || _b === void 0 ? void 0 : _b.visible) !== true && !this._gridMark) {
72678
+ result.reMake = true;
72679
+ return result;
72680
+ }
72680
72681
  if (specChanged && !result.reMake && this._isComponentOnlySpecChange(spec, prevSpec)) {
72681
72682
  result.effects = Object.assign(Object.assign({}, result.effects), { component: true, layout: true, render: true });
72682
72683
  }
@@ -75963,6 +75964,21 @@
75963
75964
  [ComponentTypeEnum.markLine]: true,
75964
75965
  [ComponentTypeEnum.markArea]: true
75965
75966
  };
75967
+ const MARKER_ADDITION_REMAKE_SPEC_KEYS = {
75968
+ autoRange: true,
75969
+ regionId: true,
75970
+ regionIndex: true,
75971
+ seriesId: true,
75972
+ seriesIndex: true,
75973
+ relativeSeriesId: true,
75974
+ relativeSeriesIndex: true,
75975
+ startRelativeSeriesId: true,
75976
+ startRelativeSeriesIndex: true,
75977
+ endRelativeSeriesId: true,
75978
+ endRelativeSeriesIndex: true,
75979
+ specifiedDataSeriesId: true,
75980
+ specifiedDataSeriesIndex: true
75981
+ };
75966
75982
  class BaseChart extends CompilableBase {
75967
75983
  getSpec() {
75968
75984
  return this._spec;
@@ -76137,6 +76153,12 @@
76137
76153
  this.getComponentsByType = (type) => {
76138
76154
  return this._components.filter(c => c.type === type);
76139
76155
  };
76156
+ this._isMarkerAdditionSpecSafeWithoutRemake = (spec) => {
76157
+ if (!spec || typeof spec !== 'object' || spec.visible === false) {
76158
+ return false;
76159
+ }
76160
+ return !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some(key => !isNil$1(spec[key]));
76161
+ };
76140
76162
  this._paddingSpec = normalizeLayoutPaddingSpec((_a = spec.padding) !== null && _a !== void 0 ? _a : option.getTheme('padding'));
76141
76163
  this._event = new Event$1(option.eventDispatcher, option.mode);
76142
76164
  this._dataSet = option.dataSet;
@@ -76536,7 +76558,7 @@
76536
76558
  .sort();
76537
76559
  }
76538
76560
  updateSpec(spec) {
76539
- var _a;
76561
+ var _a, _b;
76540
76562
  const result = {
76541
76563
  change: false,
76542
76564
  reMake: false,
@@ -76562,7 +76584,7 @@
76562
76584
  const nextSpec = spec[key];
76563
76585
  if (isArray$1(currentSpec) &&
76564
76586
  currentSpec.length !== array(nextSpec).length &&
76565
- !this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) {
76587
+ !this._canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) {
76566
76588
  result.reMake = true;
76567
76589
  this.setLayoutTag(true, null, false);
76568
76590
  return result;
@@ -76597,6 +76619,9 @@
76597
76619
  this.setLayoutTag(true, null, false);
76598
76620
  return result;
76599
76621
  }
76622
+ if (!onlyComponentSpecsChanged && ((_a = result.effects) === null || _a === void 0 ? void 0 : _a.localOnly)) {
76623
+ delete result.effects.localOnly;
76624
+ }
76600
76625
  if (isUpdateSpecResultLocalOnly(result)) {
76601
76626
  return result;
76602
76627
  }
@@ -76606,7 +76631,7 @@
76606
76631
  componentUpdateResult.componentOnlyUpdatedComponents.forEach(component => {
76607
76632
  component.reInit(component.getSpec());
76608
76633
  });
76609
- if ((_a = result.effects) === null || _a === void 0 ? void 0 : _a.layout) {
76634
+ if ((_b = result.effects) === null || _b === void 0 ? void 0 : _b.layout) {
76610
76635
  this.setLayoutTag(true, null, false);
76611
76636
  }
76612
76637
  return result;
@@ -76619,7 +76644,9 @@
76619
76644
  this.reInit();
76620
76645
  if (!onlySeriesSpecsChanged || !this._canSkipChartDataStages(result)) {
76621
76646
  this.updateDataSpec();
76622
- this.updateGlobalScaleDomain();
76647
+ this.reDataFlow();
76648
+ this._reRunStackDataFlow();
76649
+ this.getAllModels().forEach(model => model.onDataUpdate());
76623
76650
  }
76624
76651
  return result;
76625
76652
  }
@@ -76702,6 +76729,9 @@
76702
76729
  mergeUpdateResult(result, componentResult);
76703
76730
  }
76704
76731
  });
76732
+ if (!result.reMake) {
76733
+ this._createMissingMarkerComponentsForSpecs(result, componentCache);
76734
+ }
76705
76735
  for (const key in componentCache) {
76706
76736
  if (Object.prototype.hasOwnProperty.call(componentCache, key)) {
76707
76737
  const element = componentCache[key];
@@ -76732,6 +76762,19 @@
76732
76762
  hasNonComponentOnlyUpdate
76733
76763
  };
76734
76764
  }
76765
+ _canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76766
+ return (this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) ||
76767
+ this._canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec));
76768
+ }
76769
+ _canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76770
+ if (!MARKER_COMPONENT_SPEC_KEYS[key] || !isArray$1(currentSpec) || !isArray$1(nextSpec)) {
76771
+ return false;
76772
+ }
76773
+ if (nextSpec.length <= currentSpec.length) {
76774
+ return false;
76775
+ }
76776
+ return nextSpec.slice(currentSpec.length).every(this._isMarkerAdditionSpecSafeWithoutRemake);
76777
+ }
76735
76778
  _canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
76736
76779
  return (MARKER_COMPONENT_SPEC_KEYS[key] &&
76737
76780
  isArray$1(currentSpec) &&
@@ -76751,6 +76794,9 @@
76751
76794
  return hasMarkerRemoval && onlyMarkerRemoval;
76752
76795
  }
76753
76796
  _isComponentSpecKey(key) {
76797
+ if (MARKER_COMPONENT_SPEC_KEYS[key]) {
76798
+ return true;
76799
+ }
76754
76800
  return this._components.some(component => {
76755
76801
  return (component.specKey || component.type) === key;
76756
76802
  });
@@ -76810,6 +76856,57 @@
76810
76856
  !result.changeTheme &&
76811
76857
  !result.changeBackground);
76812
76858
  }
76859
+ _reRunStackDataFlow() {
76860
+ var _a, _b;
76861
+ if (!this._series.some(series => { var _a; return (_a = series.getStack) === null || _a === void 0 ? void 0 : _a.call(series); })) {
76862
+ return;
76863
+ }
76864
+ (_b = (_a = this._stack) === null || _a === void 0 ? void 0 : _a.stackAll) === null || _b === void 0 ? void 0 : _b.call(_a);
76865
+ this._series.forEach(series => {
76866
+ if (series.getViewDataFilter()) {
76867
+ series.reTransformViewData();
76868
+ }
76869
+ });
76870
+ }
76871
+ _getModelSpecIndex(specInfo) {
76872
+ var _a;
76873
+ const specPath = (_a = specInfo.specPath) !== null && _a !== void 0 ? _a : [];
76874
+ const specIndex = specPath[specPath.length - 1];
76875
+ return typeof specIndex === 'number' ? specIndex : 0;
76876
+ }
76877
+ _hasComponentForSpecInfo(key, specInfo) {
76878
+ const specIndex = this._getModelSpecIndex(specInfo);
76879
+ return this._components.some(component => {
76880
+ return (component.specKey || component.type) === key && component.getSpecIndex() === specIndex;
76881
+ });
76882
+ }
76883
+ _createMissingMarkerComponentsForSpecs(result, componentCache) {
76884
+ var _a;
76885
+ let createdCount = 0;
76886
+ (_a = this._specTransformer) === null || _a === void 0 ? void 0 : _a.forEachComponentInSpec(this._spec, (constructor, specInfo) => {
76887
+ if (result.reMake) {
76888
+ return;
76889
+ }
76890
+ const compSpecKey = constructor.specKey || constructor.type;
76891
+ if (!MARKER_COMPONENT_SPEC_KEYS[compSpecKey] || this._hasComponentForSpecInfo(compSpecKey, specInfo)) {
76892
+ return;
76893
+ }
76894
+ if (!this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec)) {
76895
+ result.reMake = true;
76896
+ return;
76897
+ }
76898
+ this._createComponent(constructor, specInfo);
76899
+ if (componentCache[compSpecKey]) {
76900
+ componentCache[compSpecKey].componentCount++;
76901
+ }
76902
+ createdCount++;
76903
+ }, this._option.getSpecInfo());
76904
+ if (!createdCount) {
76905
+ return;
76906
+ }
76907
+ result.change = true;
76908
+ result.effects = Object.assign(Object.assign({}, result.effects), { component: true, layout: true, render: true });
76909
+ }
76813
76910
  _removeMarkerComponentsForEmptySpecs(result) {
76814
76911
  const removedComponents = this._components.filter(component => {
76815
76912
  var _a;