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

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.

1 Like

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!

2 Likes

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

2 Likes

I just ran the tests on the above JFiddle in Chrome and found test 10 to again be failing.

I then ran the same tests on the JFiddle in Firefox and found test 10 to be PASSING.

Why?