[rkward-cvs] rkward/rkward/plugins/plots plot_options.php,NONE,1.1 plot_options.xml,NONE,1.1 histogram.php,1.1,1.2 histogram.xml,1.1,1.2

Thomas Friedrichsmeier tfry at users.sourceforge.net
Mon Mar 20 19:34:01 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/plugins/plots
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10768/rkward/plugins/plots

Modified Files:
	histogram.php histogram.xml 
Added Files:
	plot_options.php plot_options.xml 
Log Message:
Basic embedding or RKComponents works

--- NEW FILE: plot_options.php ---
<?
function preprocess () {
}

function calculate () {
}

function printout () {
	$log; $xaxt; $yaxt; $xlim; $ylim; $xlab; $ylab;

	$xvar = getRK_val ("xvar");
	$yvar = getRK_val ("yvar");
	if ($yvar == "") {
		$yvar = "1:length (" . $xvar .")";
	}

	// X axis
	$xaxt = getRK_val ("xaxt");
	$have_x_axis = ($xaxt == "");
	if ($have_x_axis) {
		$log .= getRK_val ("xlog");

		$xlab = getRK_val ("xlab");
		if (($xlab != "") && (getRK_val ("xlabisexp") != "1")) {
			$xlab = "\"" . $xlab . "\"";
		}
		if ($xlab != "") $xlab = ", xlab=" . $xlab;

		$xminvalue = getRK_val ("xminvalue");
		$xmaxvalue = getRK_val ("xmaxvalue");
		if (($xminvalue != "") || ($xmaxvalue != "")) {
			$xlim = ", xlim=c (";
			if ($xminvalue == "") $xlim .= "min (" . $xvar . ")";
			else $xlim .= $xminvalue;
			$xlim .= ", ";
			if ($xmaxvalue == "") $xlim .= "max (" . $xvar . ")";
			else $xlim .= $xmaxvalue;
			$xlim .= ")";
		}
	} else {
		$xaxt = ", xaxt=\"" . $xaxt . "\"";
	}

	// same for Y axis
	$yaxt = getRK_val ("yaxt");
	$have_y_axis = ($yaxt == "");
	if ($have_y_axis) {
		$log .= getRK_val ("ylog");

		$ylab = getRK_val ("ylab");
		if (($ylab != "") && (getRK_val ("ylabisexp") != "1")) {
			$ylab = "\"" . $ylab . "\"";
		}
		if ($ylab != "") $ylab = ", ylab=" . $ylab;

		$yminvalue = getRK_val ("yminvalue");
		$ymaxvalue = getRK_val ("ymaxvalue");
		if (($yminvalue != "") || ($ymaxvalue != "")) {
			$ylim = ", ylim=c (";
			if ($yminvalue == "") $ylim .= "min (" . $yvar . ")";
			else $ylim .= $yminvalue . ", ";
			$ylim .= ", ";
			if ($ymaxvalue == "") $ylim .= "max (" . $yvar . ")";
			else $ylim .= $ymaxvalue;
			$ylim .= ")";
		}
	} else {
		$yaxt = ", yaxt=\"" . $yaxt . "\"";
	}

	// final touches
	if ($log != "") $log = ", log=\"" . $log . "\"";

	// make option string
	$options = $xaxt . $yaxt . $log . $xlim . $ylim . $xlab . $ylab;

	echo ($options);
}

function cleanup () {
}
?>
Index: histogram.php
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugins/plots/histogram.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** histogram.php	12 Mar 2006 18:48:26 -0000	1.1
--- histogram.php	20 Mar 2006 19:33:58 -0000	1.2
***************
*** 12,16 ****
  ?>cat ("<h1>Histogram</h1>")
  rk.graph.on ()
! plot (hist (<? getRK ("x"); ?>, freq = <? getRK ("scale"); ?>))
  rk.graph.off ()
  cat ("<table border = \"1\">")
