@visactor/react-vchart 2.1.0-alpha.3 → 2.1.0-alpha.5

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.js CHANGED
@@ -55847,11 +55847,13 @@
55847
55847
  }
55848
55848
  renderMarks() {
55849
55849
  var _a;
55850
- this._hasCommitedMark() && (log(`--- start of renderMarks(${this._count}) ---`), this.clearProgressive(), this._rootMarks.forEach(mark => {
55850
+ let hasCommitedMark = this._hasCommitedMark();
55851
+ const needsLayout = this._layoutState === LayoutState.before;
55852
+ (hasCommitedMark || needsLayout) && (log(`--- start of renderMarks(${this._count}) ---`), this.clearProgressive(), hasCommitedMark && this._rootMarks.forEach(mark => {
55851
55853
  mark.render();
55852
- }), this._layoutState === LayoutState.before && (this._layoutState = LayoutState.layouting, null === (_a = this._compileChart) || void 0 === _a || _a.onLayout(), this._layoutState = LayoutState.reevaluate, this._hasCommitedMark() && this._rootMarks.forEach(mark => {
55854
+ }), needsLayout && (this._layoutState = LayoutState.layouting, null === (_a = this._compileChart) || void 0 === _a || _a.onLayout(), this._layoutState = LayoutState.reevaluate, hasCommitedMark = this._hasCommitedMark(), hasCommitedMark && this._rootMarks.forEach(mark => {
55853
55855
  mark.render();
55854
- }), this.handleLayoutEnd()), this.findProgressiveMarks(), this.updateStateAnimation(), this._doRender(!0), this.doPreProgressive(), log(`--- start of renderMarks(${this._count}) ---`), this._count++);
55856
+ }), this.handleLayoutEnd()), hasCommitedMark && (this.findProgressiveMarks(), this.updateStateAnimation()), this._doRender(!0), hasCommitedMark && this.doPreProgressive(), log(`--- start of renderMarks(${this._count}) ---`), this._count++);
55855
55857
  }
55856
55858
  reuseOrMorphing(morphConfig = {}) {
55857
55859
  const {
@@ -64017,17 +64019,15 @@
64017
64019
  }
64018
64020
  }
64019
64021
  _compareSpec(spec, prevSpec) {
64022
+ var _a, _b;
64020
64023
  const result = super._compareSpec(spec, prevSpec);
64021
64024
  if (result.reMake) return result;
64022
64025
  const specChanged = !isEqual(prevSpec, spec);
64023
- return result.reRender = !0, (null == prevSpec ? void 0 : prevSpec.type) !== (null == spec ? void 0 : spec.type) || (null == prevSpec ? void 0 : prevSpec.visible) !== (null == spec ? void 0 : spec.visible) ? (result.reMake = !0, result) : (result.reMake = ["grid", "subGrid", "tick", "subTick", "label", "domainLine", "title"].some(k => {
64024
- var _a, _b;
64025
- return (null === (_a = null == prevSpec ? void 0 : prevSpec[k]) || void 0 === _a ? void 0 : _a.visible) !== (null === (_b = null == spec ? void 0 : spec[k]) || void 0 === _b ? void 0 : _b.visible);
64026
- }), specChanged && !result.reMake && this._isComponentOnlySpecChange(spec, prevSpec) && (result.effects = Object.assign(Object.assign({}, result.effects), {
64026
+ return result.reRender = !0, (null == prevSpec ? void 0 : prevSpec.type) !== (null == spec ? void 0 : spec.type) || (null == prevSpec ? void 0 : prevSpec.visible) !== (null == spec ? void 0 : spec.visible) ? (result.reMake = !0, result) : !0 !== (null === (_a = null == spec ? void 0 : spec.grid) || void 0 === _a ? void 0 : _a.visible) || !0 === (null === (_b = null == prevSpec ? void 0 : prevSpec.grid) || void 0 === _b ? void 0 : _b.visible) || this._gridMark ? (specChanged && !result.reMake && this._isComponentOnlySpecChange(spec, prevSpec) && (result.effects = Object.assign(Object.assign({}, result.effects), {
64027
64027
  component: !0,
64028
64028
  layout: !0,
64029
64029
  render: !0
64030
- })), result);
64030
+ })), result) : (result.reMake = !0, result);
64031
64031
  }
