Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6010 for branches/histogram


Ignore:
Timestamp:
04/14/11 00:18:46 (14 years ago)
Author:
abeham
Message:

#1465

  • worked on histogram integration
    • Added control to display DataRowVisualProperties
    • Added a dialog to select the DataRowVisualProperties of different series
    • Added a Properties menu item to the context menu and an option to show or hide this item (default is hide)
Location:
branches/histogram
Files:
8 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.Designer.cs

    r5832 r6010  
    8989      series1.Name = "Default";
    9090      this.chart.Series.Add(series1);
     91      this.chart.ShowPropertiesContextMenuItem = true;
    9192      this.chart.Size = new System.Drawing.Size(359, 248);
    9293      this.chart.TabIndex = 3;
     
    9697      title1.Text = "Title";
    9798      this.chart.Titles.Add(title1);
     99      this.chart.PropertiesClicked += new System.EventHandler(this.chart_PropertiesClicked);
    98100      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
    99101      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r5445 r6010  
    133133          series.ChartType = SeriesChartType.FastPoint;
    134134          break;
     135        case DataRowVisualProperties.DataRowChartType.Histogram:
     136          series.ChartType = SeriesChartType.Column;
     137          series["PointWidth"] = "1";
     138          break;
    135139        default:
    136140          series.ChartType = SeriesChartType.FastPoint;
     
    283287      else {
    284288        DataRow row = (DataRow)sender;
     289        if (chart.Series[row.Name].IsCustomPropertySet("PointWidth"))
     290          chart.Series[row.Name].DeleteCustomProperty("PointWidth");
    285291        switch (row.VisualProperties.ChartType) {
    286292          case DataRowVisualProperties.DataRowChartType.Line:
     
    296302            chart.Series[row.Name].ChartType = SeriesChartType.FastPoint;
    297303            break;
     304          case DataRowVisualProperties.DataRowChartType.Histogram:
     305            chart.Series[row.Name].ChartType = SeriesChartType.Column;
     306            chart.Series[row.Name]["PointWidth"] = "1";
     307            break;
    298308          default:
    299309            chart.Series[row.Name].ChartType = SeriesChartType.FastPoint;
     
    354364          Series rowSeries = chart.Series[row.Name];
    355365          if (!invisibleSeries.Contains(rowSeries)) {
    356             foreach (IndexedItem<double> item in e.Items) {
    357               if (IsInvalidValue(item.Value))
    358                 rowSeries.Points[item.Index].IsEmpty = true;
    359               else {
    360                 rowSeries.Points[item.Index].YValues = new double[] { item.Value };
    361                 rowSeries.Points[item.Index].IsEmpty = false;
     366            if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) {
     367              rowSeries.Points.Clear();
     368              FillSeriesWithRowValues(rowSeries, row);
     369            } else {
     370              foreach (IndexedItem<double> item in e.Items) {
     371                if (IsInvalidValue(item.Value))
     372                  rowSeries.Points[item.Index].IsEmpty = true;
     373                else {
     374                  rowSeries.Points[item.Index].YValues = new double[] { item.Value };
     375                  rowSeries.Points[item.Index].IsEmpty = false;
     376                }
    362377              }
    363378            }
     
    429444
    430445    private void FillSeriesWithRowValues(Series series, DataRow row) {
    431       for (int i = 0; i < row.Values.Count; i++) {
    432         var value = row.Values[i];
    433         DataPoint point = new DataPoint();
    434         point.XValue = row.VisualProperties.StartIndexZero ? i : i + 1;
    435         if (IsInvalidValue(value))
    436           point.IsEmpty = true;
    437         else
    438           point.YValues = new double[] { value };
    439         series.Points.Add(point);
    440       }
     446      if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) {
     447        series.Points.Clear();
     448        if (!row.Values.Any()) return;
     449        int bins = row.VisualProperties.Bins;
     450
     451        double minValue = row.Values.Min();
     452        double maxValue = row.Values.Max();
     453        double intervalWidth = (maxValue - minValue) / bins;
     454        if (intervalWidth <= 0) return;
     455
     456        if (!row.VisualProperties.ExactBins) {
     457          intervalWidth = HumanRoundRange(intervalWidth);
     458          minValue = Math.Floor(minValue / intervalWidth) * intervalWidth;
     459          maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth;
     460        }
     461
     462        double current = minValue, intervalCenter = intervalWidth / 2.0;
     463        int frequency = 0;
     464        foreach (double v in row.Values.Where(x => !IsInvalidValue(x)).OrderBy(x => x)) {
     465          while (v > current + intervalWidth) {
     466            series.Points.AddXY(current + intervalCenter, frequency);
     467            current += intervalWidth;
     468            frequency = 0;
     469          }
     470          frequency++;
     471        }
     472        series.Points.AddXY(current + intervalCenter, frequency);
     473      } else {
     474        for (int i = 0; i < row.Values.Count; i++) {
     475          var value = row.Values[i];
     476          DataPoint point = new DataPoint();
     477          point.XValue = row.VisualProperties.StartIndexZero ? i : i + 1;
     478          if (IsInvalidValue(value))
     479            point.IsEmpty = true;
     480          else
     481            point.YValues = new double[] { value };
     482          series.Points.Add(point);
     483        }
     484      }
     485    }
     486
     487    private double HumanRoundRange(double range) {
     488      double base10 = Math.Pow(10.0, Math.Floor(Math.Log10(range)));
     489      double rounding = range / base10;
     490      if (rounding <= 1.5) rounding = 1;
     491      else if (rounding <= 2.25) rounding = 2;
     492      else if (rounding <= 3.75) rounding = 2.5;
     493      else if (rounding <= 7.5) rounding = 5;
     494      else rounding = 10;
     495      return rounding * base10;
    441496    }
    442497
     
    459514      }
    460515    }
     516
     517    private void chart_PropertiesClicked(object sender, EventArgs e) {
     518      DataTableVisualPropertiesDialog dialog = new DataTableVisualPropertiesDialog(Content);
     519      dialog.ShowDialog();
     520    }
    461521    #endregion
    462522
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj

    r5994 r6010  
    130130      <DependentUpon>AggregatedHistogramHistoryView.cs</DependentUpon>
    131131    </Compile>
     132    <Compile Include="DataRowVisualPropertiesControl.cs">
     133      <SubType>UserControl</SubType>
     134    </Compile>
     135    <Compile Include="DataRowVisualPropertiesControl.Designer.cs">
     136      <DependentUpon>DataRowVisualPropertiesControl.cs</DependentUpon>
     137    </Compile>
     138    <Compile Include="DataTableVisualPropertiesDialog.cs">
     139      <SubType>Form</SubType>
     140    </Compile>
     141    <Compile Include="DataTableVisualPropertiesDialog.Designer.cs">
     142      <DependentUpon>DataTableVisualPropertiesDialog.cs</DependentUpon>
     143    </Compile>
    132144    <Compile Include="HistogramHistoryView.cs">
    133145      <SubType>UserControl</SubType>
     
    193205      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    194206      <Name>HeuristicLab.Collections-3.3</Name>
     207    </ProjectReference>
     208    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
     209      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
     210      <Name>HeuristicLab.Common.Resources-3.3</Name>
    195211    </ProjectReference>
    196212    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
     
    251267    <EmbeddedResource Include="AggregatedHistogramHistoryView.resx">
    252268      <DependentUpon>AggregatedHistogramHistoryView.cs</DependentUpon>
     269    </EmbeddedResource>
     270    <EmbeddedResource Include="DataRowVisualPropertiesControl.resx">
     271      <DependentUpon>DataRowVisualPropertiesControl.cs</DependentUpon>
     272    </EmbeddedResource>
     273    <EmbeddedResource Include="DataTableView.resx">
     274      <DependentUpon>DataTableView.cs</DependentUpon>
     275    </EmbeddedResource>
     276    <EmbeddedResource Include="DataTableVisualPropertiesDialog.resx">
     277      <DependentUpon>DataTableVisualPropertiesDialog.cs</DependentUpon>
    253278    </EmbeddedResource>
    254279    <EmbeddedResource Include="HeatMapView.resx">
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/HeuristicLabAnalysisViewsPlugin.cs.frame

    r5446 r6010  
    3131  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3232  [PluginDependency("HeuristicLab.Common", "3.3")]
     33  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3334  [PluginDependency("HeuristicLab.Core", "3.3")]
    3435  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
  • branches/histogram/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs

    r5445 r6010  
    3636      Columns,
    3737      Points,
    38       Bars
     38      Bars,
     39      Histogram
    3940    }
    4041    #endregion
     
    8081      }
    8182    }
     83    private int bins;
     84    public int Bins {
     85      get { return bins; }
     86      set {
     87        if (bins != value) {
     88          bins = value;
     89          OnPropertyChanged("Bins");
     90        }
     91      }
     92    }
     93    private bool exactBins;
     94    public bool ExactBins {
     95      get { return exactBins; }
     96      set {
     97        if (exactBins != value) {
     98          exactBins = value;
     99          OnPropertyChanged("ExactBins");
     100        }
     101      }
     102    }
    82103
    83104    #region Persistence Properties
     
    101122      get { return startIndexZero; }
    102123      set { startIndexZero = value; }
     124    }
     125    [Storable(Name = "Bins")]
     126    private int StorableBins {
     127      get { return bins; }
     128      set { bins = value; }
     129    }
     130    [Storable(Name = "ExactBins")]
     131    private bool StorableExactBins {
     132      get { return exactBins; }
     133      set { exactBins = value; }
    103134    }
    104135    #endregion
  • branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs

    r5996 r6010  
    6868        for (int j = 0; j < solution.Length; j++)
    6969          impact += weights[source, j] * distances[target, solution[j]];
    70         alleles[i] = new Allele(source.ToString() + "-" + target.ToString(), impact);
     70        alleles[i] = new Allele(source.ToString() + "->" + target.ToString(), impact);
    7171      }
    7272
  • branches/histogram/HeuristicLab.Visualization.ChartControlsExtensions/3.3/EnhancedChart.Designer.cs

    r5445 r6010  
    5050      this.copyImageToClipboardBitmapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5151      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
     52      this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     53      this.propertiesToolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
    5254      this.contextMenuStrip.SuspendLayout();
    5355      ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
     
    5860      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    5961            this.exportChartToolStripMenuItem,
    60             this.copyImageToClipboardBitmapToolStripMenuItem});
     62            this.copyImageToClipboardBitmapToolStripMenuItem,
     63            this.propertiesToolStripSeparator,
     64            this.propertiesToolStripMenuItem});
    6165      this.contextMenuStrip.Name = "contextMenuStrip";
    62       this.contextMenuStrip.Size = new System.Drawing.Size(257, 48);
     66      this.contextMenuStrip.Size = new System.Drawing.Size(257, 76);
     67      this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
    6368      //
    6469      // exportChartToolStripMenuItem
     
    7883      // saveFileDialog
    7984      //
    80       this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF " +
    81           "(*.gif)|*.gif|TIFF (*.tif)|*.tif\"";
     85      this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (" +
     86          "*.gif)|*.gif|TIFF (*.tif)|*.tif\"";
    8287      this.saveFileDialog.FilterIndex = 2;
     88      //
     89      // propertiesToolStripMenuItem
     90      //
     91      this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem";
     92      this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
     93      this.propertiesToolStripMenuItem.Text = "Properties";
     94      this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesToolStripMenuItem_Click);
     95      //
     96      // propertiesToolStripSeparator
     97      //
     98      this.propertiesToolStripSeparator.Name = "propertiesToolStripSeparator";
     99      this.propertiesToolStripSeparator.Size = new System.Drawing.Size(253, 6);
    83100      //
    84101      // EnhancedChart
     
    97114    private System.Windows.Forms.ToolStripMenuItem copyImageToClipboardBitmapToolStripMenuItem;
    98115    private System.Windows.Forms.SaveFileDialog saveFileDialog;
     116    private System.Windows.Forms.ToolStripSeparator propertiesToolStripSeparator;
     117    private System.Windows.Forms.ToolStripMenuItem propertiesToolStripMenuItem;
    99118  }
    100119}
  • branches/histogram/HeuristicLab.Visualization.ChartControlsExtensions/3.3/EnhancedChart.cs

    r5445 r6010  
    4040    [DefaultValue(true)]
    4141    public bool EnableMiddleClickPanning { get; set; }
     42    [DefaultValue(false)]
     43    public bool ShowPropertiesContextMenuItem { get; set; }
    4244
    4345    public static void CustomizeChartArea(ChartArea chartArea) {
     
    138140    #endregion
    139141
     142    private void contextMenuStrip_Opening(object sender, CancelEventArgs e) {
     143      propertiesToolStripSeparator.Visible = ShowPropertiesContextMenuItem;
     144      propertiesToolStripMenuItem.Visible = ShowPropertiesContextMenuItem;
     145    }
     146
    140147    private void exportChartToolStripMenuItem_Click(object sender, System.EventArgs e) {
    141148      // Set image file format
     
    168175      Clipboard.SetDataObject(bmp);
    169176    }
     177
     178    private void propertiesToolStripMenuItem_Click(object sender, EventArgs e) {
     179      OnPropertiesClicked();
     180    }
     181
     182    public event EventHandler PropertiesClicked;
     183    private void OnPropertiesClicked() {
     184      var handler = PropertiesClicked;
     185      if (handler != null) handler(this, EventArgs.Empty);
     186    }
    170187  }
    171188}
  • branches/histogram/HeuristicLab.Visualization.ChartControlsExtensions/3.3/HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj

    r5970 r6010  
    141141    </ProjectReference>
    142142  </ItemGroup>
     143  <ItemGroup>
     144    <EmbeddedResource Include="EnhancedChart.resx">
     145      <DependentUpon>EnhancedChart.cs</DependentUpon>
     146    </EmbeddedResource>
     147  </ItemGroup>
    143148  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    144149  <PropertyGroup>
Note: See TracChangeset for help on using the changeset viewer.