upvote
What is the purpose of those animations? If I could use them in a presentation where I click through a diagram adding things as i click and their connections being animated for highlight then sure. I don’t really like the example where the text changes in you link, the whole diagram jumping around just because a text changes seems like something that would be annoying. So I guess you would need to render everything and keep some things hidden until activated?!

As a side not, I would love a proper Swimlane-diagram. I think you have all the building blocks with your ability to nest things in flowcharts, just need to force-align some boxes in different swimlanes and align the lanes themselves (and probably a lot more behind the scenes).

reply
The purpose is to make use of a dimension of the visual space previously unused to make diagrams more expressive.

Even if it's something simple like a node turning from green to red to convey it's shutting down. Maybe something like that before animations would be a text saying, "this node will shut down now", which takes reading/zooming into text.

I also think it can, if used well, result in diagrams that ⋆⋆spark joy⋆⋆. People like to see diagrams like that, even if it's not more utilitarian. I think sketch mode is an example of this. It changes the font to an objectively less readable one, yet I often hear people make all their D2 diagrams in sketch mode.

reply
deleted
reply
Hi Alixander! I started using D2 just a couple months ago -- the first time I had to design a system at work. I'm really happy with it -- I was amazed how easy it was to pick up.

TBH, I don't think these fancy animations are necessary. If I want to call attention to a certain box or arrow in the diagram, I would rather turn it red than have anything moving.

reply
There's another HN discussion going, about declarative diagramming [0], from where I learned about Ilograph [1]. And which makes great use of animations for system documentation.

[0] https://news.ycombinator.com/item?id=45706792

[1] https://www.ilograph.com/features.html

reply
I think diagrams are opinionated. I’d like to show animations instead of just colors. Data flow for example. Yes arrows help, but animations help better. It is all about personal preference. There is no right or wrong.
reply
What if that style is already used though? (e.g. other connections are red)
reply
Well, in any case, I would make it a contrasting color.
reply
First of all, thanks for your work on D2, it is the coolest of them all IMHO. I would definitely use animations because management loves shiny things and if they are happy I get my salary bumped.

I have recently made a solution for dynamically codifying the network layout of AWS accounts with D2. D2 was the only solution that was allowing to render a lot of objects without having to fight the engine with tons of hints. My only complaint was/is that the sdk/d2lib was very under-documented, so initially I started off with generating text as a map before realizing that there is a better way that is barely used. It took me some time to figure out how to use the lib for the trickier parts.

reply
Would love to see that shared in github/lab if you’re allowed.
reply
I would share it, but BigCorp would come after me. It is nothing terribly smart really. I am using steampipe to list all the regions for VPC/Subnets/NAT GW/IGW/[everything else networky] and loop through the list adding nodes to the diagram. There is a long list of accounts which all gets generated and committed in a git repo. The big challenge was to make it all readable instead of making a mess.
reply
I know this is a big request, but lately I've been using LLMs to quickly draft and showcase architecture decision. I mainly fallback to mermaid, but I am curious if d2 would be more flexible? I usually endup visualizing anyway with drawio. I am curious if there are plans on creating a more user friendly interface (mcp, or tool calling feature) with llms.
reply
There’s also PlantUML, which is much more featureful than Mermaid but can’t use JS to render text to a diagram in-browser. There is a server that you could use JS to load images from.

I haven’t used prompts to generate diagrams, but Cursors autocomplete seems to recognize the syntax at least.

reply
I would be interested in this as well, but would love it to be more like openapi protocol, with an agents.md.
reply
reply
I love this hahah. Diagrams as a comic book.

The urge to add silly stuff like this vs working on v2 of sequence diagram that has much more demand is often tempting.

reply
Thoughts on Animations:

* Reveal.js style declaration for "keyframe 1", declaration for "keyframe 2" and then automatic animation/transition between the two. Animation "themes" of fade in/out, pop in/out of nodes. I like the arrow "growing" theme from the article but would also see cases where I want the nodes to appear first and the arrows grow to them, and also a case where the arrow grows and the nodes appear at the end.

