bupaverse / processanimateR

Token replay animation for process maps created with processmapR by using SVG animations (SMIL) and the htmlwidget package.
https://bupaverse.github.io/processanimateR/
Other
66 stars 11 forks source link

Error using animate_process with mode = "off" #15

Closed serkserk closed 5 years ago

serkserk commented 5 years ago

When using animate_process to render a static process map with mode = "off", i get the error Failed to render the graph. It is probably too large. Original error: TypeError: Cannot read property 'reduce' of undefined in the browser (no error in console) Using mode = "relative/absolute" dont produce the error

I have the last version of processanimateR/bupaR/DiagrammeR ...

Code to replicate:

processanimateR::animate_process(patients, mode = "off")

JesseVent commented 5 years ago

What kind of system are you running this off of?.. I can't replicate it by running the same code, maybe clear the R session, and run the below.

It's definitely not an issue with processanimateR, I have only experienced this when generating huge graph objects, and it appears to be an inherited issue with the diagrammeR package, due to use of viz.js which in turn calls the graphviz framework.. and how it handles calculated node widths/splines when calculating curves in graphviz.

library(processanimateR)
library(eventdataR)
processanimateR::animate_process(patients, mode = "off")
sessionInfo()
gc()

Or alternatively to see the raw rendered graph object processanimateR::animate_process(patients, mode = "off")$x .

Related: https://github.com/rich-iannone/DiagrammeR/issues/151 http://graphviz.996277.n3.nabble.com/Out-of-memory-issue-td4193.html

My Results


Restarting R session...

> library(processanimateR)
> library(eventdataR)
> processanimateR::animate_process(patients, mode = "off")
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

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

other attached packages:
[1] bindrcpp_0.2.2             eventdataR_0.2.0           processanimateR_1.0.1.9000

**Packages to note with particular importance are highlighted**

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0             lubridate_1.7.4        tidyr_0.8.2           
 [4] edeaR_0.8.1            **visNetwork_2.0.5**       assertthat_0.2.0      
 [7] digest_0.6.18          V8_1.5                 mime_0.6              
[10] R6_2.3.0               plyr_1.8.4             httr_1.4.0            
[13] ggplot2_3.1.0          pillar_1.3.1           **bupaR_0.4.1**           
[16] rlang_0.3.1            lazyeval_0.2.1         curl_3.3              
[19] shinyTime_0.2.1        rstudioapi_0.9.0       data.table_1.12.0     
[22] miniUI_0.1.1.1         DiagrammeR_1.0.0       downloader_0.4        
[25] readr_1.3.1            stringr_1.3.1          htmlwidgets_1.3       
[28] **igraph_1.2.2**           munsell_0.5.0          shiny_1.2.0           
[31] compiler_3.5.2         influenceR_0.1.0       rgexf_0.15.3          
[34] httpuv_1.4.5.1         pkgconfig_2.0.2        htmltools_0.3.6       
[37] tidyselect_0.2.5       tibble_2.0.1           gridExtra_2.3         
[40] XML_3.98-1.16          viridisLite_0.3.0      crayon_1.3.4          
[43] dplyr_0.7.8            later_0.7.5.9001       **DiagrammeRsvg_0.1**     
[46] grid_3.5.2             jsonlite_1.6           xtable_1.8-3          
[49] gtable_0.2.0           magrittr_1.5           scales_1.0.0          
[52] stringi_1.2.4          viridis_0.5.1          promises_1.0.1        
[55] ggthemes_4.0.1         brew_1.0-6             RColorBrewer_1.1-2    
[58] tools_3.5.2            forcats_0.3.0          glue_1.3.0            
[61] processmapR_0.3.2.9000 purrr_0.3.0            hms_0.4.2             
[64] Rook_1.1-1             yaml_2.2.0             colorspace_1.4-0      
[67] plotly_4.8.0           bindr_0.1.1           
> gc()
          used (Mb) gc trigger  (Mb) limit (Mb) max used  (Mb)
Ncells 1254715 67.1    2347174 125.4         NA  2347174 125.4
Vcells 2049834 15.7    8388608  64.0      32768  3247267  24.8
serkserk commented 5 years ago

I'm running this in Ubuntu 18.04.1 with vmware and chromium as a browser

I already tried to restart the session with no luck

I also tried with Mozilla and got a similar error: Failed to render the graph. It is probably too large. Original error: TypeError: data.tokens.case is undefined

Size should not be an issue with the patient data.

Here are the output:

Restarting R session...

