Add slight hysteresis to chart height to prevent scrollbar juddering (#15321)

This commit is contained in:
karwosts 2023-02-14 04:01:01 -08:00 committed by GitHub
parent d8fe7d9a01
commit 1e7fe59519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -233,7 +233,11 @@ export default class HaChartBase extends LitElement {
{
id: "afterRenderHook",
afterRender: (chart) => {
this._chartHeight = chart.height;
const change = chart.height - (this._chartHeight ?? 0);
if (!this._chartHeight || change > 0 || change < -12) {
// hysteresis to prevent infinite render loops
this._chartHeight = chart.height;
}
},
legend: {
...this.options?.plugins?.legend,