git ssb

2+

mixmix / ticktack



Commit fe2b96982fed8ff1598c65dfccc21dc2c5d79b9f

change data plotting + ranges (needs testing in different timezones?)

mix irving committed on 5/1/2018, 5:10:22 AM
Parent: b00977e5053049e9827db3a20714d9979d7e12d3

Files changed

app/page/statsShow.jschanged
config/chart.jschanged
app/page/statsShow.jsView
@@ -264,9 +264,9 @@
264264
265265 return Object.keys(grouped)
266266 .map(day => {
267267 return {
268- t: day * DAY + 10,
268+ t: day * DAY + DAY / 2,
269269 y: grouped[day].length
270270 }
271271 // NOTE - this collects the data points for a day at t = 10ms into the day
272272 // this is necessary for getting counts to line up (bars, and daily count)
@@ -286,9 +286,9 @@
286286 const { lower, upper } = range
287287 const slice = data
288288 .filter(d => d.t > lower && d.t <= upper)
289289 .map(d => d.y)
290- .sort((a, b) => a < b)
290+ .sort((a, b) => a > b ? -1 : +1)
291291
292292 var h = slice[0]
293293 if (!h || h < 10) h = 10
294294 else h = h + (5 - h % 5)
@@ -303,11 +303,10 @@
303303 // Update the x-axes bounds of the graph!
304304 context.range(range => {
305305 const { lower, upper } = range
306306
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
310309
311310 chart.update()
312311 })
313312
@@ -326,5 +325,4 @@
326325 }
327326 }
328327 function toDay (ts) { return Math.floor(ts / DAY) }
329328 }
330-
config/chart.jsView
@@ -26,10 +26,10 @@
2626 type: 'time',
2727 distribution: 'linear',
2828 time: {
2929 unit: 'day',
30- min: new Date(lower - DAY / 2),
31- max: new Date(upper - DAY / 2),
30+ min: lower,
31+ max: upper,
3232 tooltipFormat: 'MMMM D',
3333 stepSize: 7
3434 },
3535 bounds: 'ticks',

Built with git-ssb-web