0

so this is my code pretty simple flowchart. I was wondering how I could size the nodes so they're on a fixedsize (fixedsize = FALSE does not work) so they change size based on the text inside the boxes. I also was wondering is their a way to color the nodes based on information that is entered into the table? any help would be appreciated, thank you

    library(DiagrammeR)
    library(dplyr)
    
    
    e <- read.csv("edges.csv",stringsAsFactors  = FALSE)
    
    n <- read.csv("nodes.csv", stringsAsFactors = FALSE)
    e$to <- as.character(e$to)
     
    
    create_graph()  %>%
      add_nodes_from_table(table=n,label_col = task) %>%
      add_edges_from_table(table=e,from_col = from,to_col = to,from_to_map = label) %>%
    
      set_node_attrs(
        node_attr = "shape",
        values = "square"
      ) %>%
   set_node_attrs(

    node_attr = "fixedsize",

    values = FALSE) %>%
      
      render_graph(layout = "tree")

Output of flow chart

edges

nodes

Lizzie S
  • 1
  • 1
  • 1
    Welcome to SO. Good if you could make a fully reproducible question, which sometimes means creating dummy data :) – geotheory Apr 08 '21 at 21:41
  • 1
    seems like `width` or `fixedsize = FALSE` passed to `create_node_df` to change the size, but you have to [go looking for it](https://rich-iannone.github.io/DiagrammeR/ndfs_edfs.html) since it's not documented in `?create_node_df` – rawr Apr 08 '21 at 22:03
  • I figured out how to resize the nodes by using `set_node_attrs(node_attr = "fixedsize",values = FALSE)`. I'm still working on how to change the color of the nodes based on what is entered in the table. – Lizzie S Apr 09 '21 at 14:27
  • Any suggestions or links to sites that would help me solve this would be very helpful. Thank you! – Lizzie S Apr 09 '21 at 14:35

0 Answers0