I’ve tested the svg in Illustrator, Inkscape and Affinity Designer. I’m not sure of what you’re seeing; for me the difference is that the texts at the left and right have an added rect outline in inkscape (which I suppose shouldn’t show, since it has visibility: hidden;).
Thanks to all for your feedbacks and tests.
Yes, I was very surprised to discover that the rendering of the SVG image is not correct on Inkscape (1.0.2). The first and last colums shoud not have a rectangle around the text (opacity at 0).
In fact I could be satisfied with the proposed PNG file from Observable since the rendering is correct
but is there a way to control its size while this image is produced from the SVG code ?
I need an image with a bigger definition to be included in a report.
Observable uses the following heuristic to determine the size of the PNG:
If bothwidth and height attribute are set, use both.
Else, if a valid viewBox attribute is set, use width and height from the viewBox.
Else determine the display size of the SVG and use that.
The resulting width and height values are multiplied by the devicePixelRatio.
Source:
let n = +e.getAttribute("width")
, r = +e.getAttribute("height");
n && r || ({width: n, height: r} = e.viewBox.baseVal),
n && r || ({width: n, height: r} = e.getBoundingClientRect());
const i = window.devicePixelRatio || 1
, a = document.createElement("canvas");
a.width = n * i,
a.height = r * i;
Thanks for those fix tips @PBrockmann I know they will be useful to others (like myself) with SVG to inkscape render issues.
@mootari@Fil would it be possible to add a button to use the observable PNG save API with custom size parameters? And is there an example of that? Great tips too btw, thanks
The other route is to change the SVG size (by changing width, height and scale, or viewBox and scale): if you make it 4x bigger the native “download png” will return a 4x bigger png.
Yes indeed but some set ups (font size, width of rectangle nodes, thickness of stroke for labels) have to be set again. So not so seamless.
I have found easier to use density parameter from inkscape.