Issues with date object -Data Viz- Heat Map

My code:
I’m trying to make a heat map for the data visualization certification. I’m having issues with the dates on the x-axis. It should be displaying the years 1753 - 2009 but right now it won’t display any year before 1890. Not even hard coding the dates will make it display correctly. I assume it’s because I don’t get date objects, but any input is appreciated!

Hello @partum!

The problem is caused by the default formatting behavior of axis labels. You can fix this problem by changing the default format.

// Replace the axis with the variable name of the x-axis in your code
someAxis.tickFormat(label => new Date(label).getFullYear());

Thus corresponding years will be shown as the labels for the x-axis.

Also, you should remove the nice method in the xScale because it rounds the min and max domains and this causes the tests to fail.

Don’t hesitate to ask about any problems you may encounter in the future. Happy coding!

That got it to work. Thank you!

1 Like