Skip to content

Instantly share code, notes, and snippets.

@saptarshiguha
Created February 2, 2016 19:03
Show Gist options
  • Select an option

  • Save saptarshiguha/939075233c63bec942a4 to your computer and use it in GitHub Desktop.

Select an option

Save saptarshiguha/939075233c63bec942a4 to your computer and use it in GitHub Desktop.
library(shiny)
library(rbokeh)
D <- data.frame(x=c(2, 3, 5, 6, 8, 7),
y=c(6, 4, 3, 8, 7, 5))
links <- list("0" = c(2,3),
"1" = c(1, 4, 5),
"2" = c(1,6),
"3" = c(2,5),
"4" = c(2,4),
"5" = c(3,4,5)
)
p <- figure(width=400,height=500,tools="None", title="Hover Over Points")
src <- data.frame(x0=numeric(0), y0=numeric(0), x1=numeric(0), y1=numeric(0))
callback <- custom_callback(code=sprintf("
var links=%s;
var data = {'x0': [], 'y0': [], 'x1': [], 'y1': []};
var cdata = cb_obj.get('data');
var indices = cb_data.index['1d'].indices;
debugger
console.log(cdata);
console.log(indices);
", rjson::toJSON(links)))
## p <- ly_segments(p, x0=x0, y0=y0, x1=x1,y1=y1, color="olive"
## , alpha=0.6, line_width=3
## , data=src,lname = "links")
p <- ly_points(p, x=x,y=y, color="olive", size=30
,data= D
, alpha=0.4
, hover_color="red", hover_alpha=1.0
, hover_callback = callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment