Skip to main content
100%

Molecule

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Jul 3, 2012

A force-directed layout draws a molecular graph, with atoms as colored, size-scaled circles and bonds as connecting lines. Each node is labeled with its chemical symbol from the data file, and bonds are drawn thick or as double lines based on the bond value. The visualization uses `d3.layout.force` for simulation and SVG for rendering, reading atom and bond data from a JSON file. The code offsets double bonds by overlaying a white separator line on the thicker stroke.

AI-generated description

This is a quick hack to draw two parallel links between nodes. Yes, you can scale it to more than two nodes, but it gets increasingly awkward. The alternative is to compute the paths manually, say by computing the perpendicular vector of the vector between the node centers, and offsetting the links accordingly.

gpl-3.0 Licensed

Similar vizzes