Fix statistic chart tooltip values (#24074)

This commit is contained in:
Paul Bottein 2025-02-05 10:18:29 +01:00 committed by GitHub
parent fe041e442d
commit f0507a88a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,14 +198,17 @@ export class StatisticsChart extends LitElement {
const statisticId = this._statisticIds[param.seriesIndex]; const statisticId = this._statisticIds[param.seriesIndex];
const stateObj = this.hass.states[statisticId]; const stateObj = this.hass.states[statisticId];
const entry = this.hass.entities[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 const options = getNumberFormatOptions(stateObj, entry) ?? {
? this.hass.formatEntityState(stateObj, stateValue) maximumFractionDigits: 2,
: `${formatNumber( };
stateValue,
const value = `${formatNumber(
rawValue,
this.hass.locale, this.hass.locale,
getNumberFormatOptions(undefined, entry) options
)}${unit}`; )}${unit}`;
const time = const time =