Description Usage Arguments Value Examples
This produces a widget holding a "div" tag that other
JavaScript libraries can use to place their content.
There are a few reference class methods that make this
possible. The div_id
method returns the DOM id of
the div object that is produced. The
add_handler_onload
method can be used to call a
handler after the external libraries are loaded. This is
an asynchronous call, so one need not worry that the
libraries are done downloading. This call might require
JavaScript commands to be processed that are not produced
by a gWidgetsWWW2 handler. The add_js_queue
method
allows one to push such commands back to the browser. The
method load_external
is used to load external
scripts by specifying the appropriate url(s).
1 2 3 |
container |
parent container |
handler |
optional handler bound via
|
action |
optional value to paramaterize handler |
... |
passed along to |
width |
a pre-specified width (in pixels) for the widget |
height |
a pre-specified height (in pixels) for the widget |
ext.args |
A list of extra arguments to pass to the ExtJS constructor |
a GPanel
reference class object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | w <- gwindow("windows and dialogs")
g <- ggroup(cont=w, horizontal=FALSE)
pan <- gpanel(cont=g, width=200, height=200)
## will load d3 javascript library
d3_url <- "http://mbostock.github.com/d3/d3.js?2.7.1"
## template to simply insert HTML
## div_id comes from pan$div_id()
tpl <- "
function(data, status, xhr) {
d3.select('#{{div_id}}').html('Look ma HTML');
}
"
## more complicated example to draw a line
tpl2 <- "
function(data, status, xhr) {
var chart = d3.select('#{{div_id}}').append('svg')
.attr('class', 'chart')
.attr('width', 200)
.attr('height', 200);
chart.append('line')
.attr('x1', 25)
.attr('x2', 200 - 25)
.attr('y1', 100)
.attr('y2', 100)
.style('stroke', '#000');
}
"
cmd <- whisker.render(tpl2, list(div_id=pan$div_id()))
gpanel_load_external(pan, d3_url, cmd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.