From dfb883d2f6ac0d804e3b663b9ca0aba8f36dae76 Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:47:08 -0500 Subject: [PATCH] fix(dashboards): Account for "Releases" as a series when formatting `LineChartWidget` legend (#81772) Account for it when determining whether to show the legend. If one series is shown, no legend. If one series _and releases_ are shown, show the legend! --- .../lineChartWidget/lineChartWidgetVisualization.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/static/app/views/dashboards/widgets/lineChartWidget/lineChartWidgetVisualization.tsx b/static/app/views/dashboards/widgets/lineChartWidget/lineChartWidgetVisualization.tsx index a25567f74459b1..92689959945475 100644 --- a/static/app/views/dashboards/widgets/lineChartWidget/lineChartWidgetVisualization.tsx +++ b/static/app/views/dashboards/widgets/lineChartWidget/lineChartWidgetVisualization.tsx @@ -139,6 +139,13 @@ export function LineChartWidgetVisualization(props: LineChartWidgetVisualization })(deDupedParams, asyncTicket); }; + let visibleSeriesCount = props.timeseries.length; + if (releaseSeries) { + visibleSeriesCount += 1; + } + + const showLegend = visibleSeriesCount > 1; + return ( { @@ -184,13 +191,13 @@ export function LineChartWidgetVisualization(props: LineChartWidgetVisualization utc={props.utc} grid={{ left: 0, - top: props.timeseries.length > 1 ? 25 : 10, + top: showLegend ? 25 : 10, right: 1, bottom: 0, containLabel: true, }} legend={ - props.timeseries.length > 1 + showLegend ? { top: 0, left: 0,