Range of change for one axis y nvd3 / d3

I am currently using the multiChart model and I have two different y Axes. I would like to change both axes to start at 0, because currently they start at the smallest data point y.

I tried to do the following

chart.yAxis1 tickFormat(d3.format(',.f')) .domain([0,max_y]); 

but it does not work

and

 .forceY ([0, max_y]) 

he tells me that there is no forceY function

Any ideas?

+6
source share
2 answers

You can force the minimum and maximum values ​​in NVD3 to be linear or bar graphs, as shown below:

 chart.bars.forceY([0]); chart.lines.forceY([0,100]); 
+10
source

.domain([0, max_y]) should be used on the scale object, not the axis object .

So:

 var yScale = d3.scale.linear().domain([0,max_y]) var yAxis = d3.svg.axis().scale(yScale) 

This should work; if not, you should post what you have as jsfiddle .

+1
source

Source: https://habr.com/ru/post/947128/


All Articles