64032
64032
  _isComponentOnlySpecChange(spec, prevSpec) {
64033
64033
  return Object.keys(Object.assign(Object.assign({}, prevSpec), spec)).every(key => isEqual(null == prevSpec ? void 0 : prevSpec[key], null == spec ? void 0 : spec[key]) || AXIS_COMPONENT_ONLY_CHANGE_KEYS[key]);
@@ -66320,10 +66320,25 @@
66320
66320
  return t;
66321
66321
  };
66322
66322
  const MARKER_COMPONENT_SPEC_KEYS = {
66323
- [ComponentTypeEnum.markPoint]: !0,
66324
- [ComponentTypeEnum.markLine]: !0,
66325
- [ComponentTypeEnum.markArea]: !0
66326
- };
66323
+ [ComponentTypeEnum.markPoint]: !0,
66324
+ [ComponentTypeEnum.markLine]: !0,
66325
+ [ComponentTypeEnum.markArea]: !0
66326
+ },
66327
+ MARKER_ADDITION_REMAKE_SPEC_KEYS = {
66328
+ autoRange: !0,
66329
+ regionId: !0,
66330
+ regionIndex: !0,
66331
+ seriesId: !0,
66332
+ seriesIndex: !0,
66333
+ relativeSeriesId: !0,
66334
+ relativeSeriesIndex: !0,
66335
+ startRelativeSeriesId: !0,
66336
+ startRelativeSeriesIndex: !0,
66337
+ endRelativeSeriesId: !0,
66338
+ endRelativeSeriesIndex: !0,
66339
+ specifiedDataSeriesId: !0,
66340
+ specifiedDataSeriesIndex: !0
66341
+ };
66327
66342
  let BaseChart$1 = class BaseChart extends CompilableBase {
66328
66343
  getSpec() {
66329
66344
  return this._spec;
@@ -66399,7 +66414,7 @@
66399
66414
  }, this.getComponentsByKey = key => this._components.filter(c => (c.specKey || c.type) === key), this.getComponentByUserId = userId => {
66400
66415
  const component = this._components.find(s => s.userId === userId);
66401
66416
  if (component) return component;
66402
- }, this.getComponentsByType = type => this._components.filter(c => c.type === type), this._paddingSpec = normalizeLayoutPaddingSpec(null !== (_a = spec.padding) && void 0 !== _a ? _a : option.getTheme("padding")), this._event = new Event$1(option.eventDispatcher, option.mode), this._dataSet = option.dataSet, this._chartData = new ChartData(this._dataSet), this._modelOption = Object.assign(Object.assign({}, option), {
66417
+ }, this.getComponentsByType = type => this._components.filter(c => c.type === type), this._isMarkerAdditionSpecSafeWithoutRemake = spec => !(!spec || "object" != typeof spec || !1 === spec.visible) && !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some(key => !isNil$1(spec[key])), this._paddingSpec = normalizeLayoutPaddingSpec(null !== (_a = spec.padding) && void 0 !== _a ? _a : option.getTheme("padding")), this._event = new Event$1(option.eventDispatcher, option.mode), this._dataSet = option.dataSet, this._chartData = new ChartData(this._dataSet), this._modelOption = Object.assign(Object.assign({}, option), {
66403
66418
  mode: this._option.mode,
66404
66419
  map: this._idMap,
66405
66420
  getChartLayoutRect: () => this._layoutRect,
@@ -66713,7 +66728,7 @@
66713
66728
  return Object.keys(spec).filter(key => !ignoreKeys[key]).sort();
66714
66729
  }
66715
66730
  updateSpec(spec) {
66716
- var _a;
66731
+ var _a, _b;
66717
66732
  const result = {
66718
66733
  change: !1,
66719
66734
  reMake: !1,
@@ -66729,7 +66744,7 @@
66729
66744
  const key = currentKeys[i],
66730
66745
  currentSpec = this._spec[key],
66731
66746
  nextSpec = spec[key];
66732
- if (isArray$1(currentSpec) && currentSpec.length !== array(nextSpec).length && !this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) return result.reMake = !0, this.setLayoutTag(!0, null, !1), result;
66747
+ if (isArray$1(currentSpec) && currentSpec.length !== array(nextSpec).length && !this._canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) return result.reMake = !0, this.setLayoutTag(!0, null, !1), result;
66733
66748
  }
66734
66749
  const oldSpec = this._spec,
66735
66750
  onlyMarkerComponentsRemoved = this._isOnlyMarkerComponentsRemoved(this._spec, spec, currentKeys),
@@ -66740,9 +66755,9 @@
66740
66755
  if (this.updateGlobalScale(result), result.reMake) return this.setLayoutTag(!0, null, !1), result;
66741
66756
  if (this.updateRegionSpec(result), result.reMake) return this.setLayoutTag(!0, null, !1), result;
66742
66757
  const componentUpdateResult = this.updateComponentSpec(result);
66743
- return result.reMake ? (this.setLayoutTag(!0, null, !1), result) : isUpdateSpecResultLocalOnly(result) ? result : onlyComponentSpecsChanged && !componentUpdateResult.hasNonComponentOnlyUpdate && (isUpdateSpecResultComponentOnly(result) || this._isComponentScaleDomainOnlyUpdate(result)) ? (componentUpdateResult.componentOnlyUpdatedComponents.forEach(component => {
66758
+ return result.reMake ? (this.setLayoutTag(!0, null, !1), result) : (!onlyComponentSpecsChanged && (null === (_a = result.effects) || void 0 === _a ? void 0 : _a.localOnly) && delete result.effects.localOnly, isUpdateSpecResultLocalOnly(result) ? result : onlyComponentSpecsChanged && !componentUpdateResult.hasNonComponentOnlyUpdate && (isUpdateSpecResultComponentOnly(result) || this._isComponentScaleDomainOnlyUpdate(result)) ? (componentUpdateResult.componentOnlyUpdatedComponents.forEach(component => {
66744
66759
  component.reInit(component.getSpec());
66745
- }), (null === (_a = result.effects) || void 0 === _a ? void 0 : _a.layout) && this.setLayoutTag(!0, null, !1), result) : (this.setLayoutTag(!0, null, !1), this.updateSeriesSpec(result), result.reMake || (this.reInit(), onlySeriesSpecsChanged && this._canSkipChartDataStages(result) || (this.updateDataSpec(), this.updateGlobalScaleDomain())), result);
66760
+ }), (null === (_b = result.effects) || void 0 === _b ? void 0 : _b.layout) && this.setLayoutTag(!0, null, !1), result) : (this.setLayoutTag(!0, null, !1), this.updateSeriesSpec(result), result.reMake || (this.reInit(), onlySeriesSpecsChanged && this._canSkipChartDataStages(result) || (this.updateDataSpec(), this.reDataFlow(), this._reRunStackDataFlow(), this.getAllModels().forEach(model => model.onDataUpdate()))), result));
66746
66761
  }
66747
66762
  updateChartConfig(result, oldSpec) {
66748
66763
  var _a, _b;
@@ -66788,7 +66803,7 @@
66788
66803
  componentResult = c.updateSpec(cmpSpec);
66789
66804
  isUpdateSpecResultComponentOnly(componentResult) || this._isComponentScaleDomainOnlyUpdate(componentResult) ? componentOnlyUpdatedComponents.push(c) : isEqual(previousComponentSpec, cmpSpec) || (hasNonComponentOnlyUpdate = !0), mergeUpdateResult(result, componentResult);
66790
66805
  }
66791
- });
66806
+ }), result.reMake || this._createMissingMarkerComponentsForSpecs(result, componentCache);
66792
66807
  for (const key in componentCache) if (Object.prototype.hasOwnProperty.call(componentCache, key)) {
66793
66808
  const element = componentCache[key];
66794
66809
  element.componentCount !== element.specCount && (result.reMake = !0);
@@ -66810,6 +66825,12 @@
66810
66825
  hasNonComponentOnlyUpdate: hasNonComponentOnlyUpdate
66811
66826
  };
