[英]d3.js nvd3.js — Get y-axis min/max values
I'm using NVD3's lineChart model. 我正在使用NVD3的lineChart模型。
I need to force-set the min and max y-axis values relative to the actual ones, eg: 我需要强制设置相对于实际值的最小和最大y轴值,例如:
chart.lines.forceY([min/1.1,max*1.1]); chart.lines.forceY([分钟/ 1.1,最大* 1.1]);
How can I get the current min/max y-axis values? 如何获得当前的最小/最大y轴值?
您可以通过chart.yAxis.scale().domain()
获取当前域。
If you have already set the y-axis domain like so: 如果您已经设置了y轴域,如下所示:
var yAxis = d3.svg.axis().scale(y)
.orient("left").ticks(5);
y.domain([0, d3.max(yourData)]);
you can access the values through y
. 你可以通过y
访问这些值。 y[0]
is the minimum, y[1]
is the max. y[0]
是最小值, y[1]
是最大值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.