rich-iannone / DiagrammeR

Graph and network visualization using tabular data in R
https://rich-iannone.github.io/DiagrammeR/
Other
1.68k stars 247 forks source link

Are the new features of gantt charts mermaid.js updated? #494

Closed corinabioinformatic closed 7 months ago

corinabioinformatic commented 11 months ago

Hello, I noticed there are several updates in mermaid.js when creating a gantt chart like:

Example:

WORKS FINE:

m0 <- mermaid("
                    gantt
                    dateFormat  YYYY-MM-DD 
                    title Gantt Chart - Project 
                    %% This is a comment

                    section Assured timeline
                    Time test :done, first_1, 2017-05-01, 2019-07-07

                    section Test1
                    robot1 (1230 plants) :done, first_1,  2018-05-15, 2018-07-30
                    robot2 (1003)           :done, first_1,  2018-06-15, 45d
                    robot3 (576)       :done, first_1,  2018-08-01, 2d
                    robot4 (576)       :done, first_1,  2018-08-02, 15d
                    boot5 (576)            :done, first_1,  2018-09-10, 2d

                    section Test2 (288)
                    A (223 77%)        :done, first_2,  2018-09-20, 2018-12-15
                    B                       :done, first_3,  2018-12-16, 2019-01-05
                    C                       :      first_3,  2019-06-01, 2019-06-15

                    section Test3 (288)
                    I                       :done, first_3,  2018-12-16, 2019-01-05
                    II                       :      first_3,  2019-06-01, 2019-06-15
                    III (263)            :      first_3,  2019-07-16, 2019-09-15
                    ")  %>% 
  style_widget("display:none", "line.today")

# make a copy so we can compare in a tag list later
m2 <- m0

m2$x$config = list(ganttConfig = list(
  # a little tricky setup in what is already a hack
  #  treat this like a filter function with filter as second component in array
  #  and the time formatter in the first
  #  more than likely you will want to know your scale
  axisFormatter = list(list(
    "%b,%Y" # date format to return; see d3 time formatting <-"%d %b,%Y"
    ,htmlwidgets::JS(
      'function(d){ return d.getMonth() }' # filter for Mondays or day of week = 1
    )
  ))
))

m2

DOES NOT WORK. When adding axisFormat line, or tickInterval line or First/Last milestone lines do now work (altough in the mermaid live version works fine (axisFormat workaround here).

m0 <- mermaid("
                    gantt
                    dateFormat  YYYY-MM-DD 
                    %% This is a comment
                    %% none of these work using DiagrammR---------------
                    axisFormat %d/%m
                    tickInterval 1day
                   Functionality added                 :milestone, 2014-01-25, 1d
                   %% ----------------------------------------------------------
                    title Gantt Chart - Project 

                    section Assured timeline
                    Time test :done, first_1, 2017-05-01, 2019-07-07

                    section Test1
                    robot1 (1230 plants) :done, first_1,  2018-05-15, 2018-07-30
                    robot2 (1003)           :done, first_1,  2018-06-15, 45d
                    robot3 (576)       :done, first_1,  2018-08-01, 2d
                    robot4 (576)       :done, first_1,  2018-08-02, 15d
                    boot5 (576)            :done, first_1,  2018-09-10, 2d

                    section Test2 (288)
                    A (223 77%)        :done, first_2,  2018-09-20, 2018-12-15
                    B                       :done, first_3,  2018-12-16, 2019-01-05
                    C                       :      first_3,  2019-06-01, 2019-06-15

                    section Test3 (288)
                    I                       :done, first_3,  2018-12-16, 2019-01-05
                    II                       :      first_3,  2019-06-01, 2019-06-15
                    III (263)            :      first_3,  2019-07-16, 2019-09-15
                    ")  

m0

In which file and folder at mermaid github project could i find this chunck of code to take a look and experiment with those functions too?

TenanATC commented 10 months ago

DiagrammeR is definitely using an older version of mermaid.js. I've tried 'hacking' the package to use an updated version to no avail. Since it's such a thin wrapper, I'd think this is a simple update but perhaps not? I'd be interested to hear from the DEVs. I'd also be happy to help with this update if they want to provide a baseline level of guidance.

For the time being, I've simply been going to https://mermaid.live/ and saving the code in an R script for posterity. It's not ideal, but it gets the job done.

olivroy commented 7 months ago

Duplicate of #475