Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3.js nvd3.js — Get y-axis min/max values

I'm using NVD3's lineChart model.

I need to force-set the min and max y-axis values relative to the actual ones, e.g.:

chart.lines.forceY([min/1.1,max*1.1]);

How can I get the current min/max y-axis values?

like image 269
gipadm Avatar asked Nov 20 '13 09:11

gipadm


2 Answers

You can get the current domain through chart.yAxis.scale().domain().

like image 64
Lars Kotthoff Avatar answered Nov 20 '22 09:11

Lars Kotthoff


If you have already set the y-axis domain like so:

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[0] is the minimum, y[1] is the max.

like image 2
wordsforthewise Avatar answered Nov 20 '22 10:11

wordsforthewise