bupaverse / processmapR

Visualize event logs using directed graphs, i.e. process maps.
https://bupaverse.github.io/processmapR/
Other
9 stars 6 forks source link

process_map and render=FALSE ignores layout specification #27

Open kkmann opened 4 years ago

kkmann commented 4 years ago

Hey,

I bumped into this while trying to export my maps to pdf via 'export_graph'. It works fine but ignores custom layout specifications.

fmannhardt commented 4 years ago

I assume you are taking about the parameters generated with layout_pm. Indeed, this is a limitation as we are unable to set the relevant DOT attributes via the DiagrammeR library if the map is not rendered staight away, which I assume is what you need to do for the export? A reproducible example would be good to confirm this.

I already created an issue upstream here: https://github.com/rich-iannone/DiagrammeR/issues/360

For now, there is little we can do about this (except patching DiagrammeR, which I would like to avoid). We should definitely document this, but I had hoped that DiagrammeR would be updated.

You may have some success by manually applying our workaround before passing it into the export function:

        # hack to add 'weight' attribute to the graph
        graph$edges_df %>%
            mutate(len = weight, decorate = constraint) -> graph$edges_df

        graph %>% render_graph() -> graph

        graph$x$diagram %>%
            stringr::str_replace_all("len", "weight") %>%
            stringr::str_replace_all("decorate", "constraint") -> graph$x$diagram
kkmann commented 4 years ago

Yes, exactly, makes it a bit tricky to produce high quality pdf graphs for publications. Thanks for raising that with DiagrammR!