git.haldean.org sousvide / 6c47706
Fix div-by-0 bug in chart generation. Will Haldean Brown 8 years ago
1 changed file(s) with 11 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
1818
1919 N := len(s.History)
2020
21 maxVal := float64(0)
21 maxVal := float64(1)
2222 for _, h := range s.History {
2323 if h.Temp > maxVal {
2424 maxVal = h.Temp
5151
5252 // draw grid before data so it's under everything
5353 even := true
54 for i := 0; i <= ImgHeight; i += int(5 * pxPerUnitY) {
55 y := ImgHeight - i
56 if even {
57 svgs.Line(0, y, ImgWidth, y, "stroke:#DDD; stroke-width:1")
58 } else {
59 svgs.Line(0, y, ImgWidth, y, "stroke:#EEE; stroke-width:1")
54 step := int(5 * pxPerUnitY)
55 if step >= 1 {
56 for i := 0; i <= ImgHeight; i += step {
57 y := ImgHeight - i
58 if even {
59 svgs.Line(0, y, ImgWidth, y, "stroke:#DDD; stroke-width:1")
60 } else {
61 svgs.Line(0, y, ImgWidth, y, "stroke:#EEE; stroke-width:1")
62 }
63 even = !even
6064 }
61 even = !even
6265 }
6366
6467 // draw data