Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/04/16 17:17:08 (8 years ago)
Author:
pfleck
Message:

#2597 Implemented correct coloring when multiple solutions are added for comparison with respect potential overlapping confidence intervals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs

    r13831 r13836  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Globalization;
    2526using System.Linq;
     
    2728using System.Windows.Forms.DataVisualization.Charting;
    2829using HeuristicLab.Common;
     30using HeuristicLab.MainForm.WindowsForms;
    2931using HeuristicLab.Visualization.ChartControlsExtensions;
    3032
     
    110112    public GradientChart() {
    111113      InitializeComponent();
     114
     115      // Configure axis
     116      chart.CustomizeAllChartAreas();
     117      chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
     118      chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
     119      chart.ChartAreas[0].CursorX.Interval = 0;
     120
     121      chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
     122      chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
     123      chart.ChartAreas[0].CursorY.Interval = 0;
    112124    }
    113125
     
    187199      axis.Interval = axisInterval;
    188200
    189       // Create series
    190       chart.Series.Clear();
     201      // Create series <mean, conf. interval>
     202      var seriesDict = new Dictionary<Series, Series>();
    191203      for (int i = 0; i < solutions.Count; ++i) {
    192204        var solution = solutions[i];
    193205        Series confidenceIntervalPlotSeries;
    194         var series = CreateSeries(solution, out confidenceIntervalPlotSeries);
    195         series.Name = Solutions.First().ProblemData.TargetVariable + " " + i;
     206        var meanSeries = CreateSeries(solution, out confidenceIntervalPlotSeries);
     207        meanSeries.Name = Solutions.First().ProblemData.TargetVariable + " " + i;
     208        seriesDict.Add(meanSeries, confidenceIntervalPlotSeries);
    196209        if (confidenceIntervalPlotSeries != null)
    197           chart.Series.Add(confidenceIntervalPlotSeries);
     210          confidenceIntervalPlotSeries.Name = "95% Conf. Interval " + meanSeries.Name;
     211      }
     212
     213      chart.SuspendRepaint();
     214      chart.Series.Clear();
     215      // Add mean series for applying palette colors
     216      foreach (var series in seriesDict.Keys) {
     217        series.LegendText = series.Name;
    198218        chart.Series.Add(series);
    199219      }
     220      chart.Palette = ChartColorPalette.BrightPastel;
     221      chart.ApplyPaletteColors();
     222      chart.Palette = ChartColorPalette.None;
     223
     224      foreach (var series in seriesDict) {
     225        if (series.Value == null) continue;
     226        int idx = chart.Series.IndexOf(series.Key);
     227        series.Value.Color = Color.FromArgb(40, series.Key.Color);
     228        series.Value.IsVisibleInLegend = false;
     229        chart.Series.Insert(idx, series.Value);
     230      }
     231      chart.ResumeRepaint(true);
     232
     233
    200234      //// calculate Y-axis interval
    201235      //double ymin = 0, ymax = 0;
Note: See TracChangeset for help on using the changeset viewer.