forceY
forces the domain to include the values you pass in, it doesn't shrink the domain created from the data. To set a specific domain, you set chart.yDomain([0,1])
. However, that would set the domain to [0,1] regardless of what your data is. As I understand it, you only want to change the behaviour when all your y-values are 0.
For that, try chart.forceY([1])
. Now, when NVD3 tries to figure out the domain, it will see both the zero values from the data and the 1 from the force statement. So it will have a valid domain and it won't have to make up a domain by adding and subtracting 1 from the data value.
forceY
-- #11767379 – EmpoisonstackedAreaChart
, where apparentlyyDomain
doesn't work as expected. – Baltic