D3 Bar Chart - why the test fails

Hey, I’ve finished the Bar Chart project, but one test (#10 - x-axis) keeps failing:

https://codepen.io/wawraf/pen/wXpZdg?editors=0110

I’ve noticed that when i change y-axis ticks format, test fails for this axis too (#11), but i still an’t figure it out whats wrong with x-axis.

Please help me find out whether the problems lies in my code or in test suite.

Have a closer look at how you account for the padding.

const xScale = d3.scaleTime()
    .domain([new Date(minDate), (new Date(maxDate))]).range([0, w-2*padding]);

Thanks! Problem solved.

Hi,
I’m working on the data visualisation projects now. I saw your old post about the bar chart project. Your codepen is helping me a lot. In case you still care…your last error can be fixed by using the xScale for your rect.attr(“x”), but be sure to convert d[0] to Date(). Now you can pass 14/14.

use this:
return xScale(new Date(d[0])); //use xScale, pass test

instead of:
return (padding + i * (w - 2 * padding) / data.length); //calculate on the fly using i, fails test