The key to this line is:
let xAxis = axisBottom().scale(x).ticks(6);
Try changing like this:
let xAxis = axisBottom(x).ticks(6);
For a full working example, see jsFiddle
EDIT
Improved js script above to enable formatting.
Snippet from jsFiddle below:
let x = d3 .scaleTime() .range([0, totalWidth]) .domain(d3.extent(data)); let xAxis = d3 .axisBottom(x) .ticks(d3.timeDay, 1) .tickFormat(d3.timeFormat("%a %d"));
Ashley coolman
source share