Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/13/10 13:07:31 (14 years ago)
Author:
mkommend
Message:

customized x-axis labels in BoxPlotView (ticket #1135)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBoxPlotView.cs

    r4094 r4211  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.ComponentModel;
    25 using System.Data;
    26 using System.Drawing;
    2724using System.Linq;
    28 using System.Text;
    2925using System.Windows.Forms;
    3026using System.Windows.Forms.DataVisualization.Charting;
    31 using HeuristicLab.Common;
    3227using HeuristicLab.Core;
    3328using HeuristicLab.Data;
     
    4641    private string yAxisValue;
    4742    private Dictionary<int, Dictionary<object, double>> categoricalMapping;
    48     private Dictionary<double, Series> seriesCache;
     43    private SortedDictionary<double, Series> seriesCache;
    4944
    5045    public RunCollectionBoxPlotView() {
    5146      InitializeComponent();
    5247      this.categoricalMapping = new Dictionary<int, Dictionary<object, double>>();
    53       this.seriesCache = new Dictionary<double, Series>();
     48      this.seriesCache = new SortedDictionary<double, Series>();
    5449      this.chart.ChartAreas[0].Visible = false;
    5550      this.chart.Series.Clear();
     
    307302      axis.CustomLabels.Clear();
    308303      if (categoricalMapping.ContainsKey(dimension)) {
    309         CustomLabel label = null;
    310304        foreach (var pair in categoricalMapping[dimension]) {
    311305          string labelText = pair.Key.ToString();
     306          CustomLabel label = new CustomLabel();
     307          label.ToolTip = labelText;
    312308          if (labelText.Length > 25)
    313309            labelText = labelText.Substring(0, 25) + " ... ";
    314           label = axis.CustomLabels.Add(pair.Value - 0.5, pair.Value + 0.5, labelText);
     310          label.Text = labelText;
    315311          label.GridTicks = GridTickTypes.TickMark;
    316         }
    317         axis.IsLabelAutoFit = false;
    318         axis.LabelStyle.Enabled = true;
    319         axis.LabelStyle.Angle = 0;
    320         axis.LabelStyle.TruncatedLabels = true;
     312          label.FromPosition = pair.Value - 0.5;
     313          label.ToPosition = pair.Value + 0.5;
     314          axis.CustomLabels.Add(label);
     315        }
    321316      } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) {
    322317        this.chart.ChartAreas[0].RecalculateAxesScale();
     
    329324          axis.CustomLabels.Add(i - correspondingAxis.LabelStyle.Interval / 2, i + correspondingAxis.LabelStyle.Interval / 2, x);
    330325        }
     326      } else if (chart.ChartAreas[BoxPlotChartAreaName].AxisX == axis) {
     327        double position = 1.0;
     328        foreach (Series series in chart.Series) {
     329          if (series.Name != BoxPlotSeriesName) {
     330            string labelText = series.Points[0].XValue.ToString();
     331            CustomLabel label = new CustomLabel();
     332            label.FromPosition = position - 0.5;
     333            label.ToPosition = position + 0.5;
     334            label.GridTicks = GridTickTypes.TickMark;
     335            label.Text = labelText;
     336            axis.CustomLabels.Add(label);
     337            position++;
     338          }
     339        }
    331340      }
    332341    }
Note: See TracChangeset for help on using the changeset viewer.