Issues with Data Visualization Project 1 Bar Chart Tests 10 & 13

I’m encountering errors that I’m having difficulty troubleshooting. One is with the x-axis and the second is with the tooltip functionality.

1) X-axis Issue

I failed the test case 10:
The data-date attribute and its corresponding bar element should align with the corresponding value on the x-axis.

The result is
AssertionError: x values don't line up with x locations : expected false to be true.


2) Tooltip Issue

I failed the test case 2:
My tooltip should have a "data-date" property that corresponds to the "data-date" of the active area.

The result is
AssertionError: Tooltip's "data-date" property should be equal to the active area's "data-date" property: expected '1993-1-01' to equal '1993-01-01'.

However, sometimes it passed even with the same code. :woman_shrugging:t2:


Link to the challenge - Visualize Data with a Bar Chart

Link to my source code


Any help is appreciated!

I solved the test case 10 by referring to: Visualize Data with a Bar Chart - not passing test number 10

  • new Date()
  • scaleTime()

by myrmidonut

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!