mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Another fix for history chart axis rounding (#25852)
This commit is contained in:
parent
e6fbe0d538
commit
1a8ff83e2d
@ -731,20 +731,17 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _formatYAxisLabel = (value: number) => {
|
private _formatYAxisLabel = (value: number) => {
|
||||||
const formatOptions =
|
// show the first significant digit for tiny values
|
||||||
value >= 1 || value <= -1
|
const maximumFractionDigits = Math.max(
|
||||||
? undefined
|
1,
|
||||||
: {
|
// use the difference to the previous value to determine the number of significant digits #25526
|
||||||
// show the first significant digit for tiny values
|
-Math.floor(
|
||||||
maximumFractionDigits: Math.max(
|
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
||||||
2,
|
)
|
||||||
// use the difference to the previous value to determine the number of significant digits #25526
|
);
|
||||||
-Math.floor(
|
const label = formatNumber(value, this.hass.locale, {
|
||||||
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
maximumFractionDigits,
|
||||||
)
|
});
|
||||||
),
|
|
||||||
};
|
|
||||||
const label = formatNumber(value, this.hass.locale, formatOptions);
|
|
||||||
const width = measureTextWidth(label, 12) + 5;
|
const width = measureTextWidth(label, 12) + 5;
|
||||||
if (width > this._yWidth) {
|
if (width > this._yWidth) {
|
||||||
this._yWidth = width;
|
this._yWidth = width;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user