akshay tuptewar
unread,Mar 13, 2023, 1:49:49 AM3/13/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Shiny - Web Framework for R
library(shiny)
library(DiagrammeR)
ui <- fluidPage(
textInput("node_A", " A:",width = '50px'),
textInput("node_B", " B:",width = '50px'),
grVizOutput("my_graphviz")
)
server <- function(input, output) {
output$my_graphviz <- renderDiagrammeR({
# Convert inputs to integers
node_A <- as.integer(input$node_A)
node_B <- as.integer(input$node_B)
# Calculate sum of node A and B
node_c <- node_A + node_B
my_graphviz <- grViz(paste0("digraph {
graph[rankdir = LR]
node[shape = ellipse, style = filled]
A[label = '", node_A, "']
B[label = '", node_B, "']
c[label = '", node_c, "']
edge[color = black]
A -> B
B -> c
A[label = paste('<table><tr><td><b>Node A</b></td></tr><tr><td><button onclick=\\'alert(\\\"Button clicked!\\\")\\'>Click me</button></td></tr></table>')]
}"))
my_graphviz
})
}
shinyApp(ui, server)