Fix statistic chart tooltip values (#24074)

This commit is contained in:
Paul Bottein 2025-02-05 10:18:29 +01:00 committed by Bram Kragten
parent 786ff787d1
commit 553bb61db7

View File

@ -199,15 +199,18 @@ export class StatisticsChart extends LitElement {
const statisticId = this._statisticIds[param.seriesIndex];
const stateObj = this.hass.states[statisticId];
const entry = this.hass.entities[statisticId];
const stateValue = String(param.value[1]);
// max series can have 3 values, as the second value is the max-min to form a band
const rawValue = String(param.value[2] ?? param.value[1]);
const value = stateObj
? this.hass.formatEntityState(stateObj, stateValue)
: `${formatNumber(
stateValue,
this.hass.locale,
getNumberFormatOptions(undefined, entry)
)}${unit}`;
const options = getNumberFormatOptions(stateObj, entry) ?? {
maximumFractionDigits: 2,
};
const value = `${formatNumber(
rawValue,
this.hass.locale,
options
)}${unit}`;
const time =
index === 0