Last active
November 9, 2015 19:36
-
-
Save statwonk/623cebaab9da7d3938d9 to your computer and use it in GitHub Desktop.
A DiagrammeR app
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(shiny) | |
library(DiagrammeR) | |
library(magrittr) | |
shinyServer(function(input, output) { | |
output$diagram_plot <- renderDiagrammeR({ | |
graph <- | |
create_graph() %>% | |
set_graph_name("Boxes and Circles") %>% | |
set_graph_time() %>% | |
set_global_graph_attr("graph", "overlap", "true") %>% | |
set_global_graph_attr("node", "shape", "box") %>% | |
set_global_graph_attr("node", "fontname", "Helvetica") %>% | |
set_global_graph_attr("node", "color", "blue") %>% | |
set_global_graph_attr("edge", "color", "gray") %>% | |
add_node_df(create_nodes(c("A", "B", "C", "D", "E", "F"))) %>% | |
set_node_attr("F", "color", "black") %>% | |
add_node_df(create_nodes(1:8)) %>% | |
select_nodes(1:8) %>% | |
set_node_attr_with_selection("shape", "circle") %>% | |
set_node_attr_with_selection("fixedsize", "true") %>% | |
set_node_attr_with_selection("width", 0.9) %>% | |
clear_selection() %>% | |
add_edge_df(create_edges(c("A", "B", "B", "B", | |
"C", "1", "E", "2", | |
"1", "1", "E", "4", | |
"5", "6", "3"), | |
c("1", "2", "3", "4", | |
"A", "D", "A", "4", | |
"5", "F", "6", "6", | |
"7", "7", "8"))) %>% | |
set_edge_attr("B", "3", "color", "red") %>% | |
set_edge_attr("C", "A", "color", "green") %>% | |
set_edge_attr("3", "8", "color", "blue") | |
render_graph(graph) | |
}) | |
}) |
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(shiny) | |
shinyUI(fluidPage( | |
titlePanel("DiagrammeR Shiny App"), | |
DiagrammeROutput("diagram_plot") | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment