Skip to content

Commit

Permalink
馃毟 Temp graph: Scale ticksize based on cutoff time
Browse files Browse the repository at this point in the history
If there would be more of 10 ticks on the x-axis, add 5min to the tick
interval until that's no longer the case. That way the x-axis on the
graph now automatically scales so that the axis tick labels are still
readable and usable.

Closes #5003
  • Loading branch information
foosel committed May 6, 2024
1 parent 956bab3 commit 169f848
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/octoprint/static/js/app/viewmodels/temperature.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,11 @@ $(function () {
)
return [];

const tickSize = 5 * 60 * 1000; // 5 minutes
let tickSize = 5 * 60 * 1000; // 5 minutes
while ((axis.max - axis.min) / tickSize > 10) {
tickSize += 5 * 60 * 1000; // 5 minutes
}

const ticks = [];
let val = axis.max;
while (val > axis.min) {
Expand All @@ -592,7 +596,7 @@ $(function () {
} else if (diffInMins === 0) {
return gettext("now");
} else {
return "- " + diffInMins + " " + gettext("min");
return "-" + diffInMins + gettext("min");
}
}
},
Expand Down

0 comments on commit 169f848

Please sign in to comment.