Skip to content Skip to sidebar Skip to footer

How To Parse Date On D3 With A Specific Interval

I'm trying to solve this challenge from FreeCodeCamp. I managed to display the chart with the right data on the Y axis (2000, 4000, 6000, etc...). On the X axis I would like to di

Solution 1:

I created a fiddle which I think gives the desired results. The change I did was on your scale band axis creation I updated it to:

var xAxis = d3.axisBottom(x)
    .tickValues(x.domain().filter(function(d, i) {return !(i%4);}));

You can change the i%4 to however many ticks you would like. You could also make it so that it returns only certain data points if you wish eg. return d == Feb 2018 More information found here.

Post a Comment for "How To Parse Date On D3 With A Specific Interval"