|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | import {
|
21 |
| - hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, indexOf |
| 21 | + hasOwn, assert, isString, retrieve2, retrieve3, defaults, each, indexOf, |
| 22 | + map |
22 | 23 | } from 'zrender/src/core/util';
|
23 | 24 | import * as graphicUtil from '../../util/graphic';
|
24 | 25 | import { setDefaultStateProxy, toggleHoverEmphasis } from '../../util/states';
|
@@ -56,7 +57,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
|
56 | 57 | import Displayable from 'zrender/src/graphic/Displayable';
|
57 | 58 | import Axis2D from '../../coord/cartesian/Axis2D';
|
58 | 59 | import { RectLike } from 'zrender/src/core/BoundingRect';
|
59 |
| -import { PathStyleProps } from 'zrender/src/graphic/Path'; |
| 60 | +import Path, { PathStyleProps } from 'zrender/src/graphic/Path'; |
60 | 61 | import { TextStyleProps } from 'zrender/src/graphic/Text';
|
61 | 62 | import {
|
62 | 63 | convertToEC4StyleForCustomSerise,
|
@@ -87,7 +88,8 @@ import CustomSeriesModel, {
|
87 | 88 | PrepareCustomInfo,
|
88 | 89 | CustomPathOption,
|
89 | 90 | CustomRootElementOption,
|
90 |
| - CustomSeriesOption |
| 91 | + CustomSeriesOption, |
| 92 | + CustomCompoundPathOption |
91 | 93 | } from './CustomSeries';
|
92 | 94 | import { PatternObject } from 'zrender/src/graphic/Pattern';
|
93 | 95 | import {
|
@@ -352,7 +354,36 @@ function createEl(elOption: CustomElementOption): Element {
|
352 | 354 | el = new graphicUtil.Group();
|
353 | 355 | }
|
354 | 356 | else if (graphicType === 'compoundPath') {
|
355 |
| - throw new Error('"compoundPath" is not supported yet.'); |
| 357 | + const shape = (elOption as CustomCompoundPathOption).shape; |
| 358 | + if (!shape || !shape.paths) { |
| 359 | + let errMsg = ''; |
| 360 | + if (__DEV__) { |
| 361 | + errMsg = 'shape.paths must be specified in compoundPath'; |
| 362 | + } |
| 363 | + throwError(errMsg); |
| 364 | + } |
| 365 | + const paths = map(shape.paths as Path[], function (path) { |
| 366 | + if (path.type === 'path') { |
| 367 | + return graphicUtil.makePath(path.shape.pathData, path, null); |
| 368 | + } |
| 369 | + const Clz = graphicUtil.getShapeClass(path.type); |
| 370 | + if (!Clz) { |
| 371 | + if (typeof path.buildPath === 'function') { |
| 372 | + return path; |
| 373 | + } |
| 374 | + let errMsg = ''; |
| 375 | + if (__DEV__) { |
| 376 | + errMsg = 'graphic type "' + graphicType + '" can not be found.'; |
| 377 | + } |
| 378 | + throwError(errMsg); |
| 379 | + } |
| 380 | + return new Clz(); |
| 381 | + }); |
| 382 | + el = new graphicUtil.CompoundPath({ |
| 383 | + shape: { |
| 384 | + paths |
| 385 | + } |
| 386 | + }); |
356 | 387 | }
|
357 | 388 | else {
|
358 | 389 | const Clz = graphicUtil.getShapeClass(graphicType);
|
@@ -1148,7 +1179,7 @@ function doCreateOrUpdateAttachedTx(
|
1148 | 1179 | attachedTxInfo: AttachedTxInfo
|
1149 | 1180 | ): void {
|
1150 | 1181 | // Group does not support textContent temporarily until necessary.
|
1151 |
| - if (el.isGroup) { |
| 1182 | + if (el.isGroup || el.type === 'compoundPath') { |
1152 | 1183 | return;
|
1153 | 1184 | }
|
1154 | 1185 |
|
|
0 commit comments