what i want to do: I have multiple files with different CreationDates. The X-Axis = Dates and the Y-Axis = Values from 0-100. I want to create a Line Chart displaying all the Values of each Day marked with an X -> e.g. (10.07.2017 = 50 and 60 -> displaying an X at 50 and one at 60 both at the 10.07.2017)
This is done already the code is this one:
for (int i=0; i< orderedList.Count(); i++)//iterating through Files
{
int max_col = 0, max_rows = 0;
double[][] temp = FileManager.ReadCSV(orderedList[i].FullName.ToString(),ref max_rows, ref max_col); //reading the file to a double[][]
chartGraphic.Series[0].Points.AddXY(orderedList[i].CreationTime.Date, 100-Statistics.Prozent_NIO(temp, 1)); //adding the point to the Chart -> Prozent_NIO returns the y-value
}
I am using a Chart with Series[0] ChartType = points
Now i want to mark points in Series1 for each existing X-Value(date). The Y-Value should be the average of all existing Y-Values of series[0] of this specific date. The Series1 ChartType = Line
Example:
Series[0] Points are:
X-Value = 10.07.2017 Y-Values = 10;20;30
X-Value = 11.07.2017 Y-Values = 50;60;
So Series1 Points SHOULD BE:
X-Value = 10.07.2017 Y-Value = 20 (average of 10,20,30)
X-Value = 11.07.2017 Y-Value = 55 (average of 50,60)
While Series[0] only displays the Marked Points (no connection between ech) and Series1 will draw a line between eacht point.
I researched already but couldnt find a specific answer for this...
What i tried:
double temp_average=0;
double temp_number=0;
for (int i=0; i< orderedList.Count(); i++)// (FileInfo file in orderedList)
{
int max_col = 0, max_rows = 0;
double[][] temp = FileManager.ReadCSV(orderedList[i].FullName.ToString(),ref max_rows, ref max_col); chartGraphic.Series[0].Points.AddXY(orderedList[i].CreationTime.Date, 100-Statistics.Prozent_NIO(temp, 1));
if (i != 0)
{
if (orderedList[i].CreationTime.Date == orderedList[i - 1].CreationTime.Date) //times are similar -> add value to temp_averge and count number up
{
temp_average += Convert.ToDouble(chartGraphic.Series[0].Points[i - 1].YValues);
temp_number++;
}
else //Times different -> add last y value then calculate average and reset the variables
{
temp_average += Convert.ToDouble(chartGraphic.Series[0].Points[i - 1].YValues); //add last point
temp_number++;
chartGraphic.Series[1].Points.AddXY(orderedList[i - 1].CreationTime.Date, temp_average / temp_number); // add point in series 1
temp_average = 0;
temp_number = 0;*/
}
}
}
But this does not work it says i cant convert double[] to double =/
Edit: I tried to use a FinancialFormula too, but this one does not really go through the average, it just predicts the further trend i used:
chartGraphic.Series.Add("TrendLine");
chartGraphic.Series["TrendLine"].ChartType = Graph.SeriesChartType.Line;
chartGraphic.Series["TrendLine"].Color = Color.Red;
chartGraphic.DataManipulator.IsStartFromFirst = true;
chartGraphic.DataManipulator.FinancialFormula(FinancialFormula.Forecasting, "Linear, 1, false, false", chartGraphic.Series[0], chartGraphic.Series["TrendLine"]);
Here is an example of the current Chart. Now what i want to do is a Line displaying the Average of each X-Value (date) the red line (trend) was my attempt but this just does forecast the next values which is nice to have too but not what i wanted. I need to draw a line Through the Average of thepoints -> the start of the red line should be higher conidering there are 2 points on 100 and 2 on 90 it should be at 95 not ~92 where it is