Parsing SVG for interactivity

35 views
Skip to first unread message

D L

unread,
Jul 11, 2017, 11:45:57 AM7/11/17
to SCRAM Support and User Discussions

Currently, while developing an application which hopefully will use SCRAM, I am exporting SVG file from SCRAM GUI.

In future releases can you consider injecting id's into all SVG elements (g, rect, circle, text, polyline) so that the exported SVG model can bind with javascript for user interactivity?

An added request is to consider exporting SVG in command line mode, since SCRAM GUI expects to run in desktop and not a server. The generation of SVG (with injected id's in elements) in a headless server is what I have in mind.   In SCRAM GUI QtSvg class generates SVG so I might need to explore a non-Qt non-GUI approach to generate SVG.

Until this feature may be built into SCRAM I am post processing the SVG data with python script to inject element id's.

Olzhas Rakhimov

unread,
Jul 11, 2017, 3:22:43 PM7/11/17
to D L, SCRAM Support and User Discussions
Hello,

On Tue, Jul 11, 2017 at 8:45 AM, D L <dl6...@gmail.com> wrote:

Currently, while developing an application which hopefully will use SCRAM, I am exporting SVG file from SCRAM GUI.

​This sounds exciting. Is it open-source (on GitHub)?​
 

In future releases can you consider injecting id's into all SVG elements (g, rect, circle, text, polyline) so that the exported SVG model can bind with javascript for user interactivity?

An added request is to consider exporting SVG in command line mode, since SCRAM GUI expects to run in desktop and not a server. The generation of SVG (with injected id's in elements) in a headless server is what I have in mind.   In SCRAM GUI QtSvg class generates SVG so I might need to explore a non-Qt non-GUI approach to generate SVG.

​The Qt approach is so convenient and simple that I don't know how to make it do what you want.
I believe you are the best person to tackle this issue and implement the features you need;
otherwise, I have no idea.
You can hack this feature while the gui is still in development before its release.

Until this feature may be built into SCRAM I am post processing the SVG data with python script to inject element id's.


Can Inkscape do this magic for you?

Regards,
Olzhas Rakhimov​

D L

unread,
Jul 12, 2017, 11:18:48 AM7/12/17
to SCRAM Support and User Discussions

Your idea to use Inkscape (already installed in Ubuntu 16.04) proved to be useful.
In particular Inkscape's command line options allow operations
in a server environment.

Running the command ..
inkscape --usage

shows this option ..

-l--export-plain-svg=FILENAME

So after exporting baobab1.svg from scram-gui I ran ..

inkscape -f baobab2.svg -l baobab2_inkscape.svg


which injects id attributes into "plain svg".

I then used jquery to apply interactivity to a first test gate and this works.

I will write up the workflow after further testing.
The idea is to use readily available opensource libraries for building interactive trees.
I have mentioned D3.js in an earlier post but there are other useful scripts which work with D3.js.

A localhost server (on port 8000) for testing interactivity can be launched by this command ..

python3 -m http.server 8000


Reply all
Reply to author
Forward
0 new messages