Guest User

Untitled

a guest
Feb 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. library(plotly)
  2. library(crosstalk)
  3. library(htmlwidgets)
  4.  
  5. mtcars %>%
  6. SharedData$new() %>%
  7. plot_ly(x = ~wt, y = ~mpg) %>%
  8. highlight("plotly_selected", dynamic = TRUE) %>%
  9. onRender(
  10. "function(el, x) {
  11. var gd = document.getElementById(el.id);
  12. gd.on('plotly_selected', function(ed) {
  13. var xmax = ed.range.x[1];
  14. var ymin = ed.range.y[0];
  15. var vline = {type: 'line', y0: 0, y1: 1, yref: 'paper', x0: xmax, x1: xmax, line: {dash: 'dot'}};
  16. var hline = {type: 'line', x0: 0, x1: 1, xref: 'paper', y0: ymin, y1: ymin, line: {dash: 'dot'}};
  17. Plotly.relayout(gd, {shapes: [vline, hline]})
  18. })
  19. }"
  20. )
Add Comment
Please, Sign In to add comment