datastorm-open / visNetwork

R package, using vis.js library for network visualization
Other
545 stars 125 forks source link

Can graph internals be exposed to the DOM? #382

Closed julianstanley closed 4 years ago

julianstanley commented 4 years ago

Right now, the visNetwork graph is all within a <canvas> tag. Is it feasible to expose elements within the graph to the DOM?

I'm asking about this feature to make it possible to test visNetwork plots with tools like Selenium (or even shinytest, which I don't think is able to interact with visNetwork at all at this time).

image

bthieurmel commented 4 years ago

vis.js use HTML canvas for rendering, and I think it's not possible to use/set other configuration

julianstanley commented 4 years ago

Yep, that makes sense. I suppose I can expose my graph's data for testing by setting it to the window on render:

  output$my_graph <- renderVisNetwork({
    visNetwork(
      nodes = data.frame(id = "A", label = "A")
    ) %>%
      onRender("(el, x) => {window.myData = x}")
  })

and, besides that, I'll just work on the tricks associated with automating canvas testing.

Thanks!