public void update_regGraph(string str) { PlotModel pm = new PlotModel(); pm.Title = str; scatter_series = new ScatterSeries(); scatter_series.MarkerFill = OxyColor.FromAColor(100, OxyColors.CornflowerBlue); scatter_series.MarkerType = MarkerType.Circle; line_series_regGraph = new LineSeries(); line_series_regGraph.Color = OxyColors.BlueViolet; int j; if (timeIndex < 300) { j = 0; } else { j = timeIndex - 300; } Point[] points = new Point[300]; float Xmin = allDataCsv[index_g][j]; float Xmax = allDataCsv[index_g][j]; int k = 0; for (; j < timeIndex; j++) { scatter_series.Points.Add(new ScatterPoint(allDataCsv[index_g][j], allDataCsv[correlated_index][j], 2, 0)); points[k++] = new Point(allDataCsv[index_g][j], allDataCsv[correlated_index][j]); if (allDataCsv[index_g][j] < Xmin) { Xmin = allDataCsv[index_g][j]; } if (allDataCsv[index_g][j] > Xmax) { Xmax = allDataCsv[index_g][j]; } } Line reg_line = Pearson.linear_reg(points, k - 1); line_series_regGraph.Points.Add(new DataPoint(Xmin, reg_line.f(Xmin))); line_series_regGraph.Points.Add(new DataPoint(Xmax, reg_line.f(Xmax))); pm.Series.Add(line_series_regGraph); pm.Series.Add(scatter_series); this.RegGraph = pm; this.RegGraph.InvalidatePlot(true); }
// a graph has been chosen. public void chooseGraph(string str) { Dictionary <int, Tuple <float, float> > anomalys; Title_Orig = str; index_g = chunks.FindIndex(a => a == str); correlated_index = Pearson.bestCore(allDataCsv, index_g); update_graph(str); update_graph_two(chunks[correlated_index]); update_regGraph("Linear regression line"); valid = 1; if (dllDynamic != null) { anomalys = dllDynamic.Update(testDataCsv[index_g], testDataCsv[correlated_index], allDataCsv[index_g], allDataCsv[correlated_index]); toGraph(anomalys); } }