question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVG render issue when theme values stored as strings

See original GitHub issue

Version

5.2.1

Reproduction link

https://jsfiddle.net/eb9dz2f3/3/

Steps to reproduce

  1. Add line width to template, but store it as a string (same as the output from ECharts theme builder)
  2. Use SVG renderer
  3. Change grid: top argument until the line stops appearing (in example link, changing it to 17% makes the line disappear, but 18% works)

What is expected?

Line should render as normal

What is actually happening?

Line doesn’t render under both of these conditions:

  • Renderer is SVG
  • Certain values are inputted into the grid: top argument

This is a strange issue. A line chart I built stopped rendering the line, but I was able to get a bar and scatter to work with the same data. I had the line working earlier and the only thing I changed to break it was the grid: top argument. After playing around with different values for that argument, I found that some numbers worked while others didn’t.

I checked the renderer and this is an issue specific to SVG - the chart works as normal with Canvas. My assumption was that there is some strange rounding happening when it tries to calculate the position of the line. I couldn’t find anything wrong with the underlying SVG elements on inspection in my browser, so the actual problem is a mystery to me.

After looking further into it, I found that the line width option in my custom theme file was stored as a string instead of a number. Changing it to a number solved the SVG rendering problem.

I built the custom theme using the ECharts theme builder, which outputs a string if you edit the line width option.

I am not sure if this is an issue with the theme builder or SVG rendering, but wanted to share in case it’s helpful to anyone else. Everything is working for me now.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
plainheartcommented, Oct 27, 2021

This is definitely caused by an unexpected lineWidth of type string. Let’s take a look at the rect command in SVG path builder. https://github.com/ecomfe/zrender/blob/master/src/svg/graphic.ts#L247-L253 We will find there will be a calculation error when the width/height of type string plus the numeric x/y.

I’m not sure if it’s necessary to be fixed. But anyway, we should ensure that the lineWidth is a number. @pissang

Fortunately, this issue doesn’t exist in the next version. https://github.com/ecomfe/zrender/blob/next/src/svg/SVGPathRebuilder.ts#L113-L120

The theme builder does need further improvement. @Ovilia

0reactions
Oviliacommented, Nov 4, 2021

Thanks for reporting. I will look into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG image errors occur while rendering in flutter
My Suggestion is First download the Svg image in file formate then add the package flutter_svg: ^1.0.3 in pubspec.yaml. add the Svg image...
Read more >
5 Gotchas You're Gonna Face Getting Inline SVG Into ...
How it works, is if you use preserve-- as a prefix to any valid attribute in the source SVG, that attribute will be...
Read more >
SVG size issue after update - WordPress.org
This was a bug on our part as that filter expects the values of height and width to be an integer. We've changed...
Read more >
<path> - SVG: Scalable Vector Graphics - MDN Web Docs
The SVG element is the generic element to define a shape. All the basic shapes can be created ... Value type: <string> ;...
Read more >
SVG support | Adobe Experience Manager
Support for rendering images in this release of Image Serving is limited. Referencing images from within SVG should be used only in situations ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found