How to draw a vertical line in SVG
14,306
you want x1, not x
<style>
svg#chart {
background: lightgray;
}
#chart line {stroke: #555555; stroke-width:1}
</style>
<svg id="chart" width="300" height="225">
<line x1="20" y1="20" x2="20" y2="130"></line>
</svg>
Related videos on Youtube
Comments
-
johnchase almost 2 years
I am trying to draw a vertical line with SVG.
<style> svg#chart { background: lightgray; } #chart line {stroke: #555555; stroke-width:1} </style> <svg id="chart" width="300" height="225"> <line x="20" y1="20" x2="20" y2="130"></line> </svg>
Given that "x" and "x2" are the same I would have expected the line to be completely vertical. I'm pretty new to this type of programming, so I am likely missing something very obvious, however this is not the behavior I would have expected.
How do I make this line vertical?
-
Harry over 7 yearsTypo. It should be
x1
. Since you've not definedx1
it is getting assumed as 0 and so the angular line. -
AthMav over 7 yearswhy dont you use a program like inkscape?
-
-
johnchase over 7 yearsOf course it was something so obvious. I'm still getting used to web programming where things don't throw horrible traceback errors with typos. Thanks you very much for your answer!