[chronojump] Added graph for runSimple



commit 0c7c6618f65f5e38c3177e031237cc84c1f1f99d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 21 14:57:15 2011 +0100

    Added graph for runSimple

 po/POTFILES.in                |    1 +
 src/Makefile.am               |    1 +
 src/statType.cs               |   16 ++---
 src/stats/graphs/runSimple.cs |  155 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+), 11 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 43c2ffb..7614d64 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -62,6 +62,7 @@ src/stats/graphs/rjAVGSD.cs
 src/stats/graphs/rjEvolution.cs
 src/stats/graphs/rjIndex.cs
 src/stats/graphs/rjPotencyBosco.cs
+src/stats/graphs/runSimple.cs
 src/stats/graphs/sjCmjAbk.cs
 src/stats/graphs/sjCmjAbkPlus.cs
 src/stats/ieIub.cs
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f77dba..fb1f1f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -130,6 +130,7 @@ FILES = \
  	stats/graphs/fv.cs\
  	stats/graphs/potency.cs\
 	stats/graphs/rjAVGSD.cs\
+ 	stats/graphs/runSimple.cs\
 	sqlite/main.cs\
  	sqlite/preferences.cs\
  	sqlite/session.cs\
diff --git a/src/statType.cs b/src/statType.cs
index b7dffea..4bb69cc 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -375,17 +375,11 @@ public class StatType {
 				return false;
 			}
 		
-			//only no indexes now	
-			//if(statisticSubType == Catalog.GetString("No indexes")) 
-			//{
-				//RunType myType = new RunType(statisticApplyTo);
-				if(graph) {
-					//myStat = new GraphRunSimple (myStatTypeStruct);
-					myStat = new StatRunSimple (myStatTypeStruct, treeview_stats);
-				} else {
-					myStat = new StatRunSimple (myStatTypeStruct, treeview_stats);
-				}
-			//}
+			if(graph) {
+				myStat = new GraphRunSimple (myStatTypeStruct);
+			} else {
+				myStat = new StatRunSimple (myStatTypeStruct, treeview_stats);
+			}
 		}
 		
 		myStat.FakeButtonRowCheckedUnchecked.Clicked += 
diff --git a/src/stats/graphs/runSimple.cs b/src/stats/graphs/runSimple.cs
new file mode 100644
index 0000000..cf23aa2
--- /dev/null
+++ b/src/stats/graphs/runSimple.cs
@@ -0,0 +1,155 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2009   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.Data;
+using Gtk;
+using System.Collections; //ArrayList
+using System.Drawing;
+using System.Drawing.Imaging;
+using Mono.Unix;
+
+
+public class GraphRunSimple : StatRunSimple
+{
+	protected string operation;
+
+	//for simplesession
+	GraphSerie serieSpeed;
+	GraphSerie serieDistance;
+	GraphSerie serieTime;
+	
+	public GraphRunSimple (StatTypeStruct myStatTypeStruct)
+	{
+		completeConstruction (myStatTypeStruct, treeview);
+		
+		this.dataColumns = 3; //for Simplesession
+		
+		if (statsJumpsType == 2) {
+			this.operation = "MAX";
+		} else {
+			this.operation = "AVG";
+		}
+
+		CurrentGraphData.WindowTitle = Catalog.GetString("ChronoJump graph");
+		//title is shown on the graph except it's a report, then title will be on the html
+		if(myStatTypeStruct.ToReport) {
+			CurrentGraphData.GraphTitle = "";
+		} else {
+			CurrentGraphData.GraphTitle = "Simple runs";
+		}
+		
+		if(sessions.Count == 1) {
+			//four series, the four columns
+			serieSpeed = new GraphSerie();
+			serieDistance = new GraphSerie();
+			serieTime = new GraphSerie();
+				
+			serieSpeed.Title = Catalog.GetString("Speed");
+			serieDistance.Title = Catalog.GetString("Distance");
+			serieTime.Title = Catalog.GetString("Time");;
+			
+			serieSpeed.IsLeftAxis = true;
+			serieDistance.IsLeftAxis = false;
+			serieTime.IsLeftAxis = false;
+
+			CurrentGraphData.LabelLeft = Catalog.GetString("Speed") + "(m/s)";
+			CurrentGraphData.LabelRight = 
+				Catalog.GetString("Distance") + "(m), " +
+				Catalog.GetString("Time") + "(s)";
+		} else {
+			for(int i=0; i < sessions.Count ; i++) {
+				string [] stringFullResults = sessions[i].ToString().Split(new char[] {':'});
+				CurrentGraphData.XAxisNames.Add(stringFullResults[1].ToString());
+			}
+			CurrentGraphData.LabelLeft = Catalog.GetString("Speed") + "(s)";
+			CurrentGraphData.LabelRight = "";
+		}
+	}
+
+	protected override void printData (string [] statValues) 
+	{
+		//values are recorded for calculating later AVG and SD
+		recordStatValues(statValues);
+
+		if(sessions.Count == 1) {
+			int i=0;
+			bool foundAVG = false;
+			//we need to save this transposed
+			foreach (string myValue in statValues) {
+				if(i == 0) {
+					//don't plot AVG and SD rows
+					if( myValue == Catalog.GetString("AVG")) 
+						foundAVG = true;
+					else
+						CurrentGraphData.XAxisNames.Add(myValue);
+				} else if(i == 1) {
+					if(foundAVG)
+						serieSpeed.Avg = Convert.ToDouble(myValue);
+					else
+						serieSpeed.SerieData.Add(myValue);
+				} else if(i == 2) {
+					if(foundAVG)
+						serieDistance.Avg = Convert.ToDouble(myValue);
+					else
+						serieDistance.SerieData.Add(myValue);
+				} else if(i == 3) {
+					if(foundAVG)
+						serieTime.Avg = Convert.ToDouble(myValue);
+					else
+						serieTime.SerieData.Add(myValue);
+				} 
+
+				if(foundAVG && i == dataColumns) {
+					//add created series to GraphSeries ArrayList
+					//check don't do it two times
+					if(GraphSeries.Count == 0) {
+						GraphSeries.Add(serieSpeed);
+						GraphSeries.Add(serieDistance);
+						GraphSeries.Add(serieTime);
+					}
+					return;
+				}
+
+				i++;
+			}
+		} else {
+			GraphSerie mySerie = new GraphSerie();
+			mySerie.IsLeftAxis = true;
+
+			int i=0;
+			foreach (string myValue in statValues) {
+				if( myValue == Catalog.GetString("SD") ) 
+					return;
+				
+				if(i == 0) 
+					mySerie.Title = myValue;
+				else if( i == sessions.Count + 1 ) { //eg, for 2 sessions: [(0)person name, (1)sess1, (2)sess2, (3)AVG]
+					if(myValue != "-")
+						mySerie.Avg = Convert.ToDouble(myValue);
+				} else 
+					mySerie.SerieData.Add(myValue);
+				
+				i++;
+			}
+			GraphSeries.Add(mySerie);
+		}
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]