小编Ern*_*ona的帖子

使用d3.js从csv文件中绘制voronoi图

我想从cmb文件中的一组点使用http://mbostock.github.com/d3/ex/voronoi.html绘制voronoi图.

我修改了代码:

var w = 1200,
h = 800;

d3.text("ReMeRi_4_2_2_0.csv", function(datasetText) {

var vertices = d3.csv.parseRows(datasetText);

var svg = d3.select("#chart")
  .append("svg")
    .attr("width", w)
    .attr("height", h)
    .attr("class", "BuPu");


svg.selectAll("path")
    .data(d3.geom.voronoi(vertices))
  .enter().append("path")
    .attr("class", function(d, i) { return i ? "q" + (i % 9) + "-9" : null; })
    .attr("d", function(d) { return "M" + d.join("L") + "Z"; })

svg.selectAll("circle")
    .data(vertices.slice(1))
  .enter().append("circle")
    .attr("transform", function(d) { return "translate(" + d + ")"; })
    .attr("r", 2)

 text1 = svg.append("svg:text")
    .text("control")
    .attr("x", 150) …
Run Code Online (Sandbox Code Playgroud)

csv voronoi d3.js

5
推荐指数
1
解决办法
1675
查看次数

标签 统计

csv ×1

d3.js ×1

voronoi ×1