Skip to content

Commit d2c05a7

Browse files
committed
feat(custom): support compoundPath in custom series
1 parent 7714361 commit d2c05a7

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/animation/customGraphicTransition.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,25 @@ export function applyUpdateTransition(
149149
const propsToSet = {} as ElementProps;
150150

151151
prepareTransformAllPropsFinal(el, elOption, propsToSet);
152-
prepareShapeOrExtraAllPropsFinal('shape', elOption, propsToSet);
153-
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);
152+
153+
if (el.type === 'compound') {
154+
/**
155+
* We cannot directly clone shape for compoundPath,
156+
* because it makes the path to be an object instead of a Path instance,
157+
* and thus missing `buildPath` method.
158+
*/
159+
const paths: Path[] = (el as Path).shape.paths;
160+
const optionPaths = elOption.shape.paths as TransitionElementOption['shape']['paths'];
161+
for (let i = 0; i < optionPaths.length; i++) {
162+
const path = optionPaths[i];
163+
prepareShapeOrExtraAllPropsFinal('shape', path, paths[i]);
164+
prepareShapeOrExtraAllPropsFinal('extra', path, paths[i]);
165+
}
166+
}
167+
else {
168+
prepareShapeOrExtraAllPropsFinal('shape', elOption, propsToSet);
169+
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);
170+
}
154171

155172
if (!isInit && hasAnimation) {
156173
prepareTransformTransitionFrom(el, elOption, transFromProps);

src/chart/custom/CustomView.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,14 @@ function createEl(elOption: CustomElementOption): Element {
364364
throwError(errMsg);
365365
}
366366
const paths = map(shape.paths as Path[], function (path) {
367+
if (path.type === 'path') {
368+
return createEl(path as unknown as CustomPathOption);
369+
}
367370
const Clz = graphicUtil.getShapeClass(path.type);
368371
if (!Clz) {
372+
if (typeof path.buildPath === 'function') {
373+
return path;
374+
}
369375
let errMsg = '';
370376
if (__DEV__) {
371377
errMsg = 'graphic type "' + graphicType + '" can not be found.';

0 commit comments

Comments
 (0)