-
Notifications
You must be signed in to change notification settings - Fork 86
Fix problem to create png svg in node.js with 3D plots #391
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 problem to create png svg in node.js with 3D plots #391
Conversation
|
@linev I am going to take a look at the failing tests on Ubuntu and commit a fix |
this returns the raw RGBA pixels made by `resvg-js`
|
@linev i pushed 3 commits that apparently make CI pass. requesting feedback please |
linev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merging you changes into dev branch.
Seems to be several small adjustments need to be done, but this is cosmetics.
Thanks for looking into the problem and providing solution for it!
@linev |
There are no really urgent issues. |
This PR attempts to fix #257 by using a more modern SVG renderer called resvg-js.
The problem
The original renderer used by
jsrootisnode-canvaswhich depends onlibrsvgon Linux. The issue arises when the user runsnpm installto installjsrootas this causesnode-canvasto fetch and link its binary to an outdated (and broken) version of
librsvg.This causes SVG to PNG conversion to be buggy often rendering empty plots. See the full discussion.
The solution
resvg-jswas added as anpmdependency ofjsroot, hence the changes inpackage.jsonandpackage-lock.json.In order leverage it, a refactoring had to be made in
jsroot's painting base module (BasePainter.mjs).Now, the code has two branches for converting SVGs to PNGs: the first one uses
resvg-jsand the secondnode-canvas.However, the former shall be taken in all cases as the feature flag that mandates whether the module uses
resvg-jsis hardcoded totrue.Results
Before the change, the test of running
demo/node/make_image.jsyielded alego.pngwithout the 3D plot.Now, it correctly generates it. Further tests should be made to assure this change is safe. In any case, it can be readily turned off by setting
RESVG_FEATURE_FLAGtofalse.I hope this helps!