Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(svg): duplicate id for background rect with multiple charts #1002

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/canvas/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export default class Layer extends Eventful {
* rect if and only if it's not painted this frame and was
* previously painted on the canvas.
*/
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
const shouldPaint = el && el.shouldBePainted(viewWidth, viewHeight, true, true);
if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
// el was removed
const prevRect = el.getPrevPaintRect();
Expand Down
3 changes: 1 addition & 2 deletions src/svg/Painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ function createBackgroundVNode(
width,
height,
x: '0',
y: '0',
id: '0'
y: '0'
}
);
if (isGradient(backgroundColor)) {
Expand Down
3 changes: 1 addition & 2 deletions test/svg-backgroundColor.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
});
zr.add(txt);

var linearGradient = new zrender.LinearGradient();
linearGradient.addColorStop(0, '#a598e1');
linearGradient.addColorStop(1, '#14c4ba');
Expand Down Expand Up @@ -95,7 +95,6 @@
else {
bg = text = 'none';
}
console.log(text);
zr.setBackgroundColor(bg);
txt.setStyle({ text: 'SVG BackgroundColor: ' + text });
i++;
Expand Down