GanttDiagram Class

A Gantt chart: tasks on a time axis, grouped in sections, which start at a date or after other tasks and last a duration or until another task (Mermaid gantt). The dates have no time zone; nothing depends on the current date, unless GanttDiagram.Today is set.

public sealed class GanttDiagram : Diagram
Inheritance
Diagram GanttDiagram

Constructors

NameDescription
GanttDiagram()

GanttDiagram()

GanttDiagram.cs
public GanttDiagram()

No documentation is available.

Properties

NameDescription
AxisFormatGets or sets the format of the dates of the axis, as the strftime of d3: %Y-%m-%d, %H:%M, %b %d..., or null for %Y-%m-%d.
BarGapGets or sets the space between two rows of tasks, in pixels. The default is 4.
BarHeightGets or sets the height of the bars of the tasks, in pixels. The default is 20.
CompactGets or sets a value that indicates whether the tasks of a section that do not overlap share a row (Mermaid displayMode: compact).
DateFormatGets or sets the format of the dates in Mermaid, as dayjs: YYYY-MM-DD (the default), HH:mm, X (Unix seconds)... See GanttDiagram.FormatDate.
ExcludesGets the days the tasks do not count, in lower case: weekends, the name of a day (friday), or a date in GanttDiagram.DateFormat or YYYY-MM-DD. A task that spans them is longer, unless it ends at a YYYY-MM-DD date.
HideTodayMarkerGets or sets a value that indicates whether the marker of today is hidden (Mermaid todayMarker off).
IncludesGets the dates that the tasks count even when GanttDiagram.Excludes excludes them.
InclusiveEndDatesGets or sets a value that indicates whether the end dates of the tasks are included: a task that ends on a date lasts until the end of that day.
LeftPaddingGets or sets the width of the column of the titles of the sections, on the left of the axis, in pixels. The default is 75.
SectionsGets the sections.
TasksGets the tasks that are in no section, drawn first.
TickIntervalGets or sets the interval between the ticks of the axis, or null to choose about ten ticks.
TodayGets or sets the date the marker of today is drawn at, or null for no marker. Mermaid draws it at the current date, which a Mermaid text does not set.
TodayMarkerStyleGets or sets the style of the line of the marker of today, or null for the theme.
TopAxisGets or sets a value that indicates whether the axis is drawn above the tasks too.
WeekStartGets or sets the first day of a week, where the ticks of a weekly GanttDiagram.TickInterval are. The default is DayOfWeek.Sunday.
WeekendStartGets or sets the first day of the weekend that weekends excludes: DayOfWeek.Saturday (the default) or DayOfWeek.Friday.
WidthGets or sets the width of the chart, in pixels (Mermaid useWidth). The default is 1200.

AxisFormat

GanttDiagram.cs

Gets or sets the format of the dates of the axis, as the strftime of d3: %Y-%m-%d, %H:%M, %b %d..., or null for %Y-%m-%d.

public string? AxisFormat { get; set; }

Property value

string?

Gets or sets the space between two rows of tasks, in pixels. The default is 4.

public double BarGap { get; set; }

Property value

double

Gets or sets the height of the bars of the tasks, in pixels. The default is 20.

public double BarHeight { get; set; }

Property value

double

Gets or sets a value that indicates whether the tasks of a section that do not overlap share a row (Mermaid displayMode: compact).

public bool Compact { get; set; }

Property value

bool

DateFormat

GanttDiagram.cs

Gets or sets the format of the dates in Mermaid, as dayjs: YYYY-MM-DD (the default), HH:mm, X (Unix seconds)... See GanttDiagram.FormatDate.

public string DateFormat { get; set; }

Property value

string

Exceptions

ArgumentException
The format is empty, or contains a comma, a semicolon, # or a line break.

Gets the days the tasks do not count, in lower case: weekends, the name of a day (friday), or a date in GanttDiagram.DateFormat or YYYY-MM-DD. A task that spans them is longer, unless it ends at a YYYY-MM-DD date.

public IList<string> Excludes { get; }

Property value

IList<string>

HideTodayMarker

GanttDiagram.cs

Gets or sets a value that indicates whether the marker of today is hidden (Mermaid todayMarker off).

public bool HideTodayMarker { get; set; }

Property value

bool

Gets the dates that the tasks count even when GanttDiagram.Excludes excludes them.

