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 771436131528e8181a4c867fcff8b1afcb39fbec Author: Ovilia <[email protected]> AuthorDate: Tue Oct 8 18:10:42 2024 +0800 feat(custom): support compoundPath in custom series --- src/chart/custom/CustomSeries.ts | 15 +++++++++++++++ src/chart/custom/CustomView.ts | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts index 4c3a9433f..9f1126056 100644 --- a/src/chart/custom/CustomSeries.ts +++ b/src/chart/custom/CustomSeries.ts @@ -234,9 +234,24 @@ export interface CustomTextOption extends CustomDisplayableOption, TransitionOpt keyframeAnimation?: ElementKeyframeAnimationOption<TextProps> | ElementKeyframeAnimationOption<TextProps>[] } +export interface CustomompoundPathOptionOnState extends CustomDisplayableOptionOnState { + style?: PathStyleProps; +} +export interface CustomCompoundPathOption extends CustomDisplayableOption, TransitionOptionMixin<PathProps> { + type: 'compoundPath'; + shape?: PathProps['shape']; + style?: PathStyleProps & TransitionOptionMixin<PathStyleProps>; + emphasis?: CustomompoundPathOptionOnState; + blur?: CustomompoundPathOptionOnState; + select?: CustomompoundPathOptionOnState; + + keyframeAnimation?: ElementKeyframeAnimationOption<PathProps> | ElementKeyframeAnimationOption<PathProps>[] +} + export type CustomElementOption = CustomPathOption | CustomImageOption | CustomTextOption + | CustomCompoundPathOption | CustomGroupOption; // Can only set focus, blur on the root element. diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts index afb047da3..2f02ddb32 100644 --- a/src/chart/custom/CustomView.ts +++ b/src/chart/custom/CustomView.ts @@ -18,7 +18,8 @@ */ import { - hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, indexOf + hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, indexOf, + map } from 'zrender/src/core/util'; import * as graphicUtil from '../../util/graphic'; import { setDefaultStateProxy, toggleHoverEmphasis } from '../../util/states'; @@ -54,6 +55,7 @@ import SeriesData, { DefaultDataVisual } from '../../data/SeriesData'; import GlobalModel from '../../model/Global'; import ExtensionAPI from '../../core/ExtensionAPI'; import Displayable from 'zrender/src/graphic/Displayable'; +import Path from 'zrender/src/graphic/Path'; import Axis2D from '../../coord/cartesian/Axis2D'; import { RectLike } from 'zrender/src/core/BoundingRect'; import { PathStyleProps } from 'zrender/src/graphic/Path'; @@ -87,7 +89,8 @@ import CustomSeriesModel, { PrepareCustomInfo, CustomPathOption, CustomRootElementOption, - CustomSeriesOption + CustomSeriesOption, + CustomCompoundPathOption } from './CustomSeries'; import { PatternObject } from 'zrender/src/graphic/Pattern'; import { @@ -352,7 +355,30 @@ function createEl(elOption: CustomElementOption): Element { el = new graphicUtil.Group(); } else if (graphicType === 'compoundPath') { - throw new Error('"compoundPath" is not supported yet.'); + const shape = (elOption as CustomCompoundPathOption).shape; + if (!shape || !shape.paths) { + let errMsg = ''; + if (__DEV__) { + errMsg = 'shape.paths must be specified in compoundPath'; + } + throwError(errMsg); + } + const paths = map(shape.paths as Path[], function (path) { + const Clz = graphicUtil.getShapeClass(path.type); + if (!Clz) { + let errMsg = ''; + if (__DEV__) { + errMsg = 'graphic type "' + graphicType + '" can not be found.'; + } + throwError(errMsg); + } + return new Clz(); + }); + el = new graphicUtil.CompoundPath({ + shape: { + paths + } + }); } else { const Clz = graphicUtil.getShapeClass(graphicType); @@ -1148,7 +1174,7 @@ function doCreateOrUpdateAttachedTx( attachedTxInfo: AttachedTxInfo ): void { // Group does not support textContent temporarily until necessary. - if (el.isGroup) { + if (el.isGroup || el.type === 'compoundPath') { return; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
