Skip to content

Instantly share code, notes, and snippets.

View saptarshiguha's full-sized avatar

Saptarshi Guha saptarshiguha

View GitHub Profile
handle_hover_callback <- function(x, model)
UseMethod("handle_hover_callback", x)
handle_hover_callback.character <- function(x, model) {
list(
code = x,
args = list(hover = model$ref)
)
}
# - create a HoverTool model
# - need to point to glyph
# add ref to plot$attributes$tools
# add model to object
## this is only used internally
## users cannot manually add a hover tool
## it must be done through the hover argument to the layer functions
add_hover <- function(fig, tooltips, renderer_ref) {
library("shiny")
library("rbokeh")
p <- print_model_json
callback = shiny_callback("hoverInfo")
options(hoverCallback=callback)
D <- data.frame(x=1:3,y=runif(3))
ui <- fluidPage(
rbokehOutput("rbokeh", width = 500, height = 540),
textOutput("x_range_text"),
#!/bin/sh
TFILE="/tmp/$$.R"
cat << EOF > $TFILE
args = (commandArgs(trailingOnly=TRUE))[-1]
cran <- c()
gh <- c()
CRAN <- FALSE;GH <- FALSE
RHIPE = terralib.includecstring [[
#include <R.h>
#include <Rinternals.h>
#include <Rmath.h>
SEXP counter(SEXP );
SEXP status(SEXP );
SEXP collect(SEXP ,SEXP );
SEXP collect_buffer(SEXP ,SEXP );
]]
os = require("os")
options(rbokehViewDir = "~/public_html/tmp/rbokeh")
options(viewer = (function(){
first <- TRUE
function(u,height){
rbokehdir <- getOption("rbokehViewDir")
for(k in list.files(dirname(u),full=TRUE)){
file.copy(k, rbokehdir, overwrite=TRUE,recursive=TRUE)
}
index_html <- file.path(rbokehdir, "index.html")
message(sprintf("Viewing figure at %s", index_html))
## In https://github.com/rstudio/htmltools/blob/master/R/html_print.R#L41
## html_print doesn't have an option on how and where to write the html
## it always creates anothe temporary directory and writes the HTML there
## This bypasses that with an uglry recursive copy ...
options(rbokehViewDir = tempfile("rbokehviz"))
if(!file.exists(getOption("rbokehViewDir")))
dir.create(getOption("rbokehViewDir"))
## On my remote system, i have a public_html/tmp folder setup that i
## In https://github.com/rstudio/htmltools/blob/master/R/html_print.R#L41
## html_print doesn't have an option on how and where to write the html
## it always creates anothe temporary directory and writes the HTML there
## This bypasses that with an uglry recursive copy ...
options(rbokehViewDir = tempfile("rbokehviz"))
if(!file.exists(getOption("rbokehViewDir")))
dir.create(getOption("rbokehViewDir"))
## On my remote system, i have a public_html/tmp folder setup that i
## In https://github.com/rstudio/htmltools/blob/master/R/html_print.R#L41
## html_print doesn't have an option on how and where to write the html
## it always creates anothe temporary directory and writes the HTML there
## This bypasses that with an uglry recursive copy ...
options(rbokehViewDir = tempfile("rbokehviz"))
if(!file.exists(getOption("rbokehViewDir")))
dir.create(getOption("rbokehViewDir"))
## On my remote system, i have a public_html/tmp folder setup that i
## In https://github.com/rstudio/htmltools/blob/master/R/html_print.R#L41
## html_print doesn't have an option on how and where to write the html
## it always creates anothe temporary directory and writes the HTML there
## This bypasses that with an uglry recursive copy ...
options(rbokehViewDir = tempfile("rbokehviz"))
if(!file.exists(getOption("rbokehViewDir")))
dir.create(getOption("rbokehViewDir"))
options(viewer = (function(){