score:1

Accepted answer

You can provide specific tick values to be displayed on a d3 chart.

Firstly, correct your date parser:

var parseDate = d3.time.format("%e-%b-%y %H:%M").parse;  // %e instead of %d

First, you need to get the list of tick values you want to display. After you've loaded the csv and processed it, extract the tick values and assign them to your xAxis:

d3.csv("data.csv", function(error, data) {
    data.forEach(function(d) {
        d.date = parseDate(d.date);
        d.close = +d.close;
    });
    var tickValues = data.map(function(d) { return d.date; });

    xAxis
        .tickValues(tickValues)
        .tickFormat(d3.time.format('%H:%M'));

Do not forget to remove the ticks on your current xAxis definition.


Related Query

More Query from same tag