--- 12,16 ----
  ?>cat ("<h1>Histogram</h1>")
  rk.graph.on ()
! plot (hist (<? getRK ("x"); ?>, freq = <? getRK ("scale"); ?>)<? getRK ("plotoptions.code.printout"); ?>)
  rk.graph.off ()
  cat ("<table border = \"1\">")

Index: histogram.xml
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugins/plots/histogram.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** histogram.xml	12 Mar 2006 18:48:26 -0000	1.1
--- histogram.xml	20 Mar 2006 19:33:58 -0000	1.2
***************
*** 2,5 ****
--- 2,8 ----
  <document>
    <code file="histogram.php" />
+   <logic>
+     <connect client="plotoptions.xvar" governor="x.available"/>
+   </logic>
    <dialog label="Histogram" >
      <tabbook>
***************
*** 21,24 ****
--- 24,30 ----
            </column>
          </column>
+ 	</tab>
+       <tab label="Plot options">
+ 		<embed id="plotoptions" component="rkward::plot_options" />
        </tab>
      </tabbook>

--- NEW FILE: plot_options.xml ---
<!DOCTYPE rkplugin>
<document>
	<code file="plot_options.php" />
	<logic>
		<connect client="xlog.enabled" governor="xaxt.state" />
		<connect client="xlab.enabled" governor="xaxt.state" />
		<convert id="xlabfilled" mode="notequals" sources="xlab.text" standard="" />
		<convert id="xlabspecified" mode="and" sources="xlabfilled;xlab.enabled" />
		<connect client="xlabisexp.enabled" governor="xlabspecified" />
		<connect client="xminvalue.enabled" governor="xaxt.state" />
		<connect client="xmaxvalue.enabled" governor="xaxt.state" />

		<connect client="ylog.enabled" governor="yaxt.state" />
		<connect client="ylab.enabled" governor="yaxt.state" />
		<convert id="ylabfilled" mode="notequals" sources="ylab.text" standard="" />
		<convert id="ylabspecified" mode="and" sources="ylabfilled;ylab.enabled" />
		<connect client="ylabisexp.enabled" governor="ylabspecified" />
		<connect client="yminvalue.enabled" governor="yaxt.state" />
		<connect client="ymaxvalue.enabled" governor="yaxt.state" />

		<outside id="xvar" />
		<outside id="yvar" />
	</logic>
	<dialog label="Default plot options" >
		<tabbook>
			<tab label="Axes" >
				<column>
					<frame id="axistypes" label="Axis types">
						<row>
							<checkbox id="xaxt" label="Draw X axis" checked="true" value="" value_unchecked="n" />
							<checkbox id="yaxt" label="Draw Y axis" checked="true" value="" value_unchecked="n" />
						</row>
						<row>
							<checkbox id="xlog" label="X axis logarithmic" checked="false" value="x" value_unchecked="" />
							<checkbox id="ylog" label="Y axis logarithmic" checked="false" value="y" value_unchecked="" />
						</row>
					</frame>
					<frame id="axislabels" label="Labels (leave empty for default)">
						<row>
							<input id="xlab" label="X axis label" />
							<input id="ylab" label="Y axis label" />
						</row>
						<text>Interpret these labels be as R expressions (as opposed to string literals)?</text>
						<row>
							<checkbox id="xlabisexp" label="interpret as expression" value="1" />
							<checkbox id="ylabisexp" label="interpret as expression" value="1" />
						</row>
					</frame>
					<frame id="scale" label="Scale (Minimum/Maximum values for X/Y). Leave blank for automatic">
						<row>
							<input id="xminvalue" label="Min X value" />
							<input id="yminvalue" label="Min Y value" />
						</row>
						<row>
							<input id="xmaxvalue" label="Max X value" />
							<input id="ymaxvalue" label="Max Y value" />
						</row>
					</frame>
				</column>
			</tab>
		</tabbook>
	</dialog>
</document>





More information about the rkward-tracker mailing list