Line

Lines have the following attributes:

  • x1: starting x position
  • y1: starting y position
  • x2: ending x position
  • y2: ending y position

Here are two examples:

<!--the first element won't be visible because it doesn't have a strokethe second will be visible because it does have a stroke--><line x1="0" y1="0" x2="100" y2="100"/><line x1="0" y1="0" x2="100" y2="100" stroke="purple"/>

The following output will be displayed:

Get D3.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.