OS: Windows 7,R 版本: 3.4.3,R 工作室:1.1.383
下面的代码利用R的DiagrammeR包生成了一个很好的甘特图。我在导出此包的输出时遇到问题。在R Studio中,我可以单击Zoom
,并出现甘特图的全屏图像。然后我继续Export > Copy to Clipboard
,当我粘贴时,我会将这个奇怪的裁剪版本的图像粘贴到我的目的地。
裁剪的奇怪之处在于它拍摄了实际图像的部分屏幕截图以及我的R Studio会话的一部分,并将两者加在一起。就像坐标关闭一样。我也尝试了Export > Save as Image
,但发生了同样的问题。错误??我以同样的方式从 ggplot2 输出许多图形,但这永远不会发生。
我的临时解决方案是使用 Windows 的截图工具来拍摄我自己的"缩放"屏幕截图,但这并不可取。DiagrammeR使用美人鱼降价,不管这意味着什么,为了它的价值。
library(DiagrammeR)
mermaid("
gantt
dateFormat YYYY-MM-DD
title A Very Nice Gantt Diagram
section Basic Tasks
This is completed :done, first_1, 2014-01-06, 2014-01-08
This is active :active, first_2, 2014-01-09, 3d
Do this later : first_3, after first_2, 5d
Do this after that : first_4, after first_3, 5d
section Important Things
Completed, critical task :crit, done, import_1, 2014-01-06,24h
Also done, also critical :crit, done, import_2, after import_1, 2d
Doing this important task now :crit, active, import_3, after import_2, 3d
Next critical task :crit, import_4, after import_3, 5d
section The Extras
First extras :active, extras_1, after import_4, 3d
Second helping : extras_2, after extras_1, 20h
More of the extras : extras_3, after extras_1, 48h
")
您可以先将 html 小部件另存为 html 文件,然后使用 webshot
将其另存为 png 文件。
htmlwidgets::saveWidget(m, file="m.html")
webshot::webshot("m.html", "m.png")
数据:
library(DiagrammeR)
m <- mermaid("
gantt
dateFormat YYYY-MM-DD
title A Very Nice Gantt Diagram
section Basic Tasks
This is completed :done, first_1, 2014-01-06, 2014-01-08
This is active :active, first_2, 2014-01-09, 3d
Do this later : first_3, after first_2, 5d
Do this after that : first_4, after first_3, 5d
section Important Things
Completed, critical task :crit, done, import_1, 2014-01-06,24h
Also done, also critical :crit, done, import_2, after import_1, 2d
Doing this important task now :crit, active, import_3, after import_2, 3d
Next critical task :crit, import_4, after import_3, 5d
section The Extras
First extras :active, extras_1, after import_4, 3d
Second helping : extras_2, after extras_1, 20h
More of the extras : extras_3, after extras_1, 48h
")