Created
May 8, 2017 02:47
-
-
Save cpsievert/655c4b529a89d4f4d0aba2f69583f64f to your computer and use it in GitHub Desktop.
Use restyle to add some points after initial render
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotly) | |
library(htmlwidgets) | |
plot_ly(x = c(1, 2), y = c(1, 2)) %>% | |
onRender( | |
'function(el, x) { | |
setTimeout(function() { | |
var gd = document.getElementById(el.id); | |
var obj = {"mode": "markers"}; | |
for (var i = 0; i < 10; i++) { | |
var j = i + 2; | |
var x = "x[" + j + "]"; | |
var y = "y[" + j + "]"; | |
// iteration values | |
obj[x] = [j]; | |
// likelihood | |
obj[y] = [Math.random()]; | |
Plotly.restyle(gd, obj); | |
} | |
}, 1000) | |
}') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment