jiahuang / d3-timeline

Simple JS timeline plugin for d3
1.04k stars 280 forks source link

Errors when all times are coincident #88

Open al opened 8 years ago

al commented 8 years ago

If it transpires that all of your data points are coincident then beginning will equal ending and https://github.com/jiahuang/d3-timeline/blob/master/src/d3-timeline.js#L223 will become undefined causing errors like:

Error: <circle> attribute cx: Expected length, "NaN".

It's trivial to add a default window in such cases, although the choice of sensible width is not obvious.

// (after line 220)
//
// If all the times are the same, force the timeline to cover
// 12 hours on either side.
//
if (beginning === ending) {
  beginning -= (12 * 60 * 60 * 1000);
  ending += (12 * 60 * 60 * 1000);
}