Fix initial size of temperature graph
Plot area was wrongly sized due to (invisible) X axis tick labels. We now initialize an empty plot to min/max timestamps of "now" to circumvent this. Additionally plot was not properly initialized on initial load of page due to onAfterTabChange not firing for the first tab. Also added a bit for tick labels.
This commit is contained in:
parent
e99f762974
commit
50983c8524
2 changed files with 15 additions and 6 deletions
|
|
@ -497,6 +497,10 @@ $(function() {
|
|||
callViewModels(allViewModels, "onTabChange", [current, previous]);
|
||||
};
|
||||
|
||||
var onAfterTabChange = function(current, previous) {
|
||||
callViewModels(allViewModels, "onAfterTabChange", [current, previous]);
|
||||
};
|
||||
|
||||
var tabs = $('#tabs a[data-toggle="tab"]');
|
||||
tabs.on('show', function (e) {
|
||||
var current = e.target.hash;
|
||||
|
|
@ -507,10 +511,11 @@ $(function() {
|
|||
tabs.on('shown', function (e) {
|
||||
var current = e.target.hash;
|
||||
var previous = e.relatedTarget.hash;
|
||||
callViewModels(allViewModels, "onAfterTabChange", [current, previous]);
|
||||
onAfterTabChange(current, previous);
|
||||
});
|
||||
|
||||
onTabChange(OCTOPRINT_INITIAL_TAB);
|
||||
onAfterTabChange(OCTOPRINT_INITIAL_TAB, undefined);
|
||||
|
||||
// Fix input element click problems on dropdowns
|
||||
$(".dropdown input, .dropdown label").click(function(e) {
|
||||
|
|
|
|||
|
|
@ -330,10 +330,14 @@ $(function() {
|
|||
|
||||
// convert to minutes
|
||||
var diffInMins = Math.round(diff / (60 * 1000));
|
||||
if (diffInMins === 0)
|
||||
if (diffInMins === 0) {
|
||||
return gettext("just now");
|
||||
else
|
||||
} else if (diffInMins < 0) {
|
||||
// we can't look into the future
|
||||
return "";
|
||||
} else {
|
||||
return "- " + diffInMins + " " + gettext("min");
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
|
|
@ -357,6 +361,7 @@ $(function() {
|
|||
if (!heaterOptions) return undefined;
|
||||
|
||||
var maxTemps = [310/1.1];
|
||||
var now = Date.now();
|
||||
|
||||
var showFahrenheit = self._shallShowFahrenheit();
|
||||
|
||||
|
|
@ -379,12 +384,12 @@ $(function() {
|
|||
data.push({
|
||||
label: gettext("Actual") + " " + heaterOptions[type].name + ": " + actualTemp,
|
||||
color: heaterOptions[type].color,
|
||||
data: actuals
|
||||
data: actuals.length ? actuals : [[now, undefined]]
|
||||
});
|
||||
data.push({
|
||||
label: gettext("Target") + " " + heaterOptions[type].name + ": " + targetTemp,
|
||||
color: pusher.color(heaterOptions[type].color).tint(0.5).html(),
|
||||
data: targets
|
||||
data: targets.length ? targets : [[now, undefined]]
|
||||
});
|
||||
|
||||
maxTemps.push(self.getMaxTemp(actuals, targets));
|
||||
|
|
@ -450,7 +455,6 @@ $(function() {
|
|||
};
|
||||
|
||||
self.getMaxTemp = function(actuals, targets) {
|
||||
var pair;
|
||||
var maxTemp = 0;
|
||||
actuals.forEach(function(pair) {
|
||||
if (pair[1] > maxTemp){
|
||||
|
|
|
|||
Loading…
Reference in a new issue