From fa3625985c383435b7c5e9d4ef2f9f500fa5a1b2 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Mon, 14 Aug 2023 00:52:38 -0700 Subject: [PATCH] Show statistics bands when charting min/max only (#17549) --- src/components/chart/statistics-chart.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/chart/statistics-chart.ts b/src/components/chart/statistics-chart.ts index d3edd154f7..f414eb7871 100644 --- a/src/components/chart/statistics-chart.ts +++ b/src/components/chart/statistics-chart.ts @@ -329,8 +329,14 @@ class StatisticsChart extends LitElement { const statTypes: this["statTypes"] = []; - const drawBands = + const hasMean = this.statTypes.includes("mean") && statisticsHaveType(stats, "mean"); + const drawBands = + hasMean || + (this.statTypes.includes("min") && + statisticsHaveType(stats, "min") && + this.statTypes.includes("max") && + statisticsHaveType(stats, "max")); const sortedTypes = drawBands ? [...this.statTypes].sort((a, b) => { @@ -358,13 +364,14 @@ class StatisticsChart extends LitElement { `ui.components.statistics_charts.statistic_types.${type}` ), fill: drawBands - ? type === "min" + ? type === "min" && hasMean ? "+1" : type === "max" ? "-1" : false : false, - borderColor: band ? color + (this.hideLegend ? "00" : "7F") : color, + borderColor: + band && hasMean ? color + (this.hideLegend ? "00" : "7F") : color, backgroundColor: band ? color + "3F" : color + "7F", pointRadius: 0, data: [],