Fix tooltip and click action on device energy graph (#10094)

This commit is contained in:
Bram Kragten 2021-09-29 00:21:47 +02:00 committed by GitHub
parent b6344eb6e8
commit 68095417b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,6 +130,10 @@ export class HuiEnergyDevicesGraphCard
tooltip: {
mode: "nearest",
callbacks: {
title: (item) => {
const entity = this.hass.states[item[0].label];
return entity ? computeStateName(entity) : item[0].label;
},
label: (context) =>
`${context.dataset.label}: ${formatNumber(
context.parsed.x,
@ -149,7 +153,7 @@ export class HuiEnergyDevicesGraphCard
);
fireEvent(this, "hass-more-info", {
// @ts-ignore
entityId: this._chartData?.datasets[0]?.data[index]?.label,
entityId: this._chartData?.datasets[0]?.data[index]?.y,
});
},
})