* Impress js zoom, movement, focus

I would like to use animations to help me communicate something or to make my point. I'm not necessarily looking to spark joy - I'd very much see that as a "nice to have" (i.e. for each or the above make the defaults pretty).

reply
You get this when transitioning boards in our hosted platform (try clicking): https://d2studio.ai/diagrams/664641071

I don't add this for D2 CLI because the outputs there are SVG, and this feature requires Javascript.

reply
I'm a bit surprised at the first "cool slop" example, I'd expect a "more tangible" (by way of animation) data flow visualization to be useful rather than fluff. Though since it's not dynamic (it's not based on live data or anything), maybe that's why it'd be superfluous?
reply
It's superfluous because the arrow already points in a direction; the line animation doesn't tell you anything the arrowhead doesn't.
reply
On the example animation not all paths are taken, so that is one bit of extra information that the animation does provide. Though even if it was fully identical, I do find it considerably easier to see where the data is moving based on dots tracing out a path than I do by scanning for small arrows in a massive diagram, hence my confusion on this. Fair point though.
reply
deleted
reply
This would be super useful for my project
reply
Hi Alixander

Thanks for the good work!

I am late to the party, but let me add my grain of salt. I think animations could be a killer feature when preparing for talks. This is something I already do with a modified version of graphviz (I explain my workflow below) and d2 seems to have almost all functionalities I need to adapt it but one (the one I had to add to graphviz): hardcoding custom HTML attributes in the generated SVG for animation purposes.

Let me explain: I have been using revealjs for making slides for a while now. The way "animation" is dealt with here is really interesting: html blocks having the "fragment" class will be visited with a class "current-fragment" and "fragment-visited" one after the other. One can then play with the animation using CSS, eg, .fragment is not displayed but .fragment.current-fragment and .fragment.fragment-visited are displayed. Hence, moving through slides allows to display new content in the slides. Nothing prevents it to work on inlined svg and I can use d2 to create diagrams with nodes/edges having the fragment class and revealjs will incrementally make them appear.

I am however missing something here. Revealjs visits fragments by walking the DOM. Hence the animation depends on the order the diagram is generated in. Moreover, it is impossible to make several nodes appear together (or you need them in the same sub-diagram). Revealjs has a nice workaround: you can add a data-fragment-index attributes in your tag. Nodes will then be visited by following the fragment-index order. Being able to just add indices to the fragment in d2 would be enough to completely animate the diagram using revealjs without any overhead, by just inlining the generated svg into the slides.

I actually do that with graphviz already, where I slightly modified the source to that I can add a data-fragment-index in nodes/edges, which allows me to animate diagrams, see [1] for example for a recent animation I did for a talk.

I guess I could do this in d2 too, but since you are expressing an interest in animation, let me tell you that just being able to specify an order in which blocks are visited and that this is performed via css modification is an extremely powerful approach (you can not only make things appear/disappear, you can also change colors for highlighting or anything you can think of that is doable in css ; changing sizes is a bit of an adventure though as you may fall into inconsistent drawing). Moreover, if you use the fragment/data-fragment-index terminology, you would directly be compatible with revealjs, which could be a really nice combination (though, there are some shortcomings with revealjs regarding fragments index which is why I now use a homecooked [2], minimal version of the same idea ; like having more than one index for a block, or being forced to use numbers for index where 1a 1b 1c would be more interesting to "insert" transition between two existing ones without having to renumber).

Let me just conclude with an example. I would love to be able to write this in d2, to make the edge "CONNECT" appears and the "info" node at the first transition:

```

a: "Alice"

b: "Bob"

a -> b: "CONNECT" {

  class: "fragment",

  fragment-index: 1
}

info: "Alice and Bob are connected" {

  class: "fragment",

  fragment-index: 1
} ```

[1] https://florent.capelli.me/talks/251016-JITA/#/103

[2] https://github.com/fcapelli/monoski/

reply
Put me in the camp of “animation is valuable even when it’s redundant information.” Guiding the eye and helping to digest information is valuable, and even the slop examples are useful in my opinion
reply