Function Repository Resource:

ProjectDataGanttChart

Source Notebook

Create Gantt charts for datasets with project data

Contributed by: Anton Antonov

ResourceFunction["ProjectDataGanttChart"][ds]

plots a Gantt chart for a project dataset ds.

Details and Options

ResourceFunction["ProjectDataGanttChart"] takes all options of TimelinePlot.
ResourceFunction["ProjectDataGanttChart"] expects datasets with column names "Group","Project","StartDate","EndDate".
If the column "Group" is not provided, then the column "Group" is added with all of its values being a generic group name.
If the column "Project" is not provided, then the column "Project" is added, populated with generic project names. 
If ResourceFunction["ProjectDataGanttChart"] is given a numerical matrix with two columns, then that matrix is transformed into a dataset with columns "StartDate" and "EndDate".

Examples

Basic Examples (2) 

Create a Gantt chart from a Dataset:

In[1]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/883f741e-f7bc-4609-b291-415a15c84c27"]
Out[1]=

Here is a dataset with project data:

In[2]:=
SeedRandom[7];
dsData = ResourceFunction[
    "RandomTabularDataset"][{6, {"Group", "Project", "StartDate", "EndDate"}},
   "Generators" -> {
     "Group " <> ToString[#] & /@ Range[3],
     RandomWord,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &
     }];
dsData = dsData[All, If[#StartDate > #EndDate, Join[#, <|"StartDate" -> #EndDate, "EndDate" -> #StartDate|>], #] &];
dsData[SortBy[{#Group, #StartDate, #EndDate} &]]
Out[3]=

Here is the Gantt chart:

In[4]:=
ResourceFunction["ProjectDataGanttChart"][dsData]
Out[4]=

Scope (4) 

Create data without groups:

In[5]:=
SeedRandom[1];
dsData = ResourceFunction[
    "RandomTabularDataset"][{4, {"Project", "StartDate", "EndDate"}},
   "Generators" -> {
     RandomWord,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &
     }];
dsData = Sort@dsData[All, If[#StartDate > #EndDate, Join[#, <|"StartDate" -> #EndDate, "EndDate" -> #StartDate|>], #] &]
Out[7]=

Make the Gantt chart:

In[8]:=
ResourceFunction["ProjectDataGanttChart"][dsData]
Out[8]=

Create data without projects:

In[9]:=
SeedRandom[66];
dsData = ResourceFunction[
    "RandomTabularDataset"][{4, {"Group", "StartDate", "EndDate"}},
   "Generators" -> {
     RandomWord[2],
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &
     }];
dsData = Sort@dsData[All, If[#StartDate > #EndDate, Join[#, <|"StartDate" -> #EndDate, "EndDate" -> #StartDate|>], #] &]
Out[11]=

Make the Gantt chart:

In[12]:=
ResourceFunction["ProjectDataGanttChart"][dsData]
Out[12]=

Create data that only includes start and end dates:

In[13]:=
SeedRandom[46];
dsData = ResourceFunction[
    "RandomTabularDataset"][{4, {"StartDate", "EndDate"}},
   "Generators" -> {
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &
     }];
dsData = Sort@dsData[All, If[#StartDate > #EndDate, Join[#, <|"StartDate" -> #EndDate, "EndDate" -> #StartDate|>], #] &]
Out[15]=

Make the Gantt chart:

In[16]:=
ResourceFunction["ProjectDataGanttChart"][dsData]
Out[16]=

Make a random matrix with two columns and plot the Gantt chart for it:

In[17]:=
SeedRandom[33];
ResourceFunction["ProjectDataGanttChart"][
 RandomReal[{0, 100}, {12, 2}]]
Out[18]=

Options (1) 

ProjectDataGanttChart takes all the options of TimelinePlot:

In[19]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/100de267-cb1f-4af3-8c81-48724c5f5c60"]
Out[19]=

Applications (3) 

Here is a dataset with data for 64 projects:

In[20]:=
SeedRandom[32];
dsData = ResourceFunction[
    "RandomTabularDataset"][{64, {"Group", "Project", "StartDate", "EndDate"}},
   "Generators" -> {
     "Group " <> ToString[#] & /@ Range[8],
     RandomWord,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &,
     DateObject[DateList[#][[1 ;; 3]]] & /@ ResourceFunction["RandomDate"][#] &
     }];
dsData = dsData[All, If[#StartDate > #EndDate, Join[#, <|"StartDate" -> #EndDate, "EndDate" -> #StartDate|>], #] &];
dsData[SortBy[{#Group, #StartDate, #EndDate} &]];

See a sample of the data:

In[21]:=
SeedRandom[90];
RandomSample[dsData, 12]
Out[22]=

Here is the corresponding Gantt chart:

In[23]:=
ResourceFunction["ProjectDataGanttChart"][dsData, ImageSize -> 1000, AspectRatio -> 1, PlotStyle -> Directive[{Thickness[0.01], CapForm["Butt"]}]]
Out[23]=

Publisher

Anton Antonov

Version History

  • 1.0.0 – 20 May 2022

Source Metadata

Related Resources

License Information