Simple patch to grapher



Hi guys,

Attached is a patch which does the following to graphs:

- Limits the length of the labels on the graph to 40ish characters.
- Escapes any remaining newlines.
- Escapes any remaining double quotes.

The first one gets rid of potentially huge nodes (ie, htmlblock).
The other two fix errors that causes dot to have minors fits over.

I also have a problem that dot doesn't seem to finish running.  Does
Graph work correctly for other people?

Also, I generate SVG files, you can zoom and they still look good!

If people are cool with this patch then I'll apply it.

Cheers!

-- 
Andrew Ruthven
Senior Systems Engineer, Actrix Networks Ltd   -->   www.actrix.gen.nz
At Actrix puck actrix gen nz
At Home:  andrew etc gen nz

Index: engine/Grapher.cs
===================================================================
RCS file: /cvs/gnome/dashboard/engine/Grapher.cs,v
retrieving revision 1.8
diff -u -w -r1.8 Grapher.cs
--- engine/Grapher.cs	17 Feb 2004 03:06:07 -0000	1.8
+++ engine/Grapher.cs	2 May 2004 06:59:03 -0000
@@ -239,11 +239,27 @@
 
 		private string GraphClueNode (Clue c)
 		{
+			String text = c.Text;
+
+			// We don't want really long labels.  They look ugly.
+			if (text.Length > 40) {
+				 text = text.Substring (0, 40) + "...";
+			}
+
+			// dot doesn't like labels with line breaks in them.
+			text = text.Replace("\n", "\\n");
+
+			// Need the double step to make sure we don't escape a pre-existing
+			// escape.
+			text = text.Replace("\\\"", "\"");
+			text = text.Replace("\"", "\\\""); 
+
+
 			return String.Format
 				("    c{0} [ label=\"Clue: Type: {1} Text: {2}\" color=\"dodgerblue\" style=\"filled\" ];\n",
 				 Math.Abs (c.GetHashCode ()),
 				 c.Type,
-				 c.Text);
+				 text);
 		}
 
 		private string GraphCluePacketClueArc (CluePacket cp, Clue c)


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