Skip to content

Commit

Permalink
Hide tooltip after clicking on a chart to display more info
Browse files Browse the repository at this point in the history
  • Loading branch information
k3a committed Oct 3, 2023
1 parent e288b00 commit bed2625
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/chart/state-history-chart-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ export class StateHistoryChartLine extends LitElement {
return;
}

const points = e.chart.getElementsAtEventForMode(
const chart = e.chart;

const points = chart.getElementsAtEventForMode(
e,
"nearest",
{ intersect: true },
Expand All @@ -192,6 +194,7 @@ export class StateHistoryChartLine extends LitElement {
fireEvent(this, "hass-more-info", {
entityId: this._entityIds[firstPoint.datasetIndex],
});
chart.canvas.dispatchEvent(new Event("mouseout")); // to hide tooltip
}
},
};
Expand Down
1 change: 1 addition & 0 deletions src/components/chart/state-history-chart-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class StateHistoryChartTimeline extends LitElement {
// @ts-ignore
entityId: this._chartData?.datasets[index]?.label,
});
chart.canvas.dispatchEvent(new Event("mouseout")); // to hide tooltip
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class HuiEnergyDevicesGraphCard
// @ts-ignore
entityId: this._chartData?.datasets[0]?.data[index]?.y,
});
chart.canvas.dispatchEvent(new Event("mouseout")); // to hide tooltip
},
})
);
Expand Down

0 comments on commit bed2625

Please sign in to comment.