View source: R/BrowserViz-class.R
BrowserViz constructor | R Documentation |
This constructor function:
creates the BrowserViz object
initializes the httpuv web server
prepares that web server to additionally handle websocket traffic
loads a "browserFile" - an html/javascript/css web page to communicate with in your web browser
opens websocket communication between your R session and your browser
installs an optional "httpQueryProcessingFunction" to handle http (non-websocket) requests.
BrowserViz(
host = "localhost",
portRange = 10000:10100,
title = "BrowserViz",
browserFile,
quiet = TRUE,
httpQueryProcessingFunction = NULL
)
host |
character The constructor will open an http/websocket port here for web browsers to connect to. localhost by default |
portRange |
The constructor looks for a free websocket port in this range. 10000:10100 by default |
title |
Used for the web browser window, "igvR" by default |
browserFile |
The full path to the bundled html, js and libraries, and css which constitute the browser app |
quiet |
A logical variable controlling verbosity during execution |
httpQueryProcessingFunction |
a function, default NULL, provides subclasses with the opportunity to execute code on the http server created here. |
An object of the BrowserViZ class
library(BrowserViz)
browserVizBrowserFile <- system.file(package="BrowserViz", "browserCode", "dist", "bvDemoApp.html")
if(BrowserViz::webBrowserAvailableForTesting()){
bvApp <- BrowserViz(browserFile=browserVizBrowserFile, quiet=TRUE)
data <- list(lowercase=letters, uppercase=LETTERS)
json.returned <- roundTripTest(bvApp, data)
data.returned <- fromJSON(json.returned)
stopifnot(identical(data, data.returned))
html <- sprintf("<h3>round trip of json-encoded data, %d chars</h3>",
nchar(json.returned))
displayHTMLInDiv(bvApp, html, "bvDemoDiv")
closeWebSocket(bvApp)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.