score:3

Accepted answer

If I understand your question correctly, you want to make sure that each bar has always the same height in pixels, regardless the number of bars.

If that's correct, set the range dynamically. For instance:

var barSize = 40;
y.range([barSize*data.length, 0]);

Here is your plunker with the complete data array: https://plnkr.co/edit/zNOMcQob6fSFkEYclyzS?p=preview

Now, for comparison, the same code with just three data elements: https://plnkr.co/edit/KciR2eheLLIOS1SHUM7i?p=preview

PS: You have duplicated names for the area property. That doesn't work with an ordinal scale.

PPS: A good idea is also setting the SVG height according to the data length.


Related Query