bartbutenaers / node-red-contrib-ui-svg

A Node-RED widget node to show interactive SVG (vector graphics) in the dashboard
Apache License 2.0
93 stars 27 forks source link

getSVG and setSVG content by msg #82

Closed tkirchm closed 3 years ago

tkirchm commented 3 years ago

Hi @bartbutenaers

Can't you store svg content from an msg in your node? Store incoming msg = {"command":”setSVG”, "svg":”SVG-XML from client”} in SVG in node. And get svg as message when command "getSVG" arrives.

My workflow would be to create svg in the node with DrawSVG and get the information to make some calculations and then return the result. An example would be to calculate sum of input in a box and create a text with results.

getSVG

Client side svg would be awesome to get latest information. This flow will be activated by button and so there will always be a client.

This way it would also be possible to include local files by opening them in a flow and send it to the SVG-node.

Thomas

bartbutenaers commented 3 years ago

Hi Thomas (@tkirchm ),

You surely get the first price for determination :-)

Recently I have already added a replace_svg command, which allows you to replace the SVG by a new one.
P.S. there is still a sizing bug that I need to fix when I have time ...

And your example make sense, with the button on the frontend. So I have added tonight a get_svg command to solve your headaches.

Would be nice if you could test it, and let me know whether it works correctly. You can install it from Github, inside your .node-red folder:

npm install bartbutenaers/node-red-contrib-ui-svg

P.S. If you have a (small basic) example of how you update the SVG XML in the ouput message - and feed it back into the input - it would be nice if you can share it here, so others can learn from it!

Bart

bartbutenaers commented 3 years ago

Hi Thomas (@tkirchm ), Would be nice if you could give me some feedback, because it would like to build a new release (containing features and fixes other users are waiting for ...). Thanks! Bart

tkirchm commented 3 years ago

Hi Bart,

sorry for letting you wait. Christmas is very busy. get_svg works great and now I'm starting to learn how to build an own node to use svg.getIntersectionList. I couldn't get it to work in function node. Thomas

bartbutenaers commented 3 years ago

Thanks for the feedback!! And yes undeed busy times...

About the svg.getIntersectionList: how do you wanted to do that in a function node? Because the function node code is running on the server, and the svg is running in the frontend browser.

tkirchm commented 3 years ago

Hi,

I'll insert some example soon. Yes it is impossible to use it on server. I will try to solve that in browser.

bartbutenaers commented 3 years ago

Version 2.2.0 has been published on NPM, which contains the get_svg command.