> library(processanimateR)
> library(eventdataR)
> processanimateR::animate_process(patients, mode = "off")
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
 [4] LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] bindrcpp_0.2.2             eventdataR_0.2.0           processanimateR_1.0.1.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0             lubridate_1.7.4        tidyr_0.8.2            edeaR_0.8.1           
 [5] **visNetwork_2.0.5**       assertthat_0.2.0       digest_0.6.18          V8_2.0                
 [9] mime_0.6               R6_2.3.0               plyr_1.8.4             httr_1.4.0            
[13] ggplot2_3.1.0          pillar_1.3.1           **bupaR_0.4.1**            rlang_0.3.1           
[17] curl_3.3               lazyeval_0.2.1         shinyTime_0.2.1        rstudioapi_0.9.0      
[21] data.table_1.12.0      miniUI_0.1.1.1         DiagrammeR_1.0.0       downloader_0.4        
[25] readr_1.3.1            stringr_1.3.1          htmlwidgets_1.3        **igraph_1.2.2**          
[29] munsell_0.5.0          shiny_1.2.0            compiler_3.4.4         influenceR_0.1.0      
[33] rgexf_0.15.3           httpuv_1.4.5.1         pkgconfig_2.0.2        htmltools_0.3.6       
[37] tidyselect_0.2.5       tibble_2.0.1           gridExtra_2.3          XML_3.98-1.16         
[41] viridisLite_0.3.0      crayon_1.3.4           dplyr_0.7.8            later_0.7.5           
[45] **DiagrammeRsvg_0.1**      grid_3.4.4             jsonlite_1.6           xtable_1.8-3          
[49] gtable_0.2.0           magrittr_1.5           scales_1.0.0           stringi_1.2.4         
[53] viridis_0.5.1          promises_1.0.1         ggthemes_4.0.1         brew_1.0-6            
[57] RColorBrewer_1.1-2     tools_3.4.4            forcats_0.3.0          glue_1.3.0            
[61] processmapR_0.3.2.9000 purrr_0.3.0            hms_0.4.2              Rook_1.1-1            
[65] yaml_2.2.0             colorspace_1.4-0       plotly_4.8.0           bindr_0.1.1           
> gc()
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells 1073861 57.4    1770749 94.6  1442291 77.1
Vcells 1550668 11.9    2937338 22.5  1985247 15.2
> processanimateR::animate_process(patients, mode = "off")$x
$rendered_process
[1] "digraph {\n\ngraph [layout = \"dot\",\n       outputorder = \"edgesfirst\",\n       bgcolor = \"white\",\n       rankdir = \"LR\"]\n\nnode [fontname = \"Helvetica\",\n      fontsize = \"10\",\n      shape = \"circle\",\n      fixedsize = \"true\",\n      width = \"0.5\",\n      style = \"filled\",\n      fillcolor = \"aliceblue\",\n      color = \"gray70\",\n      fontcolor = \"gray50\"]\n\nedge [fontname = \"Helvetica\",\n     fontsize = \"8\",\n     len = \"1.5\",\n     color = \"gray80\",\n     arrowsize = \"0.5\"]\n\n  \"1\" [label = \"Blood test\n237\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"black\", color = \"grey\", tooltip = \"Blood test\n237\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#ECE7F2\"] \n  \"2\" [label = \"Check-out\n492\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"white\", color = \"grey\", tooltip = \"Check-out\n492\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#0570B0\"] \n  \"3\" [label = \"Discuss Results\n495\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"white\", color = \"grey\", tooltip = \"Discuss Results\n495\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#0570B0\"] \n  \"4\" [label = \"End\", shape = \"circle\", style = \"rounded,filled\", fontcolor = \"brown4\", color = \"brown4\", tooltip = \"End\n500\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#FFFFFF\"] \n  \"5\" [label = \"MRI SCAN\n236\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"black\", color = \"grey\", tooltip = \"MRI SCAN\n236\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#ECE7F2\"] \n  \"6\" [label = \"Registration\n500\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"white\", color = \"grey\", tooltip = \"Registration\n500\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#0570B0\"] \n  \"7\" [label = \"Start\", shape = \"circle\", style = \"rounded,filled\", fontcolor = \"chartreuse4\", color = \"chartreuse4\", tooltip = \"Start\n500\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#FFFFFF\"] \n  \"8\" [label = \"Triage and Assessment\n500\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"white\", color = \"grey\", tooltip = \"Triage and Assessment\n500\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#0570B0\"] \n  \"9\" [label = \"X-Ray\n261\", shape = \"rectangle\", style = \"rounded,filled\", fontcolor = \"black\", color = \"grey\", tooltip = \"X-Ray\n261\", penwidth = \"1.5\", fixedsize = \"FALSE\", fontname = \"Arial\", fontsize = \"10\", fillcolor = \"#ECE7F2\"] \n\"1\"->\"4\" [label = \"1\", penwidth = \"1.008\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"1\"->\"5\" [label = \"236\", penwidth = \"2.888\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"2\"->\"4\" [label = \"492\", penwidth = \"4.936\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"3\"->\"2\" [label = \"492\", penwidth = \"4.936\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"3\"->\"4\" [label = \"3\", penwidth = \"1.024\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"5\"->\"3\" [label = \"236\", penwidth = \"2.888\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"6\"->\"8\" [label = \"500\", penwidth = \"5\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"7\"->\"6\" [label = \"500\", penwidth = \"5\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"8\"->\"1\" [label = \"237\", penwidth = \"2.896\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"8\"->\"4\" [label = \"2\", penwidth = \"1.016\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"8\"->\"9\" [label = \"261\", penwidth = \"3.088\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"9\"->\"3\" [label = \"259\", penwidth = \"3.072\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n\"9\"->\"4\" [label = \"2\", penwidth = \"1.016\", color = \"dodgerblue4\", fontname = \"Arial\", fontsize = \"10\"] \n}"

