SVG connect two points with a line

ashu picture ashu · Jun 24, 2013 · Viewed 12.8k times · Source

Is there any way to connect two point using a line in SVG .I am having the following to create point in SVG.

<?xml version="1.0" standalone="no"?>

<svg width="200px" height="200px" version="1.1" xmlns="http://www.w3.org/2000/svg">

  <path d="M10 10"/>

  <!-- Points -->

  <circle cx="10" cy="10" r="2" fill="red"/>
  <circle cx="90" cy="90" r="2" fill="red"/>
  <circle cx="90" cy="10" r="2" fill="red"/>
  <circle cx="10" cy="90" r="2" fill="red"/>

</svg>

I need to draw a line between points using jquery functions.

Answer

Peter Collingridge picture Peter Collingridge · Jun 24, 2013

You can use a line:

<line x1="10" y1="10" x2="90" y2="90" stroke-width="1" stroke="black"/>

Or a path:

<path d="M10 10 90 90" stroke-width="1" stroke="black"/>

Why do you need jQuery?