Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Side effects of renderGrViz/grVizOutput not documented #472

Open
Tracked by #508
ralmond opened this issue Jul 22, 2022 · 0 comments
Open
Tracked by #508

Side effects of renderGrViz/grVizOutput not documented #472

ralmond opened this issue Jul 22, 2022 · 0 comments

Comments

@ralmond
Copy link

ralmond commented Jul 22, 2022

Creating an output using grVizOutput and then assigning the output of renderGrViz in addition to rendering the graph, also creates input elements. This side effect is not really documented anywhere that I can see, so developers can't use it.

ui <- fluidPage(
   #...
   grVizOutput("graph")
  #...
)

server <- function (input, output) {
  output$graph <- renderGrViz({grViz("digraph ...")})
  #...
}

Will, in addition to rendering the graph, create a reactive element input$graph_click. This appears to be a list with elements nodeValues and id.

Here is the relevant Javascript code from DiagrammeR.js (starting at line 135)

 $("#" + id + " .node").click(function(e) {
          // Build return object *obj* with node-id and node textContent
          var obj = {
            id: e.currentTarget.id,
            nodeValues: e.currentTarget.textContent
          };
          // Send *obj* to Shiny's inputs (input$[id]+_click  e.g.: input$vtree_click))
          Shiny.setInputValue(id + "_click", obj, {priority: "event"});
        });

I gather that these represent the id and label of the nodes, but this is a guess.

Really, documentation needs to be added to the renderGrViz and grVizOutput functions so that this behavior is well specified.

This issue gives a functioning example.

#402

@olivroy olivroy mentioned this issue Nov 16, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant