Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/08 13:36:57 (16 years ago)
Author:
gkronber
Message:
  • asynchronous downloading of agents and results from the CEDMA server
  • created a chart that displays points as bubbles (scatter-plot + optional third dimension for the size of the bubble, larger bubbles are more transparent than smaller bubbles)

ticket #268 (Possibility to open the function-tree of any model (represented as point in the scatter-plot))

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/ResultListView.cs

    r560 r561  
    1414    private ResultList results;
    1515    private const string FREQUENCY = "<Frequency>";
     16    private const string CONSTANT_SIZE = "<constant>";
    1617    private double xJitterFactor = 0.0;
    1718    private double yJitterFactor = 0.0;
     
    2122    public ResultListView(ResultList results) {
    2223      this.results = results;
     24      results.Changed += new EventHandler(results_Changed);
    2325      InitializeComponent();
    24       dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 1);
    2526      xAxisComboBox.Items.AddRange(results.VariableNames);
    2627      yAxisComboBox.Items.Add(FREQUENCY);
    2728      yAxisComboBox.Items.AddRange(results.VariableNames);
     29      sizeComboBox.Items.Add(CONSTANT_SIZE);
     30      sizeComboBox.Items.AddRange(results.VariableNames);
     31      sizeComboBox.SelectedItem = sizeComboBox.Items[0];
     32      InitChart();
     33    }
     34
     35    private DateTime lastUpdate = DateTime.Now;
     36    void results_Changed(object sender, EventArgs e) {
     37      if(DateTime.Now.Subtract(lastUpdate).TotalSeconds < 3) return;
     38      lastUpdate = DateTime.Now;
     39      InitChart();
     40    }
     41
     42    private void InitChart() {
     43      dataChart.Chart = new BubbleChart(0, 0, 100, 100);
     44      foreach(string dim in results.VariableNames) {
     45        dataChart.Chart.AddDimension(dim);
     46        IList<double> xs = results.GetValues(dim);
     47        for(int i = 0; i < xs.Count; i++) {
     48          double x = xs[i];
     49          if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
     50          if(!double.IsNaN(x)) {
     51            dataChart.Chart.AddDataPoint(dim, x);
     52          }
     53        }
     54      }
    2855    }
    2956
     
    4572        CreateHistogramChart();
    4673      } else {
    47         CreateScatterplot();
     74        dataChart.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
    4875      }
    4976    }
    5077
    51     private void CreateScatterplot() {
    52       double minX = double.PositiveInfinity;
    53       double minY = double.PositiveInfinity;
    54       double maxX = double.NegativeInfinity;
    55       double maxY = double.NegativeInfinity;
    56 
    57       xTrackBar.Enabled = true;
    58       yTrackBar.Enabled = true;
    59       Random random = new Random();
    60       Color curCol = Color.FromArgb(30, Color.Blue);
    61       Pen p = new Pen(curCol);
    62       SolidBrush b = new SolidBrush(curCol);
    63       IList<double> xs = results.GetValues((string)xAxisComboBox.SelectedItem);
    64       IList<double> ys = results.GetValues((string)yAxisComboBox.SelectedItem);
    65       dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
    66       dataChart.Chart.UpdateEnabled = false;
    67       dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
    68       dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Points, p, b);
    69       for(int i = 0; i < xs.Count; i++) {
    70         double x = xs[i] + (random.NextDouble() * 2.0 - 1.0) * xJitterFactor;
    71         double y = ys[i] + (random.NextDouble() * 2.0 - 1.0) * yJitterFactor;
    72         if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
    73         if(double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
    74         if(!double.IsNaN(x) && !double.IsNaN(y)) {
    75           dataChart.Chart.AddDataPoint(0, x, y);
    76           if(x > maxX) maxX = x;
    77           if(y > maxY) maxY = y;
    78           if(x < minX) minX = x;
    79           if(y < minY) minY = y;
    80         }
    81       }
    82       dataChart.Chart.UpdateEnabled = true;
    83       if(minX<maxX && minY<maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY);
     78    private void CreateHistogramChart() {
     79      // TASK
    8480    }
    85 
    86     private void CreateHistogramChart() {
    87       double minX = double.PositiveInfinity;
    88       double minY = double.PositiveInfinity;
    89       double maxX = double.NegativeInfinity;
    90       double maxY = double.NegativeInfinity;
    91 
    92       xTrackBar.Enabled = false;
    93       yTrackBar.Enabled = false;
    94       Color curCol = Color.Blue;
    95       Pen p = new Pen(curCol);
    96       SolidBrush b = new SolidBrush(curCol);
    97       // frequency
    98       dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100);
    99       dataChart.Chart.UpdateEnabled = false;
    100       dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both));
    101       Histogram h = results.GetHistogram((string)xAxisComboBox.SelectedItem);
    102       for(int i = 0; i < h.Buckets; i++) {
    103         double lower = h.LowerValue(i);
    104         double upper = h.UpperValue(i);
    105         int freq = h.Frequency(i);
    106         if(lower < minX) minX = lower;
    107         if(upper > maxX) maxX = upper;
    108         if(freq > maxY) maxY = freq;
    109         dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Bars, p, b);
    110         dataChart.Chart.AddDataPoint(0, lower, 0);
    111         dataChart.Chart.AddDataPoint(0, upper, freq);
    112       }
    113       minY = 0;
    114       dataChart.Chart.UpdateEnabled = true;
    115       if(minX < maxX && minY < maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY);
    116     }
    117 
    118     private void yTrackBar_ValueChanged(object sender, EventArgs e) {
     81   
     82    private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
    11983      if(dataChart.Chart != null) {
    120         yJitterFactor = yTrackBar.Value / 100.0 * maxYJitterPercent * dataChart.Chart.Size.Height;
     84        double xJitterFactor = xTrackBar.Value / 100.0 ;
     85        double yJitterFactor = yTrackBar.Value / 100.0 ;
     86        dataChart.Chart.SetJitter(xJitterFactor, yJitterFactor);
    12187      }
    12288      UpdateChart();
    12389    }
    12490
    125     private void xTrackBar_ValueChanged(object sender, EventArgs e) {
     91    private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    12692      if(dataChart.Chart != null) {
    127         xJitterFactor = xTrackBar.Value / 100.0 * maxXJitterPercent * dataChart.Chart.Size.Width;
     93        dataChart.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
     94        UpdateChart();
    12895      }
    129       UpdateChart();
    13096    }
    13197  }
Note: See TracChangeset for help on using the changeset viewer.