I've created a x-axis with a custom tickFormat
in D3.
It prints a tick for each month, but labels January as the year, i.e 2014, 2013, etc.
var xAxis = d3.svg.axis()
.scale(x)
.orient('bottom')
.ticks(d3.time.month, 1)
.tickFormat(d3.time.format.multi([["%b", function(d) { return d.getMonth(); }], ["%Y", function() { return true; }]]))
.tickSize(4)
.tickPadding(8);
I'd like to vary the tickSize
as well and have a long tick for the year markers.
But it doesn't appear you can use a function to return a value. This should print a random tick size for each date, but fails:
.tickSize(function(d){ return Math.random() * 50 })