I am creating a svg x-y-chart in d3.js. Is it possible to create ticks of different lengths depending on tickValue?
I have made my own tickFormat function myTickFormat
and use that in .tickFormat([format])
and that works fine because [format] is expected to be a function. But it is not possible to do the same with .innerTickSize([size])
, which expects a number.
E.g. if I want the tick at value 70 to be longer I want to do something like this:
var myTickSize = function(d) {
if (d === 70) { return 20;}
return 6;
};
But when I use myTickSize
as argument to .innerTickSize()
:
var yScale = d3.scale.linear();
var yAxis = d3.svg.axis()
.scale(yScale).orient("left")
.innerTickSize(myTickSize);
I get an Error: Invalid value for attribute x2="NaN" error for each tick.