<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>myd3</title>
</head>
<body>
<div class='myd3_drawlines'></div>
<div class='myd3_drawrect'></div>
<div class='myd3_drawpie'></div>
<script src='d3.js'></script>
<script src='myd3.js'></script>
<script>
var arr = [1,4,16,16*16,16*16*16,16*16*16*16,16*16*1,16*16,16,4,1];
draws_d3.drawlines(arr,'.myd3_drawlines',300,200,false,'aaa').attr('stroke','red').attr('stroke-width',5);//后面这些,false,'aaa').attr('stroke','red').attr('stroke-width',5);参数可省略
draws_d3.drawrect([1,4,6,2,3,7],['china','japan','usa','thailand','russia','holland'],'.myd3_drawrect',30,200);
draws_d3.drawpie([['apple',60],['sansong',80],['huawei',60],['lenovo',100]],'.myd3_drawpie',200,200);
</script>
</body>
</html>
因为太麻烦了我只写了常用的曲线图,柱状图和饼图,而且代码写得不是太好,就是提供给懒得学d3.js的人凑合着用,我的函数只提供了简单的几个参数,如果想要更多的话可以对我源代码进行修改,至少比你自己重新写要简单的多。