#7751 Statistics Plot: add relative frequency percentage option

This commit is contained in:
Kristian Bendiksen 2021-06-30 10:53:36 +02:00
parent 84bf5d5454
commit 0cbfd11dc3
2 changed files with 9 additions and 3 deletions

View File

@ -55,8 +55,11 @@ namespace caf
template <>
void caf::AppEnum<RimStatisticsPlot::HistogramFrequencyType>::setUp()
{
addItem( RimStatisticsPlot::HistogramFrequencyType::ABSOLUTE_FREQUENCY, "ABSOLUTE_FREQUENCY", "Absolute" );
addItem( RimStatisticsPlot::HistogramFrequencyType::RELATIVE_FREQUENCY, "RELATIVE_FREQUENCY", "Relative" );
addItem( RimStatisticsPlot::HistogramFrequencyType::ABSOLUTE_FREQUENCY, "ABSOLUTE_FREQUENCY", "Absolute Frequency" );
addItem( RimStatisticsPlot::HistogramFrequencyType::RELATIVE_FREQUENCY, "RELATIVE_FREQUENCY", "Relative Frequency" );
addItem( RimStatisticsPlot::HistogramFrequencyType::RELATIVE_FREQUENCY_PERCENT,
"RELATIVE_FREQUENCY_PERCENT",
"Relative Frequency [%]" );
setDefault( RimStatisticsPlot::HistogramFrequencyType::ABSOLUTE_FREQUENCY );
}
} // namespace caf
@ -290,6 +293,8 @@ void RimStatisticsPlot::updatePlots()
for ( double value : histogramData.histogram )
{
if ( m_histogramFrequencyType() == HistogramFrequencyType::RELATIVE_FREQUENCY ) value /= sumElements;
if ( m_histogramFrequencyType() == HistogramFrequencyType::RELATIVE_FREQUENCY_PERCENT )
value = value / sumElements * 100.0;
*set0 << value;
minValue = std::min( minValue, value );
maxValue = std::max( maxValue, value );

View File

@ -47,7 +47,8 @@ public:
enum class HistogramFrequencyType
{
ABSOLUTE_FREQUENCY,
RELATIVE_FREQUENCY
RELATIVE_FREQUENCY,
RELATIVE_FREQUENCY_PERCENT
};
RimStatisticsPlot();