[rkward-cvs] SF.net SVN: rkward: [1967] trunk/rkward/rkward/plugins/plots

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 17 22:49:00 UTC 2007


Revision: 1967
          http://rkward.svn.sourceforge.net/rkward/?rev=1967&view=rev
Author:   tfry
Date:     2007-09-17 15:49:00 -0700 (Mon, 17 Sep 2007)

Log Message:
-----------
More flexible labeling for piechart plugin

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/plots/piechart.php
    trunk/rkward/rkward/plugins/plots/piechart.rkh
    trunk/rkward/rkward/plugins/plots/piechart.xml

Modified: trunk/rkward/rkward/plugins/plots/piechart.php
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.php	2007-09-17 19:02:54 UTC (rev 1966)
+++ trunk/rkward/rkward/plugins/plots/piechart.php	2007-09-17 22:49:00 UTC (rev 1967)
@@ -17,13 +17,13 @@
 
 function doPrintout ($final) {
 	$vars = getRK_val ("x");
-	$names = getRK_val ("names");
 	$tabulate= getRK_val ("tabulate")=="TRUE";
 	$radius = getRK_val ("radius");
 	$angle = getRK_val ("angle");
 	$density = getRK_val ("density");
 	$col = getRK_val ("colors");
 	$clockwise = getRK_val ("clockwise");
+	$names_mode = getRK_val ("names_mode");
 
 	$options = "";
 	$options .= ", clockwise =" . $clockwise;
@@ -54,8 +54,13 @@
 <?	}
 ?>
 try ({
-<?	if (!empty ($plotpre)) printIndented ("\t", $plotpre); ?>
-	names (x) <- <? echo ($names); ?>;
+<?	if (!empty ($plotpre)) printIndented ("\t", $plotpre);
+	if ($names_mode == "rexp") {
+		echo ("\tnames(x) <- " . getRK_val ("names_exp") . "\n");
+	} else if ($names_mode == "custom") {
+		echo ("\tnames(x) <- c (\"" . str_replace (";", "\", \"", trim (getRK_val ("names_custom"))) . "\")\n");
+	}
+?>
 	pie(x<? echo ($options); ?>)
 <?	if (!empty ($plotpost)) printIndented ("\t", $plotpost); ?>
 })

Modified: trunk/rkward/rkward/plugins/plots/piechart.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.rkh	2007-09-17 19:02:54 UTC (rev 1966)
+++ trunk/rkward/rkward/plugins/plots/piechart.rkh	2007-09-17 22:49:00 UTC (rev 1967)
@@ -11,11 +11,10 @@
 	<settings>
 		<caption id="tab_variables"/>
 		<setting id="x">Matrix, vector or a factor. Data needs to be numeric unless the tabulate option is checked, below.</setting>
-		<setting id="names">Defines the names for the data. You can use the data set as input or enter names (must be type "string" in this case).
-	</setting>
 		<setting id="tabulate">Use tabulate option mainly for factor variables or wherever else applicable.</setting>
 		<caption id="tab_options"/>
 		<setting id="colors">Type of colors to use.</setting>
+		<setting id="names_mode">Method for assigning labels to the plot. "default" means, the labels are chosen automatically. If no labels are available, this will generally print the values. The other options allow you to specify the labels as literal string, or as an R statement (e.g. if the names are stored in a different variable in the workspace).</setting>
 		<setting id="radius">Radius of the pie. For long labels it may be necessary to make the pie smaller than the default.</setting>
 		<setting id="angle">Slope of shading lines, given as an angle in degrees (counter-clockwise).</setting>
 		<setting id="density">Density of shading lines (lines per inch). The default value of NULL means no shading lines are drawn. Negative values also inhibit the drawing of shading lines.</setting>

Modified: trunk/rkward/rkward/plugins/plots/piechart.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.xml	2007-09-17 19:02:54 UTC (rev 1966)
+++ trunk/rkward/rkward/plugins/plots/piechart.xml	2007-09-17 22:49:00 UTC (rev 1967)
@@ -7,6 +7,13 @@
 		<set id="plotoptions.allow_xlim" to="false"/>
 		<set id="plotoptions.allow_type" to="false"/>
 		<set id="plotoptions.allow_log" to="false"/>
+
+		<convert id="custom_names" mode="equals" sources="names_mode.string" standard="custom"/>
+		<convert id="rexp_names" mode="equals" sources="names_mode.string" standard="rexp"/>
+		<connect client="names_custom.visible" governor="rexp_names.not"/>
+		<connect client="names_custom.enabled" governor="custom_names"/>
+		<connect client="names_exp.visible" governor="rexp_names"/>
+		<connect client="names_exp.required" governor="rexp_names"/>
 	</logic>
 	<dialog label="Pie chart" >
 		<tabbook>
@@ -16,21 +23,32 @@
 					<column>
 					<varslot min_vars="1" id="x" source="vars" required="true" label="Variable"/>
 					<checkbox id="tabulate" label="Tabulate" value="TRUE" value_unchecked="FALSE" checked="false" />
-					<varslot min_vars="1" id="names" source="vars" required="true" label="Names"/>
 					<stretch/>
 					<preview id="preview"/>
 					</column>
 				</row>
 			</tab>
 			<tab label="Options" id="tab_options">
-				<radio id="colors" label="Colors" >
-					<option value="default" label="Default (pastel)"/>
-					<option value="grayscale" label="Grayscale"/>
-					<option value="rainbow" label="Rainbow colors" checked="true"/>
-				</radio>
+				<row>
+					<radio id="colors" label="Colors" >
+						<option value="default" label="Default (pastel)"/>
+						<option value="grayscale" label="Grayscale"/>
+						<option value="rainbow" label="Rainbow colors" checked="true"/>
+					</radio>
+					<column label="Labels">
+						<radio id="names_mode" label="Labeling" >
+							<option value="default" label="Default labels" checked="true"/>
+							<option value="custom" label="Custom labels"/>
+							<option value="rexp" label="From R expression"/>
+						</radio>
+						<input id="names_exp" label="Expression to use for labels" initial="names (x)"/>
+						<input id="names_custom" label="Labels (separated by ';')" initial="First label;Second label"/>
+					</column>
+				</row>
 				<checkbox id="clockwise" label="clockwise" value="TRUE" value_unchecked="FALSE" checked="false" />
 				<spinbox id="radius" type="real" min="0.01" max="1" initial="0.8" label="Radius"/>
-				<spinbox id="density" type="real" initial="NULL" label="density"/>
+<!-- TODO: density and angle are a bit pointless, when given as a single option. Rather those should allow to enter/specify a vector! -->
+				<spinbox id="density" type="real" min="-1" max="10000" initial="-1" label="density" default_precision="0"/>
 				<spinbox id="angle" type="real" min="0" initial="45" max="360" label="angle"/>
 				<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options"/>
 			</tab>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list