From 26747417971d8b543583063175a9e91cca5eecd6 Mon Sep 17 00:00:00 2001 From: Nicanor Romero Venier Date: Tue, 29 Sep 2015 19:08:22 +0200 Subject: [PATCH 1/2] Change the max temp of chart dynamically --- .../static/js/app/viewmodels/temperature.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/octoprint/static/js/app/viewmodels/temperature.js b/src/octoprint/static/js/app/viewmodels/temperature.js index 9b58d2ec..964e7b29 100644 --- a/src/octoprint/static/js/app/viewmodels/temperature.js +++ b/src/octoprint/static/js/app/viewmodels/temperature.js @@ -232,6 +232,8 @@ $(function() { var heaterOptions = self.heaterOptions(); if (!heaterOptions) return; + var maxTemps = [310]; + _.each(_.keys(heaterOptions), function(type) { if (type == "bed" && !self.hasBed()) { return; @@ -258,12 +260,32 @@ $(function() { color: pusher.color(heaterOptions[type].color).tint(0.5).html(), data: targets }); + + maxTemps.push(self.getMaxTemp(actuals, targets)); }); + self.plotOptions.yaxis.max = Math.max.apply(null, maxTemps); + self.plotOptions.yaxis.ticks = self.plotOptions.yaxis.max / 30; $.plot(graph, data, self.plotOptions); } }; + self.getMaxTemp = function(actuals, targets) { + var pair; + var maxTemp = 0; + actuals.forEach(function(pair) { + if (pair[1] > maxTemp){ + maxTemp = pair[1]; + } + }); + targets.forEach(function(pair) { + if (pair[1] > maxTemp){ + maxTemp = pair[1]; + } + }); + return maxTemp; + } + self.setTarget = function(item) { var value = item.newTarget(); if (!value) return; From 4a7c81d1c6aa196bec63bc7fd41894419c2a1745 Mon Sep 17 00:00:00 2001 From: Nicanor Romero Venier Date: Wed, 30 Sep 2015 09:20:40 +0200 Subject: [PATCH 2/2] Added offset to max Y in temperature chart --- src/octoprint/static/js/app/viewmodels/temperature.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/temperature.js b/src/octoprint/static/js/app/viewmodels/temperature.js index 964e7b29..dc75c9f8 100644 --- a/src/octoprint/static/js/app/viewmodels/temperature.js +++ b/src/octoprint/static/js/app/viewmodels/temperature.js @@ -232,7 +232,7 @@ $(function() { var heaterOptions = self.heaterOptions(); if (!heaterOptions) return; - var maxTemps = [310]; + var maxTemps = [310/1.1]; _.each(_.keys(heaterOptions), function(type) { if (type == "bed" && !self.hasBed()) { @@ -264,8 +264,7 @@ $(function() { maxTemps.push(self.getMaxTemp(actuals, targets)); }); - self.plotOptions.yaxis.max = Math.max.apply(null, maxTemps); - self.plotOptions.yaxis.ticks = self.plotOptions.yaxis.max / 30; + self.plotOptions.yaxis.max = Math.max.apply(null, maxTemps) * 1.1; $.plot(graph, data, self.plotOptions); } };