Changeset 13818


Ignore:
Timestamp:
05/02/16 12:30:56 (4 years ago)
Author:
bburlacu
Message:

#2597: Fixed small bug when the values are not correctly rendered in the chart initially. removed unused variable limits from view.

Location:
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
3 edited

Legend:

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

    r13780 r13818  
    4848      series1.Name = "Series1";
    4949      this.Series.Add(series1);
     50      this.AnnotationPositionChanged += new System.EventHandler(this.chart_AnnotationPositionChanged);
    5051      this.AnnotationPositionChanging += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.AnnotationPositionChangingEventArgs>(this.chart_AnnotationPositionChanging);
    5152      this.DragDrop += new System.Windows.Forms.DragEventHandler(this.GradientChart_DragDrop);
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs

    r13817 r13818  
    198198      if (internalDataset == null || solutionList == null || !solutionList.Any())
    199199        return;
    200       if (min.IsAlmost(max) || min > max)
    201         return;
    202       if (points == 0)
     200      if (min.IsAlmost(max) || min > max || points == 0)
    203201        return;
    204202      Series.Clear();
     
    207205      Annotations.Clear();
    208206      Annotations.Add(vla);
     207      double axisMin, axisMax, axisInterval;
     208      // calculate X-axis interval
     209      ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);
     210      var axis = ChartAreas[0].AxisX;
     211      axis.Minimum = axisMin;
     212      axis.Maximum = axisMax;
     213      axis.Interval = axisInterval;
     214
    209215      for (int i = 0; i < solutionList.Count; ++i) {
    210216        var solution = solutionList[i];
     
    214220        var p = series.Points.Last();
    215221        vla.X = p.XValue;
    216         ChartAreas[0].AxisX.Title = Variable + " " + vla.X.ToString("N3", CultureInfo.CurrentCulture);
    217         //        var ta = new TextAnnotation {
    218         //          Text = string.Format("X: {0:0.000}, Y: {1:0.000}", p.XValue, p.YValues[0]),
    219         //          Visible = true,
    220         //          X = p.XValue,
    221         //          Y = p.YValues[0],
    222         //          AxisX = ChartAreas[0].AxisX,
    223         //          AxisY = ChartAreas[0].AxisY
    224         //        };
    225         //        ta.ClipToChartArea = "ChartArea1";
    226         //        ta.Name = series.Name;
    227         //        Annotations.Add(ta);
    228       }
    229       CalculateAxisInterval();
    230       AddStripLines();
     222      }
     223      // calculate Y-axis interval
     224      double ymin = 0, ymax = 0;
     225      foreach (var v in Series[0].Points.Select(x => x.YValues[0])) {
     226        if (ymin > v) ymin = v;
     227        if (ymax < v) ymax = v;
     228      }
     229      ChartUtil.CalculateAxisInterval(ymin, ymax, 5, out axisMin, out axisMax, out axisInterval);
     230      axis = ChartAreas[0].AxisY;
     231      axis.Minimum = axisMin;
     232      axis.Maximum = axisMax;
     233      axis.Interval = axisInterval;
     234      ChartAreas[0].AxisX.Title = Variable + " : " + vla.X.ToString("N3", CultureInfo.CurrentCulture); // set axis titlet
     235      AddStripLines(); // add strip lines
    231236      if (ShowLegend)
    232237        AddLegends();
     
    311316    }
    312317
    313     private void CalculateAxisInterval() {
    314       double axisMin, axisMax, axisInterval;
    315       ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);
    316       var axis = ChartAreas[0].AxisX;
    317       axis.Minimum = axisMin;
    318       axis.Maximum = axisMax;
    319       axis.Interval = axisInterval;
    320 
    321       double ymin = 0, ymax = 0;
    322       foreach (var v in Series[0].Points.Select(x => x.YValues[0])) {
    323         if (ymin > v) ymin = v;
    324         if (ymax < v) ymax = v;
    325       }
    326       ChartUtil.CalculateAxisInterval(ymin, ymax, 5, out axisMin, out axisMax, out axisInterval);
    327       axis = ChartAreas[0].AxisY;
    328       axis.Minimum = axisMin;
    329       axis.Maximum = axisMax;
    330       axis.Interval = axisInterval;
    331     }
    332 
    333318    private void RegisterEvents() {
    334319      AnnotationPositionChanging += chart_AnnotationPositionChanging;
     
    352337    }
    353338
    354     //    private void chart_AnnotationPositionChanged(object sender, EventArgs e) {
    355     //      var a = Annotations[0];
    356     //      var x = a.X;
    357     //      var s = Series[0];
    358     //      var n = s.Points.Count;
    359     //      var y = GetEstimatedValue(x);
    360     //      s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 };
    361     //      a.TextStyle = TextStyle.Default;
    362     //      Refresh();
    363     //    }
     339    private void chart_AnnotationPositionChanged(object sender, EventArgs e) {
     340      var annotation = VerticalLineAnnotation;
     341      var x = annotation.X;
     342      internalDataset.SetVariableValue(x, Variable, 0);
     343      for (int i = 0; i < solutionList.Count; ++i) {
     344        var y = GetEstimatedValue(solutionList[i], x);
     345        var s = Series[i];
     346        var n = s.Points.Count;
     347        s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 };
     348      }
     349      ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);
     350      Update();
     351      OnVariableValueChanged(this, EventArgs.Empty);
     352    }
    364353
    365354    private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) {
     
    371360      if (e.NewLocationX < axisX.Minimum)
    372361        e.NewLocationX = axisX.Minimum;
    373       var x = e.NewLocationX;
    374       internalDataset.SetVariableValue(x, Variable, 0);
    375       for (int i = 0; i < solutionList.Count; ++i) {
    376         var y = GetEstimatedValue(solutionList[i], x);
    377         var s = Series[i];
    378         var n = s.Points.Count;
    379         s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 };
    380       }
    381       ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);
    382       Update();
    383       OnVariableValueChanged(this, EventArgs.Empty);
     362      //      var x = e.NewLocationX;
     363      //      internalDataset.SetVariableValue(x, Variable, 0);
     364      //      for (int i = 0; i < solutionList.Count; ++i) {
     365      //        var y = GetEstimatedValue(solutionList[i], x);
     366      //        var s = Series[i];
     367      //        var n = s.Points.Count;
     368      //        s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 };
     369      //      }
     370      //      ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);
     371      //      Update();
     372      //      OnVariableValueChanged(this, EventArgs.Empty);
    384373    }
    385374
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.cs

    r13817 r13818  
    3333    private ModifiableDataset internalDataset;
    3434    private Dictionary<string, GradientChart> charts;
    35     private Dictionary<string, DoubleLimit> variableLimits;
    3635
    3736    private const int Points = 1000;
     
    7574      // update charts and variable limits
    7675      charts = new Dictionary<string, GradientChart>();
    77       variableLimits = new Dictionary<string, DoubleLimit>();
    7876      foreach (var x in pd.AllowedInputVariables) {
    7977        double min = 0, max = 0;
     
    8280          if (v < min) min = v;
    8381        }
    84         variableLimits[x] = new DoubleLimit(min, max);
    8582        var gradientChart = new GradientChart { Dock = DockStyle.Fill, ShowLegend = false, Margin = Padding.Empty };
    8683        gradientChart.VariableValueChanged += (o, e) => {
Note: See TracChangeset for help on using the changeset viewer.