NVD3/D3 change y axis minimum value

Most charts have a forceX and forceY functions which take a array of values. You can use it like this:

  var chart = nv.models.lineChart();
  chart.forceX([0, 10])
  chart.forceY([-1, 1])

Which will ensure that on your xAxis you are always showing at least 0 and 10, but won't restrict the domain if you manipulate it directly. That is if you do something like:

chart.yAxis.scale().domain([0, maxValue]);

and your data has negative X values that won't show on your chart because they'll fall outside of the specified domain, but they will, if you use forceX.


You don't need to add a "dummy" data point, all you need is adjust the input domain of the scale, e.g. something like

chart.yAxis.scale().domain([0, maxValue]);