d3 time scale x axis with unix timestamp

Viewed 25559

Having trouble formatting the x-axis of this time-series chart using d3 js.

Here is a working example: http://tributary.io/inlet/7798421

The issue: I can only see 1 date (label) on my x-axis, regardless of total # of ticks specified. How can I display the time on x-axis with 4-6 ticks?

EDIT: Solution below thanks to Lars.

Here is my time in UTC:

var data = [
    {"time": 1387212120, "open": 368, "close": 275, "high": 380, "low": 158},
    {"time": 1387212130, "open": 330, "close": 350, "high": 389, "low": 310},
    {"time": 1387212140, "open": 213, "close": 253, "high": 289, "low": 213}];

data.forEach(function(d){ d.time = new Date(d.time * 1000) });

And then d3 accept it, in default format, or you can customize.

1 Answers
Related