d2 icon indicating copy to clipboard operation
d2 copied to clipboard

[feature request] component and tab shapes

Open pmoura opened this issue 1 year ago • 8 comments

It would be possible to provide a tab and component shapes as found in Graphviz (https://graphviz.org/doc/info/shapes.html)? This helps in generating similar diagrams when using d2 as an alternative to Graphviz.

pmoura avatar Nov 22 '24 14:11 pmoura

@pmoura

The tab shape is too similar to package shape in D2.

The component shape imo is too UML-specific, and supporting UML is not a goal of D2. Can you just map those to rectangle in your tool?

alixander avatar Dec 06 '24 11:12 alixander

Indeed I'm currently using d2 package shape as the alternative to the Graphviz tab shape.

But d2 rectangle shape is not (in my particular case) a good replacement for the Graphviz component shape. Btw, I don't use or generate UML diagrams as UML is too limited and fails to cover most of my language constructs.

pmoura avatar Dec 06 '24 14:12 pmoura

So the only difference between rectangle and the component shape is the two mini rectangles on the left? It's my understanding that that's just an arbitrary symbol that UML bestows meaning to. If your goal also isn't UML, can you elaborate on why it's valuable?

alixander avatar Dec 06 '24 19:12 alixander

I need a shape for a component (category in Logtalk lingo) that visually helps distinguish from objects and protocols (interfaces), which uses a box/rectangle shape. But I don't see this as related to UML at all. Providing similar shapes to Graphviz helps projects compatibility and migration when generating diagrams.

pmoura avatar Dec 06 '24 19:12 pmoura

Would this feature suffice? (https://github.com/terrastruct/d2/issues/1081#issuecomment-2417317267)

Basically adding a <<type>> to objects, distinct from label.

alixander avatar Dec 06 '24 20:12 alixander

My diagrams tool already supports an option that does just that. The text is printed below the label in a small font size. You can see an old example at:

https://logtalk.org/diagrams/tools/tools_directory_load_diagram.svg

pmoura avatar Dec 06 '24 20:12 pmoura

That's not a d2 diagram. I thought you were looking for a feature in d2 diagrams for your use case.

alixander avatar Dec 06 '24 23:12 alixander

I am. I just provided that old example to show that what you described as "adding a << type >> to objects, distinct from label" is already implemented by Logtalk's diagrams tool, which currently supports both Graphviz dot and d2 graph language output files. It's a Logtalk user choice which graph language to use. I just upload a d2 version of the same diagram at:

https://logtalk.org/diagrams/d2/tools_directory_load_diagram.svg

The tool supported for d2 is currently marked as experimental, with the main feature missing being links in edges.

pmoura avatar Dec 07 '24 00:12 pmoura