D3js bar graph project- why are my bars upside down?

Sorry for the basic question. Here’s my code pen: https://codepen.io/partum/pen/OJBOmwM
I thought the trick to get you bars to appear right side up was to set height to the container height minus the bar height, which I tried to do with this line: .attr("height", (d) => (h-yScale(d[1]))) but my bars are still upside down. I tried switching the values around, with no luck.

The issue was at the line .attr("y", (d, i) => padding) when positioning the rectangles. It should be .attr("y", (d) => yScale(d[1])). I’m not really sure why, but it works!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.