You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/01/26 04:42:45 UTC
[echarts] branch enhance-morph updated: refact(custom): default to
clone path
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/enhance-morph by this push:
new ae8d321 refact(custom): default to clone path
ae8d321 is described below
commit ae8d321ac81f964817246da4b177311bb66de47e
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jan 26 12:41:36 2021 +0800
refact(custom): default to clone path
---
src/chart/custom/CustomView.ts | 5 ++---
src/chart/custom/transitionHelper.ts | 32 +++++++++++++++++++++++---------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts
index c6fc280..a9daaf1 100644
--- a/src/chart/custom/CustomView.ts
+++ b/src/chart/custom/CustomView.ts
@@ -210,9 +210,9 @@ export default class CustomChartView extends ChartView {
const transFromProps = {} as ElementProps;
const propsToSet = {} as ElementProps;
const styleOpt = elOption.style;
- prepareShapeOrExtraTransitionFrom('extra', rawFrom, elOption, transFromProps, false);
+ prepareShapeOrExtraTransitionFrom('extra', from, elOption, transFromProps, false);
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);
- prepareStyleTransitionFrom(rawFrom, elOption, styleOpt, transFromProps, false);
+ prepareStyleTransitionFrom(from, elOption, styleOpt, transFromProps, false);
(propsToSet as DisplayableProps).style = styleOpt;
applyPropsDirectly(to, propsToSet);
@@ -237,7 +237,6 @@ export default class CustomChartView extends ChartView {
const diffMode: DataDiffMode = transOpt ? 'multiple' : 'oneToOne';
-
(new DataDiffer(
oldData ? oldData.getIndices() : [],
data.getIndices(),
diff --git a/src/chart/custom/transitionHelper.ts b/src/chart/custom/transitionHelper.ts
index fe182e7..361feb3 100644
--- a/src/chart/custom/transitionHelper.ts
+++ b/src/chart/custom/transitionHelper.ts
@@ -24,15 +24,17 @@ import {
morphPath,
isCombineMorphing,
SeparateConfig,
- CombineConfig
+ CombineConfig,
+ SplitPathParams
} from 'zrender/src/tool/morphPath';
import { Path } from '../../util/graphic';
import { SeriesModel } from '../../export/api';
import Element, { ElementAnimateConfig } from 'zrender/src/Element';
import { AnimationEasing } from 'zrender/src/animation/easing';
import { PayloadAnimationPart } from '../../util/types';
-import { isArray, isFunction } from 'zrender/src/core/util';
+import { defaults, extend, isArray, isFunction } from 'zrender/src/core/util';
import Displayable from 'zrender/src/graphic/Displayable';
+import { clonePath } from 'zrender/src/tool/path';
type DescendentElements = Element[];
@@ -77,6 +79,14 @@ export function getMorphAnimationConfig(seriesModel: SeriesModel, dataIndex: num
return config;
}
+function clonePaths({ path, count }: SplitPathParams) {
+ const paths = [];
+ for (let i = 0; i < count; i++) {
+ paths.push(clonePath(path));
+ }
+ return paths;
+}
+
export function applyMorphAnimation(
from: DescendentPaths | DescendentPaths[],
to: DescendentPaths | DescendentPaths[],
@@ -102,6 +112,9 @@ export function applyMorphAnimation(
}
if (many) {
+ const animationCfgWithSplitPath = defaults({
+ splitPath: clonePaths
+ }, animationCfg);
// TODO mergeByName
for (let i = 0; i < one.length; i++) {
const manyPaths: Path[] = [];
@@ -112,28 +125,29 @@ export function applyMorphAnimation(
}
let fromIndividuals;
let toIndividuals;
+
if (many === from) { // manyToOne
const res = combineMorph(
- manyPaths, one[i], animationCfg as CombineConfig
+ manyPaths, one[i], animationCfgWithSplitPath
);
fromIndividuals = res.fromIndividuals;
toIndividuals = res.toIndividuals;
}
else { // oneToMany
const res = separateMorph(
- one[i], manyPaths, animationCfg as SeparateConfig
+ one[i], manyPaths, animationCfgWithSplitPath
);
fromIndividuals = res.fromIndividuals;
toIndividuals = res.toIndividuals;
}
- for (let i = 0; i < fromIndividuals.length; i++) {
+ for (let k = 0; k < fromIndividuals.length; k++) {
updateOtherProps(
- fromIndividuals[i],
- toIndividuals[i],
- many === from ? manyPaths[i] : one[i],
- many === from ? one[i] : manyPaths[i]
+ fromIndividuals[k],
+ toIndividuals[k],
+ many === from ? manyPaths[k] : one[i],
+ many === from ? one[i] : manyPaths[k]
);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org