Changeset 7129 for branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis
- Timestamp:
- 12/05/11 20:17:59 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.Designer.cs
r6802 r7129 44 44 /// </summary> 45 45 private void InitializeComponent() { 46 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea 1= new System.Windows.Forms.DataVisualization.Charting.ChartArea();47 System.Windows.Forms.DataVisualization.Charting.Legend legend 1= new System.Windows.Forms.DataVisualization.Charting.Legend();46 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 47 System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 48 48 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 49 this.targetVariableComboBox = new System.Windows.Forms.ComboBox(); 50 this.label = new System.Windows.Forms.Label(); 51 this.prognosedValuesCheckbox = new System.Windows.Forms.CheckBox(); 49 52 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 50 53 this.SuspendLayout(); … … 52 55 // chart 53 56 // 54 chartArea1.Name = "ChartArea"; 55 this.chart.ChartAreas.Add(chartArea1); 56 this.chart.Dock = System.Windows.Forms.DockStyle.Fill; 57 legend1.Alignment = System.Drawing.StringAlignment.Center; 58 legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 59 legend1.Name = "Default"; 60 this.chart.Legends.Add(legend1); 61 this.chart.Location = new System.Drawing.Point(0, 0); 57 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 58 | System.Windows.Forms.AnchorStyles.Left) 59 | System.Windows.Forms.AnchorStyles.Right))); 60 chartArea2.Name = "ChartArea"; 61 this.chart.ChartAreas.Add(chartArea2); 62 legend2.Alignment = System.Drawing.StringAlignment.Center; 63 legend2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 64 legend2.Name = "Default"; 65 this.chart.Legends.Add(legend2); 66 this.chart.Location = new System.Drawing.Point(0, 31); 62 67 this.chart.Name = "chart"; 63 this.chart.Size = new System.Drawing.Size(3 58, 225);68 this.chart.Size = new System.Drawing.Size(388, 194); 64 69 this.chart.TabIndex = 0; 65 70 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); … … 68 73 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 69 74 // 75 // targetVariableComboBox 76 // 77 this.targetVariableComboBox.FormattingEnabled = true; 78 this.targetVariableComboBox.Location = new System.Drawing.Point(91, 4); 79 this.targetVariableComboBox.Name = "targetVariableComboBox"; 80 this.targetVariableComboBox.Size = new System.Drawing.Size(173, 21); 81 this.targetVariableComboBox.TabIndex = 1; 82 this.targetVariableComboBox.SelectedIndexChanged += new System.EventHandler(this.targetVariableComboBox_SelectedIndexChanged); 83 // 84 // label 85 // 86 this.label.AutoSize = true; 87 this.label.Location = new System.Drawing.Point(4, 7); 88 this.label.Name = "label"; 89 this.label.Size = new System.Drawing.Size(81, 13); 90 this.label.TabIndex = 2; 91 this.label.Text = "Target variable:"; 92 // 93 // prognosedValuesCheckbox 94 // 95 this.prognosedValuesCheckbox.AutoSize = true; 96 this.prognosedValuesCheckbox.Checked = true; 97 this.prognosedValuesCheckbox.CheckState = System.Windows.Forms.CheckState.Checked; 98 this.prognosedValuesCheckbox.Location = new System.Drawing.Point(271, 7); 99 this.prognosedValuesCheckbox.Name = "prognosedValuesCheckbox"; 100 this.prognosedValuesCheckbox.Size = new System.Drawing.Size(112, 17); 101 this.prognosedValuesCheckbox.TabIndex = 3; 102 this.prognosedValuesCheckbox.Text = "Prognosed Values"; 103 this.prognosedValuesCheckbox.UseVisualStyleBackColor = true; 104 this.prognosedValuesCheckbox.CheckedChanged += new System.EventHandler(this.prognosedValuesCheckbox_CheckedChanged); 105 // 70 106 // TimeSeriesPrognosisSolutionLineChartView 71 107 // … … 73 109 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 74 110 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 111 this.Controls.Add(this.prognosedValuesCheckbox); 112 this.Controls.Add(this.label); 113 this.Controls.Add(this.targetVariableComboBox); 75 114 this.Controls.Add(this.chart); 76 115 this.Name = "TimeSeriesPrognosisSolutionLineChartView"; 77 this.Size = new System.Drawing.Size(3 58, 225);116 this.Size = new System.Drawing.Size(388, 225); 78 117 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 79 118 this.ResumeLayout(false); 119 this.PerformLayout(); 80 120 81 121 } … … 84 124 85 125 private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart; 126 private System.Windows.Forms.ComboBox targetVariableComboBox; 127 private System.Windows.Forms.Label label; 128 private System.Windows.Forms.CheckBox prognosedValuesCheckbox; 86 129 } 87 130 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.cs
r6802 r7129 36 36 private const string PROGNOSEDVALUES_TEST_SERIES_NAME = "Prognosed Values (test)"; 37 37 private const string PROGNOSEDVALUES_ALL_SERIES_NAME = "Prognosed Values (all samples)"; 38 private string prevTargetVariable; 38 39 39 40 public new ITimeSeriesPrognosisSolution Content { … … 57 58 } 58 59 60 private void UpdateTargetVariables() { 61 // populate combobox 62 targetVariableComboBox.Items.Clear(); 63 if (Content != null) { 64 foreach (var targetVariable in Content.ProblemData.TargetVariables) 65 targetVariableComboBox.Items.Add(targetVariable); 66 67 targetVariableComboBox.SelectedIndex = 0; 68 } 69 } 70 71 72 59 73 private void RedrawChart() { 60 74 this.chart.Series.Clear(); … … 62 76 this.chart.ChartAreas[0].AxisX.Minimum = 0; 63 77 this.chart.ChartAreas[0].AxisX.Maximum = Content.ProblemData.Dataset.Rows - 1; 78 string targetVariable = (string)targetVariableComboBox.SelectedItem; 79 int varIndex = Content.ProblemData.TargetVariables.ToList().IndexOf(targetVariable); 64 80 65 81 this.chart.Series.Add(TARGETVARIABLE_SERIES_NAME); 66 this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = Content.ProblemData.TargetVariable;82 this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = targetVariable; 67 83 this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine; 68 84 this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(), 69 Content.ProblemData.Dataset.GetDoubleValues( Content.ProblemData.TargetVariable).ToArray());85 Content.ProblemData.Dataset.GetDoubleValues(targetVariable).ToArray()); 70 86 71 87 this.chart.Series.Add(PROGNOSEDVALUES_TRAINING_SERIES_NAME); 72 88 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].LegendText = PROGNOSEDVALUES_TRAINING_SERIES_NAME; 73 89 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine; 74 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.PrognosedTrainingValues.ToArray()); 90 if (prognosedValuesCheckbox.Checked) { 91 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points 92 .DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), 93 Content.PrognosedTrainingValues.ElementAt(varIndex).ToArray()); 94 } else { 95 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points 96 .DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), 97 Content.GetPrognosedValues(Content.ProblemData.TrainingIndizes, 1).Select(v => v.ElementAt(varIndex).First()).ToArray()); 98 } 75 99 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Tag = Content; 76 100 this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, PROGNOSEDVALUES_TRAINING_SERIES_NAME); … … 82 106 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].LegendText = PROGNOSEDVALUES_TEST_SERIES_NAME; 83 107 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine; 84 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.PrognosedTestValues.ToArray()); 108 if (prognosedValuesCheckbox.Checked) { 109 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points 110 .DataBindXY(Content.ProblemData.TestIndizes.ToArray(), 111 Content.PrognosedTestValues.ElementAt(varIndex).ToArray()); 112 } else { 113 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points 114 .DataBindXY(Content.ProblemData.TestIndizes.ToArray(), 115 Content.GetPrognosedValues(Content.ProblemData.TestIndizes, 1).Select( 116 v => v.ElementAt(varIndex).First()).ToArray()); 117 } 85 118 this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Tag = Content; 86 87 88 int[] allIndizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();89 var estimatedValues = Content.PrognosedValues.ToArray();90 List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();91 92 this.chart.Series.Add(PROGNOSEDVALUES_ALL_SERIES_NAME);93 this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].LegendText = PROGNOSEDVALUES_ALL_SERIES_NAME;94 this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;95 this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);96 this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Tag = Content;97 this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, PROGNOSEDVALUES_ALL_SERIES_NAME);98 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0;99 this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None;100 this.ToggleSeriesData(this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME]);101 119 102 120 UpdateCursorInterval(); … … 130 148 protected override void OnContentChanged() { 131 149 base.OnContentChanged(); 150 UpdateTargetVariables(); 151 } 152 153 private void Content_ProblemDataChanged(object sender, EventArgs e) { 154 UpdateTargetVariables(); 155 } 156 private void Content_ModelChanged(object sender, EventArgs e) { 132 157 RedrawChart(); 133 158 } 134 private void Content_ProblemDataChanged(object sender, EventArgs e) { 159 160 private void targetVariableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 135 161 RedrawChart(); 136 162 } 137 private void Content_ModelChanged(object sender, EventArgs e) {163 private void prognosedValuesCheckbox_CheckedChanged(object sender, EventArgs e) { 138 164 RedrawChart(); 139 165 } … … 207 233 } 208 234 } else if (Content != null) { 209 string targetVariableName = Content.ProblemData.TargetVariable; 235 string targetVariable = (string)targetVariableComboBox.SelectedItem; 236 int varIndex = Content.ProblemData.TargetVariables.ToList().IndexOf(targetVariable); 237 210 238 211 239 IEnumerable<int> indizes = null; 212 240 IEnumerable<double> predictedValues = null; 213 241 switch (series.Name) { 214 case PROGNOSEDVALUES_ALL_SERIES_NAME:215 indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();216 var estimatedValues = Content.PrognosedValues.ToArray();217 predictedValues = indizes.Select(index => estimatedValues[index]).ToList();218 break;219 242 case PROGNOSEDVALUES_TRAINING_SERIES_NAME: 220 243 indizes = Content.ProblemData.TrainingIndizes.ToArray(); 221 predictedValues = Content.PrognosedTrainingValues. ToArray();244 predictedValues = Content.PrognosedTrainingValues.ElementAt(varIndex).ToArray(); 222 245 break; 223 246 case PROGNOSEDVALUES_TEST_SERIES_NAME: 224 247 indizes = Content.ProblemData.TestIndizes.ToArray(); 225 predictedValues = Content.PrognosedTestValues. ToArray();248 predictedValues = Content.PrognosedTestValues.ElementAt(varIndex).ToArray(); 226 249 break; 227 250 } … … 255 278 e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black; 256 279 } 280 257 281 } 258 282 }
Note: See TracChangeset
for help on using the changeset viewer.