Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more-info chart rendering #23619

Merged
merged 9 commits into from
Jan 14, 2025
Merged

Fix more-info chart rendering #23619

merged 9 commits into from
Jan 14, 2025

Conversation

MindFreeze
Copy link
Contributor

@MindFreeze MindFreeze commented Jan 7, 2025

Proposed change

This removes a resize action after the dialog is open and instead just sets a fixed height to achieve the same size. All the resize methods were only used for this so I removed them.
I don't know if this will entirely fix the slow render issue since I can't reproduce it but it should at least help.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@MindFreeze
Copy link
Contributor Author

@karwosts can you try this PR and see if opening a more info dialog with a chart is improved, pls?

@bramkragten
Copy link
Member

This also removed the initial animation I think? So can we remove the animation-container and animation css now too?

@bramkragten
Copy link
Member

I think we can even remove all the _chartHeight logic.

@bramkragten
Copy link
Member

One thing that doesn't work well anymore now, is resizing. Try to resize the more info window (click the title, or resize your window). I think this also changed the logic for dashboard cards, if it is better or worse I dont know 😄 , but means we cant release this as a patch then.

Previously the height would stay the same, now it changes the height if the width changes, but not directly as it first needs a call to render. Then the graph doesn't always react directly to the change of height of the container.

CleanShot 2025-01-07 at 14 26 23@2x

@MindFreeze
Copy link
Contributor Author

fixed it to the initial height now

@bramkragten
Copy link
Member

fixed it to the initial height now

I think we should move that logic to ha-chart-base as that will also use the clientWidth / 2 if height is not set.

@@ -84,8 +84,6 @@ export class StatisticsChart extends LitElement {

@property() public period?: string;

@property({ attribute: false, type: Number }) public height?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the height option completely?

@@ -69,8 +69,6 @@ export class StateHistoryCharts extends LitElement {

@property({ attribute: "fit-y-data", type: Boolean }) public fitYData = false;

@property({ attribute: false, type: Number }) public height?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the height option completely? I think we can keep this?

@@ -54,8 +54,6 @@ export class StateHistoryChartLine extends LitElement {

@property({ attribute: "fit-y-data", type: Boolean }) public fitYData = false;

@property({ attribute: false, type: Number }) public height?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the height option completely? I think we can keep this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't there before so isn't used. I didn't want to add extra attributes without a use case. We can always add it if we need it.

@karwosts
Copy link
Contributor

karwosts commented Jan 7, 2025

@karwosts can you try this PR and see if opening a more info dialog with a chart is improved, pls?

The more info dialog seems better on this branch, but all my energy cards are undesirably huge now (really big bottom padding), and the loading is sometimes really janky. I've never seen anything like this before.

energy-loading

@MindFreeze
Copy link
Contributor Author

Aha, so this is what _chartHeight was for. I added back some of that logic to fix the energy panel

@MindFreeze MindFreeze requested a review from bramkragten January 8, 2025 13:26
if (!this.height) {
// lock the height
// this removes empty space below the chart
this.height = chart.height;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add back the hysteresis then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore as we don't animate it. Only lock it once after the first render

@bramkragten bramkragten added this to the 2025.1 milestone Jan 14, 2025
@bramkragten bramkragten merged commit d3e832c into dev Jan 14, 2025
15 checks passed
@bramkragten bramkragten deleted the more-info-chart-fix branch January 14, 2025 10:24
piitaya pushed a commit that referenced this pull request Jan 23, 2025
* Fix more-info chart rendering

* lint fix

* remove animation-container & _chartHeight

* don't change height on resize

* handle default height in ha-chart-base

* fix chart height in energy panel

* lint

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More-info dialog is slow and laggy after update to 2025.1.0
4 participants