jiahuang / d3-timeline

Simple JS timeline plugin for d3
1.03k stars 281 forks source link

How to change the timescale to seconds #79

Closed ruslander closed 8 years ago

ruslander commented 8 years ago

Interesting library, kudos to the creators!

Looked through the code unfortunately could not figure out how to change the time scale. In particular i want to have seconds on X axis. Here is my data set I try to render:

{
  "times": [
    {
      "starting_time": 1458012262211,
      "ending_time": 1458012262720,
      "label": "[Follower]",
      "color": "green"
    },
    {
      "starting_time": 1458012262720,
      "ending_time": 1458012263121,
      "label": "[Candidate]",
      "color": "Purple"
    },
    {
      "starting_time": 1458012263121,
      "ending_time": 1458012263288,
      "label": "[Leader]",
      "color": "blue"
    }
  ],
  "label": "10.10.10.1,3000"
}

Any hint highly appreciated, Cheers!

inodb commented 8 years ago

I think this should help you: https://github.com/jiahuang/d3-timeline#tickformatformat--ticktime--tickinterval--ticksize-

ruslander commented 8 years ago

Yes it worked, this is what I had to do

.tickFormat({
      format: d3.time.format('%S %L'),
      tickTime: d3.time.milliseconds,
      tickInterval: 1,
      tickSize: 6
    })
inodb commented 8 years ago

Great! Thanks for sharing