doLayout method

  1. @override
void doLayout(
  1. Context context,
  2. Graph graph,
  3. num width,
  4. num height,
)
override

Implementation

@override
void doLayout(Context context, Graph graph, num width, num height) {
  num w = center[0].convert(width);
  num h = center[1].convert(height);
  Random random = Random();
  double scaleFactor = 0.9;
  for (var node in graph.nodes) {
    node.x = (random.nextDouble() - 0.5) * scaleFactor * width + w;
    node.y = (random.nextDouble() - 0.5) * scaleFactor * height + h;
  }
}