66812
66827
  }
66828
+ _canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
66829
+ return this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) || this._canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec);
66830
+ }
66831
+ _canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
66832
+ return !!(MARKER_COMPONENT_SPEC_KEYS[key] && isArray$1(currentSpec) && isArray$1(nextSpec)) && !(nextSpec.length <= currentSpec.length) && nextSpec.slice(currentSpec.length).every(this._isMarkerAdditionSpecSafeWithoutRemake);
66833
+ }
66813
66834
  _canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
66814
66835
  return MARKER_COMPONENT_SPEC_KEYS[key] && isArray$1(currentSpec) && currentSpec.length > 0 && isArray$1(nextSpec) && 0 === nextSpec.length;
66815
66836
  }
@@ -66819,7 +66840,7 @@
66819
66840
  return hasMarkerRemoval && onlyMarkerRemoval;
66820
66841
  }
66821
66842
  _isComponentSpecKey(key) {
66822
- return this._components.some(component => (component.specKey || component.type) === key);
66843
+ return !!MARKER_COMPONENT_SPEC_KEYS[key] || this._components.some(component => (component.specKey || component.type) === key);
66823
66844
  }
66824
66845
  _isOnlyComponentSpecsChanged(currentSpec, nextSpec, specKeys) {
66825
66846
  let hasComponentSpecChange = !1;
@@ -66845,6 +66866,38 @@
66845
66866
  const effects = result.effects;
66846
66867
  return !(!(null == effects ? void 0 : effects.component) || !effects.scaleDomain || result.reMake || result.reCompile || result.reSize || effects.remake || effects.compile || effects.data || effects.series || effects.animation || result.reTransformSpec || result.reAnimate || result.changeTheme || result.changeBackground);
66847
66868
  }
