jiahuang / d3-timeline

Simple JS timeline plugin for d3
1.04k stars 280 forks source link

Setting tickValues #64

Closed inodb closed 8 years ago

inodb commented 9 years ago

I'd like to use tickValues (https://github.com/mbostock/d3/wiki/SVG-Axes#tickValues) to set specific axis values. Can you recommend a way how to do that?

inodb commented 9 years ago

I've solved it by adding an extra option to tickFormat:

var xAxis = d3.svg.axis()
  .scale(xScale)
  .orient(orient)
  .tickFormat(tickFormat.format)
  .tickSize(tickFormat.tickSize);

if (tickFormat.tickValues !== null) {
  xAxis.tickValues(tickFormat.tickValues);
} else {
  xAxis.ticks(tickFormat.numTicks || tickFormat.tickTime, tickFormat.tickInterval);
}

Want me to send a PR?

jiahuang commented 9 years ago

Yeah a PR would be great, thanks :)