d3贝塞尔曲线link

25次阅读

共计 551 个字符,预计需要花费 2 分钟才能阅读完成。

    let data=[{source:{x:100,y:100},target:{x:250,y:120}},
      {source:{x:100,y:100},target:{x:250,y:250}}
    ]
    /*let data={source:[100,100],
      target:[200,200]
    }*/
    function handle(data){
      let result={source:[],
        target:[]}
      result.source[0]=data.source.x
        result.source[1]=data.source.y
        result.target[0]=data.target.x
        result.target[1]=data.target.y
        return result
    }
    let link=d3.linkHorizontal()
    //let path=link(handle(data[0]))
    //console.log(path)
    this.svg.selectAll('.link').data(data).join(enter=>{enter.append('path')
        .attr('d',d=>link(handle(d)))
        .attr('fill','none')
        .attr('stroke','#000')
    })

正文完
 0