Commit fe2b96982fed8ff1598c65dfccc21dc2c5d79b9f
change data plotting + ranges (needs testing in different timezones?)
mix irving committed on 5/1/2018, 5:10:22 AMParent: b00977e5053049e9827db3a20714d9979d7e12d3
Files changed
app/page/statsShow.js | changed |
config/chart.js | changed |
app/page/statsShow.js | ||
---|---|---|
@@ -264,9 +264,9 @@ | ||
264 | 264 | |
265 | 265 | return Object.keys(grouped) |
266 | 266 | .map(day => { |
267 | 267 | return { |
268 | - t: day * DAY + 10, | |
268 | + t: day * DAY + DAY / 2, | |
269 | 269 | y: grouped[day].length |
270 | 270 | } |
271 | 271 | // NOTE - this collects the data points for a day at t = 10ms into the day |
272 | 272 | // this is necessary for getting counts to line up (bars, and daily count) |
@@ -286,9 +286,9 @@ | ||
286 | 286 | const { lower, upper } = range |
287 | 287 | const slice = data |
288 | 288 | .filter(d => d.t > lower && d.t <= upper) |
289 | 289 | .map(d => d.y) |
290 | - .sort((a, b) => a < b) | |
290 | + .sort((a, b) => a > b ? -1 : +1) | |
291 | 291 | |
292 | 292 | var h = slice[0] |
293 | 293 | if (!h || h < 10) h = 10 |
294 | 294 | else h = h + (5 - h % 5) |
@@ -303,11 +303,10 @@ | ||
303 | 303 | // Update the x-axes bounds of the graph! |
304 | 304 | context.range(range => { |
305 | 305 | const { lower, upper } = range |
306 | 306 | |
307 | - chart.options.scales.xAxes[0].time.min = new Date(lower - DAY / 2) | |
308 | - chart.options.scales.xAxes[0].time.max = new Date(upper - DAY / 2) | |
309 | - // the squeezing in by DAY/2 is to stop data outside range from half showing | |
307 | + chart.options.scales.xAxes[0].time.min = lower | |
308 | + chart.options.scales.xAxes[0].time.max = upper | |
310 | 309 | |
311 | 310 | chart.update() |
312 | 311 | }) |
313 | 312 | |
@@ -326,5 +325,4 @@ | ||
326 | 325 | } |
327 | 326 | } |
328 | 327 | function toDay (ts) { return Math.floor(ts / DAY) } |
329 | 328 | } |
330 | - |
Built with git-ssb-web