Stop a percentage Y axis expanding past 100 - #53824
Merged
Merged
Conversation
timmo001
previously approved these changes
Aug 27, 2026
A percentage has a real ceiling the way zero is a real floor, but the gap that keeps series off the plot edges did not know that: a battery reading 20-100% rounded out to an axis labelled up to 120%, and one sitting flat at 100% — a device left on the charger — reached 160%. Recognise the unit at the two line-chart call sites and hold the axis at 100, mirroring the existing zero clamp. Only while the data stays under it, since power factor is also reported in % and is signed.
MindFreeze
force-pushed
the
percent-axis-ceiling
branch
from
August 27, 2026 12:57
e87f3d3 to
fa6f02e
Compare
timmo001
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
A percentage has a real ceiling the way zero is a real floor, but the gap that keeps series off the plot edges did not know that — so a battery reading 20–100% rounded out to an axis labelled up to 120%, and one sitting flat at 100% reached 160%. This recognises the unit at the two line-chart call sites and holds the axis at 100, mirroring the zero clamp already there. It applies only while the data stays under the ceiling, since power factor is also reported in
%and is signed.Stacked on #53821, which introduced the gap and the zero clamp — review that one first.
Screenshots
A battery sitting at 99%.
Before — the axis runs to 160% and roughly 40% of the plot is values a battery cannot report:
After — the axis stops at 100:
Type of change
Additional information
Why the unit rather than the device class
device_classwould be the more precise signal, but it is not available at either call site.LineChartUnitcarries it, yetstate-history-chartsnever forwards it, and it is only populated whensplit_device_classesis on — which the more info dialog and the history graph card both leave off.StatisticsMetaDatahas nodevice_classfield at all. The unit string is the only signal both callers already hold, and every existing percentage check in the frontend compares the bare"%"literal.Why the clamp is conditional
%is not a 0–100 unit in general:power_factoris reported in%and core allows it to be signed. The clamp therefore fires only when the widened maximum would actually cross 100, exactly like the zero clamp only fires when the widened minimum would cross zero. A series that genuinely reads 140% is left alone.A battery that reaches 100% then sits flush against the top edge, as the second screenshot shows. That is the intended symmetry with
0rather than a regression — an area fill is anchored at the axis minimum, so nothing collapses at the top, and labelling an axis to 160% is the worse of the two.Checklist
If user exposed functionality or configuration variables are added/changed:
To help with the load of incoming pull requests: