对于散点图,使用的数组需要包含坐标元素,即 x, y。同时,散点图需要使用 circle 元素。
var svg = d2.select("body") ???.append("svg") ???.attr({ ???????width:w, ???????height:h})svg.selectAll("circle") ???.data(dataset) ???.enter() ???.append("circle") ???.attr("cx",function(d){ ???????return d[0]; ???}) ???.attr("cy",function(d){ ???????return d[1]; ???}) ???.attr("r",5);
D3.js 绘制散点图
原文地址:https://www.cnblogs.com/guangluwutu/p/9971826.html