Lurker News
I love making diagrams to help understand, plan, etc. However, the options are (A) auto-placement languages like Mermaid or Graphviz (which don't let me decide how the diagram looks), or (B) software like Draw.io which are powerful but are very time consuming (and inefficient for agents to manipulate).

I wanted to have the benefits of both, where you can define a diagram in a diagram language, but also retain a high degree of control over what the diagram looks like.
I also wanted this to work well for humans and agents.
On the Github link, there's a playground where you can try it out without installation. There's also instructions for a simple npm install and for installing a skill you can use with Claude or other agents.

Comments (119) 47 threads

Earlier comments
threecheese1 reply#
Does this need to be shipped with a renderer? A better question is, are the node layout instructions ultimately being translated into absolute positions?

If so, you could target any number of render backends, keeping the same simple interface for your agent, avoiding the bazillion problems rendering engines face to work well across the ecosystem.

jpwalsh234#
Great idea! Yep, the layout instructions are translated into absolute positions. The one gap right now is just that the CLI doesn't give you a way to say "just calculate the positions, stop there, and give me JSON". The logic basically exists to do that, with a minor tweak to the CLI to allow that.

I'll add that to my Reladraw todo list!

Footprint05212 replies#
That’s what I have been using, but from glancing through this repository, it looks like the win here is that you can define where you want things and yet still have diagram as code
jpwalsh234#
Yep, exactly! D2 is in the same family as Mermaid, i.e., automatic layout, with some escape hatches like grid placement or absolute positioning. Reladraw sits in a gap between automatic layout and absolute positioning.
2muchcoffeeman#
D2 has some support for this. You can fix the position of certain elements and then it will redraw things around it.

I’ve been thinking about something similar to this but D2 wasn’t totally open source until now.

the__alchemist#
I suspect the subject line to this "Where you decide where to place things" is a step away from D2; I find that fussy in D2!
rramon1 reply#
Cool, I think there's a bug when switching themes in the web ui in Safari, the artifacts example with the dark red background isn't readable in light themes. Vesper would be a nice theme to add.
jpwalsh234#
Yep, thanks for noticing. Definitely a bug with the themes. Now fixed. And, Vesper theme added in version 0.9.0 in npm and also in the playground :)
jpwalsh2341 reply#
Thanks! The big difference is that Pikchr uses "turtle" graphics (where a cursor walks along and draws shapes). Reladraw lets you state relationships and relative positions.

So, if you have a container with children, or multiple nodes off to the right of another, with links between them, adding or resizing one adjusts the rest, without re-specifying positions the way turtle graphics would require.

gandreani1 reply#
Can you share an example?

I've been playing with pikchr quite a bit and it has containers and you can specify links relative to the container. I can picture (pun not intended) your counter-example

jpwalsh2342 replies#
Great question, I had to noodle that one over a bit, but I think it helped me clarify that difference between pikchr and reladraw. My container example was a poor one, and you are right that pikchr can handle adding elements to a container without fiddling.

My main objection to pikchr is that it is turtle graphics plus coordinate offsets, which to me feels like the wrong tool when I want to say "I have A to the left, and B, C, and D all right of A". I don't want to have to translate that to turtle graphic movements like saying "there's a group, draw B, move down some amount, place C, move down again, place D".
Similarly, if I'm thinking at the level of abstraction of nodes and edges and relative positions, it feels awkward to say something like this in pikchr (where the 0.2 is a guess to fiddle with):

  arrow from Web.s down 0.2 then right until even with DB.s then to DB.s
Rather than saying in reladraw:

  edge web -> db   from: bottom  to: bottom
I think it's less a matter of "reladraw can do it, but pikchr cannot". It's more like, "both can get to the same destination, but how you get there is a matter of taste and how you express your intent".

For example in pikchr:

  A: box "A" fit
  G: [
    down
    B: box "B" fit
    move 0.1
    C: box "C" fit
    move 0.1
    D: box "D" fit
    move 0.1
    E: box "E" fit
  ] with .w at A.e+(0.5,0)
  arrow from A to G.B chop
  arrow from A to G.C chop
  arrow from A to G.D chop
  arrow from A to G.E chop
To me, it's not as clear that your intent is that you want several nodes right of A. However, in reladraw, it's clearer to me that the intent is "these things are right of A":

  node a "A"
  node b "B"  right of a
  node c "C"  right of a
  node d "D"  right of a
  node e "E"  right of a
  edge a -> b
  edge a -> c
  edge a -> d
  edge a -> e
However, that's a subjective taste thing and I could see some people liking the pikchr approach.

Continue this thread — 2 replies

Load more comments