How to Start a D3.js Layout

The easiest way to create a D3.js layout is to start with an <svg> element that acts as the container (i.e. backdrop) for your chart. Simply add something like:

  <svg width="300px" height="300px"></svg>

To whatever width or height you choose. Then you can add other elements within it, for example:

      <svg width="300px" height="300px">
<rect x="20" y="20" width="20px" height="20" rx="5" ry="5" />
<rect x="60" y="20" width="20px" height="20" rx="5" ry="5" />
<rect x="100" y="20" width="20px" height="20" rx="5" ry="5"/>
</svg>

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Contact

3420 Pump Rd. #181
Henrico, VA 23233

+1 804 430 9444

Contact Us

Connect