Feature Request: Add Data Attributes to SVG Elements for Interactivity
Feature Request: Add Data Attributes to SVG Elements for Interactivity
Thanks for making BandageNG, I like it a lot! However, the current SVG output lacks identifiers for the graphical elements (e.g., lines, bars, and text) that represent contigs. This makes it challenging to create interactive web visualizations where users can click on or hover over elements to get more information.
Proposed Feature:
I propose adding data attributes to each SVG element that corresponds to the corresponding contig. For example, each element could have a data-contig attribute with the value set to the contig's identifier, like so:
<g data-contig="contig_1" fill="#4682b4" ...> // option 1: the group tag
<path data-contig="contig_1" vector-effect="none" .../> // option 2: the path elements
</g>
Maybe it's easier or makes more sense to follow the gfa entries instead? E.g. data-gfa-type="L" data-gfa-id="edge_1"?
Thanks for considering my suggestion. I can't do it myself because I don't know QT or C++.
Alternative/Workaround:
A technically simpler solution could be an option to save labels as text and not convert them to paths. (I managed to implement this in gfaviz.)
Thanks for the suggestion! I doubt this is ever possible without complete rewrite of SVG output and essentially a manual rendering. Current we just use Qt's QSVGGenerator as an output device and there are not so much customization points: https://doc.qt.io/qt-6/qsvggenerator.html Essentially, the SVG device is used as a "canvas" and all high-level information is already lost at this point, there are no callbacks to augment generated SVG with something else.
I see, that's what I feared... What about the workaround, though? I.e. saving all text as text, not rendering them to paths?