Ace Dimasuhid Ace Dimasuhid - 4 months ago 18
Javascript Question

nvd3 set scale from big to small

I have a simple line graph where the Y value spans from 0-100. I want to reverse the Y range to go instead to 100-0. Graph code is below:

nv.addGraph(function() {
var values = that.getGraphValues();
var chart = nv.models.lineChart()
.forceY([100, 1]);

.tickFormat(function(d) { return d3.time.format('%b %d')(new Date(d)); });

.tickFormat(d3.format(',r'));'#chart svg')

nv.utils.windowResize(function() {'#chart svg').call(chart) });

return chart;


You need to set the domain of the graph explicitly. In D3 terms "domain" is the expected extent of the data. If you don't set it yourself, it is calculated as [minValue, maxValue]. But you can explicitly set it to anything, even such that the first number is bigger than the second number.

var chart = nv.models.lineChart()