mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Fix min max issues in statistics chart (#28493)
This commit is contained in:
@@ -184,17 +184,11 @@ export class StatisticsChart extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _datasetHidden(ev: CustomEvent) {
|
private _datasetHidden(ev: CustomEvent) {
|
||||||
if (!this._legendData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._hiddenStats.add(ev.detail.id);
|
this._hiddenStats.add(ev.detail.id);
|
||||||
this.requestUpdate("_hiddenStats");
|
this.requestUpdate("_hiddenStats");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _datasetUnhidden(ev: CustomEvent) {
|
private _datasetUnhidden(ev: CustomEvent) {
|
||||||
if (!this._legendData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._hiddenStats.delete(ev.detail.id);
|
this._hiddenStats.delete(ev.detail.id);
|
||||||
this.requestUpdate("_hiddenStats");
|
this.requestUpdate("_hiddenStats");
|
||||||
}
|
}
|
||||||
@@ -521,7 +515,9 @@ export class StatisticsChart extends LitElement {
|
|||||||
`ui.components.statistics_charts.statistic_types.${type}`
|
`ui.components.statistics_charts.statistic_types.${type}`
|
||||||
),
|
),
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
sampling: "minmax",
|
// minmax sampling operates independently per series, breaking stacking alignment
|
||||||
|
// https://github.com/apache/echarts/issues/11879
|
||||||
|
sampling: band && drawBands ? "lttb" : "minmax",
|
||||||
animationDurationUpdate: 0,
|
animationDurationUpdate: 0,
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
@@ -539,12 +535,19 @@ 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";
|
||||||
|
if (this._hiddenStats.has(`${statistic_id}-${bandBottom}`)) {
|
||||||
|
// changing the stackOrder forces echarts to render the stacked series that are not hidden #28472
|
||||||
|
series.stackOrder = "seriesDesc";
|
||||||
|
(series as LineSeriesOption).areaStyle = undefined;
|
||||||
|
} else {
|
||||||
|
series.stackOrder = "seriesAsc";
|
||||||
if (drawBands && type === bandTop) {
|
if (drawBands && type === bandTop) {
|
||||||
(series as LineSeriesOption).areaStyle = {
|
(series as LineSeriesOption).areaStyle = {
|
||||||
color: color + "3F",
|
color: color + "3F",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!this.hideLegend) {
|
if (!this.hideLegend) {
|
||||||
const showLegend = hasMean
|
const showLegend = hasMean
|
||||||
? type === "mean"
|
? type === "mean"
|
||||||
@@ -586,7 +589,8 @@ export class StatisticsChart extends LitElement {
|
|||||||
} else if (
|
} else if (
|
||||||
type === bandTop &&
|
type === bandTop &&
|
||||||
this.chartType === "line" &&
|
this.chartType === "line" &&
|
||||||
drawBands
|
drawBands &&
|
||||||
|
!this._hiddenStats.has(`${statistic_id}-${bandBottom}`)
|
||||||
) {
|
) {
|
||||||
const top = stat[bandTop] || 0;
|
const top = stat[bandTop] || 0;
|
||||||
val.push(Math.abs(top - (stat[bandBottom] || 0)));
|
val.push(Math.abs(top - (stat[bandBottom] || 0)));
|
||||||
|
|||||||
Reference in New Issue
Block a user