如何设置x和y轴的交点 [英] How to set intersection point of x and y axis

查看:187
本文介绍了如何设置x和y轴的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用d3.js作为散点图,我想绘制x和y轴,使它们相交点(100,75)。如何做到这一点?
我使用

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("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);

但是这不会根据比例改变,我已经使用了比例变量。
如果您需要更多信息,请让我知道。

But this will not change according to the scale,and I have used variable for scale. Please let me know if you need more information.

推荐答案

,您可以使用轴的比例确定,即

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);

,类似地对于y轴。您可能需要稍微调整偏移量才能考虑其他偏移量,标签等。

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

这篇关于如何设置x和y轴的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