简体   繁体   English

d3用彩带​​连接弧和点

[英]d3 connect arc and point with a ribbon

Given a set of arcs that make up a circle and random points generated inside of said circle, what's the best way to generate an area or chord that connects a slice of the array to one of the points and not just the exact center? 给定一组组成一个圆的圆弧和在所述圆内部生成的随机点,生成将数组的一个切片连接到这些点中的一个而不仅仅是确切中心的区域或和弦的最佳方法是什么?

I was thinking that a ribbon or chord layout would be helpful here but the chord layout seems specific to connecting arcs (though admittedly I've only spent about two days researching it and am struggling with actual usage) 我以为丝带或和弦的布局在这里会有所帮助,但和弦​​的布局似乎特定于连接弧(尽管我只花了大约两天的时间进行研究,并在实际使用中苦苦挣扎)

Right now I have a simple arbitrary arc and circle as such - 现在,我有一个简单的任意弧形和圆形-

var width = 1000;
var height = 600;

var svg = d3.select("body")
    .append("svg")
    .attr("width", width)
    .attr("height", height)
    .append("g")
    .attr("transform", "translate(" + width/2 + "," + height/2 + ")");

let arc = svg.append("path")
    .datum({
      id: 1,
      startAngle: 0,
      endAngle: .50 * (2 * Math.PI)
    })
    .style("fill", "blue")
    .attr("d", d3.arc()
      .innerRadius(180)
      .outerRadius(200))

let circle = svg.append("circle")
  .attr("cx", 0)
  .attr("cy", 0)
  .attr("gradientUnits", "objectBoundingBox")
  .attr("r", 20);

Simple fiddle - http://jsfiddle.net/968o4s9m/ 简单的小提琴-http: //jsfiddle.net/968o4s9m/

Seems the best way is to draw a path manually by entering all points using lines and arcs. 似乎最好的方法是通过使用直线和圆弧输入所有点来手动绘制路径。 Ribbons do not appear to be able to connect arbitrary points and arcs from what I can tell. 根据我的判断,功能区似乎无法连接任意点和弧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM