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

Enable downsampling in echarts #24311

Merged
merged 2 commits into from
Feb 19, 2025
Merged

Enable downsampling in echarts #24311

merged 2 commits into from
Feb 19, 2025

Conversation

MindFreeze
Copy link
Contributor

@MindFreeze MindFreeze commented Feb 19, 2025

Proposed change

Was finally able to look into what Chartjs did differently before. As I suspected, they have downsampling by default while in echarts it is disabled by default. This is the main reason for the performance difference.
There are a few sampling algorithms to choose from. minmax looks good to me but lttb is also good.

This change makes echarts 2x faster than ChartJS on my test data. 7 charts on the same page, 5 of them in same card, 1 chart with 85k datapoints.

Updates take
ChartsJS: 150ms
echarts: 70ms down from 300ms

Performance can be further improved by setting symbol: "none" for history charts but then points can't be highlighted.

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 MindFreeze added this to the 2025.2 milestone Feb 19, 2025
@@ -492,8 +492,8 @@ export class StatisticsChart extends LitElement {
: this.hass.localize(
`ui.components.statistics_charts.statistic_types.${type}`
),
symbol: "circle",
symbolSize: 0,
symbol: "none",
Copy link
Member

Choose a reason for hiding this comment

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

So stats chart points can not be highlighted anymore now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Have there been points?

Copy link
Member

Choose a reason for hiding this comment

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

Yes? Although the size is set to 0... But then we have this code that sets it to none for bands, that would not be needed anymore now then?

(series as LineSeriesOption).symbol = "none";

Copy link
Contributor Author

@MindFreeze MindFreeze Feb 19, 2025

Choose a reason for hiding this comment

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

Indeed we can remove this or enable points again for stats.
symbolSize: 0 means they haven't had points since the migration and no one has complained so I don't think we need points for stats. Also the smoothing and the nature of the data makes it odd to have points

@wendevlin
Copy link
Contributor

I tested it on desktop chrome & firefox and on iOS. I really feel the difference its so smooth now 🎉

@MindFreeze MindFreeze merged commit ad48747 into dev Feb 19, 2025
15 checks passed
@MindFreeze MindFreeze deleted the chart-perf branch February 19, 2025 14:05
bramkragten pushed a commit that referenced this pull request Feb 21, 2025
* Enable downsampling in echarts

* remove unneeded symbol set
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.

Excessive history graph web browser cpu load: Blocking GUI!
3 participants