- Timestamp:
- 06/11/14 14:23:19 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs
r10967 r10987 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Drawing; 24 using HeuristicLab.Analysis; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; … … 27 29 28 30 [Item("ScatterPlot", "Represents a scatter plot.")] 29 public class ScatterPlotContent : PreprocessingChartContent { 31 public class ScatterPlotContent : Item, IViewChartShortcut { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } 34 } 30 35 31 36 public string SelectedXVariable { get; set; } 32 33 37 public string SelectedYVariable { get; set; } 34 38 35 public ScatterPlotContent(IChartLogic chartlogic) 36 : base(chartlogic) { 39 public IPreprocessingContext Context { 40 get; 41 private set; 42 } 43 public ITransactionalPreprocessingData PreprocessingData { 44 get { return Context.Data; } 45 } 46 47 public ScatterPlotContent(IPreprocessingContext context) 48 : base() { 49 this.Context = context; 37 50 } 38 51 39 52 public ScatterPlotContent(ScatterPlotContent content, Cloner cloner) 40 53 : base(content, cloner) { 41 this.SelectedXVariable = content.SelectedXVariable; 42 this.SelectedYVariable = content.SelectedYVariable; 54 this.Context = content.Context; 55 this.SelectedXVariable = content.SelectedXVariable; 56 this.SelectedYVariable = content.SelectedYVariable; 43 57 } 44 45 public static new Image StaticItemImage {46 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }47 }48 49 58 public override IDeepCloneable Clone(Cloner cloner) { 50 59 return new ScatterPlotContent(this, cloner); 51 60 } 52 61 62 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 63 int columnIndex = PreprocessingData.GetColumnIndex(variableName); 64 IList<double> values = PreprocessingData.GetValues<double>(columnIndex); 65 DataRow row = new DataRow(variableName, "", values); 66 row.VisualProperties.ChartType = chartType; 67 return row; 68 } 69 70 public IEnumerable<string> GetVariableNames() { 71 List<string> doubleVariableNames = new List<string>(); 72 73 //only return variable names from type double 74 foreach (string variableName in PreprocessingData.VariableNames) { 75 if (PreprocessingData.IsType<double>(PreprocessingData.GetColumnIndex(variableName))) 76 doubleVariableNames.Add(variableName); 77 } 78 79 return doubleVariableNames; 80 } 81 82 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY) { 83 ScatterPlot scatterPlot = new ScatterPlot(); 84 85 int xColumnIndex = PreprocessingData.GetColumnIndex(variableNameX); 86 int yColumnIndex = PreprocessingData.GetColumnIndex(variableNameY); 87 88 IList<double> xValues = PreprocessingData.GetValues<double>(xColumnIndex); 89 IList<double> yValues = PreprocessingData.GetValues<double>(yColumnIndex); 90 91 List<Point2D<double>> points = new List<Point2D<double>>(); 92 93 for (int i = 0; i < xValues.Count; i++) { 94 Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); 95 points.Add(point); 96 } 97 98 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 99 scatterPlot.Rows.Add(scdr); 100 return scatterPlot; 101 } 102 53 103 } 54 104 }
Note: See TracChangeset
for help on using the changeset viewer.