0

I have a file of the following format:

{
   "nodes":[
      {
         "id":"abc",
         "label":"some-long-title"
      },
      {
         "id":"xyz",
         "label":"another-long-title"
      }
   ],
   "links":[
      {
         "source":"abc",
         "target":"xyz"
      }
   ]
}

and I want to create a network graph where the none of the nodes or labels are overlapping each other.

I understand that using a D3 force layout with a large negative charge strength would make the nodes repel each other. However, I don't want the snapping/ticking that comes with the force layout. Ideally, I want a graph like the following example: https://bl.ocks.org/mbostock/4557698

This example contains the (x,y) coordinates in the JSON node objects, which I don't want to generate myself. Is there a way to use the D3 library to generate the (x,y) coordinates initially in a nice, evenly spread way? Or is there a way to use the force layout for initial positioning only and turn off any kind of snapping/ticking of the nodes after?

ejtt
  • 363
  • 3
  • 10

0 Answers0