@visactor/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/es5/index.js +1 -1
- package/build/index.es.js +123 -17
- package/build/index.js +123 -17
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base/base-chart.d.ts +7 -0
- package/cjs/chart/base/base-chart.js +65 -8
- package/cjs/chart/base/base-chart.js.map +1 -1
- package/cjs/compile/compiler.js +9 -7
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/component/axis/base-axis.js +3 -5
- package/cjs/component/axis/base-axis.js.map +1 -1
- package/cjs/core/expression-function.js +1 -1
- package/cjs/core/factory.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/data/data-view-utils.js +1 -1
- package/cjs/data/initialize.js +1 -1
- package/cjs/data/register.js +1 -1
- package/esm/chart/base/base-chart.d.ts +7 -0
- package/esm/chart/base/base-chart.js +63 -7
- package/esm/chart/base/base-chart.js.map +1 -1
- package/esm/compile/compiler.js +9 -7
- package/esm/compile/compiler.js.map +1 -1
- package/esm/component/axis/base-axis.js +3 -5
- package/esm/component/axis/base-axis.js.map +1 -1
- package/esm/core/expression-function.js +1 -1
- package/esm/core/factory.js +1 -1
- package/esm/core/index.js +1 -1
- package/esm/data/data-view-utils.js +1 -1
- package/esm/data/initialize.js +1 -1
- package/esm/data/register.js +1 -1
- package/package.json +5 -5
|
@@ -54,6 +54,20 @@ const MARKER_COMPONENT_SPEC_KEYS = {
|
|
|
54
54
|
[ComponentTypeEnum.markPoint]: !0,
|
|
55
55
|
[ComponentTypeEnum.markLine]: !0,
|
|
56
56
|
[ComponentTypeEnum.markArea]: !0
|
|
57
|
+
}, MARKER_ADDITION_REMAKE_SPEC_KEYS = {
|
|
58
|
+
autoRange: !0,
|
|
59
|
+
regionId: !0,
|
|
60
|
+
regionIndex: !0,
|
|
61
|
+
seriesId: !0,
|
|
62
|
+
seriesIndex: !0,
|
|
63
|
+
relativeSeriesId: !0,
|
|
64
|
+
relativeSeriesIndex: !0,
|
|
65
|
+
startRelativeSeriesId: !0,
|
|
66
|
+
startRelativeSeriesIndex: !0,
|
|
67
|
+
endRelativeSeriesId: !0,
|
|
68
|
+
endRelativeSeriesIndex: !0,
|
|
69
|
+
specifiedDataSeriesId: !0,
|
|
70
|
+
specifiedDataSeriesIndex: !0
|
|
57
71
|
};
|
|
58
72
|
|
|
59
73
|
export class BaseChart extends CompilableBase {
|
|
@@ -142,6 +156,7 @@ export class BaseChart extends CompilableBase {
|
|
|
142
156
|
const component = this._components.find((s => s.userId === userId));
|
|
143
157
|
if (component) return component;
|
|
144
158
|
}, this.getComponentsByType = type => this._components.filter((c => c.type === type)),
|
|
159
|
+
this._isMarkerAdditionSpecSafeWithoutRemake = spec => !(!spec || "object" != typeof spec || !1 === spec.visible) && !Object.keys(MARKER_ADDITION_REMAKE_SPEC_KEYS).some((key => !isNil(spec[key]))),
|
|
145
160
|
this._paddingSpec = normalizeLayoutPaddingSpec(null !== (_a = spec.padding) && void 0 !== _a ? _a : option.getTheme("padding")),
|
|
146
161
|
this._event = new Event(option.eventDispatcher, option.mode), this._dataSet = option.dataSet,
|
|
147
162
|
this._chartData = new ChartData(this._dataSet), this._modelOption = Object.assign(Object.assign({}, option), {
|
|
@@ -459,7 +474,7 @@ export class BaseChart extends CompilableBase {
|
|
|
459
474
|
return Object.keys(spec).filter((key => !ignoreKeys[key])).sort();
|
|
460
475
|
}
|
|
461
476
|
updateSpec(spec) {
|
|
462
|
-
var _a;
|
|
477
|
+
var _a, _b;
|
|
463
478
|
const result = {
|
|
464
479
|
change: !1,
|
|
465
480
|
reMake: !1,
|
|
@@ -474,7 +489,7 @@ export class BaseChart extends CompilableBase {
|
|
|
474
489
|
result;
|
|
475
490
|
for (let i = 0; i < currentKeys.length; i++) {
|
|
476
491
|
const key = currentKeys[i], currentSpec = this._spec[key], nextSpec = spec[key];
|
|
477
|
-
if (isArray(currentSpec) && currentSpec.length !== array(nextSpec).length && !this.
|
|
492
|
+
if (isArray(currentSpec) && currentSpec.length !== array(nextSpec).length && !this._canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec)) return result.reMake = !0,
|
|
478
493
|
this.setLayoutTag(!0, null, !1), result;
|
|
479
494
|
}
|
|
480
495
|
const oldSpec = this._spec, onlyMarkerComponentsRemoved = this._isOnlyMarkerComponentsRemoved(this._spec, spec, currentKeys), onlyComponentSpecsChanged = this._isOnlyComponentSpecsChanged(this._spec, spec, currentKeys), onlySeriesSpecsChanged = this._isOnlySeriesSpecsChanged(this._spec, spec, currentKeys);
|
|
@@ -487,12 +502,14 @@ export class BaseChart extends CompilableBase {
|
|
|
487
502
|
if (this.updateRegionSpec(result), result.reMake) return this.setLayoutTag(!0, null, !1),
|
|
488
503
|
result;
|
|
489
504
|
const componentUpdateResult = this.updateComponentSpec(result);
|
|
490
|
-
return result.reMake ? (this.setLayoutTag(!0, null, !1), result) :
|
|
505
|
+
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,
|
|
506
|
+
isUpdateSpecResultLocalOnly(result) ? result : onlyComponentSpecsChanged && !componentUpdateResult.hasNonComponentOnlyUpdate && (isUpdateSpecResultComponentOnly(result) || this._isComponentScaleDomainOnlyUpdate(result)) ? (componentUpdateResult.componentOnlyUpdatedComponents.forEach((component => {
|
|
491
507
|
component.reInit(component.getSpec());
|
|
492
|
-
})), (null === (
|
|
508
|
+
})), (null === (_b = result.effects) || void 0 === _b ? void 0 : _b.layout) && this.setLayoutTag(!0, null, !1),
|
|
493
509
|
result) : (this.setLayoutTag(!0, null, !1), this.updateSeriesSpec(result), result.reMake || (this.reInit(),
|
|
494
510
|
onlySeriesSpecsChanged && this._canSkipChartDataStages(result) || (this.updateDataSpec(),
|
|
495
|
-
this.
|
|
511
|
+
this.reDataFlow(), this._reRunStackDataFlow(), this.getAllModels().forEach((model => model.onDataUpdate())))),
|
|
512
|
+
result));
|
|
496
513
|
}
|
|
497
514
|
updateChartConfig(result, oldSpec) {
|
|
498
515
|
var _a, _b;
|
|
@@ -535,7 +552,7 @@ export class BaseChart extends CompilableBase {
|
|
|
535
552
|
isUpdateSpecResultComponentOnly(componentResult) || this._isComponentScaleDomainOnlyUpdate(componentResult) ? componentOnlyUpdatedComponents.push(c) : isEqual(previousComponentSpec, cmpSpec) || (hasNonComponentOnlyUpdate = !0),
|
|
536
553
|
mergeUpdateResult(result, componentResult);
|
|
537
554
|
}
|
|
538
|
-
}));
|
|
555
|
+
})), result.reMake || this._createMissingMarkerComponentsForSpecs(result, componentCache);
|
|
539
556
|
for (const key in componentCache) if (Object.prototype.hasOwnProperty.call(componentCache, key)) {
|
|
540
557
|
const element = componentCache[key];
|
|
541
558
|
element.componentCount !== element.specCount && (result.reMake = !0);
|
|
@@ -557,6 +574,12 @@ export class BaseChart extends CompilableBase {
|
|
|
557
574
|
hasNonComponentOnlyUpdate: hasNonComponentOnlyUpdate
|
|
558
575
|
};
|
|
559
576
|
}
|
|
577
|
+
_canChangeMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
|
|
578
|
+
return this._canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) || this._canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec);
|
|
579
|
+
}
|
|
580
|
+
_canAddMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
|
|
581
|
+
return !!(MARKER_COMPONENT_SPEC_KEYS[key] && isArray(currentSpec) && isArray(nextSpec)) && (!(nextSpec.length <= currentSpec.length) && nextSpec.slice(currentSpec.length).every(this._isMarkerAdditionSpecSafeWithoutRemake));
|
|
582
|
+
}
|
|
560
583
|
_canRemoveMarkerComponentsWithoutRemake(key, currentSpec, nextSpec) {
|
|
561
584
|
return MARKER_COMPONENT_SPEC_KEYS[key] && isArray(currentSpec) && currentSpec.length > 0 && isArray(nextSpec) && 0 === nextSpec.length;
|
|
562
585
|
}
|
|
@@ -567,7 +590,7 @@ export class BaseChart extends CompilableBase {
|
|
|
567
590
|
return hasMarkerRemoval && onlyMarkerRemoval;
|
|
568
591
|
}
|
|
569
592
|
_isComponentSpecKey(key) {
|
|
570
|
-
return this._components.some((component => (component.specKey || component.type) === key));
|
|
593
|
+
return !!MARKER_COMPONENT_SPEC_KEYS[key] || this._components.some((component => (component.specKey || component.type) === key));
|
|
571
594
|
}
|
|
572
595
|
_isOnlyComponentSpecsChanged(currentSpec, nextSpec, specKeys) {
|
|
573
596
|
let hasComponentSpecChange = !1;
|
|
@@ -590,6 +613,39 @@ export class BaseChart extends CompilableBase {
|
|
|
590
613
|
const effects = result.effects;
|
|
591
614
|
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);
|
|
592
615
|
}
|
|
616
|
+
_reRunStackDataFlow() {
|
|
617
|
+
var _a, _b;
|
|
618
|
+
this._series.some((series => {
|
|
619
|
+
var _a;
|
|
620
|
+
return null === (_a = series.getStack) || void 0 === _a ? void 0 : _a.call(series);
|
|
621
|
+
})) && (null === (_b = null === (_a = this._stack) || void 0 === _a ? void 0 : _a.stackAll) || void 0 === _b || _b.call(_a),
|
|
622
|
+
this._series.forEach((series => {
|
|
623
|
+
series.getViewDataFilter() && series.reTransformViewData();
|
|
624
|
+
})));
|
|
625
|
+
}
|
|
626
|
+
_getModelSpecIndex(specInfo) {
|
|
627
|
+
var _a;
|
|
628
|
+
const specPath = null !== (_a = specInfo.specPath) && void 0 !== _a ? _a : [], specIndex = specPath[specPath.length - 1];
|
|
629
|
+
return "number" == typeof specIndex ? specIndex : 0;
|
|
630
|
+
}
|
|
631
|
+
_hasComponentForSpecInfo(key, specInfo) {
|
|
632
|
+
const specIndex = this._getModelSpecIndex(specInfo);
|
|
633
|
+
return this._components.some((component => (component.specKey || component.type) === key && component.getSpecIndex() === specIndex));
|
|
634
|
+
}
|
|
635
|
+
_createMissingMarkerComponentsForSpecs(result, componentCache) {
|
|
636
|
+
var _a;
|
|
637
|
+
let createdCount = 0;
|
|
638
|
+
null === (_a = this._specTransformer) || void 0 === _a || _a.forEachComponentInSpec(this._spec, ((constructor, specInfo) => {
|
|
639
|
+
if (result.reMake) return;
|
|
640
|
+
const compSpecKey = constructor.specKey || constructor.type;
|
|
641
|
+
MARKER_COMPONENT_SPEC_KEYS[compSpecKey] && !this._hasComponentForSpecInfo(compSpecKey, specInfo) && (this._isMarkerAdditionSpecSafeWithoutRemake(specInfo.spec) ? (this._createComponent(constructor, specInfo),
|
|
642
|
+
componentCache[compSpecKey] && componentCache[compSpecKey].componentCount++, createdCount++) : result.reMake = !0);
|
|
643
|
+
}), this._option.getSpecInfo()), createdCount && (result.change = !0, result.effects = Object.assign(Object.assign({}, result.effects), {
|
|
644
|
+
component: !0,
|
|
645
|
+
layout: !0,
|
|
646
|
+
render: !0
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
593
649
|
_removeMarkerComponentsForEmptySpecs(result) {
|
|
594
650
|
const removedComponents = this._components.filter((component => {
|
|
595
651
|
var _a;
|