<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>svg dom绘制折线</title>
<style>
#mypolyline{
border: 1px solid red;
width: 200px;
height: 200px;
}
</style>
<script>
function createPolyLine(){
var root=document.getElementByIdx_x("mypolyline");
var SVG="http://www.w3.org/2000/svg";
//创建svg元素
var svg=document_createElement_xNS(SVG,"svg");
svg.setAttribute("width","200");
svg.setAttribute("height","200");
//创建我们的polyline元素
var polyline=document_createElement_xNS(SVG,"polyline");
polyline.setAttribute("points","10,10 100,10,100,100");
polyline.setAttribute("stroke","black");
polyline.setAttribute("fill","none");
svg.a(polyline);
root.a(svg);
}
</script>
</head>
<body οnlοad="createPolyLine()">
<h3>SVG DOM绘制折线图</h3>
<div id="mypolyline"></div>
</body>
</html>