美人鱼图表R之旅

3
我该如何解决这个问题。我在我的*.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文件中看到一个空白区域,但没有图表。

1个回答

4

您可以通过使用devtools包从GitHub安装DiagrammeR的开发版本,并查看差异:

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

看起来旅程图表尚未实现。
因此,为了快速(且临时)解决方案(与distill :: distill_article完美配合),您可以

在没有打包程序的情况下部署mermaid,可以像这样在HTML中插入具有绝对地址和mermaidAPI调用的script标记:

<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%')
```

这样做将命令mermaid解析器查找具有class="mermaid"的
标签。从这些标签中,mermaid将尝试读取图表定义并将它们呈现为svg图表。这对于distill::distill_website有帮助吗?

1
你好Radovan,是的,它正在运作!谢谢你的帮助。distill_website看起来很棒。Sebastian - SebastianS
很高兴能够帮助到您。 - Radovan Miletić

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接