git ssb

2+

mixmix / ticktack



Commit 157f35fd4dc9f9c94e9aec261e4b634b9f525e11

fix displayed data range for graph

mix irving committed on 4/25/2018, 10:27:29 PM
Parent: 2e6dc4c90652f68f6fc799235fb4a887ecef021f

Files changed

app/page/statsShow.jschanged
app/page/statsShow.jsView
@@ -42,8 +42,10 @@
4242 lower: endOfDay - (howFarBack + 1) * 30 * DAY
4343 }
4444 })
4545 })
46+ console.log(context.range())
47+ context.range(console.log)
4648
4749 var foci = Struct({
4850 [COMMENTS]: computed([throttle(store.comments, 1000)], (msgs) => {
4951 return flatMap(msgs, (val, key) => val)
@@ -188,9 +190,8 @@
188190 chart.update()
189191 })
190192
191193 watchAll([chartData, context.range], (data, range) => {
192- // const graphHeight = computed([chartData, context.range], (data, range) => {
193194 const { lower, upper } = range
194195 const slice = data
195196 .filter(d => d.t > lower && d.t <= upper)
196197 .map(d => d.y)
@@ -198,24 +199,20 @@
198199
199200 var h = slice[0]
200201 if (!h || h < 10) h = 10
201202 else h = h + (5 - h % 5)
203+ // set the height of the graph to a minimum or 10,
204+ // or some multiple of 5 above the max height
202205
203206 chart.options.scales.yAxes[0].ticks.max = h
204207
205208 chart.update()
206209 })
207- // graphHeight(h => {
208- // chart.options.scales.yAxes[0].ticks.max = h
209- // console.log('listen', h)
210210
211- // chart.update()
212- // })
213-
214211 context.range(range => {
215212 const { lower, upper } = range
216213
217- chart.options.scales.xAxes[0].time.min = new Date(lower + DAY / 2)
214+ chart.options.scales.xAxes[0].time.min = new Date(lower - DAY / 2)
218215 chart.options.scales.xAxes[0].time.max = new Date(upper - DAY / 2)
219216 // the squeezing in by DAY/2 is to stop data outside range from half showing
220217
221218 chart.update()
@@ -296,10 +293,10 @@
296293 type: 'time',
297294 distribution: 'linear',
298295 time: {
299296 unit: 'day',
300- min: new Date(lower),
301- max: new Date(upper),
297+ min: new Date(lower - DAY / 2),
298+ max: new Date(upper - DAY / 2),
302299 tooltipFormat: 'MMMM D',
303300 stepSize: 7
304301 },
305302 bounds: 'ticks',

Built with git-ssb-web