2

我怎么解决这个问题。我在 *.rmd 文件中添加了以下代码行:

DiagrammeR::mermaid("
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 5: Me
")

我使用 R 包 distill 来编织 distill_website。只有旅程图没有生成。我可以在 html 文件中看到一个空格,但没有图表。

4

1 回答 1

2

您可以首先使用 devtools 包从 GitHub 安装 DiagrammeR 的开发版本,然后查看区别:

devtools::install_github("rich-iannone/DiagrammeR")

似乎旅程图尚未实施。
因此,对于快速(和临时)解决方案(与 完美配合distill::distill_article),您可以

在没有捆绑器的情况下部署美人鱼,可以将script带有绝对地址的标签和mermaidAPI调用插入 HTML,如下所示:

<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad:true});</script>

```{r diagram-mermaid, echo = FALSE}
DiagrammeR::mermaid(diagram = '
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 5: Me
', height = '100%', width = '100%')
```

这样做将命令美人鱼解析器查找<div> 带有class="mermaid". 从这些标签美人鱼将尝试读取图表/图表定义并将它们呈现为 svg 图表。

这对 有什么帮助distill::distill_website吗?

于 2021-04-03T11:26:19.850 回答