Julian Laval
Julian Laval

Reputation: 1250

dc.js x-axis ticks unexpected behaviour

Having a bit of trouble with dc.js.

I have a line chart, for which I am trying to set the maximum ticks. The current graph is as such:

Graph image

I am trying to customise its x-axis ticks with the following parameters

graph.xUnits(d3.time.days).round(d3.time.day.round)
graph.xAxis().ticks(8).tickFormat(d3.time.format("%m/%d"))

As you can see, the graph is showing more than 8 ticks, and is showing an unnecessary extra value at 08/01.

Any clues as to how this can be resolved? Thanks!

Upvotes: 0

Views: 2485

Answers (1)

Mike Precup
Mike Precup

Reputation: 4218

From the docs on linear.ticks([count]), which that value is eventually passed to:

The specified count is only a hint; the scale may return more or fewer values depending on the input domain.

d3 doesn't supply a way to specify an exact tick count, save for specifying the ticks yourself. You can generate the ticks yourself, and set them with axis.tickValues([values]).

Upvotes: 2

Related Questions