Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(plotly)
- library(crosstalk)
- library(htmlwidgets)
- mtcars %>%
- SharedData$new() %>%
- plot_ly(x = ~wt, y = ~mpg) %>%
- highlight("plotly_selected", dynamic = TRUE) %>%
- onRender(
- "function(el, x) {
- var gd = document.getElementById(el.id);
- gd.on('plotly_selected', function(ed) {
- var xmax = ed.range.x[1];
- var ymin = ed.range.y[0];
- var vline = {type: 'line', y0: 0, y1: 1, yref: 'paper', x0: xmax, x1: xmax, line: {dash: 'dot'}};
- var hline = {type: 'line', x0: 0, x1: 1, xref: 'paper', y0: ymin, y1: ymin, line: {dash: 'dot'}};
- Plotly.relayout(gd, {shapes: [vline, hline]})
- })
- }"
- )
Add Comment
Please, Sign In to add comment