How to set intersection point of x and y axis

后端 未结 1 920
鱼传尺愫
鱼传尺愫 2021-01-22 11:39

I am using d3.js for scatter plot,I want to plot x and y axis such that they intersect at point(100,75).how to do this? I am using

svg.append(\"g\")
    .attr(\"         


        
相关标签:
1条回答
  • 2021-01-22 12:24

    You would need to offset the axes by the respective amount, which you can determine using the scales of the axes, i.e.

    svg.append("g")
      .attr("class", "axis")
      .attr("transform", "translate(0," + yScale(75) + ")")
      .call(xAxis2);
    

    and similarly for the y axis. You may have to tweak the offset slightly to account for other offsets, labels etc.

    0 讨论(0)
提交回复
热议问题