Enable downsampling in echarts (#24311)

* Enable downsampling in echarts

* remove unneeded symbol set
This commit is contained in:
Petar Petrov 2025-02-19 16:05:32 +02:00 committed by GitHub
parent 2801d071ba
commit ad487470fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 10 deletions

View File

@ -521,14 +521,14 @@ export class HaChartBase extends LitElement {
0 0
); );
if (dataSize > 10000) { if (dataSize > 10000) {
// for large datasets zr.flush takes 30-40% of the render time // delay the last bit of the render to avoid blocking the main thread
// so we delay it a bit to avoid blocking the main thread // this is not that impactful with sampling enabled but it doesn't hurt to have it
const zr = this.chart.getZr(); const zr = this.chart.getZr();
this._originalZrFlush = zr.flush.bind(zr); this._originalZrFlush = zr.flush;
zr.flush = () => { zr.flush = () => {
setTimeout(() => { setTimeout(() => {
this._originalZrFlush?.(); this._originalZrFlush?.call(zr);
}, 10); }, 5);
}; };
} }
} }

View File

@ -354,9 +354,10 @@ export class StateHistoryChartLine extends LitElement {
name: nameY, name: nameY,
color, color,
symbol: "circle", symbol: "circle",
step: "end",
animationDurationUpdate: 0,
symbolSize: 1, symbolSize: 1,
step: "end",
sampling: "minmax",
animationDurationUpdate: 0,
lineStyle: { lineStyle: {
width: fill ? 0 : 1.5, width: fill ? 0 : 1.5,
}, },

View File

@ -492,8 +492,8 @@ export class StatisticsChart extends LitElement {
: this.hass.localize( : this.hass.localize(
`ui.components.statistics_charts.statistic_types.${type}` `ui.components.statistics_charts.statistic_types.${type}`
), ),
symbol: "circle", symbol: "none",
symbolSize: 0, sampling: "minmax",
animationDurationUpdate: 0, animationDurationUpdate: 0,
lineStyle: { lineStyle: {
width: 1.5, width: 1.5,
@ -511,7 +511,6 @@ export class StatisticsChart extends LitElement {
if (band && this.chartType === "line") { if (band && this.chartType === "line") {
series.stack = `band-${statistic_id}`; series.stack = `band-${statistic_id}`;
series.stackStrategy = "all"; series.stackStrategy = "all";
(series as LineSeriesOption).symbol = "none";
if (drawBands && type === "max") { if (drawBands && type === "max") {
(series as LineSeriesOption).areaStyle = { (series as LineSeriesOption).areaStyle = {
color: color + "3F", color: color + "3F",