66869
+ _reRunStackDataFlow() {
66870
+ var _a, _b;
66871
+ this._series.some(series => {
66872
+ var _a;
66873
+ return null === (_a = series.getStack) || void 0 === _a ? void 0 : _a.call(series);
66874
+ }) && (null === (_b = null === (_a = this._stack) || void 0 === _a ? void 0 : _a.stackAll) || void 0 === _b || _b.call(_a), this._series.forEach(series => {
66875
+ series.getViewDataFilter() && series.reTransformViewData();
66876
+ }));
66877
+ }
66878
+ _getModelSpecIndex(specInfo) {
66879
+ var _a;
66880
+ const specPath = null !== (_a = specInfo.specPath) && void 0 !== _a ? _a : [],
66881
+ specIndex = specPath[specPath.length - 1];
66882
+ return "number" == typeof specIndex ? specIndex : 0;
66883
+ }
66884
+ _hasComponentForSpecInfo(key, specInfo) {
66885
+ const specIndex = this._getModelSpecIndex(specInfo);
66886
+ return this._components.some(component => (component.specKey || component.type) === key && component.getSpecIndex() === specIndex);
66887
+ }
66888
+ _createMissingMarkerComponentsForSpecs(result, componentCache) {
66889
+ var _a;
66890
+ let createdCount = 0;
66891
+ null === (_a = this._specTransformer) || void 0 === _a || _a.forEachComponentInSpec(this._spec, (constructor, specInfo) => {
66892
+ if (result.reMake) return;
66893
+ const compSpecKey = constructor.specKey || constructor.type;
66894
+ MARKER_COMPONENT_SPEC_KEYS[compSpecKey] && !this._hasComponentForSpecInfo(compSpecKey, specInfo) && (this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec) ? (this._createComponent(constructor, specInfo), componentCache[compSpecKey] && componentCache[compSpecKey].componentCount++, createdCount++) : result.reMake = !0);
66895
+ }, this._option.getSpecInfo()), createdCount && (result.change = !0, result.effects = Object.assign(Object.assign({}, result.effects), {
66896
+ component: !0,
66897
+ layout: !0,
66898
+ render: !0
66899
+ }));
66900
+ }
66848
66901
  _removeMarkerComponentsForEmptySpecs(result) {
66849
66902
  const removedComponents = this._components.filter(component => {
66850
66903
  var _a;