<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>D3JS 添加数据</title>
</head>
<body>
<script src="https://cdn.bootcss.com/d3/4.13.0/d3.min.js" charset="utf-8"></script>
<script type="text/javascript">
var dataset = ["I like dogs","I like cats","I like snakes"];
//选择p
d3.select("body").selectAll("p")
//绑定值
.data(dataset)
// enter部分
.enter()
//添加足够数量的p
.append('p')
.text(function (d,i){
return d;
})
</script>
</body>
</html>