This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch feat-compoundPath
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit d2c05a7656828a28d96e0e6ee28c94c9af0221ca
Author: Ovilia <[email protected]>
AuthorDate: Wed Oct 9 17:37:17 2024 +0800

    feat(custom): support compoundPath in custom series
---
 src/animation/customGraphicTransition.ts | 21 +++++++++++++++++++--
 src/chart/custom/CustomView.ts           |  6 ++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/animation/customGraphicTransition.ts 
b/src/animation/customGraphicTransition.ts
index a2bf490c5..d1a194609 100644
--- a/src/animation/customGraphicTransition.ts
+++ b/src/animation/customGraphicTransition.ts
@@ -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);
diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts
index 2f02ddb32..792b15351 100644
--- a/src/chart/custom/CustomView.ts
+++ b/src/chart/custom/CustomView.ts
@@ -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.';


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to