[chronojump] jumpsRjFatigue divide in two and shows avgs
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] jumpsRjFatigue divide in two and shows avgs
- Date: Mon, 17 Aug 2020 10:50:42 +0000 (UTC)
commit 0d743a0930c0c1db4bd68e2fe1dfe4db3dccb343
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Aug 17 12:50:04 2020 +0200
jumpsRjFatigue divide in two and shows avgs
src/gui/cairo/jumpsRjFatigue.cs | 52 +++++++++++++++++++++++++++++++++++++++++
src/gui/cairo/xy.cs | 2 +-
2 files changed, 53 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/cairo/jumpsRjFatigue.cs b/src/gui/cairo/jumpsRjFatigue.cs
index f3034814..9896b775 100644
--- a/src/gui/cairo/jumpsRjFatigue.cs
+++ b/src/gui/cairo/jumpsRjFatigue.cs
@@ -75,7 +75,12 @@ public class JumpsRjFatigueGraph : CairoXY
paintGrid(gridTypes.VERTICALLINES, false);
paintAxis();
+ g.Color = red;
plotPredictedLine(predictedLineTypes.STRAIGHT, predictedLineCrossMargins.TOUCH);
+ g.Color = black;
+
+ divideInTwoAndPlotAverage();
+
plotRealPoints(true);
writeTitle();
@@ -102,4 +107,51 @@ public class JumpsRjFatigueGraph : CairoXY
writeTextAtRight(ypos++, date, false);
}
+ private void divideInTwoAndPlotAverage()
+ {
+ List<PointF> point_l_start = new List<PointF>();
+ List<PointF> point_l_end = new List<PointF>();
+ double sumIni = 0;
+ double sumEnd = 0;
+
+ int i = 0;
+ foreach(PointF point in point_l)
+ {
+ if(i < Math.Floor(point_l.Count / 2.0))
+ {
+ point_l_start.Add(point);
+ sumIni += point.Y;
+ //LogB.Information(string.Format("Added to point_l_start: {0}", point));
+ }
+ if(point_l.Count - i -1 < Math.Floor(point_l.Count / 2.0))
+ {
+ point_l_end.Add(point);
+ sumEnd += point.Y;
+ //LogB.Information(string.Format("Added to point_l_end: {0}", point));
+ }
+
+ i ++;
+ }
+
+ double avgIni = sumIni / point_l_start.Count;
+ double avgEnd = sumEnd / point_l_end.Count;
+
+ g.MoveTo(calculatePaintX(point_l_start[0].X), calculatePaintY(avgIni));
+ g.LineTo(calculatePaintX(point_l_start[point_l_start.Count -1].X), calculatePaintY(avgIni));
+ printText(
+ //Convert.ToInt32(calculatePaintX(point_l_start[0].X)) -2,
+ graphWidth - outerMargins,
+ Convert.ToInt32(calculatePaintY(avgIni)),
+ 0, textHeight, Util.TrimDecimals(avgIni, 2), g, alignTypes.CENTER);
+
+ g.MoveTo(calculatePaintX(point_l_end[0].X), calculatePaintY(avgEnd));
+ g.LineTo(calculatePaintX(point_l_end[point_l_end.Count -1].X), calculatePaintY(avgEnd));
+ printText(
+ //Convert.ToInt32(calculatePaintX(point_l_end[point_l_end.Count -1].X)) +2,
+ graphWidth - outerMargins,
+ Convert.ToInt32(calculatePaintY(avgEnd)),
+ 0, textHeight, Util.TrimDecimals(avgEnd, 2), g, alignTypes.CENTER);
+
+ g.Stroke ();
+ }
}
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 9039ea60..9909c90a 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -69,7 +69,7 @@ public abstract class CairoXY
protected int graphWidth;
protected int graphHeight;
- Cairo.Color black;
+ protected Cairo.Color black;
Cairo.Color white;
protected Cairo.Color red;
Cairo.Color blue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]