Skip to content

Commit

Permalink
feat(custom): support compoundPath in custom series
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Oct 9, 2024
1 parent 7714361 commit d2c05a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/animation/customGraphicTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,25 @@ export function applyUpdateTransition(
const propsToSet = {} as ElementProps;

prepareTransformAllPropsFinal(el, elOption, propsToSet);
prepareShapeOrExtraAllPropsFinal('shape', elOption, propsToSet);
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);

if (el.type === 'compound') {
/**
* We cannot directly clone shape for compoundPath,
* because it makes the path to be an object instead of a Path instance,
* and thus missing `buildPath` method.
*/
const paths: Path[] = (el as Path).shape.paths;
const optionPaths = elOption.shape.paths as TransitionElementOption['shape']['paths'];
for (let i = 0; i < optionPaths.length; i++) {
const path = optionPaths[i];
prepareShapeOrExtraAllPropsFinal('shape', path, paths[i]);
prepareShapeOrExtraAllPropsFinal('extra', path, paths[i]);
}
}
else {
prepareShapeOrExtraAllPropsFinal('shape', elOption, propsToSet);
prepareShapeOrExtraAllPropsFinal('extra', elOption, propsToSet);
}

if (!isInit && hasAnimation) {
prepareTransformTransitionFrom(el, elOption, transFromProps);
Expand Down
6 changes: 6 additions & 0 deletions src/chart/custom/CustomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,14 @@ function createEl(elOption: CustomElementOption): Element {
throwError(errMsg);
}
const paths = map(shape.paths as Path[], function (path) {
if (path.type === 'path') {
return createEl(path as unknown as CustomPathOption);
}
const Clz = graphicUtil.getShapeClass(path.type);
if (!Clz) {
if (typeof path.buildPath === 'function') {
return path;
}
let errMsg = '';
if (__DEV__) {
errMsg = 'graphic type "' + graphicType + '" can not be found.';
Expand Down

0 comments on commit d2c05a7

Please sign in to comment.