@visactor/vchart 2.1.0-alpha.0 → 2.1.0-alpha.2
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 +3 -3
- package/build/index.es.js +2290 -473
- package/build/index.js +2290 -473
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base/base-chart-transformer.d.ts +3 -0
- package/cjs/chart/base/base-chart-transformer.js +21 -1
- package/cjs/chart/base/base-chart-transformer.js.map +1 -1
- package/cjs/chart/base/base-chart.d.ts +15 -9
- package/cjs/chart/base/base-chart.js +115 -24
- 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/chart/pie/base/pie-transformer.js +2 -2
- package/cjs/chart/pie/base/pie-transformer.js.map +1 -1
- package/cjs/chart/progress/circular/circular-progress-transformer.js +2 -2
- package/cjs/chart/progress/circular/circular-progress-transformer.js.map +1 -1
- package/cjs/chart/util.d.ts +4 -1
- package/cjs/chart/util.js +40 -4
- package/cjs/chart/util.js.map +1 -1
- package/cjs/chart/waterfall/waterfall-transformer.js +2 -1
- package/cjs/chart/waterfall/waterfall-transformer.js.map +1 -1
- package/cjs/compile/compiler.js +2 -2
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/compile/data/compilable-data.d.ts +1 -1
- package/cjs/compile/data/compilable-data.js +1 -1
- package/cjs/compile/data/compilable-data.js.map +1 -1
- package/cjs/compile/grammar-item.d.ts +1 -1
- package/cjs/compile/grammar-item.js.map +1 -1
- package/cjs/compile/interface/compilable-item.d.ts +1 -1
- package/cjs/compile/interface/compilable-item.js.map +1 -1
- package/cjs/component/axis/base-axis.d.ts +2 -7
- package/cjs/component/axis/base-axis.js +25 -3
- package/cjs/component/axis/base-axis.js.map +1 -1
- package/cjs/component/axis/cartesian/band-axis.d.ts +1 -7
- package/cjs/component/base/base-component.d.ts +7 -7
- package/cjs/component/base/base-component.js +41 -6
- package/cjs/component/base/base-component.js.map +1 -1
- package/cjs/component/base/release-vrender-component.d.ts +10 -0
- package/cjs/component/base/release-vrender-component.js +37 -0
- package/cjs/component/base/release-vrender-component.js.map +1 -0
- package/cjs/component/brush/brush.d.ts +2 -7
- package/cjs/component/brush/brush.js +3 -0
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/crosshair/base.d.ts +1 -7
- package/cjs/component/custom-mark/custom-mark.d.ts +1 -7
- package/cjs/component/data-zoom/data-filter-base-component.d.ts +1 -7
- package/cjs/component/geo/geo-coordinate.d.ts +1 -7
- package/cjs/component/index.js +1 -2
- package/cjs/component/label/base-label.d.ts +1 -7
- package/cjs/component/label/label.js +1 -1
- package/cjs/component/label/label.js.map +1 -1
- package/cjs/component/legend/base-legend.d.ts +2 -7
- package/cjs/component/legend/base-legend.js +20 -3
- package/cjs/component/legend/base-legend.js.map +1 -1
- package/cjs/component/marker/base-marker.d.ts +7 -7
- package/cjs/component/marker/base-marker.js +23 -6
- package/cjs/component/marker/base-marker.js.map +1 -1
- package/cjs/component/marker/mark-line/base-mark-line.js +2 -4
- package/cjs/component/marker/mark-line/base-mark-line.js.map +1 -1
- package/cjs/component/title/title.d.ts +1 -7
- package/cjs/component/title/title.js +6 -2
- package/cjs/component/title/title.js.map +1 -1
- package/cjs/constant/attribute.js +2 -1
- package/cjs/constant/scatter.js +1 -2
- package/cjs/constant/waterfall.js +2 -1
- package/cjs/core/factory.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/vchart.d.ts +5 -1
- package/cjs/core/vchart.js +28 -12
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/data-view-utils.d.ts +5 -0
- package/cjs/data/data-view-utils.js +58 -0
- package/cjs/data/data-view-utils.js.map +1 -0
- package/cjs/env/env.js +1 -1
- package/cjs/env/index.js +1 -1
- package/cjs/mark/base/base-mark.d.ts +12 -2
- package/cjs/mark/base/base-mark.js +85 -21
- package/cjs/mark/base/base-mark.js.map +1 -1
- package/cjs/mark/component.d.ts +9 -0
- package/cjs/mark/component.js +51 -3
- package/cjs/mark/component.js.map +1 -1
- package/cjs/mark/group.js +1 -1
- package/cjs/mark/group.js.map +1 -1
- package/cjs/mark/interface/mark.d.ts +2 -0
- package/cjs/mark/interface/mark.js.map +1 -1
- package/cjs/model/base-model.d.ts +3 -15
- package/cjs/model/base-model.js.map +1 -1
- package/cjs/model/interface.d.ts +13 -0
- package/cjs/model/interface.js.map +1 -1
- package/cjs/region/region.d.ts +1 -7
- package/cjs/series/area/area.d.ts +2 -0
- package/cjs/series/area/area.js +6 -0
- package/cjs/series/area/area.js.map +1 -1
- package/cjs/series/bar/bar.d.ts +3 -0
- package/cjs/series/bar/bar.js +30 -4
- package/cjs/series/bar/bar.js.map +1 -1
- package/cjs/series/base/base-series.d.ts +8 -7
- package/cjs/series/base/base-series.js +54 -13
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/base/constant.d.ts +3 -0
- package/cjs/series/base/constant.js +9 -1
- package/cjs/series/base/constant.js.map +1 -1
- package/cjs/series/box-plot/box-plot.d.ts +2 -0
- package/cjs/series/box-plot/box-plot.js +14 -2
- package/cjs/series/box-plot/box-plot.js.map +1 -1
- package/cjs/series/heatmap/heatmap.d.ts +2 -0
- package/cjs/series/heatmap/heatmap.js +10 -0
- package/cjs/series/heatmap/heatmap.js.map +1 -1
- package/cjs/series/line/line.d.ts +2 -0
- package/cjs/series/line/line.js +6 -0
- package/cjs/series/line/line.js.map +1 -1
- package/cjs/series/mixin/line-mixin.d.ts +1 -0
- package/cjs/series/mixin/line-mixin.js +6 -1
- package/cjs/series/mixin/line-mixin.js.map +1 -1
- package/cjs/series/pie/pie.d.ts +3 -7
- package/cjs/series/pie/pie.js +16 -1
- package/cjs/series/pie/pie.js.map +1 -1
- package/cjs/series/progress/circular/circular.d.ts +2 -0
- package/cjs/series/progress/circular/circular.js +9 -1
- package/cjs/series/progress/circular/circular.js.map +1 -1
- package/cjs/series/progress/linear/linear.d.ts +2 -0
- package/cjs/series/progress/linear/linear.js +17 -1
- package/cjs/series/progress/linear/linear.js.map +1 -1
- package/cjs/series/scatter/scatter.d.ts +2 -0
- package/cjs/series/scatter/scatter.js +9 -1
- package/cjs/series/scatter/scatter.js.map +1 -1
- package/cjs/series/waterfall/waterfall.d.ts +2 -0
- package/cjs/series/waterfall/waterfall.js +10 -0
- package/cjs/series/waterfall/waterfall.js.map +1 -1
- package/cjs/util/graphic-state.d.ts +1 -0
- package/cjs/util/graphic-state.js +19 -4
- package/cjs/util/graphic-state.js.map +1 -1
- package/esm/chart/base/base-chart-transformer.d.ts +3 -0
- package/esm/chart/base/base-chart-transformer.js +22 -0
- package/esm/chart/base/base-chart-transformer.js.map +1 -1
- package/esm/chart/base/base-chart.d.ts +15 -9
- package/esm/chart/base/base-chart.js +111 -23
- 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/chart/pie/base/pie-transformer.js +2 -2
- package/esm/chart/pie/base/pie-transformer.js.map +1 -1
- package/esm/chart/progress/circular/circular-progress-transformer.js +2 -2
- package/esm/chart/progress/circular/circular-progress-transformer.js.map +1 -1
- package/esm/chart/util.d.ts +4 -1
- package/esm/chart/util.js +34 -1
- package/esm/chart/util.js.map +1 -1
- package/esm/chart/waterfall/waterfall-transformer.js +2 -1
- package/esm/chart/waterfall/waterfall-transformer.js.map +1 -1
- package/esm/compile/compiler.js +2 -2
- package/esm/compile/compiler.js.map +1 -1
- package/esm/compile/data/compilable-data.d.ts +1 -1
- package/esm/compile/data/compilable-data.js +1 -1
- package/esm/compile/data/compilable-data.js.map +1 -1
- package/esm/compile/grammar-item.d.ts +1 -1
- package/esm/compile/grammar-item.js.map +1 -1
- package/esm/compile/interface/compilable-item.d.ts +1 -1
- package/esm/compile/interface/compilable-item.js.map +1 -1
- package/esm/component/axis/base-axis.d.ts +2 -7
- package/esm/component/axis/base-axis.js +25 -2
- package/esm/component/axis/base-axis.js.map +1 -1
- package/esm/component/axis/cartesian/band-axis.d.ts +1 -7
- package/esm/component/base/base-component.d.ts +7 -7
- package/esm/component/base/base-component.js +41 -5
- package/esm/component/base/base-component.js.map +1 -1
- package/esm/component/base/release-vrender-component.d.ts +10 -0
- package/esm/component/base/release-vrender-component.js +24 -0
- package/esm/component/base/release-vrender-component.js.map +1 -0
- package/esm/component/brush/brush.d.ts +2 -7
- package/esm/component/brush/brush.js +3 -0
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/crosshair/base.d.ts +1 -7
- package/esm/component/custom-mark/custom-mark.d.ts +1 -7
- package/esm/component/data-zoom/data-filter-base-component.d.ts +1 -7
- package/esm/component/geo/geo-coordinate.d.ts +1 -7
- package/esm/component/index.js +1 -2
- package/esm/component/label/base-label.d.ts +1 -7
- package/esm/component/label/label.js +1 -1
- package/esm/component/label/label.js.map +1 -1
- package/esm/component/legend/base-legend.d.ts +2 -7
- package/esm/component/legend/base-legend.js +20 -2
- package/esm/component/legend/base-legend.js.map +1 -1
- package/esm/component/marker/base-marker.d.ts +7 -7
- package/esm/component/marker/base-marker.js +24 -5
- package/esm/component/marker/base-marker.js.map +1 -1
- package/esm/component/marker/mark-line/base-mark-line.js +2 -4
- package/esm/component/marker/mark-line/base-mark-line.js.map +1 -1
- package/esm/component/title/title.d.ts +1 -7
- package/esm/component/title/title.js +6 -2
- package/esm/component/title/title.js.map +1 -1
- package/esm/constant/attribute.js +2 -1
- package/esm/constant/scatter.js +1 -2
- package/esm/constant/waterfall.js +2 -1
- package/esm/core/factory.js +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/vchart.d.ts +5 -1
- package/esm/core/vchart.js +29 -12
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/data-view-utils.d.ts +5 -0
- package/esm/data/data-view-utils.js +46 -0
- package/esm/data/data-view-utils.js.map +1 -0
- package/esm/env/env.js +1 -1
- package/esm/env/index.js +1 -1
- package/esm/mark/base/base-mark.d.ts +12 -2
- package/esm/mark/base/base-mark.js +85 -20
- package/esm/mark/base/base-mark.js.map +1 -1
- package/esm/mark/component.d.ts +9 -0
- package/esm/mark/component.js +51 -2
- package/esm/mark/component.js.map +1 -1
- package/esm/mark/group.js +1 -1
- package/esm/mark/group.js.map +1 -1
- package/esm/mark/interface/mark.d.ts +2 -0
- package/esm/mark/interface/mark.js.map +1 -1
- package/esm/model/base-model.d.ts +3 -15
- package/esm/model/base-model.js.map +1 -1
- package/esm/model/interface.d.ts +13 -0
- package/esm/model/interface.js.map +1 -1
- package/esm/region/region.d.ts +1 -7
- package/esm/series/area/area.d.ts +2 -0
- package/esm/series/area/area.js +7 -1
- package/esm/series/area/area.js.map +1 -1
- package/esm/series/bar/bar.d.ts +3 -0
- package/esm/series/bar/bar.js +30 -4
- package/esm/series/bar/bar.js.map +1 -1
- package/esm/series/base/base-series.d.ts +8 -7
- package/esm/series/base/base-series.js +50 -11
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/base/constant.d.ts +3 -0
- package/esm/series/base/constant.js +10 -0
- package/esm/series/base/constant.js.map +1 -1
- package/esm/series/box-plot/box-plot.d.ts +2 -0
- package/esm/series/box-plot/box-plot.js +13 -2
- package/esm/series/box-plot/box-plot.js.map +1 -1
- package/esm/series/heatmap/heatmap.d.ts +2 -0
- package/esm/series/heatmap/heatmap.js +10 -0
- package/esm/series/heatmap/heatmap.js.map +1 -1
- package/esm/series/line/line.d.ts +2 -0
- package/esm/series/line/line.js +7 -1
- package/esm/series/line/line.js.map +1 -1
- package/esm/series/mixin/line-mixin.d.ts +1 -0
- package/esm/series/mixin/line-mixin.js +5 -0
- package/esm/series/mixin/line-mixin.js.map +1 -1
- package/esm/series/pie/pie.d.ts +3 -7
- package/esm/series/pie/pie.js +17 -0
- package/esm/series/pie/pie.js.map +1 -1
- package/esm/series/progress/circular/circular.d.ts +2 -0
- package/esm/series/progress/circular/circular.js +10 -0
- package/esm/series/progress/circular/circular.js.map +1 -1
- package/esm/series/progress/linear/linear.d.ts +2 -0
- package/esm/series/progress/linear/linear.js +18 -0
- package/esm/series/progress/linear/linear.js.map +1 -1
- package/esm/series/scatter/scatter.d.ts +2 -0
- package/esm/series/scatter/scatter.js +10 -0
- package/esm/series/scatter/scatter.js.map +1 -1
- package/esm/series/waterfall/waterfall.d.ts +2 -0
- package/esm/series/waterfall/waterfall.js +10 -0
- package/esm/series/waterfall/waterfall.js.map +1 -1
- package/esm/util/graphic-state.d.ts +1 -0
- package/esm/util/graphic-state.js +16 -3
- package/esm/util/graphic-state.js.map +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const getDataViewsInDataSet = dataView => {
|
|
2
|
+
var _a;
|
|
3
|
+
const dataViewMap = null === (_a = null == dataView ? void 0 : dataView.dataSet) || void 0 === _a ? void 0 : _a.dataViewMap;
|
|
4
|
+
return dataViewMap ? Object.values(dataViewMap).filter(Boolean) : [];
|
|
5
|
+
}, detachDataViewListener = (source, target) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
null === (_a = null == source ? void 0 : source.target) || void 0 === _a || _a.removeListener("change", target.reRunAllTransform),
|
|
8
|
+
null === (_b = null == source ? void 0 : source.target) || void 0 === _b || _b.removeListener("markRunning", target.markRunning);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const detachDataViewDependencies = dataView => {
|
|
12
|
+
if (!dataView) return;
|
|
13
|
+
getDataViewsInDataSet(dataView).forEach((source => {
|
|
14
|
+
detachDataViewListener(source, dataView);
|
|
15
|
+
}));
|
|
16
|
+
const dependencies = null == dataView ? void 0 : dataView.rawData;
|
|
17
|
+
Array.isArray(dependencies) && dependencies.forEach((dependency => {
|
|
18
|
+
detachDataViewListener(dependency, dataView);
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const releaseDataViews = dataViews => {
|
|
23
|
+
const releaseDataViews = Array.from(new Set(dataViews.filter(Boolean)));
|
|
24
|
+
releaseDataViews.length && (releaseDataViews.forEach(detachDataViewDependencies),
|
|
25
|
+
releaseDataViews.forEach((dataView => {
|
|
26
|
+
var _a;
|
|
27
|
+
null === (_a = dataView.destroy) || void 0 === _a || _a.call(dataView);
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const releaseDataView = dataView => {
|
|
32
|
+
releaseDataViews([ dataView ]);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const releaseDataViewWithDependencies = (dataView, shouldReleaseDependency) => {
|
|
36
|
+
if (!dataView) return;
|
|
37
|
+
const dataViewsInDataSet = new Set(getDataViewsInDataSet(dataView)), releaseDependencies = [], collectReleaseDependencies = currentDataView => {
|
|
38
|
+
const dependencies = null == currentDataView ? void 0 : currentDataView.rawData;
|
|
39
|
+
Array.isArray(dependencies) && dependencies.forEach((dependency => {
|
|
40
|
+
dataViewsInDataSet.has(dependency) && shouldReleaseDependency(dependency) && !releaseDependencies.includes(dependency) && (releaseDependencies.push(dependency),
|
|
41
|
+
collectReleaseDependencies(dependency));
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
collectReleaseDependencies(dataView), releaseDataViews([ dataView, ...releaseDependencies ]);
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=data-view-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data/data-view-utils.ts"],"names":[],"mappings":"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","file":"data-view-utils.js","sourcesContent":["import type { DataView } from '@visactor/vdataset';\n\nconst getDataViewsInDataSet = (dataView?: DataView | null) => {\n const dataViewMap = dataView?.dataSet?.dataViewMap;\n\n return dataViewMap ? (Object.values(dataViewMap).filter(Boolean) as DataView[]) : [];\n};\n\nconst detachDataViewListener = (source: DataView, target: DataView) => {\n source?.target?.removeListener('change', target.reRunAllTransform);\n source?.target?.removeListener('markRunning', target.markRunning);\n};\n\nexport const detachDataViewDependencies = (dataView?: DataView | null) => {\n if (!dataView) {\n return;\n }\n\n const dataViews = getDataViewsInDataSet(dataView);\n\n dataViews.forEach(source => {\n detachDataViewListener(source, dataView);\n });\n\n const dependencies = (dataView as unknown as { rawData?: DataView[] })?.rawData;\n\n if (Array.isArray(dependencies)) {\n dependencies.forEach(dependency => {\n detachDataViewListener(dependency, dataView);\n });\n }\n};\n\nexport const releaseDataViews = (dataViews: Array<DataView | null | undefined>) => {\n const releaseDataViews = Array.from(new Set(dataViews.filter(Boolean) as DataView[]));\n\n if (!releaseDataViews.length) {\n return;\n }\n\n releaseDataViews.forEach(detachDataViewDependencies);\n releaseDataViews.forEach(dataView => {\n dataView.destroy?.();\n });\n};\n\nexport const releaseDataView = (dataView?: DataView | null) => {\n releaseDataViews([dataView]);\n};\n\nexport const releaseDataViewWithDependencies = (\n dataView: DataView | null | undefined,\n shouldReleaseDependency: (dataView: DataView) => boolean\n) => {\n if (!dataView) {\n return;\n }\n\n const dataViewsInDataSet = new Set(getDataViewsInDataSet(dataView));\n const releaseDependencies: DataView[] = [];\n const collectReleaseDependencies = (currentDataView: DataView) => {\n const dependencies = (currentDataView as unknown as { rawData?: DataView[] })?.rawData;\n\n if (!Array.isArray(dependencies)) {\n return;\n }\n\n dependencies.forEach(dependency => {\n if (\n dataViewsInDataSet.has(dependency) &&\n shouldReleaseDependency(dependency) &&\n !releaseDependencies.includes(dependency)\n ) {\n releaseDependencies.push(dependency);\n collectReleaseDependencies(dependency);\n }\n });\n };\n\n collectReleaseDependencies(dataView);\n releaseDataViews([dataView, ...releaseDependencies]);\n};\n"]}
|
package/esm/env/env.js
CHANGED
package/esm/env/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./env";
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@ import { MarkTypeEnum } from '../interface';
|
|
|
5
5
|
import type { IMarkRaw, IMarkStateStyle, IMarkStyle, IMark, IMarkOption, StyleConvert, MarkInputStyle, GroupedData, IAttrs, IMarkGraphic, ProgressiveContext, IProgressiveTransformResult, MarkType, AnimationStateValues } from '../interface';
|
|
6
6
|
import type { ICompilableMark, IMarkCompileOption, IMarkConfig, IMarkStateManager, StateValueType } from '../../compile/mark/interface';
|
|
7
7
|
import type { ICompilableInitOption } from '../../compile/interface';
|
|
8
|
-
import type { IGroupGraphicAttribute, IGroup, IGraphic } from '@visactor/vrender-core';
|
|
8
|
+
import type { IGroupGraphicAttribute, IGroup, IGraphic, StateDefinitionsInput } from '@visactor/vrender-core';
|
|
9
9
|
import { GrammarItem } from '../../compile/grammar-item';
|
|
10
10
|
import type { IModel } from '../../model/interface';
|
|
11
11
|
import type { ICompilableData } from '../../compile/data/interface';
|
|
@@ -74,7 +74,7 @@ export declare class BaseMark<T extends ICommonSpec> extends GrammarItem impleme
|
|
|
74
74
|
stopAnimationByState(state?: string): void;
|
|
75
75
|
pauseAnimationByState(state?: string): void;
|
|
76
76
|
resumeAnimationByState(state?: string): void;
|
|
77
|
-
removeProduct(): void;
|
|
77
|
+
removeProduct(releaseDetach?: boolean): void;
|
|
78
78
|
release(): void;
|
|
79
79
|
protected _simpleStyle: T;
|
|
80
80
|
setSimpleStyle(s: T): void;
|
|
@@ -82,6 +82,11 @@ export declare class BaseMark<T extends ICommonSpec> extends GrammarItem impleme
|
|
|
82
82
|
protected _option: IMarkOption;
|
|
83
83
|
protected _attributeContext: IModelMarkAttributeContext;
|
|
84
84
|
protected _encoderOfState: Record<string, Record<string, (datum: Datum) => any>>;
|
|
85
|
+
protected _sharedStateDefinitionsCacheKey?: string;
|
|
86
|
+
protected _sharedStateDefinitionsCache?: StateDefinitionsInput<Record<string, unknown>>;
|
|
87
|
+
protected _sharedStateDefinitionRefIds: WeakMap<object, number>;
|
|
88
|
+
protected _sharedStateDefinitionRefId: number;
|
|
89
|
+
protected _dynamicSharedStateNames: Set<string>;
|
|
85
90
|
_extensionChannel: {
|
|
86
91
|
[key: string | number | symbol]: string[];
|
|
87
92
|
};
|
|
@@ -155,9 +160,14 @@ export declare class BaseMark<T extends ICommonSpec> extends GrammarItem impleme
|
|
|
155
160
|
protected _getEncoderOfStyle: (stateName: string, style: Partial<IAttrs<T>>) => Record<string, (datum: Datum) => any>;
|
|
156
161
|
protected _setGraphicFromMarkConfig: (g: IMarkGraphic) => void;
|
|
157
162
|
protected _setStateOfGraphic: (g: IMarkGraphic, hasAnimation?: boolean) => void;
|
|
163
|
+
protected _getSharedStateDefinitionRefId(value: unknown): string;
|
|
164
|
+
protected _getSharedStateDefinitionValueKey(value: unknown): string;
|
|
165
|
+
protected _isStaticSharedStateAttribute(stateName: string, key: string): boolean;
|
|
158
166
|
protected _applySharedStateDefinitions(): void;
|
|
159
167
|
protected _addProgressiveGraphic(parent: IGroup, g: IMarkGraphic): void;
|
|
160
168
|
protected _runEncoder(graphics: IMarkGraphic[], noGroupEncode?: boolean): void;
|
|
169
|
+
protected _excludeStateControlledDiffAttrs(g: IMarkGraphic, diffAttrs: Record<string, any>): Record<string, any>;
|
|
170
|
+
protected _hasDiffAttrs(g: IMarkGraphic): boolean;
|
|
161
171
|
protected _runApplyGraphic(graphics: IMarkGraphic[]): void;
|
|
162
172
|
protected _updateEncoderByState(): void;
|
|
163
173
|
protected _runState(graphics: IMarkGraphic[]): void;
|
|
@@ -56,7 +56,9 @@ import { log } from "../../util/debug";
|
|
|
56
56
|
|
|
57
57
|
import { morph as runMorph } from "../../compile/morph";
|
|
58
58
|
|
|
59
|
-
import { addGraphicState, removeGraphicState } from "../../util/graphic-state";
|
|
59
|
+
import { addGraphicState, removeGraphicState, setGraphicStates } from "../../util/graphic-state";
|
|
60
|
+
|
|
61
|
+
const statesClearedBeforeReInitKey = Symbol("statesClearedBeforeReInit");
|
|
60
62
|
|
|
61
63
|
export class BaseMark extends GrammarItem {
|
|
62
64
|
commit(render, recursion) {
|
|
@@ -210,8 +212,8 @@ export class BaseMark extends GrammarItem {
|
|
|
210
212
|
stopAnimationByState(state) {}
|
|
211
213
|
pauseAnimationByState(state) {}
|
|
212
214
|
resumeAnimationByState(state) {}
|
|
213
|
-
removeProduct() {
|
|
214
|
-
this._product && this._product.parent && this._product.parent.removeChild(this._product),
|
|
215
|
+
removeProduct(releaseDetach) {
|
|
216
|
+
this._product && this._product.parent && this._product.parent.removeChild(this._product, releaseDetach),
|
|
215
217
|
this._product = null, this._compiledProductId = null;
|
|
216
218
|
}
|
|
217
219
|
release() {
|
|
@@ -229,8 +231,9 @@ export class BaseMark extends GrammarItem {
|
|
|
229
231
|
zIndex: LayoutZIndex.Mark,
|
|
230
232
|
morph: !1
|
|
231
233
|
}, this._visible = !0, this.stateStyle = {}, this._unCompileChannel = {}, this._disabledAnimationStates = [],
|
|
232
|
-
this._skipBeforeLayouted = !1, this.
|
|
233
|
-
this.
|
|
234
|
+
this._skipBeforeLayouted = !1, this._sharedStateDefinitionRefIds = new WeakMap,
|
|
235
|
+
this._sharedStateDefinitionRefId = 0, this._dynamicSharedStateNames = new Set, this._extensionChannel = {},
|
|
236
|
+
this._computeExChannel = {}, this._graphicMap = new Map, this._graphics = [], this._getEncoderOfStyle = (stateName, style) => {
|
|
234
237
|
if (style && stateName) {
|
|
235
238
|
const validEncoder = {};
|
|
236
239
|
return Object.keys(style).forEach((key => {
|
|
@@ -243,7 +246,10 @@ export class BaseMark extends GrammarItem {
|
|
|
243
246
|
setCustomizedShape && (g.pathProxy = attrs => setCustomizedShape(g.context.data, attrs, new CustomPath2D)),
|
|
244
247
|
graphicName && (isFunction(graphicName) ? g.name = graphicName(g) : g.name = graphicName);
|
|
245
248
|
}, this._setStateOfGraphic = (g, hasAnimation) => {
|
|
246
|
-
|
|
249
|
+
var _a, _b, _c;
|
|
250
|
+
g.stateProxy = null;
|
|
251
|
+
const targetStates = g.context.diffState === DiffState.enter || g.context.diffState === DiffState.update ? g.context.states : void 0, hasCurrentState = !!((null === (_a = g.currentStates) || void 0 === _a ? void 0 : _a.length) || (null === (_b = g.effectiveStates) || void 0 === _b ? void 0 : _b.length) || g.resolvedStatePatch || (null === (_c = g.registeredActiveScopes) || void 0 === _c ? void 0 : _c.size));
|
|
252
|
+
((null == targetStates ? void 0 : targetStates.length) || hasCurrentState) && setGraphicStates(g, targetStates, hasAnimation);
|
|
247
253
|
}, this.name = name, this.model = option.model, this.key = option.key, this.state = new MarkStateManager(option, this),
|
|
248
254
|
this._attributeContext = option.attributeContext, null === (_a = option.map) || void 0 === _a || _a.set(this.id, this);
|
|
249
255
|
}
|
|
@@ -577,6 +583,7 @@ export class BaseMark extends GrammarItem {
|
|
|
577
583
|
if (graphics.forEach((g => {
|
|
578
584
|
const state = g.context.animationState;
|
|
579
585
|
if ("appear" === state) return;
|
|
586
|
+
if ("update" === state && !this._hasDiffAttrs(g)) return;
|
|
580
587
|
const config = animationConfig[state];
|
|
581
588
|
if (config && config.length > 0) {
|
|
582
589
|
const configList = config.map(((item, index) => ({
|
|
@@ -675,25 +682,59 @@ export class BaseMark extends GrammarItem {
|
|
|
675
682
|
groupStyles: groupStyles
|
|
676
683
|
};
|
|
677
684
|
}
|
|
685
|
+
_getSharedStateDefinitionRefId(value) {
|
|
686
|
+
if ("object" != typeof value && "function" != typeof value || null === value) return `${value}`;
|
|
687
|
+
const objectValue = value;
|
|
688
|
+
let id = this._sharedStateDefinitionRefIds.get(objectValue);
|
|
689
|
+
return id || (id = ++this._sharedStateDefinitionRefId, this._sharedStateDefinitionRefIds.set(objectValue, id)),
|
|
690
|
+
`ref:${id}`;
|
|
691
|
+
}
|
|
692
|
+
_getSharedStateDefinitionValueKey(value) {
|
|
693
|
+
try {
|
|
694
|
+
const jsonValue = JSON.stringify(value);
|
|
695
|
+
return null != jsonValue ? jsonValue : `${value}`;
|
|
696
|
+
} catch (_error) {
|
|
697
|
+
return this._getSharedStateDefinitionRefId(value);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
_isStaticSharedStateAttribute(stateName, key) {
|
|
701
|
+
var _a, _b;
|
|
702
|
+
const stateStyle = null === (_a = this.stateStyle[stateName]) || void 0 === _a ? void 0 : _a[key];
|
|
703
|
+
if (!stateStyle || stateStyle.referer || isFunction(stateStyle.postProcess) || key in this._computeExChannel) return !1;
|
|
704
|
+
const style = stateStyle.style;
|
|
705
|
+
return !isFunction(style) && (!GradientType.includes(null == style ? void 0 : style.gradient) && (![ "outerBorder", "innerBorder" ].includes(key) && !isValidScaleType(null === (_b = null == style ? void 0 : style.scale) || void 0 === _b ? void 0 : _b.type)));
|
|
706
|
+
}
|
|
678
707
|
_applySharedStateDefinitions() {
|
|
679
708
|
var _a;
|
|
680
709
|
if (!this._product) return;
|
|
681
710
|
const stateNames = Object.keys(null !== (_a = this._encoderOfState) && void 0 !== _a ? _a : {}).filter((stateName => "group" !== stateName && "update" !== stateName));
|
|
682
|
-
if (!stateNames.length) return void (this._product.sharedStateDefinitions = void 0);
|
|
711
|
+
if (!stateNames.length) return this._dynamicSharedStateNames.clear(), void (void 0 !== this._product.sharedStateDefinitions && (this._product.sharedStateDefinitions = void 0));
|
|
683
712
|
const sortedStateNames = this._stateSort ? stateNames.slice().sort(this._stateSort) : stateNames, statePriority = new Map;
|
|
684
713
|
sortedStateNames.forEach(((stateName, index) => {
|
|
685
714
|
statePriority.set(stateName, index);
|
|
686
715
|
}));
|
|
687
|
-
const sharedStateDefinitions = {};
|
|
688
|
-
stateNames.forEach((stateName => {
|
|
716
|
+
const sharedStateDefinitions = {}, cacheKeys = [], dynamicSharedStateNames = new Set;
|
|
717
|
+
if (stateNames.forEach((stateName => {
|
|
689
718
|
var _a;
|
|
690
|
-
const encoder = this._encoderOfState[stateName];
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
719
|
+
const encoder = this._encoderOfState[stateName], patch = {}, dynamicEncoder = {}, patchKeys = [], dynamicKeys = [];
|
|
720
|
+
if (Object.keys(null != encoder ? encoder : {}).forEach((key => {
|
|
721
|
+
this._isStaticSharedStateAttribute(stateName, key) ? (patch[key] = this._computeAttribute(key, stateName)(void 0),
|
|
722
|
+
patchKeys.push(key)) : (dynamicEncoder[key] = encoder[key], dynamicKeys.push(key));
|
|
723
|
+
})), !patchKeys.length && !dynamicKeys.length) return;
|
|
724
|
+
const definition = {
|
|
725
|
+
priority: null !== (_a = statePriority.get(stateName)) && void 0 !== _a ? _a : 0
|
|
695
726
|
};
|
|
696
|
-
|
|
727
|
+
patchKeys.length && (definition.patch = patch), dynamicKeys.length && (dynamicSharedStateNames.add(stateName),
|
|
728
|
+
definition.declaredAffectedKeys = dynamicKeys, definition.resolver = ({graphic: graphic}) => this._runEncoderOfGraphic(dynamicEncoder, graphic)),
|
|
729
|
+
sharedStateDefinitions[stateName] = definition, cacheKeys.push([ stateName, definition.priority, patchKeys.sort().map((key => `${key}:${this._getSharedStateDefinitionValueKey(patch[key])}`)), dynamicKeys.sort().map((key => {
|
|
730
|
+
var _a;
|
|
731
|
+
const stateStyle = null === (_a = this.stateStyle[stateName]) || void 0 === _a ? void 0 : _a[key];
|
|
732
|
+
return `${key}:${this._getSharedStateDefinitionRefId(null == stateStyle ? void 0 : stateStyle.style)}:${this._getSharedStateDefinitionRefId(null == stateStyle ? void 0 : stateStyle.postProcess)}:${this._getSharedStateDefinitionRefId(null == stateStyle ? void 0 : stateStyle.referer)}`;
|
|
733
|
+
})) ].join("|"));
|
|
734
|
+
})), !cacheKeys.length) return this._dynamicSharedStateNames.clear(), void (void 0 !== this._product.sharedStateDefinitions && (this._product.sharedStateDefinitions = void 0));
|
|
735
|
+
const cacheKey = cacheKeys.sort().join("||");
|
|
736
|
+
this._dynamicSharedStateNames = dynamicSharedStateNames, cacheKey === this._sharedStateDefinitionsCacheKey && this._sharedStateDefinitionsCache ? this._product.sharedStateDefinitions !== this._sharedStateDefinitionsCache && (this._product.sharedStateDefinitions = this._sharedStateDefinitionsCache) : (this._sharedStateDefinitionsCacheKey = cacheKey,
|
|
737
|
+
this._sharedStateDefinitionsCache = sharedStateDefinitions, this._product.sharedStateDefinitions = sharedStateDefinitions);
|
|
697
738
|
}
|
|
698
739
|
_addProgressiveGraphic(parent, g) {
|
|
699
740
|
parent.incrementalAppendChild(g);
|
|
@@ -709,15 +750,33 @@ export class BaseMark extends GrammarItem {
|
|
|
709
750
|
g.context.finalAttrs = finalAttrs;
|
|
710
751
|
}));
|
|
711
752
|
}
|
|
753
|
+
_excludeStateControlledDiffAttrs(g, diffAttrs) {
|
|
754
|
+
var _a;
|
|
755
|
+
if (!diffAttrs || !Object.keys(diffAttrs).length) return diffAttrs;
|
|
756
|
+
let nextDiffAttrs;
|
|
757
|
+
const excludeKey = key => {
|
|
758
|
+
key in diffAttrs && (nextDiffAttrs || (nextDiffAttrs = Object.assign({}, diffAttrs)),
|
|
759
|
+
delete nextDiffAttrs[key]);
|
|
760
|
+
};
|
|
761
|
+
return g.resolvedStatePatch && Object.keys(g.resolvedStatePatch).forEach(excludeKey),
|
|
762
|
+
null === (_a = g.context.states) || void 0 === _a || _a.forEach((stateName => {
|
|
763
|
+
var _a;
|
|
764
|
+
const encoder = null === (_a = this._encoderOfState) || void 0 === _a ? void 0 : _a[stateName];
|
|
765
|
+
encoder && Object.keys(encoder).forEach(excludeKey);
|
|
766
|
+
})), null != nextDiffAttrs ? nextDiffAttrs : diffAttrs;
|
|
767
|
+
}
|
|
768
|
+
_hasDiffAttrs(g) {
|
|
769
|
+
return !!g.context.diffAttrs && Object.keys(g.context.diffAttrs).length > 0;
|
|
770
|
+
}
|
|
712
771
|
_runApplyGraphic(graphics) {
|
|
713
772
|
const hasAnimation = this.hasAnimation();
|
|
714
773
|
graphics.forEach(((g, index) => {
|
|
715
774
|
var _a, _b, _c;
|
|
716
775
|
const finalAttrs = g.context.finalAttrs, hasStateAnimation = this.hasAnimationByState(g.context.animationState);
|
|
717
776
|
if (g.setAttributes) {
|
|
718
|
-
const diffAttrs = getDiffAttributesOfGraphic(g, finalAttrs);
|
|
777
|
+
const diffAttrs = this._excludeStateControlledDiffAttrs(g, getDiffAttributesOfGraphic(g, finalAttrs));
|
|
719
778
|
g.context.diffAttrs = diffAttrs, g.context.reusing ? (g.context.lastAttrs = g.attribute,
|
|
720
|
-
g.initAttributes(
|
|
779
|
+
g.initAttributes(finalAttrs), g.context.reusing = !1) : hasStateAnimation || (hasAnimation ? g.setAttributesAndPreventAnimate(diffAttrs) : g.setAttributes(diffAttrs)),
|
|
721
780
|
!(null === (_c = this.renderContext) || void 0 === _c ? void 0 : _c.progressive) && this._product && g.parent !== this._product && this._product.appendChild(g),
|
|
722
781
|
hasAnimation && g.setFinalAttributes(finalAttrs);
|
|
723
782
|
} else {
|
|
@@ -813,7 +872,12 @@ export class BaseMark extends GrammarItem {
|
|
|
813
872
|
if (!this._product) return;
|
|
814
873
|
const stateInfo = this.state.getStateInfo(key);
|
|
815
874
|
this._graphics.forEach((g => {
|
|
816
|
-
|
|
875
|
+
const reinitStateGraphic = g, statesClearedBeforeReInit = reinitStateGraphic[statesClearedBeforeReInitKey], wasStateClearedBeforeReInit = null == statesClearedBeforeReInit ? void 0 : statesClearedBeforeReInit.includes(key), hasStateAnimation = !wasStateClearedBeforeReInit && this.hasAnimationByState("state");
|
|
876
|
+
if ("in" === this.state.checkOneState(g, g.context.data, stateInfo) ? addGraphicState(g, key, !0, hasStateAnimation) : removeGraphicState(g, key, hasStateAnimation),
|
|
877
|
+
wasStateClearedBeforeReInit) {
|
|
878
|
+
const nextStates = statesClearedBeforeReInit.filter((stateName => stateName !== key));
|
|
879
|
+
nextStates.length ? reinitStateGraphic[statesClearedBeforeReInitKey] = nextStates : delete reinitStateGraphic[statesClearedBeforeReInitKey];
|
|
880
|
+
}
|
|
817
881
|
}));
|
|
818
882
|
}
|
|
819
883
|
clearExitGraphics() {
|
|
@@ -833,7 +897,7 @@ export class BaseMark extends GrammarItem {
|
|
|
833
897
|
})
|
|
834
898
|
})));
|
|
835
899
|
g.applyAnimationState([ "exit" ], [ 1 === exitConfigList.length ? exitConfigList[0] : exitConfigList ], (() => {
|
|
836
|
-
doRemove(g, key);
|
|
900
|
+
g.context.diffState === DiffState.exit && g.isExiting && this._graphicMap.get(key) === g && doRemove(g, key);
|
|
837
901
|
}));
|
|
838
902
|
}
|
|
839
903
|
} else doRemove(g, key);
|
|
@@ -944,7 +1008,8 @@ export class BaseMark extends GrammarItem {
|
|
|
944
1008
|
}
|
|
945
1009
|
clearBeforeReInit() {
|
|
946
1010
|
this.state.clearAllStateInfo(), this.uncommit(), this.stateStyle = {}, this.getGraphics().forEach((g => {
|
|
947
|
-
|
|
1011
|
+
var _a;
|
|
1012
|
+
(null === (_a = g.currentStates) || void 0 === _a ? void 0 : _a.length) && (g[statesClearedBeforeReInitKey] = g.currentStates.slice());
|
|
948
1013
|
}));
|
|
949
1014
|
}
|
|
950
1015
|
}
|