cran / ggflowchart

:exclamation: This is a read-only mirror of the CRAN R package repository. ggflowchart — Flowcharts with 'ggplot2'. Homepage: https://nrennie.github.io/ggflowchart/
Other
2 stars 0 forks source link

Customizing arrows origin manually #1

Closed laresbernardo closed 1 year ago

laresbernardo commented 1 year ago

Hi @nrennie, thanks for this nice package! I was playing with it and wanted to customize where the arrows start and end for lateral boxes. So I (probably wrong) supposed that overwriting some of the coordinates on theplot$plot_env$plot_edges would modify the plot. I'll share exactly what I'm doing to see if there's a way to get around this.

A <- "How to tackle\nclients inquiries\nabout Robyn?"
B <- "1. Basic\n(First step for all)"
C <- "2. Medium\n(Additional support)"
D <- "3. Advanced\n(Custom support)"
BX <- paste(c("Website", "One-Pager", "Run demo.R", "Documentation"), collapse = "\n")
CX <- paste(c("Regional GTM POCs", "Community posts", "Technical posts"), collapse = "\n")
DX <- paste(c("GPOC", "Dev Team"), collapse = "\n")
data <- tibble::tibble(
  from = c(A, A, A, 
           B, C, 
           B, C, D),
  to = c(B, C, D, 
         C, D, 
         BX, CX, DX))
# Let's plot and see the results
(temp <- ggflowchart(data, family = "Arial Narrow", x_nudge = 0.45))
Screenshot 2023-05-17 at 5 13 15 PM

Now, trying to modify the values by overwritting the source of one of the arrows (from B to C):

change <- temp$plot_env$plot_edges %>%
  filter(s_e == "from", id == 4) %>%
  mutate(x = x + 0.45, y = 2) # New x and y values set here
temp$plot_env$plot_edges[
  temp$plot_env$plot_edges$id == 4 &
    temp$plot_env$plot_edges$s_e == "from", ] <- change
temp$plot_env$plot_edges # I can see it was overwritten here
# Still plotting the old values though
plot(temp)

Any hint? Are you planning to do this easier anytime soon? Thanks :)

nrennie commented 1 year ago

Hi @laresbernardo - there's already an issue open to address this: https://github.com/nrennie/ggflowchart/issues/5. This repository is just the CRAN mirror so it won't be updated until the next CRAN release (at least several months). I can't close issues or make PRs related to the issue in this repository. If you have further comments on this issue can you add them to the original repo? This issue is very close to the top of my list of things to do so it should be available in the development version soon(ish).

For a workaround for now, I would plot the arrows on top of the flowchart without those edges. e.g. add another geom_segment(). Changing the plot_env value won't work - that's not how environments work in R.