d3---贝塞尔曲线link

    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')
    })

你可能感兴趣的:(d3)