如何将DiagrammeR甘特图保存为svg文件

时间:2017-09-27 18:28:53

标签: r svg gantt-chart diagrammer mermaid

我想知道如何将使用DiagrammeR的美人鱼功能生成的甘特图保存为SVG文件。

以下文中的甘特图为例:Gantt charts with R

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
")

如何将此图表导出到svg文件中?

我已经看到有一个工具可以将DiagrammeR grViz图形导出为svg格式(https://github.com/rich-iannone/DiagrammeRsvg/blob/master/man/export_svg.Rd),但是这个工具不适用于美人鱼甘特图。

如果您尝试将其应用于之前的甘特图,则会遇到以下特定错误:

Error in context_eval(join(src), private$context) : 
Error: syntax error in line 2 near 'gantt'

有没有办法可以修改这个工具,以便它也可以处理美人鱼图形?

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] timevis_0.4       dplyr_0.7.3       tidyr_0.7.1      
[4] htmltools_0.3.6   DiagrammeRsvg_0.1 DiagrammeR_0.9.2 

loaded via a namespace (and not attached):
 [1] Rook_1.1-1         purrr_0.2.3        V8_1.5            
 [4] colorspace_1.3-2   viridisLite_0.2.0  yaml_2.1.14       
 [7] XML_3.98-1.9       rlang_0.1.2        glue_1.1.1        
[10] RColorBrewer_1.1-2 bindrcpp_0.2       bindr_0.1         
[13] plyr_1.8.4         stringr_1.2.0      munsell_0.4.3     
[16] gtable_0.2.0       visNetwork_2.0.1   htmlwidgets_0.9   
[19] evaluate_0.10.1    knitr_1.17         httpuv_1.3.5      
[22] curl_2.8.1         Rcpp_0.12.12       xtable_1.8-2      
[25] readr_1.1.1        scales_0.5.0       backports_1.1.1   
[28] jsonlite_1.5       rgexf_0.15.3       mime_0.5          
[31] gridExtra_2.3      brew_1.0-6         ggplot2_2.2.1     
[34] hms_0.3            digest_0.6.12      stringi_1.1.5     
[37] shiny_1.0.5        grid_3.3.2         rprojroot_1.2     
[40] influenceR_0.1.0   tools_3.3.2        magrittr_1.5      
[43] lazyeval_0.2.0     tibble_1.3.4       pkgconfig_2.0.1   
[46] downloader_0.4     assertthat_0.2.0   rmarkdown_1.6     
[49] rstudioapi_0.7     viridis_0.4.0      R6_2.2.2          
[52] igraph_1.1.2  

非常感谢,

最佳,

Yatrosin

0 个答案:

没有答案