Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / .block
Created June 30, 2016 05:53
adding non-default tools (e.g. lasso select)
license: none
height: 520
scrolling: no
border: yes
@hafen
hafen / .block
Created June 30, 2016 05:41
iris example w/ custom hover / url
license: none
height: 520
scrolling: no
border: yes
@hafen
hafen / .block
Created June 30, 2016 05:14
iris example
license: none
height: 520
scrolling: no
border: yes
@hafen
hafen / .block
Created March 10, 2016 01:24
blog post example
license: none
height: 520
scrolling: no
border: yes
@hafen
hafen / example.R
Last active March 3, 2016 21:41
addCallback for rmote
my_callback <- function(expr, value, ok, visible) {
if(inherits(value, "help_files_with_topic")) {
message("I'm doing one more thing with this help object...")
# do rmote serving stuff...
# except the default print method has already been called
# which if help_type == "text" will defeat the purpose of rmote
# and if help_type == "html" will result in something like
# "Error: no display specified" on a headless linux system
} else if(inherits(value, "htmlwidget")) {
message("I'm doing one more thing with this htmlwidget...")
@hafen
hafen / README.md
Created March 1, 2016 18:43
select callback
dat <- data.frame(x = runif(500), y = runif(500))

p <- figure(title = "select points to adjust mean line",
  tools = "lasso_select") %>%
  ly_points(x, y, data = dat, lname = "points") %>%
  ly_lines(x = c(0, 1), y = rep(mean(dat$y), 2), line_width = 6,
 color = "orange", alpha = 0.75, lname = "mean")
@hafen
hafen / README.md
Created February 5, 2016 01:32
scatter facet 1
grid_plot(lapply(split(dat, dat$f1), function(d) {
  figure(width = 300, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 1, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:31
scatter facet 2
grid_plot(lapply(split(dat, dat$f2), function(d) {
  figure(width = 300, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 2, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:30
scatter facet 2
grid_plot(lapply(split(dat, dat$f2), function(d) {
  figure(width = 320, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 2, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:15
scatter hexbin to points
range_callback <- custom_callback("
  var rdiff = range.get('end') - range.get('start')
  var zoomed_in = hexbin_glyph.get('_zoomed_in')
  if(rdiff < 1.5) {
    hexbin_glyph.get('_zoomed_in', true)
    points_glyph.set('visible', true)
    points_hov_glyph.set('visible', true)