Use escalas dinâmicas

d3.scaleLinear()
    .domain([0, d3.max(dataset, (d) => d[1])])
    .range([h - padding, padding])

// That's all you need to do
Bored Boar