Description Usage Arguments Note Examples
Widget to display heirarchical data. The data is described by a function which returns the offspring for agiven node in a specific format. This implementation can only show one column's worth of data and an icon.
1 2 3 |
offspring |
function with signature (path, data). Returns a
data frame with columns: key (which creates the path), offspring
(a logical indicating if the node has children), icon (a character
vector of stock icons names or ""), and any other values to
display in subsequent columns. The column names are mapped to
header names. A column named |
offspring.data |
passed to offspring call so that the offspring function can be parameterized if desired. |
multiple |
logical do we allow multiple selection. NOT IMPLEMENTED |
handler |
optional means (to |
action |
Passed to handler to parameterize a call |
container |
A parent container. In gWidgetsWWW2 a
parent container is not optional (though it can be substituted
with the |
... |
Used to pass along argument to the parent container's
|
width |
width in pixels of component. Sizing in
gWidgetsWWW2 is sometimes necessary as the arguments
|
height |
height in pixels of the component. |
ext.args |
The contructors of gWidgetsWWW2 ultimately
call an Ext constructor. The options passed to the Ext constructor
may be added to or overridden by use of this argument. Values are
passed in as named list components and with values converted into JavaScript
objects by |
TODO: implement multiple slection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # galton watson
## Not run:
offspring <- function(path, ...) {
x <- rbinom(2, 1, p=1/2)
icons <- c("dismiss","ok")[2-x]
nms <- c("branch","leaf")[x+1]
ttip <- paste("This is a ", nms)
data.frame(id=letters[1:2], hasoffspring=as.logical(x), icons=icons,
value=nms, qtip=ttip, stringsAsFactors=FALSE)
}
w <- gwindow("Galton Watson tree")
g <- ggroup(cont=w, horizontal=FALSE)
ghtml("A node in a Galton-Watson tree has 0 or 2 offspring.<br />
In this case each has equal chance.", cont=g)
gseparator(cont=g)
tr <- gtree(offspring=offspring, cont=g)
size(tr) <- c(300,300)
b <- gbutton("Try again", cont=g, handler=function(h,...) tr$update())
visible(w) <- TRUE
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.