NVD3 - setting ticks along the axis

I have an nvd3 line chart that displays a time series and cannot get ticks on the x axis to the right.

For longer periods of time, it works as expected. But for shorter periods of time (here: from 12/31/05 to 01/01/06) the same date is displayed for several ticks:

example chart

Please see the code for this diagram on JSFiddle

I want the chart to display only ticks at data points, and not between them. Is this possible with a line chart? In my opinion, this is possible with d3, but I cannot figure out if this nvd3 functionality is open.

I tried to explicitly set the number of ticks with chart.xAxis.ticks()no success. The only thing that has any effect is to explicitly set the tick values ​​with chart.xAxis.tickValues([...]), but I would prefer not to calculate them myself.

+4
source share
1 answer

A way to solve this problem as a whole is through custom multiscale time formats . Please note that this example alone will not work with NVD3, because it uses an older version of D3, but the examples below will be.

, "" , , - . , .

, 3, . . . - .

. , .tickValues() , , x :

var xvalues = [],
    tmp = data.map(function(e) { 
            return e.values.map(function(d) { return d[0]; });
          });
xvalues.concat.apply(xvalues, tmp);

, , . , , .

+3

All Articles