@visactor/vchart 2.0.0 → 2.0.1-alpha.0
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 +178 -121
- package/build/index.js +178 -120
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base/base-chart.d.ts +1 -0
- package/cjs/chart/base/base-chart.js +3 -0
- package/cjs/chart/base/base-chart.js.map +1 -1
- package/cjs/chart/interface/chart.d.ts +1 -0
- package/cjs/chart/interface/chart.js.map +1 -1
- package/cjs/compile/compiler.js +6 -2
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/component/axis/base-axis.js.map +1 -1
- package/cjs/component/axis/interface/common.js.map +1 -1
- package/cjs/component/brush/brush.js +6 -6
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/brush/interface.d.ts +1 -0
- package/cjs/component/brush/interface.js.map +1 -1
- package/cjs/component/crosshair/base.d.ts +1 -1
- package/cjs/component/crosshair/base.js +1 -1
- package/cjs/component/crosshair/base.js.map +1 -1
- package/cjs/component/crosshair/utils/cartesian.js +2 -2
- package/cjs/component/crosshair/utils/cartesian.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/vchart.js +6 -7
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/mark/base/base-mark.d.ts +3 -1
- package/cjs/mark/base/base-mark.js +33 -31
- package/cjs/mark/base/base-mark.js.map +1 -1
- package/cjs/mark/group.d.ts +1 -1
- package/cjs/mark/group.js +14 -10
- package/cjs/mark/group.js.map +1 -1
- package/cjs/mark/interface/common.d.ts +1 -1
- package/cjs/mark/interface/common.js.map +1 -1
- package/cjs/model/base-model.d.ts +1 -0
- package/cjs/model/base-model.js +1 -0
- package/cjs/model/base-model.js.map +1 -1
- package/cjs/model/interface.d.ts +1 -0
- package/cjs/model/interface.js.map +1 -1
- package/cjs/series/base/base-series.js +2 -3
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/funnel/funnel.js +0 -2
- package/cjs/series/funnel/funnel.js.map +1 -1
- package/cjs/series/map/map.js +1 -2
- package/cjs/series/map/map.js.map +1 -1
- package/cjs/series/pie/pie.js +0 -1
- package/cjs/series/pie/pie.js.map +1 -1
- package/cjs/util/mark.d.ts +1 -0
- package/cjs/util/mark.js +10 -1
- package/cjs/util/mark.js.map +1 -1
- package/esm/chart/base/base-chart.d.ts +1 -0
- package/esm/chart/base/base-chart.js +3 -0
- package/esm/chart/base/base-chart.js.map +1 -1
- package/esm/chart/interface/chart.d.ts +1 -0
- package/esm/chart/interface/chart.js.map +1 -1
- package/esm/compile/compiler.js +7 -4
- package/esm/compile/compiler.js.map +1 -1
- package/esm/component/axis/base-axis.js.map +1 -1
- package/esm/component/axis/interface/common.js.map +1 -1
- package/esm/component/brush/brush.js +6 -6
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/brush/interface.d.ts +1 -0
- package/esm/component/brush/interface.js.map +1 -1
- package/esm/component/crosshair/base.d.ts +1 -1
- package/esm/component/crosshair/base.js +1 -1
- package/esm/component/crosshair/base.js.map +1 -1
- package/esm/component/crosshair/utils/cartesian.js +2 -2
- package/esm/component/crosshair/utils/cartesian.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/vchart.js +5 -6
- package/esm/core/vchart.js.map +1 -1
- package/esm/mark/base/base-mark.d.ts +3 -1
- package/esm/mark/base/base-mark.js +34 -30
- package/esm/mark/base/base-mark.js.map +1 -1
- package/esm/mark/group.d.ts +1 -1
- package/esm/mark/group.js +17 -9
- package/esm/mark/group.js.map +1 -1
- package/esm/mark/interface/common.d.ts +1 -1
- package/esm/mark/interface/common.js.map +1 -1
- package/esm/model/base-model.d.ts +1 -0
- package/esm/model/base-model.js +1 -0
- package/esm/model/base-model.js.map +1 -1
- package/esm/model/interface.d.ts +1 -0
- package/esm/model/interface.js.map +1 -1
- package/esm/series/base/base-series.js +2 -3
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/funnel/funnel.js +0 -2
- package/esm/series/funnel/funnel.js.map +1 -1
- package/esm/series/map/map.js +1 -2
- package/esm/series/map/map.js.map +1 -1
- package/esm/series/pie/pie.js +0 -1
- package/esm/series/pie/pie.js.map +1 -1
- package/esm/util/mark.d.ts +1 -0
- package/esm/util/mark.js +7 -0
- package/esm/util/mark.js.map +1 -1
- package/package.json +6 -6
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
14
14
|
value: !0
|
|
15
15
|
}), exports.BaseMark = void 0;
|
|
16
16
|
|
|
17
|
-
const enum_1 = require("../interface/enum"), interface_1 = require("../../compile/mark/interface"), vutils_extension_1 = require("@visactor/vutils-extension"), color_1 = require("../../util/color"), scale_1 = require("../../util/scale"), gradient_1 = require("../../constant/gradient"), attribute_1 = require("../../constant/attribute"), vscale_1 = require("@visactor/vscale"), util_1 = require("../../theme/color-scheme/util"), mark_1 = require("../../compile/mark"), vutils_1 = require("@visactor/vutils"), common_1 = require("../utils/common"), interface_2 = require("../../compile/interface"), vrender_core_1 = require("@visactor/vrender-core"), util_2 = require("../../compile/mark/util"), factory_1 = require("../../core/factory"), data_1 = require("../../constant/data"), grammar_item_1 = require("../../compile/grammar-item"), layout_1 = require("../../constant/layout"), interface_3 = require("../../animation/interface"), compilable_data_1 = require("../../compile/data/compilable-data"),
|
|
17
|
+
const enum_1 = require("../interface/enum"), interface_1 = require("../../compile/mark/interface"), vutils_extension_1 = require("@visactor/vutils-extension"), color_1 = require("../../util/color"), scale_1 = require("../../util/scale"), gradient_1 = require("../../constant/gradient"), attribute_1 = require("../../constant/attribute"), vscale_1 = require("@visactor/vscale"), util_1 = require("../../theme/color-scheme/util"), mark_1 = require("../../compile/mark"), vutils_1 = require("@visactor/vutils"), common_1 = require("../utils/common"), interface_2 = require("../../compile/interface"), vrender_core_1 = require("@visactor/vrender-core"), util_2 = require("../../compile/mark/util"), factory_1 = require("../../core/factory"), data_1 = require("../../constant/data"), grammar_item_1 = require("../../compile/grammar-item"), layout_1 = require("../../constant/layout"), interface_3 = require("../../animation/interface"), compilable_data_1 = require("../../compile/data/compilable-data"), mark_2 = require("../../util/mark"), debug_1 = require("../../util/debug"), morph_1 = require("../../compile/morph");
|
|
18
18
|
|
|
19
19
|
class BaseMark extends grammar_item_1.GrammarItem {
|
|
20
20
|
commit(render, recursion) {
|
|
@@ -476,6 +476,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
476
476
|
this._dataByGroup = (0, common_1.groupData)(data, this._groupKeyGetter);
|
|
477
477
|
}
|
|
478
478
|
createAnimationStateList(type, animationConfig) {
|
|
479
|
+
var _a;
|
|
479
480
|
let config = animationConfig[type];
|
|
480
481
|
return config && Array.isArray(config) && (config = 1 === config.length ? config[0] : config),
|
|
481
482
|
Array.isArray(config) && (config = config.map(((item, index) => {
|
|
@@ -483,7 +484,9 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
483
484
|
return Object.assign(Object.assign({}, item), {
|
|
484
485
|
priority: null !== (_a = item.priority) && void 0 !== _a ? _a : 1 / 0
|
|
485
486
|
});
|
|
486
|
-
}))), config
|
|
487
|
+
}))), config ? Object.assign(Object.assign({}, config), {
|
|
488
|
+
priority: "normal" === type ? null !== (_a = config.priority) && void 0 !== _a ? _a : 1 / 0 : config.priority
|
|
489
|
+
}) : config;
|
|
487
490
|
}
|
|
488
491
|
tryRunMorphing(graphics) {
|
|
489
492
|
if (this._lastMark) {
|
|
@@ -542,30 +545,33 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
542
545
|
this._product.applyAnimationState([ "normal" ], [ normalConfig ]);
|
|
543
546
|
}
|
|
544
547
|
}
|
|
548
|
+
_setAnimationState(g) {
|
|
549
|
+
const customizedState = this._aniamtionStateCallback ? this._aniamtionStateCallback(g) : void 0;
|
|
550
|
+
g.context.animationState = null != customizedState ? customizedState : g.context.diffState,
|
|
551
|
+
g.context.animationState === enum_1.DiffState.exit && (g.context.reusing = !0, g.animates && g.animates.forEach((a => a.stop())));
|
|
552
|
+
}
|
|
545
553
|
_runJoin(data) {
|
|
546
|
-
const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey,
|
|
547
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
554
|
+
const newGroupedData = this._getDataByKey(data), prevGroupedData = this._prevDataByKey, allGraphics = [], enterGraphics = new Set(this._graphics.filter((g => g.context.diffState === enum_1.DiffState.enter))), callback = (key, newData, prevData) => {
|
|
555
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
548
556
|
let g, diffState;
|
|
549
557
|
return (0, vutils_1.isNil)(newData) ? (g = this._graphicMap.get(key), g && (diffState = enum_1.DiffState.exit)) : (0,
|
|
550
558
|
vutils_1.isNil)(prevData) ? (g = this._graphicMap.has(key) ? this._graphicMap.get(key) : {},
|
|
551
|
-
diffState = enum_1.DiffState.enter, g.isExiting = !1, (
|
|
552
|
-
g
|
|
553
|
-
|
|
554
|
-
newGraphics.push(g))), g && (g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
|
|
559
|
+
diffState = enum_1.DiffState.enter, g.isExiting = !1, this._graphicMap.set(key, g),
|
|
560
|
+
allGraphics.push(g)) : (g = this._graphicMap.get(key), g && (diffState = enum_1.DiffState.update,
|
|
561
|
+
allGraphics.push(g))), g && (enterGraphics.delete(g), g.context = Object.assign(Object.assign({}, this._getCommonContext()), {
|
|
555
562
|
diffState: diffState,
|
|
556
|
-
reusing: null === (
|
|
557
|
-
originalFieldX: null === (
|
|
558
|
-
originalFieldY: null === (
|
|
559
|
-
fieldX: null === (
|
|
560
|
-
fieldY: null === (
|
|
561
|
-
|
|
562
|
-
data: null != newData ? newData : null === (_g = g.context) || void 0 === _g ? void 0 : _g.data,
|
|
563
|
+
reusing: null === (_a = g.context) || void 0 === _a ? void 0 : _a.reusing,
|
|
564
|
+
originalFieldX: null === (_b = g.context) || void 0 === _b ? void 0 : _b.originalFieldX,
|
|
565
|
+
originalFieldY: null === (_c = g.context) || void 0 === _c ? void 0 : _c.originalFieldY,
|
|
566
|
+
fieldX: null === (_d = g.context) || void 0 === _d ? void 0 : _d.fieldX,
|
|
567
|
+
fieldY: null === (_e = g.context) || void 0 === _e ? void 0 : _e.fieldY,
|
|
568
|
+
data: null != newData ? newData : null === (_f = g.context) || void 0 === _f ? void 0 : _f.data,
|
|
563
569
|
uniqueKey: key,
|
|
564
|
-
key: newData ? this._keyGetter(newData[0]) : null === (
|
|
565
|
-
groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (
|
|
570
|
+
key: newData ? this._keyGetter(newData[0]) : null === (_g = g.context) || void 0 === _g ? void 0 : _g.key,
|
|
571
|
+
groupKey: newData ? this._groupKeyGetter(newData[0]) : null === (_h = g.context) || void 0 === _h ? void 0 : _h.groupKey,
|
|
566
572
|
indexKey: "__VCHART_DEFAULT_DATA_INDEX",
|
|
567
|
-
stateAnimateConfig: null === (
|
|
568
|
-
}),
|
|
573
|
+
stateAnimateConfig: null === (_j = this.getAnimationConfig()) || void 0 === _j ? void 0 : _j.state
|
|
574
|
+
}), this._setAnimationState(g)), g;
|
|
569
575
|
};
|
|
570
576
|
if (prevGroupedData && newGroupedData) {
|
|
571
577
|
const prevMap = new Map(prevGroupedData.data);
|
|
@@ -584,10 +590,10 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
584
590
|
this._graphicMap.delete(g.context.uniqueKey), g.parent && g.parent.removeChild(g),
|
|
585
591
|
g.release();
|
|
586
592
|
}));
|
|
587
|
-
const graphicCount =
|
|
588
|
-
|
|
593
|
+
const graphicCount = allGraphics.length;
|
|
594
|
+
allGraphics.forEach(((g, index) => {
|
|
589
595
|
g.context.graphicCount = graphicCount, g.context.graphicIndex = index;
|
|
590
|
-
})), this._dataByKey = newGroupedData, this._graphics =
|
|
596
|
+
})), this._dataByKey = newGroupedData, this._graphics = allGraphics, this.needClear = !0;
|
|
591
597
|
}
|
|
592
598
|
_runEncoderOfGraphic(styles, g, attrs = {}) {
|
|
593
599
|
return (0, common_1.runEncoder)(styles, g.context.data[0], attrs);
|
|
@@ -631,10 +637,8 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
631
637
|
var _a;
|
|
632
638
|
const finalAttrs = g.context.finalAttrs, hasStateAnimation = this.hasAnimationByState(g.context.animationState);
|
|
633
639
|
if (g.setAttributes) {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
prevAttrs[key] !== finalAttrs[key] && (diffAttrs[key] = finalAttrs[key]);
|
|
637
|
-
})), g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
|
|
640
|
+
const diffAttrs = (0, mark_2.getDiffAttributesOfGraphic)(g, finalAttrs);
|
|
641
|
+
g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
|
|
638
642
|
g.initAttributes({}), g.context.reusing = !1) : hasStateAnimation || (hasAnimation ? g.setAttributesAndPreventAnimate(diffAttrs) : g.setAttributes(diffAttrs)),
|
|
639
643
|
hasAnimation && g.setFinalAttributes(finalAttrs);
|
|
640
644
|
} else {
|
|
@@ -724,7 +728,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
724
728
|
}
|
|
725
729
|
render() {
|
|
726
730
|
this.isCommited() && (!this.getVisible() || this._skipBeforeLayouted && this.getCompiler().getLayoutState() === interface_2.LayoutState.before || ((0,
|
|
727
|
-
|
|
731
|
+
debug_1.log)(`render mark: ${this.getProductId()}, type is ${this.type}`), this.renderInner()),
|
|
728
732
|
this.uncommit());
|
|
729
733
|
}
|
|
730
734
|
updateMarkState(key) {
|
|
@@ -740,7 +744,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
740
744
|
this._graphicMap.delete(key), g.parent && g.parent.removeChild(g), g.release && g.release();
|
|
741
745
|
};
|
|
742
746
|
this._graphicMap.forEach(((g, key) => {
|
|
743
|
-
if (g.context.diffState === enum_1.DiffState.exit && !g.isExiting) if (this.hasAnimationByState("exit")) {
|
|
747
|
+
if (g.context.diffState === enum_1.DiffState.exit && !g.isExiting) if (g.context.animationState === enum_1.DiffState.exit && this.hasAnimationByState("exit")) {
|
|
744
748
|
g.isExiting = !0;
|
|
745
749
|
const animationConfig = this.getAnimationConfig();
|
|
746
750
|
if (animationConfig.exit && animationConfig.exit.length) {
|
|
@@ -850,9 +854,7 @@ class BaseMark extends grammar_item_1.GrammarItem {
|
|
|
850
854
|
(null === (_a = this.renderContext) || void 0 === _a ? void 0 : _a.beforeTransformProgressive) ? this._runBeforeProgressive() : this.renderContext.progressive && this._runProgressiveStep();
|
|
851
855
|
}
|
|
852
856
|
updateAnimationState(callback) {
|
|
853
|
-
this.
|
|
854
|
-
g.context.animationState = callback(g);
|
|
855
|
-
}));
|
|
857
|
+
this._aniamtionStateCallback = callback;
|
|
856
858
|
}
|
|
857
859
|
hasAnimationByState(state) {
|
|
858
860
|
if (!state || !this._animationConfig || !this._animationConfig[state]) return !1;
|