Setting id and class with the haskell diagrams package

328 views Asked by At

I am working with the diagrams package for haskell, and I am using the SVG backend. I embed the SVG markup directly into an HTML document, so that the graph as a part of a web page. I have built a pretty cool looking bar graph, and I would like to add some basic interactivity to it. For example, when you hover over a bar, I'd like to make the color lighter. Or maybe something would pop up as well. The way that I would like to accomplish this is by setting the class attributes of some of the SVG nodes. Is this possible with the diagrams package? I know that it can target multiple backends and that that class attribute likely has no meaningful counterpart in most of them, but I was wondering if there is nevertheless a way to sneak in backend-specific information. Thanks for any insights that anyone can provide.

1

There are 1 answers

1
Yofe On BEST ANSWER

This cannot be done currently in diagrams, although it is something we would like to have in the future. You can get part of the way there using the diagrams-canvas backend, but that only displays on a local host and cannot be embedded into a web page. The only thing I can suggest is to pretty print the svg with the -p command line option and edit the svg by hand.