[chronojump] started conversion to R ("bye bye nplot part 1")
- From: Xavier de Blas <xaviblas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [chronojump] started conversion to R ("bye bye nplot part 1")
- Date: Fri, 28 Aug 2009 13:33:04 +0000 (UTC)
commit 2cfc949cda55228ed5165e13779f4145afe32e4d
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Aug 28 15:30:41 2009 +0200
started conversion to R ("bye bye nplot part 1")
now it only graphs a custom graph (always the same), and report graphs are still not activated
TODO.txt | 2 +
chronojump_server/bin/chronojumpServer.dll | Bin 271872 -> 272384 bytes
src/constants.cs | 3 ++
src/gui/dialogImageTest.cs | 2 +-
src/statType.cs | 7 ++--
src/stats/main.cs | 55 ++++++++++++++++++++++++++++
6 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/TODO.txt b/TODO.txt
index 5897c37..d757a82 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,7 @@
TODO:
+bug: when crash it shows to update to a version that is not last
+
check all software (for the Util.TrimDecimals change)
create accept license on uploading
add accept license on uploading, and a way to retreive it from server
diff --git a/chronojump_server/bin/chronojumpServer.dll b/chronojump_server/bin/chronojumpServer.dll
index cc4831d..26a9aba 100755
Binary files a/chronojump_server/bin/chronojumpServer.dll and b/chronojump_server/bin/chronojumpServer.dll differ
diff --git a/src/constants.cs b/src/constants.cs
index 3559b7b..ce3fd1a 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -233,6 +233,9 @@ public class Constants
public static string FileNameIcon = "chronojump_icon.png";
public static string FileNameIconGraph = "chronojump_icon_graph.png";
public static string FileNameVersion = "version.txt";
+
+ public static string FileNameRGraph = "r-graph.png";
+ public static string FileNameRScript = "r-graph.txt";
public static string FileNameZoomFitIcon = "gtk-zoom-fit.png";
//public static string FileNameZoomOutIcon = "gtk-zoom-out.png";
diff --git a/src/gui/dialogImageTest.cs b/src/gui/dialogImageTest.cs
index 2f01eab..2181d4a 100644
--- a/src/gui/dialogImageTest.cs
+++ b/src/gui/dialogImageTest.cs
@@ -69,7 +69,7 @@ public class DialogImageTest
scrolledwindow28.Hide();
- Pixbuf pixbuf = new Pixbuf (null, imagePath);
+ Pixbuf pixbuf = new Pixbuf (imagePath);
image_test.Pixbuf = pixbuf;
}
diff --git a/src/statType.cs b/src/statType.cs
index 5c64f4a..cecd98d 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -393,14 +393,15 @@ public class StatType {
if(toReport) {
if(graph) {
- bool notEmpty = myStat.CreateGraph(fileName);
- if(notEmpty) { linkImage(fileName); }
+ //bool notEmpty = myStat.CreateGraphR(fileName, false); //dont' show
+ //if(notEmpty) { linkImage(fileName); }
} else {
writer.WriteLine(myStat.ReportString());
}
} else {
if(graph) {
- myStat.CreateGraph();
+ //myStat.CreateGraph();
+ myStat.CreateGraphR(Constants.FileNameRGraph, true); //show
}
}
diff --git a/src/stats/main.cs b/src/stats/main.cs
index ba485a0..b69d94e 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -28,6 +28,7 @@ using NPlot;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO; //TextWriter
+using System.Diagnostics; //Processing
using Mono.Unix;
/* ------------ CLASS HERENCY MAP ---------
@@ -877,6 +878,8 @@ public class Stat
return myGrid;
}
+ /*
+ //nplot will be converted to R
public void CreateGraph ()
{
//only graph if there's data
@@ -920,6 +923,7 @@ public class Stat
w.ShowAll ();
}
+ //nplot will be converted to R
public bool CreateGraph (string fileName)
{
//only graph if there's data
@@ -964,6 +968,57 @@ public class Stat
return true;
}
+ */
+
+ //currently only creates one customized graph
+ public bool CreateGraphR (string fileName, bool show)
+ {
+ //only graph if there's data
+ //TODO: check also later if none row is selected
+ if(CurrentGraphData.XAxisNames.Count == 0) {
+ return false;
+ }
+ if (!show) { //report
+ /*
+ string directoryName = Util.GetReportDirectoryName(ileName);
+ string [] pngs = Directory.GetFiles(directoryName, "*.png");
+
+ //if found 3 images, sure will be 1.png, 2.png and 3.png, next will be 4.png
+ //there will be always a png with chronojump_logo
+ fileName = directoryName + "/" + pngs.Length.ToString() + ".png";
+ */
+ }
+
+ fileName = System.IO.Path.Combine(Path.GetTempPath(), fileName);
+
+ string rGraphString =
+ "png(filename = '" + fileName + "', width = 670, height = 400, units = 'px',\n" +
+ " pointsize = 12, bg = 'white', res = NA)\n"+
+ "library(RSQLite)\n" +
+ "drv = dbDriver('SQLite')\n" +
+ "file = '/home/xavier/.local/share/Chronojump/database/chronojump.db'\n" +
+ "con = dbConnect(drv, file)\n" +
+ //"jumps <- dbGetQuery(con, \"select jump.*, person.sex as personsex from jump, person where type='Free' AND simulated >= 0 and jump.personID=person.UniqueID AND sessionID=14\")\n" +
+ "jumps <- dbGetQuery(con, \"select jump.*, person.sex as personsex from jump, person where jump.personID=person.UniqueID\")\n" +
+ "stripchart(jumps$tv ~ jumps$personsex, method='jitter', pch=3, jitter=.2, group.names=c('Females','Males'), xlab='Flight time')\n" +
+ "title(main='Free jump heights in sport science students and sex', sub='15 Aug 2009', cex.sub=0.75, font.sub=3, col.sub='red')\n" +
+ "dev.off()";
+
+ string rScript = System.IO.Path.Combine(Path.GetTempPath(), Constants.FileNameRScript);
+ TextWriter writer = File.CreateText(rScript);
+ writer.Write(rGraphString);
+ writer.Flush();
+ ((IDisposable)writer).Dispose();
+
+ Process r = Process.Start("R CMD BATCH " + rScript);
+ r.WaitForExit();
+
+ if(show)
+ new DialogImageTest("prueba de graph con R", fileName);
+
+ return true;
+ }
+
private int getSizeX() {
int x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]