collab/mermaid/docs/syntax/gantt.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/gantt.md](../../packages/mermaid/src/docs/syntax/gantt.md).
6dd74de6
6dd74de7# Gantt diagrams
6dd74de8
6dd74de9> A Gantt chart is a type of bar chart, first developed by Karol Adamiecki in 1896, and independently by Henry Gantt in the 1910s, that illustrates a project schedule and the amount of time it would take for any one project to finish. Gantt charts illustrate number of days between the start and finish dates of the terminal elements and summary elements of a project.
6dd74de10
6dd74de11## A note to users
6dd74de12
6dd74de13Gantt Charts will record each scheduled task as one continuous bar that extends from the left to the right. The x axis represents time and the y records the different tasks and the order in which they are to be completed.
6dd74de14
6dd74de15It is important to remember that when a date, day, or collection of dates specific to a task are "excluded", the Gantt Chart will accommodate those changes by extending an equal number of days, towards the right, not by creating a gap inside the task.
6dd74de16As shown here ![](./img/Gantt-excluded-days-within.png)
6dd74de17
6dd74de18However, if the excluded dates are between two tasks that are set to start consecutively, the excluded dates will be skipped graphically and left blank, and the following task will begin after the end of the excluded dates.
6dd74de19As shown here ![](./img/Gantt-long-weekend-look.png)
6dd74de20
6dd74de21A Gantt chart is useful for tracking the amount of time it would take before a project is finished, but it can also be used to graphically represent "non-working days", with a few tweaks.
6dd74de22
6dd74de23Mermaid can render Gantt diagrams as SVG, PNG or a MarkDown link that can be pasted into docs.
6dd74de24
6dd74de25```mermaid-example
6dd74de26gantt
6dd74de27 title A Gantt Diagram
6dd74de28 dateFormat YYYY-MM-DD
6dd74de29 section Section
6dd74de30 A task :a1, 2014-01-01, 30d
6dd74de31 Another task :after a1, 20d
6dd74de32 section Another
6dd74de33 Task in Another :2014-01-12, 12d
6dd74de34 another task :24d
6dd74de35```
6dd74de36
6dd74de37```mermaid
6dd74de38gantt
6dd74de39 title A Gantt Diagram
6dd74de40 dateFormat YYYY-MM-DD
6dd74de41 section Section
6dd74de42 A task :a1, 2014-01-01, 30d
6dd74de43 Another task :after a1, 20d
6dd74de44 section Another
6dd74de45 Task in Another :2014-01-12, 12d
6dd74de46 another task :24d
6dd74de47```
6dd74de48
6dd74de49## Syntax
6dd74de50
6dd74de51```mermaid-example
6dd74de52gantt
6dd74de53 dateFormat YYYY-MM-DD
6dd74de54 title Adding GANTT diagram functionality to mermaid
6dd74de55 excludes weekends
6dd74de56 %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)
6dd74de57
6dd74de58 section A section
6dd74de59 Completed task :done, des1, 2014-01-06,2014-01-08
6dd74de60 Active task :active, des2, 2014-01-09, 3d
6dd74de61 Future task : des3, after des2, 5d
6dd74de62 Future task2 : des4, after des3, 5d
6dd74de63
6dd74de64 section Critical tasks
6dd74de65 Completed task in the critical line :crit, done, 2014-01-06,24h
6dd74de66 Implement parser and jison :crit, done, after des1, 2d
6dd74de67 Create tests for parser :crit, active, 3d
6dd74de68 Future task in critical line :crit, 5d
6dd74de69 Create tests for renderer :2d
6dd74de70 Add to mermaid :until isadded
6dd74de71 Functionality added :milestone, isadded, 2014-01-25, 0d
6dd74de72
6dd74de73 section Documentation
6dd74de74 Describe gantt syntax :active, a1, after des1, 3d
6dd74de75 Add gantt diagram to demo page :after a1 , 20h
6dd74de76 Add another diagram to demo page :doc1, after a1 , 48h
6dd74de77
6dd74de78 section Last section
6dd74de79 Describe gantt syntax :after doc1, 3d
6dd74de80 Add gantt diagram to demo page :20h
6dd74de81 Add another diagram to demo page :48h
6dd74de82```
6dd74de83
6dd74de84```mermaid
6dd74de85gantt
6dd74de86 dateFormat YYYY-MM-DD
6dd74de87 title Adding GANTT diagram functionality to mermaid
6dd74de88 excludes weekends
6dd74de89 %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)
6dd74de90
6dd74de91 section A section
6dd74de92 Completed task :done, des1, 2014-01-06,2014-01-08
6dd74de93 Active task :active, des2, 2014-01-09, 3d
6dd74de94 Future task : des3, after des2, 5d
6dd74de95 Future task2 : des4, after des3, 5d
6dd74de96
6dd74de97 section Critical tasks
6dd74de98 Completed task in the critical line :crit, done, 2014-01-06,24h
6dd74de99 Implement parser and jison :crit, done, after des1, 2d
6dd74de100 Create tests for parser :crit, active, 3d
6dd74de101 Future task in critical line :crit, 5d
6dd74de102 Create tests for renderer :2d
6dd74de103 Add to mermaid :until isadded
6dd74de104 Functionality added :milestone, isadded, 2014-01-25, 0d
6dd74de105
6dd74de106 section Documentation
6dd74de107 Describe gantt syntax :active, a1, after des1, 3d
6dd74de108 Add gantt diagram to demo page :after a1 , 20h
6dd74de109 Add another diagram to demo page :doc1, after a1 , 48h
6dd74de110
6dd74de111 section Last section
6dd74de112 Describe gantt syntax :after doc1, 3d
6dd74de113 Add gantt diagram to demo page :20h
6dd74de114 Add another diagram to demo page :48h
6dd74de115```
6dd74de116
6dd74de117Tasks are by default sequential. A task start date defaults to the end date of the preceding task.
6dd74de118
6dd74de119A colon, `:`, separates the task title from its metadata.
6dd74de120Metadata items are separated by a comma, `,`. Valid tags are `active`, `done`, `crit`, and `milestone`. Tags are optional, but if used, they must be specified first.
6dd74de121After processing the tags, the remaining metadata items are interpreted as follows:
6dd74de122
6dd74de1231. If a single item is specified, it determines when the task ends. It can either be a specific date/time or a duration. If a duration is specified, it is added to the start date of the task to determine the end date of the task, taking into account any exclusions.
6dd74de1242. If two items are specified, the last item is interpreted as in the previous case. The first item can either specify an explicit start date/time (in the format specified by `dateFormat`) or reference another task using `after <otherTaskID> [[otherTaskID2 [otherTaskID3]]...]`. In the latter case, the start date of the task will be set according to the latest end date of any referenced task.
6dd74de1253. If three items are specified, the last two will be interpreted as in the previous case. The first item will denote the ID of the task, which can be referenced using the `later <taskID>` syntax.
6dd74de126
6dd74de127| Metadata syntax | Start date | End date | ID |
6dd74de128| ---------------------------------------------------- | --------------------------------------------------- | ----------------------------------------------------- | -------- |
6dd74de129| `<taskID>, <startDate>, <endDate>` | `startdate` as interpreted using `dateformat` | `endDate` as interpreted using `dateformat` | `taskID` |
6dd74de130| `<taskID>, <startDate>, <length>` | `startdate` as interpreted using `dateformat` | Start date + `length` | `taskID` |
6dd74de131| `<taskID>, after <otherTaskId>, <endDate>` | End date of previously specified task `otherTaskID` | `endDate` as interpreted using `dateformat` | `taskID` |
6dd74de132| `<taskID>, after <otherTaskId>, <length>` | End date of previously specified task `otherTaskID` | Start date + `length` | `taskID` |
6dd74de133| `<taskID>, <startDate>, until <otherTaskId>` | `startdate` as interpreted using `dateformat` | Start date of previously specified task `otherTaskID` | `taskID` |
6dd74de134| `<taskID>, after <otherTaskId>, until <otherTaskId>` | End date of previously specified task `otherTaskID` | Start date of previously specified task `otherTaskID` | `taskID` |
6dd74de135| `<startDate>, <endDate>` | `startdate` as interpreted using `dateformat` | `enddate` as interpreted using `dateformat` | n/a |
6dd74de136| `<startDate>, <length>` | `startdate` as interpreted using `dateformat` | Start date + `length` | n/a |
6dd74de137| `after <otherTaskID>, <endDate>` | End date of previously specified task `otherTaskID` | `enddate` as interpreted using `dateformat` | n/a |
6dd74de138| `after <otherTaskID>, <length>` | End date of previously specified task `otherTaskID` | Start date + `length` | n/a |
6dd74de139| `<startDate>, until <otherTaskId>` | `startdate` as interpreted using `dateformat` | Start date of previously specified task `otherTaskID` | n/a |
6dd74de140| `after <otherTaskId>, until <otherTaskId>` | End date of previously specified task `otherTaskID` | Start date of previously specified task `otherTaskID` | n/a |
6dd74de141| `<endDate>` | End date of preceding task | `enddate` as interpreted using `dateformat` | n/a |
6dd74de142| `<length>` | End date of preceding task | Start date + `length` | n/a |
6dd74de143| `until <otherTaskId>` | End date of preceding task | Start date of previously specified task `otherTaskID` | n/a |
6dd74de144
6dd74de145> **Note**
6dd74de146> Support for keyword `until` was added in (v10.9.0+). This can be used to define a task which is running until some other specific task or milestone starts.
6dd74de147
6dd74de148For simplicity, the table does not show the use of multiple tasks listed with the `after` keyword. Here is an example of how to use it and how it's interpreted:
6dd74de149
6dd74de150```mermaid-example
6dd74de151gantt
6dd74de152 apple :a, 2017-07-20, 1w
6dd74de153 banana :crit, b, 2017-07-23, 1d
6dd74de154 cherry :active, c, after b a, 1d
6dd74de155 kiwi :d, 2017-07-20, until b c
6dd74de156```
6dd74de157
6dd74de158```mermaid
6dd74de159gantt
6dd74de160 apple :a, 2017-07-20, 1w
6dd74de161 banana :crit, b, 2017-07-23, 1d
6dd74de162 cherry :active, c, after b a, 1d
6dd74de163 kiwi :d, 2017-07-20, until b c
6dd74de164```
6dd74de165
6dd74de166### Title
6dd74de167
6dd74de168The `title` is an _optional_ string to be displayed at the top of the Gantt chart to describe the chart as a whole.
6dd74de169
6dd74de170### Excludes
6dd74de171
6dd74de172The `excludes` is an _optional_ attribute that accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".
6dd74de173These date will be marked on the graph, and be excluded from the duration calculation of tasks. Meaning that if there are excluded dates during a task interval, the number of 'skipped' days will be added to the end of the task to ensure the duration is as specified in the code.
6dd74de174
6dd74de175#### Weekend (v\11.0.0+)
6dd74de176
6dd74de177When excluding weekends, it is possible to configure the weekends to be either Friday and Saturday or Saturday and Sunday. By default weekends are Saturday and Sunday.
6dd74de178To define the weekend start day, there is an _optional_ attribute `weekend` that can be added in a new line followed by either `friday` or `saturday`.
6dd74de179
6dd74de180```mermaid-example
6dd74de181gantt
6dd74de182 title A Gantt Diagram Excluding Fri - Sat weekends
6dd74de183 dateFormat YYYY-MM-DD
6dd74de184 excludes weekends
6dd74de185 weekend friday
6dd74de186 section Section
6dd74de187 A task :a1, 2024-01-01, 30d
6dd74de188 Another task :after a1, 20d
6dd74de189```
6dd74de190
6dd74de191```mermaid
6dd74de192gantt
6dd74de193 title A Gantt Diagram Excluding Fri - Sat weekends
6dd74de194 dateFormat YYYY-MM-DD
6dd74de195 excludes weekends
6dd74de196 weekend friday
6dd74de197 section Section
6dd74de198 A task :a1, 2024-01-01, 30d
6dd74de199 Another task :after a1, 20d
6dd74de200```
6dd74de201
6dd74de202### Section statements
6dd74de203
6dd74de204You can divide the chart into various sections, for example to separate different parts of a project like development and documentation.
6dd74de205
6dd74de206To do so, start a line with the `section` keyword and give it a name. (Note that unlike with the [title for the entire chart](#title), this name is _required_.
6dd74de207
6dd74de208### Milestones
6dd74de209
6dd74de210You can add milestones to the diagrams. Milestones differ from tasks as they represent a single instant in time and are identified by the keyword `milestone`. Below is an example on how to use milestones. As you may notice, the exact location of the milestone is determined by the initial date for the milestone and the "duration" of the task this way: _initial date_+_duration_/2.
6dd74de211
6dd74de212```mermaid-example
6dd74de213gantt
6dd74de214 dateFormat HH:mm
6dd74de215 axisFormat %H:%M
6dd74de216 Initial milestone : milestone, m1, 17:49, 2m
6dd74de217 Task A : 10m
6dd74de218 Task B : 5m
6dd74de219 Final milestone : milestone, m2, 18:08, 4m
6dd74de220```
6dd74de221
6dd74de222```mermaid
6dd74de223gantt
6dd74de224 dateFormat HH:mm
6dd74de225 axisFormat %H:%M
6dd74de226 Initial milestone : milestone, m1, 17:49, 2m
6dd74de227 Task A : 10m
6dd74de228 Task B : 5m
6dd74de229 Final milestone : milestone, m2, 18:08, 4m
6dd74de230```
6dd74de231
6dd74de232### Vertical Markers
6dd74de233
6dd74de234The `vert` keyword lets you add vertical lines to your Gantt chart, making it easy to highlight important dates like deadlines, events, or checkpoints. These markers extend across the entire chart and are positioned based on the date you provide. Unlike milestones, vertical markers don’t take up a row. They’re purely visual reference points that help break up the timeline and make important moments easier to spot.
6dd74de235
6dd74de236```mermaid-example
6dd74de237gantt
6dd74de238 dateFormat HH:mm
6dd74de239 axisFormat %H:%M
6dd74de240 Initial vert : vert, v1, 17:30, 2m
6dd74de241 Task A : 3m
6dd74de242 Task B : 8m
6dd74de243 Final vert : vert, v2, 17:58, 4m
6dd74de244```
6dd74de245
6dd74de246```mermaid
6dd74de247gantt
6dd74de248 dateFormat HH:mm
6dd74de249 axisFormat %H:%M
6dd74de250 Initial vert : vert, v1, 17:30, 2m
6dd74de251 Task A : 3m
6dd74de252 Task B : 8m
6dd74de253 Final vert : vert, v2, 17:58, 4m
6dd74de254```
6dd74de255
6dd74de256## Setting dates
6dd74de257
6dd74de258`dateFormat` defines the format of the date **input** of your gantt elements. How these dates are represented in the rendered chart **output** are defined by `axisFormat`.
6dd74de259
6dd74de260### Input date format
6dd74de261
6dd74de262The default input date format is `YYYY-MM-DD`. You can define your custom `dateFormat`.
6dd74de263
6dd74de264```markdown
6dd74de265dateFormat YYYY-MM-DD
6dd74de266```
6dd74de267
6dd74de268The following formatting options are supported:
6dd74de269
6dd74de270| Input | Example | Description |
6dd74de271| ---------- | -------------- | ------------------------------------------------------ |
6dd74de272| `YYYY` | 2014 | 4 digit year |
6dd74de273| `YY` | 14 | 2 digit year |
6dd74de274| `Q` | 1..4 | Quarter of year. Sets month to first month in quarter. |
6dd74de275| `M MM` | 1..12 | Month number |
6dd74de276| `MMM MMMM` | January..Dec | Month name in locale set by `dayjs.locale()` |
6dd74de277| `D DD` | 1..31 | Day of month |
6dd74de278| `Do` | 1st..31st | Day of month with ordinal |
6dd74de279| `DDD DDDD` | 1..365 | Day of year |
6dd74de280| `X` | 1410715640.579 | Unix timestamp |
6dd74de281| `x` | 1410715640579 | Unix ms timestamp |
6dd74de282| `H HH` | 0..23 | 24 hour time |
6dd74de283| `h hh` | 1..12 | 12 hour time used with `a A`. |
6dd74de284| `a A` | am pm | Post or ante meridiem |
6dd74de285| `m mm` | 0..59 | Minutes |
6dd74de286| `s ss` | 0..59 | Seconds |
6dd74de287| `S` | 0..9 | Tenths of a second |
6dd74de288| `SS` | 0..99 | Hundreds of a second |
6dd74de289| `SSS` | 0..999 | Thousandths of a second |
6dd74de290| `Z ZZ` | +12:00 | Offset from UTC as +-HH:mm, +-HHmm, or Z |
6dd74de291
6dd74de292More info in: <https://day.js.org/docs/en/parse/string-format/>
6dd74de293
6dd74de294### Output date format on the axis
6dd74de295
6dd74de296The default output date format is `YYYY-MM-DD`. You can define your custom `axisFormat`, like `2020-Q1` for the first quarter of the year 2020.
6dd74de297
6dd74de298```markdown
6dd74de299axisFormat %Y-%m-%d
6dd74de300```
6dd74de301
6dd74de302The following formatting strings are supported:
6dd74de303
6dd74de304| Format | Definition |
6dd74de305| ------ | ------------------------------------------------------------------------------------------ |
6dd74de306| %a | abbreviated weekday name |
6dd74de307| %A | full weekday name |
6dd74de308| %b | abbreviated month name |
6dd74de309| %B | full month name |
6dd74de310| %c | date and time, as "%a %b %e %H:%M:%S %Y" |
6dd74de311| %d | zero-padded day of the month as a decimal number \[01,31] |
6dd74de312| %e | space-padded day of the month as a decimal number \[ 1,31]; equivalent to %\_d |
6dd74de313| %H | hour (24-hour clock) as a decimal number \[00,23] |
6dd74de314| %I | hour (12-hour clock) as a decimal number \[01,12] |
6dd74de315| %j | day of the year as a decimal number \[001,366] |
6dd74de316| %m | month as a decimal number \[01,12] |
6dd74de317| %M | minute as a decimal number \[00,59] |
6dd74de318| %L | milliseconds as a decimal number \[000, 999] |
6dd74de319| %p | either AM or PM |
6dd74de320| %S | second as a decimal number \[00,61] |
6dd74de321| %U | week number of the year (Sunday as the first day of the week) as a decimal number \[00,53] |
6dd74de322| %w | weekday as a decimal number \[0(Sunday),6] |
6dd74de323| %W | week number of the year (Monday as the first day of the week) as a decimal number \[00,53] |
6dd74de324| %x | date, as "%m/%d/%Y" |
6dd74de325| %X | time, as "%H:%M:%S" |
6dd74de326| %y | year without century as a decimal number \[00,99] |
6dd74de327| %Y | year with century as a decimal number |
6dd74de328| %Z | time zone offset, such as "-0700" |
6dd74de329| %% | a literal "%" character |
6dd74de330
6dd74de331More info in: <https://github.com/d3/d3-time-format/tree/v4.0.0#locale_format>
6dd74de332
6dd74de333### Axis ticks (v10.3.0+)
6dd74de334
6dd74de335The default output ticks are auto. You can custom your `tickInterval`, like `1day` or `1week`.
6dd74de336
6dd74de337```markdown
6dd74de338tickInterval 1day
6dd74de339```
6dd74de340
6dd74de341The pattern is:
6dd74de342
6dd74de343```javascript
6dd74de344/^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/;
6dd74de345```
6dd74de346
6dd74de347More info in: <https://github.com/d3/d3-time#interval_every>
6dd74de348
6dd74de349Week-based `tickInterval`s start the week on sunday by default. If you wish to specify another weekday on which the `tickInterval` should start, use the `weekday` option:
6dd74de350
6dd74de351```mermaid-example
6dd74de352gantt
6dd74de353 tickInterval 1week
6dd74de354 weekday monday
6dd74de355```
6dd74de356
6dd74de357```mermaid
6dd74de358gantt
6dd74de359 tickInterval 1week
6dd74de360 weekday monday
6dd74de361```
6dd74de362
6dd74de363> **Warning**
6dd74de364> `millisecond` and `second` support was added in v10.3.0
6dd74de365
6dd74de366## Output in compact mode
6dd74de367
6dd74de368The compact mode allows you to display multiple tasks in the same row. Compact mode can be enabled for a gantt chart by setting the display mode of the graph via preceding YAML settings.
6dd74de369
6dd74de370```mermaid-example
6dd74de371---
6dd74de372displayMode: compact
6dd74de373---
6dd74de374gantt
6dd74de375 title A Gantt Diagram
6dd74de376 dateFormat YYYY-MM-DD
6dd74de377
6dd74de378 section Section
6dd74de379 A task :a1, 2014-01-01, 30d
6dd74de380 Another task :a2, 2014-01-20, 25d
6dd74de381 Another one :a3, 2014-02-10, 20d
6dd74de382```
6dd74de383
6dd74de384```mermaid
6dd74de385---
6dd74de386displayMode: compact
6dd74de387---
6dd74de388gantt
6dd74de389 title A Gantt Diagram
6dd74de390 dateFormat YYYY-MM-DD
6dd74de391
6dd74de392 section Section
6dd74de393 A task :a1, 2014-01-01, 30d
6dd74de394 Another task :a2, 2014-01-20, 25d
6dd74de395 Another one :a3, 2014-02-10, 20d
6dd74de396```
6dd74de397
6dd74de398## Comments
6dd74de399
6dd74de400Comments can be entered within a gantt chart, which will be ignored by the parser. Comments need to be on their own line and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax.
6dd74de401
6dd74de402```mermaid-example
6dd74de403gantt
6dd74de404 title A Gantt Diagram
6dd74de405 %% This is a comment
6dd74de406 dateFormat YYYY-MM-DD
6dd74de407 section Section
6dd74de408 A task :a1, 2014-01-01, 30d
6dd74de409 Another task :after a1, 20d
6dd74de410 section Another
6dd74de411 Task in Another :2014-01-12, 12d
6dd74de412 another task :24d
6dd74de413```
6dd74de414
6dd74de415```mermaid
6dd74de416gantt
6dd74de417 title A Gantt Diagram
6dd74de418 %% This is a comment
6dd74de419 dateFormat YYYY-MM-DD
6dd74de420 section Section
6dd74de421 A task :a1, 2014-01-01, 30d
6dd74de422 Another task :after a1, 20d
6dd74de423 section Another
6dd74de424 Task in Another :2014-01-12, 12d
6dd74de425 another task :24d
6dd74de426```
6dd74de427
6dd74de428## Styling
6dd74de429
6dd74de430Styling of the Gantt diagram is done by defining a number of CSS classes. During rendering, these classes are extracted from the file located at src/diagrams/gantt/styles.js
6dd74de431
6dd74de432### Classes used
6dd74de433
6dd74de434| Class | Description |
6dd74de435| --------------------- | ---------------------------------------------------------------------- |
6dd74de436| grid.tick | Styling for the Grid Lines |
6dd74de437| grid.path | Styling for the Grid's borders |
6dd74de438| .taskText | Task Text Styling |
6dd74de439| .taskTextOutsideRight | Styling for Task Text that exceeds the activity bar towards the right. |
6dd74de440| .taskTextOutsideLeft | Styling for Task Text that exceeds the activity bar, towards the left. |
6dd74de441| todayMarker | Toggle and Styling for the "Today Marker" |
6dd74de442
6dd74de443### Sample stylesheet
6dd74de444
6dd74de445```css
6dd74de446.grid .tick {
6dd74de447 stroke: lightgrey;
6dd74de448 opacity: 0.3;
6dd74de449 shape-rendering: crispEdges;
6dd74de450}
6dd74de451.grid path {
6dd74de452 stroke-width: 0;
6dd74de453}
6dd74de454
6dd74de455#tag {
6dd74de456 color: white;
6dd74de457 background: #fa283d;
6dd74de458 width: 150px;
6dd74de459 position: absolute;
6dd74de460 display: none;
6dd74de461 padding: 3px 6px;
6dd74de462 margin-left: -80px;
6dd74de463 font-size: 11px;
6dd74de464}
6dd74de465
6dd74de466#tag:before {
6dd74de467 border: solid transparent;
6dd74de468 content: ' ';
6dd74de469 height: 0;
6dd74de470 left: 50%;
6dd74de471 margin-left: -5px;
6dd74de472 position: absolute;
6dd74de473 width: 0;
6dd74de474 border-width: 10px;
6dd74de475 border-bottom-color: #fa283d;
6dd74de476 top: -20px;
6dd74de477}
6dd74de478.taskText {
6dd74de479 fill: white;
6dd74de480 text-anchor: middle;
6dd74de481}
6dd74de482.taskTextOutsideRight {
6dd74de483 fill: black;
6dd74de484 text-anchor: start;
6dd74de485}
6dd74de486.taskTextOutsideLeft {
6dd74de487 fill: black;
6dd74de488 text-anchor: end;
6dd74de489}
6dd74de490```
6dd74de491
6dd74de492## Today marker
6dd74de493
6dd74de494You can style or hide the marker for the current date. To style it, add a value for the `todayMarker` key.
6dd74de495
6dd74de496```
6dd74de497todayMarker stroke-width:5px,stroke:#0f0,opacity:0.5
6dd74de498```
6dd74de499
6dd74de500To hide the marker, set `todayMarker` to `off`.
6dd74de501
6dd74de502```
6dd74de503todayMarker off
6dd74de504```
6dd74de505
6dd74de506## Configuration
6dd74de507
6dd74de508It is possible to adjust the margins for rendering the gantt diagram.
6dd74de509
6dd74de510This is done by defining the `ganttConfig` part of the configuration object.
6dd74de511How to use the CLI is described in the [mermaidCLI](../config/mermaidCLI.md) page.
6dd74de512
6dd74de513mermaid.ganttConfig can be set to a JSON string with config parameters or the corresponding object.
6dd74de514
6dd74de515```javascript
6dd74de516mermaid.ganttConfig = {
6dd74de517 titleTopMargin: 25, // Margin top for the text over the diagram
6dd74de518 barHeight: 20, // The height of the bars in the graph
6dd74de519 barGap: 4, // The margin between the different activities in the gantt diagram
6dd74de520 topPadding: 75, // Margin between title and gantt diagram and between axis and gantt diagram.
6dd74de521 rightPadding: 75, // The space allocated for the section name to the right of the activities
6dd74de522 leftPadding: 75, // The space allocated for the section name to the left of the activities
6dd74de523 gridLineStartPadding: 10, // Vertical starting position of the grid lines
6dd74de524 fontSize: 12, // Font size
6dd74de525 sectionFontSize: 24, // Font size for sections
6dd74de526 numberSectionStyles: 1, // The number of alternating section styles
6dd74de527 axisFormat: '%d/%m', // Date/time format of the axis
6dd74de528 tickInterval: '1week', // Axis ticks
6dd74de529 topAxis: true, // When this flag is set, date labels will be added to the top of the chart
6dd74de530 displayMode: 'compact', // Turns compact mode on
6dd74de531 weekday: 'sunday', // On which day a week-based interval should start
6dd74de532};
6dd74de533```
6dd74de534
6dd74de535### Possible configuration params:
6dd74de536
6dd74de537| Param | Description | Default value |
6dd74de538| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
6dd74de539| mirrorActor | Turns on/off the rendering of actors below the diagram as well as above it | false |
6dd74de540| bottomMarginAdj | Adjusts how far down the graph ended. Wide borders styles with css could generate unwanted clipping which is why this config param exists. | 1 |
6dd74de541
6dd74de542## Interaction
6dd74de543
6dd74de544It is possible to bind a click event to a task. The click can lead to either a javascript callback or to a link which will be opened in the current browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
6dd74de545
6dd74de546```
6dd74de547click taskId call callback(arguments)
6dd74de548click taskId href URL
6dd74de549```
6dd74de550
6dd74de551- taskId is the id of the task
6dd74de552- callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the taskId as the parameter if no other arguments are specified.
6dd74de553
6dd74de554Beginner's tip—a full example using interactive links in an HTML context:
6dd74de555
6dd74de556```html
6dd74de557<body>
6dd74de558 <pre class="mermaid">
6dd74de559 gantt
6dd74de560 dateFormat YYYY-MM-DD
6dd74de561
6dd74de562 section Clickable
6dd74de563 Visit mermaidjs :active, cl1, 2014-01-07, 3d
6dd74de564 Print arguments :cl2, after cl1, 3d
6dd74de565 Print task :cl3, after cl2, 3d
6dd74de566
6dd74de567 click cl1 href "https://mermaidjs.github.io/"
6dd74de568 click cl2 call printArguments("test1", "test2", test3)
6dd74de569 click cl3 call printTask()
6dd74de570 </pre>
6dd74de571
6dd74de572 <script>
6dd74de573 const printArguments = function (arg1, arg2, arg3) {
6dd74de574 alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3);
6dd74de575 };
6dd74de576 const printTask = function (taskId) {
6dd74de577 alert('taskId: ' + taskId);
6dd74de578 };
6dd74de579 const config = {
6dd74de580 startOnLoad: true,
6dd74de581 securityLevel: 'loose',
6dd74de582 };
6dd74de583 mermaid.initialize(config);
6dd74de584 </script>
6dd74de585</body>
6dd74de586```
6dd74de587
6dd74de588## Examples
6dd74de589
6dd74de590### Bar chart (using gantt chart)
6dd74de591
6dd74de592```mermaid-example
6dd74de593gantt
6dd74de594 title Git Issues - days since last update
6dd74de595 dateFormat X
6dd74de596 axisFormat %s
6dd74de597 section Issue19062
6dd74de598 71 : 0, 71
6dd74de599 section Issue19401
6dd74de600 36 : 0, 36
6dd74de601 section Issue193
6dd74de602 34 : 0, 34
6dd74de603 section Issue7441
6dd74de604 9 : 0, 9
6dd74de605 section Issue1300
6dd74de606 5 : 0, 5
6dd74de607```
6dd74de608
6dd74de609```mermaid
6dd74de610gantt
6dd74de611 title Git Issues - days since last update
6dd74de612 dateFormat X
6dd74de613 axisFormat %s
6dd74de614 section Issue19062
6dd74de615 71 : 0, 71
6dd74de616 section Issue19401
6dd74de617 36 : 0, 36
6dd74de618 section Issue193
6dd74de619 34 : 0, 34
6dd74de620 section Issue7441
6dd74de621 9 : 0, 9
6dd74de622 section Issue1300
6dd74de623 5 : 0, 5
6dd74de624```
6dd74de625
6dd74de626### Timeline (with comments, CSS, config in frontmatter)
6dd74de627
6dd74de628```mermaid-example
6dd74de629---
6dd74de630 # Frontmatter config, YAML comments
6dd74de631 title: Ignored if specified in chart
6dd74de632 displayMode: compact #gantt specific setting but works at this level too
6dd74de633 config:
6dd74de634# theme: forest
6dd74de635# themeCSS: " #item36 { fill: CadetBlue } "
6dd74de636 themeCSS: " // YAML supports multiline strings using a newline markers: \n
6dd74de637 #item36 { fill: CadetBlue } \n
6dd74de638
6dd74de639 // Custom marker workaround CSS from forum (below) \n
6dd74de640 rect[id^=workaround] { height: calc(100% - 50px) ; transform: translate(9px, 25px); y: 0; width: 1.5px; stroke: none; fill: red; } \n
6dd74de641 text[id^=workaround] { fill: red; y: 100%; font-size: 15px;}
6dd74de642 "
6dd74de643 gantt:
6dd74de644 useWidth: 400
6dd74de645 rightPadding: 0
6dd74de646 topAxis: true #false
6dd74de647 numberSectionStyles: 2
6dd74de648---
6dd74de649gantt
6dd74de650 title Timeline - Gantt Sampler
6dd74de651 dateFormat YYYY
6dd74de652 axisFormat %y
6dd74de653 %% this next line doesn't recognise 'decade' or 'year', but will silently ignore
6dd74de654 tickInterval 1decade
6dd74de655
6dd74de656 section Issue19062
6dd74de657 71 : item71, 1900, 1930
6dd74de658 section Issue19401
6dd74de659 36 : item36, 1913, 1935
6dd74de660 section Issue1300
6dd74de661 94 : item94, 1910, 1915
6dd74de662 5 : item5, 1920, 1925
6dd74de663 0 : milestone, item0, 1918, 1s
6dd74de664 9 : vert, 1906, 1s %% not yet official
6dd74de665 64 : workaround, 1923, 1s %% custom CSS object https://github.com/mermaid-js/mermaid/issues/3250
6dd74de666```
6dd74de667
6dd74de668```mermaid
6dd74de669---
6dd74de670 # Frontmatter config, YAML comments
6dd74de671 title: Ignored if specified in chart
6dd74de672 displayMode: compact #gantt specific setting but works at this level too
6dd74de673 config:
6dd74de674# theme: forest
6dd74de675# themeCSS: " #item36 { fill: CadetBlue } "
6dd74de676 themeCSS: " // YAML supports multiline strings using a newline markers: \n
6dd74de677 #item36 { fill: CadetBlue } \n
6dd74de678
6dd74de679 // Custom marker workaround CSS from forum (below) \n
6dd74de680 rect[id^=workaround] { height: calc(100% - 50px) ; transform: translate(9px, 25px); y: 0; width: 1.5px; stroke: none; fill: red; } \n
6dd74de681 text[id^=workaround] { fill: red; y: 100%; font-size: 15px;}
6dd74de682 "
6dd74de683 gantt:
6dd74de684 useWidth: 400
6dd74de685 rightPadding: 0
6dd74de686 topAxis: true #false
6dd74de687 numberSectionStyles: 2
6dd74de688---
6dd74de689gantt
6dd74de690 title Timeline - Gantt Sampler
6dd74de691 dateFormat YYYY
6dd74de692 axisFormat %y
6dd74de693 %% this next line doesn't recognise 'decade' or 'year', but will silently ignore
6dd74de694 tickInterval 1decade
6dd74de695
6dd74de696 section Issue19062
6dd74de697 71 : item71, 1900, 1930
6dd74de698 section Issue19401
6dd74de699 36 : item36, 1913, 1935
6dd74de700 section Issue1300
6dd74de701 94 : item94, 1910, 1915
6dd74de702 5 : item5, 1920, 1925
6dd74de703 0 : milestone, item0, 1918, 1s
6dd74de704 9 : vert, 1906, 1s %% not yet official
6dd74de705 64 : workaround, 1923, 1s %% custom CSS object https://github.com/mermaid-js/mermaid/issues/3250
6dd74de706```
6dd74de707
6dd74de708<!--- cspell:ignore isadded --->