$activities
# A tibble: 9 x 2
  act                      id
  <chr>                 <int>
1 Blood test                1
2 Check-out                 2
3 Discuss Results           3
4 End                       4
5 MRI SCAN                  5
6 Registration              6
7 Start                     7
8 Triage and Assessment     8
9 X-Ray                     9

$tokens
data frame with 0 columns and 0 rows

$sizes
data frame with 0 columns and 0 rows

$sizes_scale
$sizes_scale$attribute
NULL

$sizes_scale$scale
[1] "identity"

$sizes_scale$domain
NULL

$sizes_scale$range
NULL

$colors
data frame with 0 columns and 0 rows

$colors_scale
$colors_scale$attribute
NULL

$colors_scale$scale
[1] "identity"

$colors_scale$domain
NULL

$colors_scale$range
NULL

$opacities
data frame with 0 columns and 0 rows

$opacities_scale
$opacities_scale$attribute
NULL

$opacities_scale$scale
[1] "identity"

$opacities_scale$domain
NULL

$opacities_scale$range
NULL

$images
data frame with 0 columns and 0 rows

$images_scale
$images_scale$attribute
NULL

$images_scale$scale
[1] "identity"

$images_scale$domain
NULL

$images_scale$range
NULL

$shape
[1] "circle"

$attributes
list()

$start_activity
[1] 7

$end_activity
[1] 4

$duration
[1] 60

$timeline
[1] FALSE

$mode
[1] "off"

$initial_state
[1] "playing"

$initial_time
[1] 0

$repeat_count
[1] 1

$repeat_delay
[1] 0.5

$jitter
[1] 0

$factor
[1] 0

$legend
NULL

$timeline_start
[1] 0

$timeline_end
[1] 0

$onclick_token_callback
[1] "function(svg_root, svg_element, case_id) {\n}"
attr(,"class")
[1] "JS_EVAL"

$onclick_token_select
[1] "function(node, selected) {\n          if (selected) {\n            node.attr(\"stroke-width\", \"3\")\n                .attr(\"stroke\", \"black\");\n          } else {\n            node.attr(\"stroke-width\", \"1\")\n                .attr(\"stroke\", \"black\");\n          }\n        }"
attr(,"class")
[1] "JS_EVAL"

$onclick_activity_callback
[1] "function(svg_root, svg_element, activity_id) {\n}"
attr(,"class")
[1] "JS_EVAL"

$onclick_activity_select
[1] "function(node, selected) {\n            if (selected) {\n              node.attr(\"stroke-width\", \"2\")\n                  .attr(\"stroke-dasharray\", \"2\")\n                  .attr(\"stroke\", \"black\");\n            } else {\n              node.attr(\"stroke-width\", \"1\")\n                  .attr(\"stroke-dasharray\", \"0\")\n                  .attr(\"stroke\", \"#c0c0c0\");\n            }\n          }"
attr(,"class")
[1] "JS_EVAL"

$processmap_renderer
[1] "graph"
serkserk commented 5 years ago

I downloaded again the highlighted package (from the cran repo) which fixed the issue ( I was using the lastest version from github) Not sure which package was the issue, I will test them later

Thank you

fmannhardt commented 5 years ago

Sorry this is a regression I introduced when optimising the JS code to render tokens, which now fails when there are no tokens to render. Just fixed it in the latest commit.