gtree: gtree widget

Description Usage Arguments Note Examples

View source: R/gtree.R

Description

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.

Usage

1
2
3
gtree(offspring = NULL, offspring.data = NULL, multiple = FALSE,
  handler = NULL, action = NULL, container = NULL, ..., width = NULL,
  height = NULL, ext.args = NULL)

Arguments

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 qtip will be rendered as a tooltip, not as another column. The order of the columns is used, so make sure it goes key, offspring, icon, any other

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 addHandlerChanged) to specify a handler for the default signal. A handler is a function with signature (h,...) where h is a list with components obj referring to the object emitting the signal, action containing values passed to the action argument, and possible other values.

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 parent argument in some circumstances). The parent specifies the widget heirarchy and the ... argument is used to pass along arguments to layout the child component in the parent container. Typically, these are passed to the add method of the parent container.

...

Used to pass along argument to the parent container's add method and possible other arguments to the underlying ference class constructors.

width

width in pixels of component. Sizing in gWidgetsWWW2 is sometimes necessary as the arguments expand and fill are not well implemented.

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 asJSObject.

Note

TODO: implement multiple slection

Examples

 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)

jverzani/gWidgetsWWW2 documentation built on Feb. 9, 2020, 5:18 p.m.