Visualize Data with a Bar Chart - not passing test number 10

Visualize Data with a Bar Chart - not passing test number 10
0.0 0

#1

Hi,

I am having trouble with passing the test number 10: The data-date attribute and its corresponding bar element should align with the corresponding value on the x-axis.

The test says that x values don’t line up with x locations : expected false to be true.

I am stuck at this for days :frowning:

Can anyone be so kind and look at my code and tell me what is causing the problem?

my code: https://jsfiddle.net/keraxz6g/

Thanks a lot.


#2

This error message with false and true is a bit misleading I think…

But the issue is that you are not setting the x-values for your bars properly. Check your line 52: you are setting x to the current index times barwidth… basically a counter that goes up. But actually your x-axis is dates! Your x is just a number, lets say 115, but the data from the json is a date, lets say 2001-10-12.

Try setting your x values in line 52 similar to how you set your xScale in line 17. Dont forget to scale them!


#3

Hi, thanks a lot for your help, now it is clear and it works correctly :slight_smile: