Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/14/11 00:18:46 (13 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/HeuristicLab.Analysis.Views/3.3
Files:
7 added
4 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")]
Note: See TracChangeset for help on using the changeset viewer.