Skip to content

Instantly share code, notes, and snippets.

@yay
Created October 4, 2016 14:29
Show Gist options
  • Save yay/53f5b9bde8bdfe5d223cc10344c1aef6 to your computer and use it in GitHub Desktop.
Save yay/53f5b9bde8bdfe5d223cc10344c1aef6 to your computer and use it in GitHub Desktop.
D3 4.x: axis & time scale issue
var now = new Date();
var then = new Date();
then.setDate(now.getDate() + 7);
var axis = d3.axisTop().ticks(d3.timeDays).tickFormat(d3.timeFormat('%b %d'));
var scale = d3.scaleTime().domain([now, then]).range([0, 500]);
axis.scale(scale);
d3.select(document.body).append('svg').append('g').call(axis); // TypeError: t.range is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment