1

I kind of new to D3. I try to create a simple timeline (actually a date line) using the d3-timeline plugin (https://github.com/denisemauldin/d3-timeline) which works perfect. Now I try to change the example from time to date. In the example code they use this data:

var testData = [
    {times: [{"starting_time": 1355752800000, "ending_time": 1355759900000}, {"starting_time": 1355767900000, "ending_time": 1355774400000}]},
    {times: [{"starting_time": 1355759910000, "ending_time": 1355761900000}, ]},
    {times: [{"starting_time": "1355759910000", "ending_time": "1355761900000"}]}
      ];

I changed this to:

var testData = [
        {times: [{"starting_time": "01-01-2001", "ending_time": "01-01-2002"}]},
        {times: [{"starting_time": "01-01-2020", "ending_time": "01-01-2021"}]}
      ];

Obviously, by default this does not work as the plugin is time based.

I tried a lot of changes, like tickformat and calculation of axis but, because of my lack of knowledge, I think I am making things worse instead of better.

Can someone help me out here?

hacking_mike
  • 1,005
  • 1
  • 8
  • 22
  • The plugin expects a timestamp, so you can use `Date.parse()` to convert it. See: https://stackoverflow.com/questions/9873197/how-to-convert-date-to-timestamp – José Luiz Ferreira Feb 06 '21 at 09:37

0 Answers0