简体   繁体   中英

d3.js map lines interrupted

I'm developing a d3.js map. I plotted points on a few countries and I connected those points with arcs. The problem is that some arcs are interrupted.

地图上的弧线中断

  gArcs.append("path") .datum({ type: "LineString", coordinates:[ [data.dataArray[i].long_from, data.dataArray[i].lat_from], [data.dataArray[i].long_to, data.dataArray[i].lat_to] ] }) .attr("class", "arc") .attr("d", path) .style({ 'stroke': lineColor, 'stroke-width':lineWidth, }) 

Any Ideas on how to draw the arcs without getting interrupted?

Finally, I chose the solution to draw straight lines with projected points on my maps to avoid interrupted arcs.

features.selectAll("path")
  .data(data.dataArray)
  .enter().append("line")
  .filter(function(d) {
    return d.country_name_from == countryNameFrom
  })
  .attr("x1", function (d) {
    return projection([d.long_from,d.lat_from])[0];
  })
  .attr("y1", function (d) {
    return projection([d.long_from,d.lat_from])[1];
  })
  .attr("x2", function (d) {
    return projection([d.long_to,d.lat_to])[0];
  })
  .attr("y2", function (d) {
    return projection([d.long_to,d.lat_to])[1];
  })
  .attr("d", path)
  .style({
    'stroke': lineColor,
    'stroke-width':lineWidth,
  })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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