From 4ca836e572a216045c8510f78a24bcdedefec4e8 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Mon, 3 Apr 2023 16:39:25 +0800 Subject: [PATCH] fix(svg): duplicate id for background rect with multiple charts --- src/svg/Painter.ts | 5 +++-- test/svg-backgroundColor.html | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/svg/Painter.ts b/src/svg/Painter.ts index fc85ed939..27bdeeb39 100644 --- a/src/svg/Painter.ts +++ b/src/svg/Painter.ts @@ -143,7 +143,7 @@ class SVGPainter implements PainterBase { const children: SVGVNode[] = []; - const bgVNode = this._bgVNode = createBackgroundVNode(width, height, this._backgroundColor, scope); + const bgVNode = this._bgVNode = createBackgroundVNode(this._id, width, height, this._backgroundColor, scope); bgVNode && children.push(bgVNode); // Ignore the root g if wan't the output to be more tight. @@ -360,6 +360,7 @@ function createMethodNotSupport(method: string): any { } function createBackgroundVNode( + zrId: string, width: number, height: number, backgroundColor: SVGPainterBackgroundColor, @@ -375,7 +376,7 @@ function createBackgroundVNode( height, x: '0', y: '0', - id: '0' + id: zrId + '-bg' } ); if (isGradient(backgroundColor)) { diff --git a/test/svg-backgroundColor.html b/test/svg-backgroundColor.html index b8603e37f..40e1e79a7 100644 --- a/test/svg-backgroundColor.html +++ b/test/svg-backgroundColor.html @@ -16,6 +16,9 @@
+ +

This should not have a rect with the same id as the above instance.

+