Link to challenge
https://codepen.io/LangXIE/pen/axZPKe?editors=0010
Problem
Hi, guys, I cannot seem to get rectangle bars showing on the svg. I don’t know why because the svg element is displaying alright. Can someone help me please
Link to challenge
https://codepen.io/LangXIE/pen/axZPKe?editors=0010
Problem
Hi, guys, I cannot seem to get rectangle bars showing on the svg. I don’t know why because the svg element is displaying alright. Can someone help me please
So there are two errors.
1 - You’re using d3.scaleLinear()
function which is only available in d3 version 4 or higher. You need to use a newer version of d3 library.
2 - While setting the y
and height
attributes on your rect
elements, you need them to be a number. And if you do something wrong with the Math in JS, you usually end up getting NaN
, which is what is happening in your case.
Here’s the fixed version, I added the comments in here for you.
https://codepen.io/anon/pen/rbLRNj?editors=1010
I don’t know this is the right graph in terms of rendered values according to the FCC tests requirements, but you can now figure out the rest on your own. Hope that helps!