AbstractSVGWizardNodeModel and new customCSS setting

Hi
Does the KNIME 3.6 org.knime.js.core.node.AbstractSVGWizardNodeModel class support the customCSS for the exported SVG image?
I mean, if my interactive javascript view node nodemodel both extends that abstract class, and implements the CSSModifiable interface, does the exported SVG in nodes’s image output port includes the user CSS roles?
Of course the javascript side of my node implements the getSVG function.

Thanks in advance.

Hi,

yes and no. On the Java side you are all set if you implement the CSSModifiable interface and save/load the CSS string into your node’s config with the setCssStyles() and getCssStyles() methods. It’s important to have it as a field in your config, so that this field will also show up in the flow variables tab of the node’s dialog. Once you have that, a view that you open up on your node should already respect any additional styling that is applied.
However to make the CSS also appear in the generated SVG of your node, you need to call
knimeService.inlineSvgStyles(svgElement);
in your getSVG() function before serialising the SVG element to a string.

Hope this helps. Let me know if you need any additional help.
Best regards,
Christian

3 Likes

Thank you Christian
I didn’t notice the existence of that method in knimeService, so I wrote my own code to extract CSS roles from document and add them to svg element: it worked but custom CSS roles were missing.

Now using knimeService.inlineSvgStyles() method, user CSS roles are included too!

Just a notice: it seems that user CSS roles are not included in exported SVG image if “Bundled PhantomJS” is selected in Javascript view section of KNIME preferences: this also occurs with KNIME javascript views such as the ‘Lift Chart (javascript node)’.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.