From d3216a73aff793ebed13766e949120f8b945cfca Mon Sep 17 00:00:00 2001 From: Everett Pompeii Date: Sat, 21 Dec 2024 16:08:44 -0600 Subject: [PATCH] filter_raw_data --- .../console/perf/plot/line/LinePlot.tsx | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/services/console/src/components/console/perf/plot/line/LinePlot.tsx b/services/console/src/components/console/perf/plot/line/LinePlot.tsx index 9055a0294..69bd5b3aa 100644 --- a/services/console/src/components/console/perf/plot/line/LinePlot.tsx +++ b/services/console/src/components/console/perf/plot/line/LinePlot.tsx @@ -165,13 +165,15 @@ const line_plot = (props: Props) => { } let metrics_found = false; - const raw_data = json_perf.results.map((result, index) => { - const data = perf_result(result, index, props.perfActive); - if ((data?.line_data?.length ?? 0) > 0) { - metrics_found = true; - } - return data; - }); + const raw_data = json_perf.results + .map((result, index) => { + const data = perf_result(result, index, props.perfActive); + if ((data?.line_data?.length ?? 0) > 0) { + metrics_found = true; + } + return data; + }) + .filter((data) => data); const raw_units = get_units(json_perf); const [x_axis_kind, x_axis_scale_type, x_axis_label] = get_x_axis( @@ -377,36 +379,40 @@ const scale_data = ( ...raw_data.map((data) => Math.min( // The primary metric series - Math.min(...data.line_data.map((datum) => datum.value ?? MAX)), + Math.min(...data.line_data?.map((datum) => datum.value ?? MAX)), // The lower value series, if active props.lower_value() - ? Math.min(...data.line_data.map((datum) => datum.lower_value ?? MAX)) + ? Math.min( + ...data.line_data?.map((datum) => datum.lower_value ?? MAX), + ) : MAX, // The upper value series, if active props.upper_value() - ? Math.min(...data.line_data.map((datum) => datum.upper_value ?? MAX)) + ? Math.min( + ...data.line_data?.map((datum) => datum.upper_value ?? MAX), + ) : MAX, // The lower boundary series, if active props.lower_boundary() ? Math.min( - ...data.line_data.map((datum) => datum.lower_limit ?? MAX), - ...data.skipped_lower_data.map((datum) => datum.y ?? MAX), + ...data.line_data?.map((datum) => datum.lower_limit ?? MAX), + ...data.skipped_lower_data?.map((datum) => datum.y ?? MAX), ) : MAX, // The upper boundary series, if active props.upper_boundary() ? Math.min( - ...data.line_data.map((datum) => datum.upper_limit ?? MAX), - ...data.skipped_upper_data.map((datum) => datum.y ?? MAX), + ...data.line_data?.map((datum) => datum.upper_limit ?? MAX), + ...data.skipped_upper_data?.map((datum) => datum.y ?? MAX), ) : MAX, // The lower alert series Math.min( - ...data.lower_alert_data.map((datum) => datum.lower_limit ?? MAX), + ...data.lower_alert_data?.map((datum) => datum.lower_limit ?? MAX), ), // The upper alert series Math.min( - ...data.upper_alert_data.map((datum) => datum.upper_limit ?? MAX), + ...data.upper_alert_data?.map((datum) => datum.upper_limit ?? MAX), ), ), ),