From 505149d6438b5ac5140de6d3cd38b29488d383ed Mon Sep 17 00:00:00 2001 From: Blake-Madden <66873089+Blake-Madden@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:15:10 -0400 Subject: [PATCH] Handle NaN in heatmap legend --- src/graphs/heatmap.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/graphs/heatmap.cpp b/src/graphs/heatmap.cpp index ad384342..90a92095 100644 --- a/src/graphs/heatmap.cpp +++ b/src/graphs/heatmap.cpp @@ -455,10 +455,14 @@ namespace Wisteria::Graphs return nullptr; } - const auto minValue = *std::min_element(m_continuousColumn->GetValues().cbegin(), - m_continuousColumn->GetValues().cend()); - const auto maxValue = *std::max_element(m_continuousColumn->GetValues().cbegin(), - m_continuousColumn->GetValues().cend()); + std::vector validData; + std::copy_if(m_continuousColumn->GetValues().cbegin(), + m_continuousColumn->GetValues().cend(), std::back_inserter(validData), + [](auto x) { return std::isfinite(x); }); + const auto minValue = + *std::min_element(validData.cbegin(), validData.cend()); + const auto maxValue = + *std::max_element(validData.cbegin(), validData.cend()); auto legend = std::make_unique( GraphItemInfo( // add spaces on the empty lines to work around SVG exporting