Commit 94347b6c authored by Wolfgang Fellger's avatar Wolfgang Fellger

Limit graph when there is no or out of bounds data

parent f58a00fa
......@@ -7,15 +7,15 @@ WeightGraph = {
}
// Adjust diagram size to data
var xMin = data[0][0];
var xMax = data[data.length-1][0];
var yMin = Infinity;
var xMin = data[0] ? data[0][0] : Date.now() - 3600 * 1000 * 24 * 5;
var xMax = data[data.length-1] ? data[data.length-1][0] : Date.now();
var yMin = 250;
var yMax = 0;
for (var x = 0; x < data.length; x++) {
if (data[x][1] < yMin)
yMin = Math.floor(data[x][1] / 5) * 5;
yMin = Math.max(Math.floor(data[x][1] / 5) * 5, 20);
if (data[x][1] > yMax)
yMax = Math.ceil(data[x][1] / 5) * 5;
yMax = Math.min(Math.ceil(data[x][1] / 5) * 5, 200);
}
yMax += 0.5;
yMin -= 0.5;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment