~sircmpwn/hnstats

8c2a8f901dd440b428dbd1f93d683421c76026d9 — Drew DeVault 6 years ago 29e5e2b
Move event lines to sample before their creation
1 files changed, 13 insertions(+), 5 deletions(-)

M templates/article.html
M templates/article.html => templates/article.html +13 -5
@@ 222,16 222,24 @@ function createTimeChart(selector, yfunc, filter, invert) {
  function eventLine(events, name) {
    for (var i = 0; i < events.length; i++) {
      var event = events[i];
      var _x = x(event.date);
      var date = event.date;
      // Adjust date to previous sample
      var s = data.samples.filter(function(s) {
        return s.created < date;
      });
      if (s.length > 0) {
        date = s[s.length - 1].created;
      }
      var _x = x(date);
      if (_x <= 0) {
        continue;
      }
      var _y = height - 5;
      if (eventDates[event.date]) {
        _y -= eventDates[event.date] * 8;
        eventDates[event.date]++;
      if (eventDates[date]) {
        _y -= eventDates[date] * 8;
        eventDates[date]++;
      } else {
        eventDates[event.date] = 1;
        eventDates[date] = 1;
      }
      g.append("line")
        .attr("class", "event")