magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.68k stars 103 forks source link

Scale and Center Graph #195

Open tuckergordon opened 3 years ago

tuckergordon commented 3 years ago

I've asked this question on Stackoverflow as well, but is there a way to scale and center a graph? I would like to display a graph that is 0.5 scale and centered within the SVG, but haven't found a good way of doing that.

Simple code snippit:

<div id="graph" style="width: 300px; height: 300px; border: 1px solid black"></div>
d3.select("#graph")
  .graphviz()
    .width(300)
    .height(300)
    .fit(true)
    .scale(.5)
    .renderDot('digraph {a -> b}');

This is somewhat related to #7 , but I didn't see an answer in there and figured it was worth bringing up since v2.2.0 came after that ticket was closed. Apologies if I should've continued the thread in that ticket instead of opening a new one

magjac commented 3 years ago

I've now answered the SO post. I guess a simpler way would be if there was something built-in to d3-graphviz, but unfortunately there currently isn't.

tuckergordon commented 3 years ago

Thank you! I'm very appreciative of your time on this! That was exactly what I was looking for.

Should I close out the issue, or leave it open for a possible future feature addition?

magjac commented 3 years ago

If this is a feature that you would like to see, I think we should keep it open. I've added the "Enhancement" label to it.