Custom classes in generated SVG

0 votes
asked Sep 10 in Question / help by Alexey
Hello PlantUML developers!

I have a question regarding possibility of adding custom ids and classes (id and class attribute) to SVG generated basing on PlantUML code.

Actually my question is more general and it’s about control over the generated SVG.

So what I want: to have some markers (ids and classes at first glance) in the generated SVG to be able to process / interact with the SVG elements after generation.

At the moment the SVG contains just a “dead” structure, which is correctly positioned.

I would like to make it more alive and so add some marker classes to the element of the diagram.

For example I would like to click on a Block in a diagram and get the information about its content – name, attributes, methods.

So it would be good to have an id for this block as well as a class which indicated that it’s a block. The same for the attributes.

Does PlantUML support such kind of customization? And how to do it?

Or maybe there is a better solution which already exists?

Please suggest.

Thank you!

1 Answer

0 votes
answered Sep 23 by boessu

Hello Alexey

I'm not sure if that helps, but the generated "g-container" in SVG has an ID according to the name of a class you've given. Example:


@startuml
class TestClass
@enduml


results in:


(...)

<!--class TestClass-->

<g id="elem_TestClass">

(...)


Beside of that I would also love if the generated SVG would contain more ID's for a reference...

...