Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsChartControl.cs =================================================================== diff -u -r095b567e3a7a0e61dd92b0e68fc6f5db883ebcdd -r3748f21da69e2c5a0f5d59168ed1d00807bedf00 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsChartControl.cs (.../IllustrationPointsChartControl.cs) (revision 095b567e3a7a0e61dd92b0e68fc6f5db883ebcdd) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsChartControl.cs (.../IllustrationPointsChartControl.cs) (revision 3748f21da69e2c5a0f5d59168ed1d00807bedf00) @@ -25,6 +25,7 @@ using System.Windows.Forms; using Core.Components.Stack.Data; using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; +using Ringtoets.Common.Forms.Factories; namespace Ringtoets.Common.Forms.Views { @@ -35,12 +36,16 @@ { private GeneralResult data; + private StackChartData chartData; + /// /// Creates a new instance of . /// public IllustrationPointsChartControl() { InitializeComponent(); + + chartData = RingtoetsStackChartDataFactory.Create(); } /// @@ -58,86 +63,17 @@ if (data != null) { - CreateColumns(); + SetChartData(); } } } - private void CreateColumns() + private void SetChartData() { - var chartData = new StackChartData(); + RingtoetsStackChartDataFactory.CreateColumns(data, chartData); + RingtoetsStackChartDataFactory.CreateRows(data, chartData); - var stochastValues = new List(); - - foreach (WindDirectionClosingSituationIllustrationPoint illustrationPoint in data.WindDirectionClosingSituationIllustrationPoints) - { - chartData.AddColumn($"{illustrationPoint.WindDirection.Name}"); - - stochastValues.AddRange(illustrationPoint.IllustrationPoint.Stochasts - .Select(illustrationPointStochast => - new TempIllustrationPoint - { - Name = illustrationPointStochast.Name, - AlphaSquared = Math.Pow(illustrationPointStochast.Alpha, 2) - })); - } - - IDictionary> lookup = new Dictionary>(); - - foreach (TempIllustrationPoint stochastValue in stochastValues) - { - if (!lookup.ContainsKey(stochastValue.Name)) - { - lookup.Add(stochastValue.Name, new List()); - } - - lookup[stochastValue.Name].Add(stochastValue.AlphaSquared); - } - - IDictionary> plotDirectly= new Dictionary>(); - - foreach (KeyValuePair> lookupValue in lookup) - { - if(!lookupValue.Value.Any(v => v < 0.01)) - { - plotDirectly.Add(lookupValue); - } - } - - foreach (KeyValuePair> pair in plotDirectly) - { - chartData.AddRow(pair.Key, pair.Value.ToArray()); - } - - Dictionary> otherLookup = lookup.Except(plotDirectly).ToDictionary(l => l.Key, l => l.Value); - - if (otherLookup.Any()) - { - var values = new double[chartData.Columns.Count()]; - int index = 0; - - foreach (KeyValuePair> keyValuePair in otherLookup) - { - foreach (double value in keyValuePair.Value) - { - values[index] += value; - index++; - } - - index = 0; - } - - chartData.AddRow("Overig", values); - } - stackChartControl.Data = chartData; } - - private class TempIllustrationPoint - { - public string Name { get; set; } - - public double AlphaSquared { get; set; } - } } } \ No newline at end of file