Changeset 6010 for branches/histogram/HeuristicLab.Analysis.Views/3.3
- Timestamp:
- 04/14/11 00:18:46 (13 years ago)
- 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 89 89 series1.Name = "Default"; 90 90 this.chart.Series.Add(series1); 91 this.chart.ShowPropertiesContextMenuItem = true; 91 92 this.chart.Size = new System.Drawing.Size(359, 248); 92 93 this.chart.TabIndex = 3; … … 96 97 title1.Text = "Title"; 97 98 this.chart.Titles.Add(title1); 99 this.chart.PropertiesClicked += new System.EventHandler(this.chart_PropertiesClicked); 98 100 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 99 101 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); -
branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.cs
r5445 r6010 133 133 series.ChartType = SeriesChartType.FastPoint; 134 134 break; 135 case DataRowVisualProperties.DataRowChartType.Histogram: 136 series.ChartType = SeriesChartType.Column; 137 series["PointWidth"] = "1"; 138 break; 135 139 default: 136 140 series.ChartType = SeriesChartType.FastPoint; … … 283 287 else { 284 288 DataRow row = (DataRow)sender; 289 if (chart.Series[row.Name].IsCustomPropertySet("PointWidth")) 290 chart.Series[row.Name].DeleteCustomProperty("PointWidth"); 285 291 switch (row.VisualProperties.ChartType) { 286 292 case DataRowVisualProperties.DataRowChartType.Line: … … 296 302 chart.Series[row.Name].ChartType = SeriesChartType.FastPoint; 297 303 break; 304 case DataRowVisualProperties.DataRowChartType.Histogram: 305 chart.Series[row.Name].ChartType = SeriesChartType.Column; 306 chart.Series[row.Name]["PointWidth"] = "1"; 307 break; 298 308 default: 299 309 chart.Series[row.Name].ChartType = SeriesChartType.FastPoint; … … 354 364 Series rowSeries = chart.Series[row.Name]; 355 365 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 } 362 377 } 363 378 } … … 429 444 430 445 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; 441 496 } 442 497 … … 459 514 } 460 515 } 516 517 private void chart_PropertiesClicked(object sender, EventArgs e) { 518 DataTableVisualPropertiesDialog dialog = new DataTableVisualPropertiesDialog(Content); 519 dialog.ShowDialog(); 520 } 461 521 #endregion 462 522 -
branches/histogram/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj
r5994 r6010 130 130 <DependentUpon>AggregatedHistogramHistoryView.cs</DependentUpon> 131 131 </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> 132 144 <Compile Include="HistogramHistoryView.cs"> 133 145 <SubType>UserControl</SubType> … … 193 205 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 194 206 <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> 195 211 </ProjectReference> 196 212 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> … … 251 267 <EmbeddedResource Include="AggregatedHistogramHistoryView.resx"> 252 268 <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> 253 278 </EmbeddedResource> 254 279 <EmbeddedResource Include="HeatMapView.resx"> -
branches/histogram/HeuristicLab.Analysis.Views/3.3/HeuristicLabAnalysisViewsPlugin.cs.frame
r5446 r6010 31 31 [PluginDependency("HeuristicLab.Collections", "3.3")] 32 32 [PluginDependency("HeuristicLab.Common", "3.3")] 33 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 34 [PluginDependency("HeuristicLab.Core", "3.3")] 34 35 [PluginDependency("HeuristicLab.Core.Views", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.