[rkward-cvs] SF.net SVN: rkward:[3779] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Sep 15 08:11:27 UTC 2011


Revision: 3779
          http://rkward.svn.sourceforge.net/rkward/?rev=3779&view=rev
Author:   tfry
Date:     2011-09-15 08:11:26 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
Embed tabulation and limitation in pie chart plugin, too.

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

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-09-14 17:23:25 UTC (rev 3778)
+++ trunk/rkward/ChangeLog	2011-09-15 08:11:26 UTC (rev 3779)
@@ -14,7 +14,7 @@
 - Fixed: Potential crash when using context menus with "focus follows mouse" window activation policy
 - Added shortcut Ctrl+Enter to insert a line break and submit from a script editor
 - Reduce CPU usage while idle
-- Barplot, dotchart, and Pareto-plot plugins gain more tabulation options				TODO: also use in piechart
+- Barplot, dot chart, pie chart, and Pareto plot plugins gain more tabulation options				TODO: add and update tests
 - rk.results() now prints rownames, where appropriate
 - "frame" elements in plugins can now be made checkable
 - Disabling or hiding a plugin component makes it non-required, implicitly

Modified: trunk/rkward/rkward/plugins/plots/piechart.js
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.js	2011-09-14 17:23:25 UTC (rev 3778)
+++ trunk/rkward/rkward/plugins/plots/piechart.js	2011-09-15 08:11:26 UTC (rev 3779)
@@ -8,13 +8,15 @@
 
 function doPrintout (full) {
 	var vars = getValue ("x");
-	var tabulate = getValue ("tabulate");
-	var tabulate_header = "";
-	if (tabulate) {
-		tabulate_header = '"Tabulate", "Yes"';
-	} else {
-		tabulate_header = '"Tabulate", "No"';
-	}
+
+	var tabulate = getValue ("tabulate.checked");
+	var main_header = '"Variable", rk.get.description (' + vars + ')';
+	if (tabulate) main_header = getValue ('tabulate_options.parameters');
+
+	var limit = getValue ("limit.checked");
+	var limit_header = "";
+	if (limit) limit_header = ", " + getValue ('limit_options.parameters');
+
 	var radius = getValue ("radius");
 	var angle = getValue ("angle");
 	var angle_inc = getValue ("angle_inc");
@@ -24,9 +26,9 @@
 	var clockwise = getValue ("clockwise");
 	var clockwise_header = "";
 	if (clockwise) {
-		clockwise_header = '"Clockwise", "Yes"';
+		clockwise_header = ', "Orientation"="Clockwise"';
 	} else {
-		clockwise_header = '"Clockwise", "No"';
+		clockwise_header = ', "Orientation"="Counter clockwise"';
 	}
 	var names_mode = getValue ("names_mode");
 
@@ -46,17 +48,22 @@
 	var plotpost = getValue ("plotoptions.code.calculate");
 
 	if (tabulate) {
-		echo ('x <- table (' + vars + ', exclude=NULL)\n');
+		echo (getValue ('tabulate_options.code.calculate'));
 	} else {
-		echo ('x <- ' + vars);
-		echo ('\n');
+		echo ('x <- ' + getValue ("x") + '\n');
+		echo ('title <- rk.get.description (' + getValue ("x") + ')\n');
 		echo ('if (!is.numeric (x)) {\n');
-		echo ('	warning ("Data may not be numeric, but proceeding as requested.\\nDid you forget to check the tabulate option?")\n');
+		echo ('	warning ("Data is not numeric, but proceeding as requested.\\nDid you forget to check the tabulate option?")\n');
 		echo ('}\n');
 	}
+
+	if (getValue ("limit.checked")) {
+		echo (getValue ('limit_options.code.calculate'));
+	}
 	echo ('\n');
+
 	if (full) {
-		echo ('rk.header ("Pie chart", parameters=list ("Variable", rk.get.description (' + vars + '), ' + tabulate_header + ', ' + clockwise_header + '))\n');
+		echo ('rk.header ("Pie chart", parameters=list (' + main_header + limit_header + clockwise_header + '))\n');
 		echo ('\n');
 		echo ('rk.graph.on ()\n');
 	}

Modified: trunk/rkward/rkward/plugins/plots/piechart.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.rkh	2011-09-14 17:23:25 UTC (rev 3778)
+++ trunk/rkward/rkward/plugins/plots/piechart.rkh	2011-09-15 08:11:26 UTC (rev 3779)
@@ -5,13 +5,20 @@
 	</summary>
 
 	<usage>
-Choose a matrix, vector or a factor to be plotted. Further options are available on the second tab.
+Draws a pie chart from numerical data, or from tabulated data. Further options are available on the second tab.
 	</usage>
 
 	<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="tabulate">Use tabulate option mainly for factor variables or wherever else applicable.</setting>
+		<setting id="tabulate">If your data needs to be tabulated / aggregated before plotting, check this option. Refer to <link href="rkward://component/one_var_tabulation"/> for details on the dependent options.</setting>
+		<setting id="x">If your data is already suitable for plotting, directly, specify it here. Otherwise, leave this empty, and check the "Tabulate" option, above.</setting>
+
+		<caption id="tab_limit_options"/>
+		<setting id="limit">If there are very many categories in your data, it may make sense to limit the amount of categories that will be displayed. Check this, if you want to set a limit. See Refer to <link href="rkward://component/limit_vector_length"/> for details on the dependent options.</setting>
+
+		<caption id="tab_labels"/>
+		<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>
+
 		<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>
@@ -28,7 +35,7 @@
 			<li><link href="rkward://component/barplot"/></li>
 			<li><link href="rkward://component/plot_options"/></li>
 			<li><link href="rkward://rhelp/pie"/></li>
-			<li><link href="rkward://rhelp/table"/></li>
+			<li><link href="rkward://component/one_var_tabulation"/></li>
 		</ul>
 	</related>
 </document>

Modified: trunk/rkward/rkward/plugins/plots/piechart.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/piechart.xml	2011-09-14 17:23:25 UTC (rev 3778)
+++ trunk/rkward/rkward/plugins/plots/piechart.xml	2011-09-15 08:11:26 UTC (rev 3779)
@@ -7,17 +7,34 @@
 		<set id="plotoptions.allow_xlim" to="false"/>
 		<set id="plotoptions.allow_type" to="false"/>
 		<set id="plotoptions.allow_log" to="false"/>
-		
+
+		<connect client="x.enabled" governor="tabulate.checked.not"/>
+		<connect client="tabulate_options.varsource.selected" governor="vars.selected" />
+
 		<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"/>
 		
 		<convert id="density_0" mode="range" sources="density.real;density_inc.real" max="0"/>
 		<connect client="angle.enabled" governor="density_0.not"/>
 		<connect client="angle_inc.enabled" governor="density_0.not"/>
+
+		<script><![CDATA[
+			gui.addChangeCommand ("tabulate.checked", "updateFunLabel ()");
+			gui.addChangeCommand ("tabulate_options.fun_label", "updateFunLabel ()");
+			updateFunLabel = function () {
+				if (gui.getValue ("tabulate.checked")) {
+					gui.setValue ("plotoptions.default_main", "title");
+					gui.setValue ("plotoptions.default_sub", gui.getValue ("tabulate_options.fun_label"));
+				} else {
+					gui.setValue ("plotoptions.default_main", "");
+					gui.setValue ("plotoptions.default_sub", "");
+				}
+			}
+			updateFunLabel ();
+		]]></script>
 	</logic>
 	<dialog label="Pie chart" >
 		<tabbook>
@@ -25,22 +42,31 @@
 				<row>
 					<varselector id="vars"/>
 					<column>
+						<frame id="tabulate" label="Tabulate data before plotting" checkable="true" checked="false">
+							<embed id="tabulate_options" component="rkward::one_var_tabulation" as_button="false" label="Tabulation Options"/>
+						</frame>
 						<varslot min_vars="1" id="x" source="vars" required="true" label="Variable"/>
-						<checkbox id="tabulate" label="Tabulate" value="1" value_unchecked="0" checked="false" />
-						<frame 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"/>
-						</frame>
 						<stretch/>
 						<preview id="preview"/>
 					</column>
 				</row>
 			</tab>
+			<tab label="Limit" id="tab_limit_options">
+				<frame id="limit" label="Limit number of groups" checkable="true" checked="false">
+					<embed id="limit_options" component="rkward::limit_vector_length" as_button="false" label="Limit Categories"/>
+				</frame>
+				<stretch/>
+			</tab>
+			<tab label="Labels" id="tab_labels">
+				<radio id="names_mode" label="Labels" >
+					<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)" required="true"/>
+				<input id="names_custom" label="Labels (separated by ';')" initial="First label;Second label"/>
+				<stretch/>
+			</tab>
 			<tab label="Options" id="tab_options">
 				<row>
 					<radio id="colors" label="Colors" >

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