I'm trying to embed a visNetwork object returned from a function, into an html div but so far I have no success.
Let's say that there is an R function that returns a visNetwork object. In its simplest form could look like:
get_plot <-function()
{
nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))
visNetwork::visNetwork(nodes, edges, width = "100%")
}
I tried to retrieve the plot with two different methods.
Using the
rplot()
method ofopencpu
:var req = $("#plot-div").rplot("get_plot",{});
which returns
ocpu/tmp/x09f8951024d611/graphics/last/png?width=100&height=100 404 (Not Found)
and indeed there is no /grraphics directory presented.
Using the usual
ocpu.call()
method of the opencpu to see what it can gets as responsevar req = ocpu.call("get_plot",{}, function (session8){ session8.getObject( function(data){ console.log(data); }) })
This one returned
ocpu/tmp/x0dabe1f8c83093/R/.val/json 400 (Bad Request)
and when visited the link I saw an error informing me that No method asJSON S3 class: htmlwidget
.
Did anyone achieve to retrieve a visNetwork
object using openCPU
and embed it into an html page? Is this possible or not?