
Last chance! 50% off unlimited learning
Sale ends in
BrowserVizDemo(portRange, host="localhost", title="BrowserVizDemo", quiet=TRUE)## S3 method for class 'BrowserVizDemoClass':
plot(obj, x, y)
## S3 method for class 'BrowserVizDemoClass':
getSelection(obj)
BrowserVizDemoClass
object returned by the
class constructor.9000:9024
. The BrowserViz
class constructor will try these one at a time in succession until
a free port is found and the connection to your web browser is
established. If no open ports are found in the supplied range,
an error is reported.library(BrowserVizDemo)
plotter <- BrowserVizDemo(4000:4024)
## make sure everything is ready to use
while(!ready(plotter)) Sys.sleep(0.1)
## plot a simple set of x-y paris
plot(plotter, 1:10, (1:10)^2)
## learn which port we are using
port(plotter)
## illustrate a "low level" call. This detail is usually hidden from
## the user, implemented and contained (in the case of this example)
## in a getWindowTitle(plotter) method call. This level of detail
## reveals what goes on behind the scenes.
msg <- list(cmd="getWindowTitle", status="request", callback="handleResponse", payload="")
send(plotter, msg)
while(!browserResponseReady(plotter)) Sys.sleep(0.1)
getBrowserResponse(plotter)
## a simpler user-level approach:
getBrowserWindowTitle(plotter)
## set and get the windowTitle
setBrowserWindowTitle(plotter, "new title")
getBrowserWindowTitle(plotter)
## BrowserVizDemo provides another information method which, like the others, will apply
## and maybe be of some use to derived classes
getBrowserWindowSize(plotter)
## finally, you should close BrowserVizDemo when you are done, returning
## the port for use by other applications.
closeWebSocket(plotter)
Run the code above in your browser using DataLab