Skip to content

Commit 7561b33

Browse files
visikyxinming.lxj
andauthored
fix(annotation): 修复annotation添加id失败 (#3601)
Co-authored-by: xinming.lxj <[email protected]>
1 parent 6fac9aa commit 7561b33

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/chart/controller/annotation.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ export default class Annotation extends Controller<BaseOption[]> {
490490
}
491491

492492
if (type === 'arc') {
493-
const { start, end } = option as ArcOption;
493+
const { start, end, ...rest } = option as ArcOption;
494494
const sp = this.parsePosition(start);
495495
const ep = this.parsePosition(end);
496496
const startAngle = getAngleByPoint(coordinate, sp);
@@ -500,28 +500,32 @@ export default class Annotation extends Controller<BaseOption[]> {
500500
}
501501

502502
o = {
503+
...rest,
503504
center: coordinate.getCenter(),
504505
radius: getDistanceToCenter(coordinate, sp),
505506
startAngle,
506507
endAngle,
507508
};
508509
} else if (type === 'image') {
509-
const { start, end } = option as ImageOption;
510+
const { start, end, ...rest } = option as ImageOption;
510511
o = {
512+
...rest,
511513
start: this.parsePosition(start),
512514
end: this.parsePosition(end),
513515
src: option.src,
514516
};
515517
} else if (type === 'line') {
516-
const { start, end } = option as LineOption;
518+
const { start, end, ...rest } = option as LineOption;
517519
o = {
520+
...rest,
518521
start: this.parsePosition(start),
519522
end: this.parsePosition(end),
520523
text: get(option, 'text', null),
521524
};
522525
} else if (type === 'region') {
523-
const { start, end } = option as RegionPositionBaseOption;
526+
const { start, end, ...rest } = option as RegionPositionBaseOption;
524527
o = {
528+
...rest,
525529
start: this.parsePosition(start),
526530
end: this.parsePosition(end),
527531
};
@@ -538,8 +542,9 @@ export default class Annotation extends Controller<BaseOption[]> {
538542
content: textContent,
539543
};
540544
} else if (type === 'dataMarker') {
541-
const { position, point, line, text, autoAdjust, direction } = option as DataMarkerOption;
545+
const { position, point, line, text, autoAdjust, direction, ...rest } = option as DataMarkerOption;
542546
o = {
547+
...rest,
543548
...this.parsePosition(position),
544549
coordinateBBox: this.getCoordinateBBox(),
545550
point,
@@ -549,15 +554,16 @@ export default class Annotation extends Controller<BaseOption[]> {
549554
direction,
550555
};
551556
} else if (type === 'dataRegion') {
552-
const { start, end, region, text, lineLength } = option as DataRegionOption;
557+
const { start, end, region, text, lineLength, ...rest } = option as DataRegionOption;
553558
o = {
559+
...rest,
554560
points: this.getRegionPoints(start, end),
555561
region,
556562
text,
557563
lineLength,
558564
};
559565
} else if (type === 'regionFilter') {
560-
const { start, end, apply, color } = option as RegionFilterOption;
566+
const { start, end, apply, color, ...rest } = option as RegionFilterOption;
561567
const geometries: Geometry[] = this.view.geometries;
562568
const shapes = [];
563569
const addShapes = (item?: IElement) => {
@@ -584,6 +590,7 @@ export default class Annotation extends Controller<BaseOption[]> {
584590
}
585591
});
586592
o = {
593+
...rest,
587594
color,
588595
shapes,
589596
start: this.parsePosition(start),

0 commit comments

Comments
 (0)