From e75d6cc622efb571a008acd61cc93c0ce57940b0 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 11 Apr 2025 22:35:31 -0600 Subject: [PATCH] hide goal line for percentages stack --- .../StylingAppStyling/StylingAppStyling.tsx | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx index 25310ce00..b300979c5 100644 --- a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx @@ -486,8 +486,34 @@ const EtcSettings: React.FC< }) => { const isScatterChart = selectedChartType === 'scatter'; const isPieChart = selectedChartType === 'pie'; + const isLineChart = selectedChartType === 'line'; + const isBarChart = selectedChartType === 'bar'; const hasYAxisValues = selectedAxis.y.length > 0; + const showGoalLine = useMemo(() => { + if (isBarChart) { + return barGroupType !== 'percentage-stack' && hasYAxisValues; + } + + if (isLineChart) { + return lineGroupType === 'percentage-stack' && hasYAxisValues; + } + + return !isScatterChart && !isPieChart && hasYAxisValues; + }, [isScatterChart, isPieChart, isLineChart, isBarChart, hasYAxisValues]); + + const showTrendline = useMemo(() => { + if (isBarChart) { + return barGroupType !== 'percentage-stack' && hasYAxisValues; + } + + if (isLineChart) { + return lineGroupType === 'percentage-stack' && hasYAxisValues; + } + + return !isPieChart && hasYAxisValues; + }, [isScatterChart, isPieChart, isLineChart, isBarChart, hasYAxisValues]); + const ComponentsLoop: { enabled: boolean; key: string; @@ -507,7 +533,7 @@ const EtcSettings: React.FC< ) }, { - enabled: !isScatterChart && !isPieChart && hasYAxisValues, + enabled: showGoalLine, key: 'goalLine', Component: (