Skip to content

graphViz - Correctly pass options to Viz() #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025

Conversation

cderv
Copy link
Contributor

@cderv cderv commented Apr 11, 2025

This also fix conflict with Quarto
quarto-dev/quarto-cli#12513

Looking at how Viz() function works

    function Viz(src) {
        var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
        var format = options.format === undefined ? "svg" : options.format;
        var engine = options.engine === undefined ? "dot" : options.engine;
        var scale = options.scale;
        var totalMemory = options.totalMemory;
        var files = options.files === undefined ? [] : options.files;
        var images = options.images === undefined ? [] : options.images;

I think it requires only one argument for the options, and then the different options are taken into this one.

It also fix the conflict problem with Quarto.

---
format: html
---

```{r}
library(DiagrammeR)
mygraph<- grViz("
digraph transmission {
  graph [layout = dot, rankdir = TB]

  node [shape = box, style = \"rounded,filled\", fillcolor = lightgray, color = gray20, fontname = Helvetica, fontsize = 12]

  D [label = 'Fruit Bat']
  B [label = 'Human', fillcolor = red]  # Red fill for B
  C [label = 'Human']

  D -> B
  B -> C
  C -> B
}
")

```
### Column {.tabset width="30%"}

```{r}
#| title: chain
mygraph
```

To be discussed.

closes #519

Copy link
Owner

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rich-iannone rich-iannone merged commit 999d742 into rich-iannone:main Apr 29, 2025
6 of 10 checks passed
@cderv cderv deleted the fix/Viz-options branch April 29, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DiagrammeR Graph not displayed when rendering in Quarto
2 participants