我正在使用d3.js进行散点图绘制,我想绘制x和y轴以使其在点(100,75)相交.如何做到这一点?
我在用
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + (padding+223) + ")")
.call(xAxis2);
//Create Y2 axis
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(" + (padding+200) + ",0)")
.call(yAxis2);
但这不会随比例尺而改变,因此我使用了变量作为比例尺.
如果您需要更多信息,请告诉我.
解决方法:
您需要将轴偏移各自的量,您可以使用轴的比例来确定该量,即
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + yScale(75) + ")")
.call(xAxis2);
和类似的y轴您可能需要稍微调整偏移量,以解决其他偏移量,标签等问题.