public IList<string> Includes { get; }

Property value

IList<string>

InclusiveEndDates

GanttDiagram.cs

Gets or sets a value that indicates whether the end dates of the tasks are included: a task that ends on a date lasts until the end of that day.

public bool InclusiveEndDates { get; set; }

Property value

bool

LeftPadding

GanttDiagram.cs

Gets or sets the width of the column of the titles of the sections, on the left of the axis, in pixels. The default is 75.

public double LeftPadding { get; set; }

Property value

double

Gets the sections.

public IList<GanttSection> Sections { get; }

Property value

IList<GanttSection>

Gets the tasks that are in no section, drawn first.

public IList<GanttTask> Tasks { get; }

Property value

IList<GanttTask>

TickInterval

GanttDiagram.cs

Gets or sets the interval between the ticks of the axis, or null to choose about ten ticks.

public GanttTickInterval? TickInterval { get; set; }

Property value

GanttTickInterval?

Gets or sets the date the marker of today is drawn at, or null for no marker. Mermaid draws it at the current date, which a Mermaid text does not set.

public DateTime? Today { get; set; }

Property value

DateTime?

TodayMarkerStyle

GanttDiagram.cs

Gets or sets the style of the line of the marker of today, or null for the theme.

public DiagramStyle? TodayMarkerStyle { get; set; }

Property value

DiagramStyle?

Gets or sets a value that indicates whether the axis is drawn above the tasks too.

public bool TopAxis { get; set; }

Property value

bool

Gets or sets the first day of a week, where the ticks of a weekly GanttDiagram.TickInterval are. The default is DayOfWeek.Sunday.

public DayOfWeek WeekStart { get; set; }

Property value

DayOfWeek

WeekendStart

GanttDiagram.cs

Gets or sets the first day of the weekend that weekends excludes: DayOfWeek.Saturday (the default) or DayOfWeek.Friday.

public DayOfWeek WeekendStart { get; set; }

Property value

DayOfWeek

Gets or sets the width of the chart, in pixels (Mermaid useWidth). The default is 1200.

public double Width { get; set; }

Property value

double

Methods

NameDescription
AddSection(DiagramText)Adds a section.
AddTask(DiagramText)Adds a task that is in no section.
EnumerateTasks()Enumerates the tasks, in order: those in no section, then those of the sections.
Find(string)Finds a task by identifier.
FormatDate(DateTime)Formats a date with GanttDiagram.DateFormat; when the text does not parse back to the same date (a format without the time, with a day of the week only, a literal after...), the date is formatted as ISO, 2014-01-06T10:30:00.000.
TryParseDate(string, DateTime)Parses a date with GanttDiagram.DateFormat, or as an ISO date (2014-01-06, 2014-01-06T10:30...).

AddSection(DiagramText)

GanttDiagram.cs

Adds a section.

public GanttSection AddSection(DiagramText title)

Parameters

title DiagramText
The title.

Returns

GanttSection The section.

AddTask(DiagramText)

GanttDiagram.cs

Adds a task that is in no section.

public GanttTask AddTask(DiagramText name)

Parameters

name DiagramText
The name.

Returns

GanttTask The task.

EnumerateTasks()

GanttDiagram.cs

Enumerates the tasks, in order: those in no section, then those of the sections.

public IEnumerable<GanttTask> EnumerateTasks()

Returns

IEnumerable<GanttTask> The tasks.

Find(string)

GanttDiagram.cs

Finds a task by identifier.

public GanttTask? Find(string id)

Parameters

id string
The identifier.

Returns

GanttTask? The last task with this identifier, as Mermaid, or null when there is none.

FormatDate(DateTime)

GanttDiagram.cs

Formats a date with GanttDiagram.DateFormat; when the text does not parse back to the same date (a format without the time, with a day of the week only, a literal after...), the date is formatted as ISO, 2014-01-06T10:30:00.000.

public string FormatDate(DateTime date)

Parameters

date DateTime
The date.

Returns

string The text.

TryParseDate(string, DateTime)

GanttDiagram.cs

Parses a date with GanttDiagram.DateFormat, or as an ISO date (2014-01-06, 2014-01-06T10:30...).

public bool TryParseDate(string text, out DateTime date)

Parameters

text string
The text.
date DateTime
The date, when the method returns true.

Returns

bool true when the text is a date.