Commit 157f35fd4dc9f9c94e9aec261e4b634b9f525e11
fix displayed data range for graph
mix irving committed on 4/25/2018, 10:27:29 PMParent: 2e6dc4c90652f68f6fc799235fb4a887ecef021f
Files changed
app/page/statsShow.js | changed |
app/page/statsShow.js | ||
---|---|---|
@@ -42,8 +42,10 @@ | ||
42 | 42 | lower: endOfDay - (howFarBack + 1) * 30 * DAY |
43 | 43 | } |
44 | 44 | }) |
45 | 45 | }) |
46 | + console.log(context.range()) | |
47 | + context.range(console.log) | |
46 | 48 | |
47 | 49 | var foci = Struct({ |
48 | 50 | [COMMENTS]: computed([throttle(store.comments, 1000)], (msgs) => { |
49 | 51 | return flatMap(msgs, (val, key) => val) |
@@ -188,9 +190,8 @@ | ||
188 | 190 | chart.update() |
189 | 191 | }) |
190 | 192 | |
191 | 193 | watchAll([chartData, context.range], (data, range) => { |
192 | - // const graphHeight = computed([chartData, context.range], (data, range) => { | |
193 | 194 | const { lower, upper } = range |
194 | 195 | const slice = data |
195 | 196 | .filter(d => d.t > lower && d.t <= upper) |
196 | 197 | .map(d => d.y) |
@@ -198,24 +199,20 @@ | ||
198 | 199 | |
199 | 200 | var h = slice[0] |
200 | 201 | if (!h || h < 10) h = 10 |
201 | 202 | 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 | |
202 | 205 | |
203 | 206 | chart.options.scales.yAxes[0].ticks.max = h |
204 | 207 | |
205 | 208 | chart.update() |
206 | 209 | }) |
207 | - // graphHeight(h => { | |
208 | - // chart.options.scales.yAxes[0].ticks.max = h | |
209 | - // console.log('listen', h) | |
210 | 210 | |
211 | - // chart.update() | |
212 | - // }) | |
213 | - | |
214 | 211 | context.range(range => { |
215 | 212 | const { lower, upper } = range |
216 | 213 | |
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) | |
218 | 215 | chart.options.scales.xAxes[0].time.max = new Date(upper - DAY / 2) |
219 | 216 | // the squeezing in by DAY/2 is to stop data outside range from half showing |
220 | 217 | |
221 | 218 | chart.update() |
@@ -296,10 +293,10 @@ | ||
296 | 293 | type: 'time', |
297 | 294 | distribution: 'linear', |
298 | 295 | time: { |
299 | 296 | 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), | |
302 | 299 | tooltipFormat: 'MMMM D', |
303 | 300 | stepSize: 7 |
304 | 301 | }, |
305 | 302 | bounds: 'ticks', |
Built with git-ssb-web