ACE-IoT-Solutions / ace-svg-react

Grafana SVG Rendering Panel using the 7+ Plugin Framework
https://grafana.com/grafana/plugins/aceiot-svg-panel/
MIT License
41 stars 14 forks source link

Is there a way to preserve child ids when cloning ? #4

Closed eriklouise closed 3 years ago

eriklouise commented 4 years ago

Hello ACE.SVG Fellows :-)

I'm currently writing a script to duplicate and arrange an SVG group according the size of my grafana dataset. This script was initially written (and this part was working fine) for marcuscalidus-svg-panel and I'm porting it to ace-svg-react (for better dataset handling). When I clone (clone then addto) an existing SVG group, all childs ids are messed up like "SvgjsG" instead of their original id. Is there a way to prevent this ?

acedrew commented 3 years ago

I think that is the behavior of svg.js. The raw SVG code is available in the options object, you could potentially parse it as vanilla DOM code and then generate an SVG.js object for each child node you want, does that make sense? However if you create an ID conflict, things are likely not going to work well for you. On the other hand, classes should be preserved over clones, so you could potentially add classes, then access them with each cloned DOM fragment handle.

acedrew commented 3 years ago

Closing due to no follow up.