There is such a schedule: https://jsfiddle.net/v85rzofL/

The problem is that the maximum number is 100000. But when yScale range produces values from 0 to 100000 without taking into account the fact that the maximum input number(50000) is twice less than the maximum allowable number. In this case, a curve is constructed so that the value of 50000 reaches the top of the chart, not half.

Question: how to use the data that the curve is built correctly? Ie the values of the curve must be independent of the value axis Y. namely, a point of 50,000 (from 100,000) must be placed exactly opposite 50000, 100000 and not the contrary.

The problem is that the maximum number is 100000. But when yScale range produces values from 0 to 100000 without taking into account the fact that the maximum input number(50000) is twice less than the maximum allowable number. In this case, a curve is constructed so that the value of 50000 reaches the top of the chart, not half.

Question: how to use the data that the curve is built correctly? Ie the values of the curve must be independent of the value axis Y. namely, a point of 50,000 (from 100,000) must be placed exactly opposite 50000, 100000 and not the contrary.

asked March 23rd 20 at 19:15

1 answer

answered on

Solution

Get

`yScale.domain(d3.extent(data, (d) => d.amount))`

- so you re-ask interval of values, taking as boundaries the minimum (was 0, left 0) and maximum (instead of the previously installed 100000 50000 was, therefore, "the line reaches the top of the chart") their data.Thanks for the help, much helped! - Alfonz commented on March 23rd 20 at 19:20

Find more questions by tags D3.jsJavaScript