jiahuang / d3-timeline

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

Use both rectangels and circles #55

Closed inodb closed 9 years ago

inodb commented 9 years ago

I think it would be great to allow one to make a timeline with both rectangles and circles. That way events without a stop date could be displayed as a circle, whereas events with start and stop date could be a rectangle. Is this possible in the current implementation?

jiahuang commented 9 years ago

This would require some code changes. This line selects the display type. Instead of using only one type, it needs to go into the data item and append a type based off of that.

I'm not sure I want it to be a circle by default if there is no stop time. Perhaps each dataset or data element can have a display variable that it uses.

Ex:

var testData = [
  {label: "person a", display: "circle", times: [
    {"starting_time": 1355752800000, "ending_time": 1355759900000},
    {"starting_time": 1355767900000, "ending_time": 1355774400000}]},
  {label: "person b", times: [
    {"starting_time": 1355759910000, "ending_time": 1355761900000, display: "circle"}]},
  {label: "person c", times: [
    {"starting_time": 1355761910000, "ending_time": 1355763910000}]},
  ];

Would make the series for person a all be circles, along with the one data element from person b. It would be up to the user to massage the data to have the right display types for elements with no ending times.

inodb commented 9 years ago

Thanks for the reply! That looks like a good solution to me.