Charts
gantt-chart
Tasks as bars along a time axis, one row each, under optional group headings: how far each has got, which must finish before another starts (arrows), milestones as diamonds and a line for today, with Up and Down reading each task.
When to use it
Planning or reporting work over time: a project plan, a release schedule, a timeline of events with lengths. For events without length use timeline (a list) or a line-chart annotation; for a calendar of single days use calendar or calendar-heatmap.
See it working
The demonstration the browser checks drive, with the keyboard as well as the pointer. More of it is on the Charts page.
Scatter and bubble
- Tea
- Coffee
- Cocoa
| name | Price | Rating | Sold | kind |
|---|---|---|---|---|
| Blend 1 | 6.2 | 3.1 | 626 | Tea |
| Blend 32 | 6.4 | 4.9 | 540 | Coffee |
| Blend 15 | 7.6 | 4.5 | 261 | Cocoa |
| Blend 23 | 8.1 | 4.1 | 429 | Coffee |
| Blend 9 | 8.8 | 3.6 | 369 | Cocoa |
| Blend 35 | 11 | 5 | 430 | Coffee |
| Blend 7 | 11.3 | 5 | 189 | Tea |
| Blend 31 | 11.6 | 3.5 | 46 | Tea |
| Blend 18 | 12.4 | 3.3 | 120 | Cocoa |
| Blend 14 | 12.4 | 3.9 | 52 | Coffee |
| Blend 6 | 12.6 | 3.6 | 361 | Cocoa |
| Blend 16 | 13.7 | 3.9 | 608 | Tea |
| Blend 3 | 14.4 | 3.5 | 372 | Cocoa |
| Blend 27 | 15.3 | 3.7 | 475 | Cocoa |
| Blend 28 | 15.9 | 4.5 | 626 | Tea |
| Blend 26 | 15.9 | 4.6 | 43 | Coffee |
| Blend 11 | 16 | 4.2 | 448 | Coffee |
| Blend 29 | 16 | 4.6 | 298 | Coffee |
| Blend 34 | 16.7 | 4.4 | 637 | Tea |
| Blend 25 | 16.7 | 4.9 | 621 | Tea |
| Blend 33 | 17.4 | 3 | 411 | Cocoa |
| Blend 20 | 17.4 | 3.7 | 66 | Coffee |
| Blend 30 | 17.6 | 4.5 | 371 | Cocoa |
| Blend 21 | 18.3 | 4.8 | 369 | Cocoa |
| Blend 2 | 18.6 | 4 | 283 | Coffee |
| Blend 17 | 18.7 | 4.4 | 238 | Coffee |
| Blend 4 | 19.1 | 3.5 | 134 | Tea |
| Blend 10 | 19.7 | 3.1 | 588 | Tea |
| Blend 5 | 19.8 | 4 | 158 | Coffee |
| Blend 36 | 20.5 | 4.2 | 538 | Cocoa |
| Blend 13 | 20.9 | 3.1 | 145 | Tea |
| Blend 22 | 20.9 | 4.3 | 592 | Tea |
| Blend 8 | 21.8 | 3.4 | 126 | Coffee |
| Blend 24 | 22 | 4.9 | 543 | Cocoa |
| Blend 19 | 22.4 | 3.6 | 154 | Tea |
| Blend 12 | 23.4 | 4.2 | 593 | Cocoa |
Histogram
| Minutes | Count |
|---|---|
| 14 – 16 | 1 |
| 16 – 18 | 2 |
| 18 – 20 | 3 |
| 20 – 22 | 3 |
| 22 – 24 | 5 |
| 24 – 26 | 20 |
| 26 – 28 | 25 |
| 28 – 30 | 23 |
| 30 – 32 | 25 |
| 32 – 34 | 28 |
| 34 – 36 | 34 |
| 36 – 38 | 22 |
| 38 – 40 | 17 |
| 40 – 42 | 18 |
| 42 – 44 | 7 |
| 44 – 46 | 6 |
| 46 – 48 | 0 |
| 48 – 50 | 1 |
Box plot and violin
| region (Milliseconds) | Count | Lowest | First quartile | Median | Third quartile | Highest | Outliers |
|---|---|---|---|---|---|---|---|
| North | 41 | 89 | 112 | 119 | 128 | 144 | 260 |
| South | 40 | 109 | 132 | 144.5 | 152.25 | 174 | |
| East | 41 | 136 | 157 | 172 | 185 | 200 | 330 |
| West | 40 | 140 | 171.5 | 191.5 | 212.25 | 234 |
| region (ms) | Count | Lowest | First quartile | Median | Third quartile | Highest | Outliers |
|---|---|---|---|---|---|---|---|
| North | 41 | 89 | 112 | 119 | 128 | 144 | 260 |
| South | 40 | 109 | 132 | 144.5 | 152.25 | 174 | |
| East | 41 | 136 | 157 | 172 | 185 | 200 | 330 |
| West | 40 | 140 | 171.5 | 191.5 | 212.25 | 234 |
Fan chart
- Observed
- Forecast (median)
- 90% interval
- 50% interval
| Week | Observed | Forecast (median) | 90% interval | 50% interval |
|---|---|---|---|---|
| 1 | 108 | |||
| 2 | 111 | |||
| 3 | 110 | |||
| 4 | 107 | |||
| 5 | 109 | |||
| 6 | 116 | |||
| 7 | 125 | |||
| 8 | 130 | |||
| 9 | 129 | |||
| 10 | 127 | |||
| 11 | 127 | |||
| 12 | 133 | |||
| 13 | 142 | |||
| 14 | 148 | 142 | 142 – 142 | 142 – 142 |
| 15 | 144.6 | 139.1 – 150.6 | 142 – 147.4 | |
| 16 | 147.2 | 136.2 – 159.2 | 142 – 152.8 | |
| 17 | 149.8 | 133.3 – 167.8 | 142 – 158.2 | |
| 18 | 152.4 | 130.4 – 176.4 | 142 – 163.6 | |
| 19 | 155 | 127.5 – 185 | 142 – 169 | |
| 20 | 157.6 | 124.6 – 193.6 | 142 – 174.4 | |
| 21 | 160.2 | 121.7 – 202.2 | 142 – 179.8 | |
| 22 | 162.8 | 118.8 – 210.8 | 142 – 185.2 | |
| 23 | 165.4 | 115.9 – 219.4 | 142 – 190.6 | |
| 24 | 168 | 113 – 228 | 142 – 196 |
Small multiples
- North
- South
- East
- West
- Centre
- Coast
| region | Month | Visits |
|---|---|---|
| North | 1 | 46 |
| North | 2 | 51 |
| North | 3 | 52 |
| North | 4 | 50 |
| North | 5 | 45 |
| North | 6 | 38 |
| North | 7 | 31 |
| North | 8 | 25 |
| North | 9 | 21 |
| North | 10 | 21 |
| North | 11 | 24 |
| North | 12 | 29 |
| South | 1 | 59 |
| South | 2 | 63 |
| South | 3 | 63 |
| South | 4 | 60 |
| South | 5 | 55 |
| South | 6 | 50 |
| South | 7 | 46 |
| South | 8 | 44 |
| South | 9 | 46 |
| South | 10 | 51 |
| South | 11 | 59 |
| South | 12 | 67 |
| East | 1 | 65 |
| East | 2 | 64 |
| East | 3 | 59 |
| East | 4 | 52 |
| East | 5 | 44 |
| East | 6 | 38 |
| East | 7 | 34 |
| East | 8 | 34 |
| East | 9 | 37 |
| East | 10 | 42 |
| East | 11 | 48 |
| East | 12 | 54 |
| West | 1 | 72 |
| West | 2 | 69 |
| West | 3 | 64 |
| West | 4 | 59 |
| West | 5 | 55 |
| West | 6 | 53 |
| West | 7 | 55 |
| West | 8 | 60 |
| West | 9 | 68 |
| West | 10 | 76 |
| West | 11 | 84 |
| West | 12 | 89 |
| Centre | 1 | 72 |
| Centre | 2 | 65 |
| Centre | 3 | 57 |
| Centre | 4 | 51 |
| Centre | 5 | 47 |
| Centre | 6 | 47 |
| Centre | 7 | 50 |
| Centre | 8 | 55 |
| Centre | 9 | 62 |
| Centre | 10 | 67 |
| Centre | 11 | 71 |
| Centre | 12 | 71 |
| Coast | 1 | 73 |
| Coast | 2 | 68 |
| Coast | 3 | 64 |
| Coast | 4 | 62 |
| Coast | 5 | 64 |
| Coast | 6 | 69 |
| Coast | 7 | 77 |
| Coast | 8 | 85 |
| Coast | 9 | 93 |
| Coast | 10 | 98 |
| Coast | 11 | 100 |
| Coast | 12 | 99 |
Bars to 100 percent
- Web
- App
- Shop
| quarter | Web | App | Shop |
|---|---|---|---|
| Q1 | 320 (49.2%) | 210 (32.3%) | 120 (18.5%) |
| Q2 | 360 (48.6%) | 270 (36.5%) | 110 (14.9%) |
| Q3 | 400 (48.2%) | 330 (39.8%) | 100 (12%) |
| Q4 | 440 (47.8%) | 390 (42.4%) | 90 (9.8%) |
Treemap
| Part | Value | Share |
|---|---|---|
| Housing / Rent | 1,200 | 43.6% |
| Housing / Power | 140 | 5.1% |
| Housing / Water | 60 | 2.2% |
| Housing / Repairs | 90 | 3.3% |
| Food / Groceries | 420 | 15.3% |
| Food / Cafés | 90 | 3.3% |
| Food / Takeaway | 70 | 2.5% |
| Travel / Transit pass | 110 | 4% |
| Travel / Bike | 30 | 1.1% |
| Travel / Trains | 120 | 4.4% |
| Leisure / Books | 40 | 1.5% |
| Leisure / Music | 25 | 0.9% |
| Leisure / Sport | 55 | 2% |
| Savings | 300 | 10.9% |
Top
Sunburst
| Part | Value | Share |
|---|---|---|
| Housing / Rent | 1,200 | 43.6% |
| Housing / Power | 140 | 5.1% |
| Housing / Water | 60 | 2.2% |
| Housing / Repairs | 90 | 3.3% |
| Food / Groceries | 420 | 15.3% |
| Food / Cafés | 90 | 3.3% |
| Food / Takeaway | 70 | 2.5% |
| Travel / Transit pass | 110 | 4% |
| Travel / Bike | 30 | 1.1% |
| Travel / Trains | 120 | 4.4% |
| Leisure / Books | 40 | 1.5% |
| Leisure / Music | 25 | 0.9% |
| Leisure / Sport | 55 | 2% |
| Savings | 300 | 10.9% |
- Housing54.2%
- Food21.1%
- Travel9.5%
- Leisure4.4%
- Savings10.9%
Circle packing
| Part | Value | Share |
|---|---|---|
| Housing / Rent | 1,200 | 43.6% |
| Housing / Power | 140 | 5.1% |
| Housing / Water | 60 | 2.2% |
| Housing / Repairs | 90 | 3.3% |
| Food / Groceries | 420 | 15.3% |
| Food / Cafés | 90 | 3.3% |
| Food / Takeaway | 70 | 2.5% |
| Travel / Transit pass | 110 | 4% |
| Travel / Bike | 30 | 1.1% |
| Travel / Trains | 120 | 4.4% |
| Leisure / Books | 40 | 1.5% |
| Leisure / Music | 25 | 0.9% |
| Leisure / Sport | 55 | 2% |
| Savings | 300 | 10.9% |
Sankey
| From | To | Amount |
|---|---|---|
| Salary | Budget | 2,400 |
| Freelance | Budget | 600 |
| Budget | Rent | 1,200 |
| Budget | Food | 600 |
| Budget | Travel | 300 |
| Budget | Saved | 900 |
Network graph
- App
- Library
- Tool
| Node | Group | Linked to |
|---|---|---|
| App | App | Ui, Charts, Maps, Forms, Three, Tests |
| Ui | Library | App, Theme, Icons, Motion, Forms |
| Charts | Library | App, Maths, Theme |
| Maps | Library | App, Maths, Theme |
| Maths | Library | Charts, Maps |
| Motion | Library | Ui, Theme |
| Three | Tool | Theme, App |
| Theme | Tool | Ui, Charts, Maps, Motion, Three |
| Icons | Tool | Ui |
| Dates | Tool | Forms |
| Forms | Tool | App, Ui, Dates |
| Tests | Tool | App |
Calendar heatmap
| day | Workouts |
|---|---|
| 2026-01-01 | 4 |
| 2026-01-02 | 8 |
| 2026-01-03 | 2 |
| 2026-01-04 | 2 |
| 2026-01-08 | 9 |
| 2026-01-09 | 5 |
| 2026-01-13 | 8 |
| 2026-01-15 | 11 |
| 2026-01-17 | 2 |
| 2026-01-18 | 4 |
| 2026-01-19 | 6 |
| 2026-01-21 | 10 |
| 2026-01-23 | 7 |
| 2026-01-24 | 3 |
| 2026-01-25 | 3 |
| 2026-01-26 | 8 |
| 2026-01-27 | 7 |
| 2026-01-29 | 10 |
| 2026-01-30 | 9 |
| 2026-02-01 | 3 |
| 2026-02-02 | 11 |
| 2026-02-03 | 4 |
| 2026-02-04 | 7 |
| 2026-02-05 | 8 |
| 2026-02-06 | 7 |
| 2026-02-08 | 2 |
| 2026-02-09 | 6 |
| 2026-02-11 | 4 |
| 2026-02-12 | 6 |
| 2026-02-13 | 6 |
| 2026-02-14 | 2 |
| 2026-02-15 | 2 |
| 2026-02-16 | 7 |
| 2026-02-21 | 4 |
| 2026-02-22 | 4 |
| 2026-02-25 | 11 |
| 2026-02-26 | 4 |
| 2026-02-27 | 5 |
| 2026-03-02 | 7 |
| 2026-03-03 | 6 |
| 2026-03-04 | 4 |
| 2026-03-05 | 10 |
| 2026-03-06 | 11 |
| 2026-03-08 | 3 |
| 2026-03-11 | 6 |
| 2026-03-13 | 6 |
| 2026-03-16 | 6 |
| 2026-03-18 | 8 |
| 2026-03-20 | 4 |
| 2026-03-21 | 2 |
| 2026-03-23 | 12 |
| 2026-03-24 | 12 |
| 2026-03-25 | 9 |
| 2026-03-27 | 10 |
| 2026-03-28 | 1 |
| 2026-03-29 | 3 |
| 2026-03-30 | 6 |
| 2026-04-01 | 5 |
| 2026-04-02 | 9 |
| 2026-04-03 | 5 |
| 2026-04-04 | 3 |
| 2026-04-06 | 5 |
| 2026-04-07 | 9 |
| 2026-04-09 | 10 |
| 2026-04-10 | 9 |
| 2026-04-13 | 6 |
| 2026-04-14 | 10 |
| 2026-04-16 | 11 |
| 2026-04-17 | 10 |
| 2026-04-19 | 4 |
| 2026-04-21 | 5 |
| 2026-04-23 | 6 |
| 2026-04-25 | 2 |
| 2026-04-26 | 2 |
| 2026-04-28 | 12 |
| 2026-04-29 | 5 |
| 2026-04-30 | 9 |
| 2026-05-03 | 1 |
| 2026-05-04 | 12 |
| 2026-05-05 | 8 |
| 2026-05-07 | 5 |
| 2026-05-08 | 8 |
| 2026-05-10 | 4 |
| 2026-05-12 | 5 |
| 2026-05-13 | 5 |
| 2026-05-15 | 8 |
| 2026-05-16 | 3 |
| 2026-05-17 | 2 |
| 2026-05-18 | 11 |
| 2026-05-20 | 9 |
| 2026-05-21 | 8 |
| 2026-05-22 | 4 |
| 2026-05-23 | 2 |
| 2026-05-28 | 7 |
| 2026-05-29 | 10 |
| 2026-05-31 | 2 |
| 2026-06-02 | 10 |
| 2026-06-05 | 4 |
| 2026-06-06 | 3 |
| 2026-06-07 | 2 |
| 2026-06-08 | 8 |
| 2026-06-11 | 5 |
| 2026-06-12 | 4 |
| 2026-06-13 | 3 |
| 2026-06-14 | 1 |
| 2026-06-15 | 11 |
| 2026-06-16 | 4 |
| 2026-06-19 | 7 |
| 2026-06-22 | 4 |
| 2026-06-23 | 9 |
| 2026-06-24 | 5 |
| 2026-06-25 | 7 |
| 2026-06-28 | 2 |
| 2026-06-29 | 5 |
| 2026-06-30 | 10 |
Gantt chart
| Task | Group | Start | End | Done | After |
|---|---|---|---|---|---|
| Research | Product | Mar 2, 2026 | Mar 10, 2026 | 100% | |
| Design | Product | Mar 9, 2026 | Mar 20, 2026 | 100% | Research |
| Build | Product | Mar 16, 2026 | Apr 10, 2026 | 45% | Design |
| Test | Product | Apr 6, 2026 | Apr 17, 2026 | 0% | Build |
| Write the story | Marketing | Mar 23, 2026 | Apr 3, 2026 | 60% | |
| Update the site | Marketing | Apr 6, 2026 | Apr 14, 2026 | 0% | Write the story |
| Launch | Marketing | Apr 20, 2026 | Milestone | Test, Update the site |
Density
| # | Distance (km) | Fare |
|---|---|---|
| 1 | 1.4 | 3.9 |
| 2 | 1.5 | 4.1 |
| 3 | 1.5 | 5.5 |
| 4 | 1.5 | 5.9 |
| 5 | 1.6 | 4.2 |
| 6 | 1.6 | 6.2 |
| 7 | 1.6 | 6.9 |
| 8 | 1.7 | 4.3 |
| 9 | 1.7 | 6.1 |
| 10 | 1.7 | 6.3 |
| 11 | 1.7 | 7.2 |
| 12 | 1.7 | 7.7 |
| 13 | 1.8 | 5.9 |
| 14 | 1.8 | 6.1 |
| 15 | 1.8 | 6.4 |
| 16 | 1.8 | 6.5 |
| 17 | 1.8 | 7 |
| 18 | 1.9 | 5.5 |
| 19 | 1.9 | 7.5 |
| 20 | 2 | 5.5 |
| 21 | 2 | 7.8 |
| 22 | 2.1 | 4.4 |
| 23 | 2.1 | 4.9 |
| 24 | 2.1 | 6.6 |
| 25 | 2.1 | 7 |
| 26 | 2.1 | 7.5 |
| 27 | 2.1 | 7.8 |
| 28 | 2.1 | 8 |
| 29 | 2.1 | 8.6 |
| 30 | 2.2 | 5.4 |
| 31 | 2.2 | 7 |
| 32 | 2.2 | 7.5 |
| 33 | 2.2 | 7.6 |
| 34 | 2.2 | 7.8 |
| 35 | 2.2 | 7.8 |
| 36 | 2.2 | 7.9 |
| 37 | 2.2 | 8 |
| 38 | 2.2 | 8.1 |
| 39 | 2.2 | 8.2 |
| 40 | 2.2 | 8.7 |
| 41 | 2.2 | 8.9 |
| 42 | 2.3 | 6 |
| 43 | 2.3 | 6.7 |
| 44 | 2.3 | 7 |
| 45 | 2.3 | 7.8 |
| 46 | 2.3 | 8.2 |
| 47 | 2.3 | 8.2 |
| 48 | 2.3 | 8.5 |
| 49 | 2.3 | 9 |
| 50 | 2.4 | 6.7 |
| 51 | 2.4 | 6.8 |
| 52 | 2.4 | 7.7 |
| 53 | 2.4 | 8 |
| 54 | 2.4 | 8.1 |
| 55 | 2.4 | 8.2 |
| 56 | 2.4 | 9.3 |
| 57 | 2.5 | 5.6 |
| 58 | 2.5 | 5.8 |
| 59 | 2.5 | 6.7 |
| 60 | 2.5 | 7 |
| 61 | 2.5 | 7.3 |
| 62 | 2.5 | 7.5 |
| 63 | 2.5 | 8.1 |
| 64 | 2.5 | 8.3 |
| 65 | 2.5 | 8.5 |
| 66 | 2.5 | 8.5 |
| 67 | 2.5 | 10.8 |
| 68 | 2.5 | 10.9 |
| 69 | 2.6 | 7.3 |
| 70 | 2.6 | 7.8 |
| 71 | 2.6 | 7.9 |
| 72 | 2.6 | 8 |
| 73 | 2.6 | 8.2 |
| 74 | 2.6 | 9.6 |
| 75 | 2.6 | 9.7 |
| 76 | 2.6 | 9.9 |
| 77 | 2.6 | 10.6 |
| 78 | 2.7 | 7.8 |
| 79 | 2.7 | 8.4 |
| 80 | 2.7 | 8.5 |
| 81 | 2.7 | 9.1 |
| 82 | 2.8 | 6.4 |
| 83 | 2.8 | 7 |
| 84 | 2.8 | 7.2 |
| 85 | 2.8 | 7.5 |
| 86 | 2.8 | 7.7 |
| 87 | 2.8 | 8 |
| 88 | 2.8 | 8.4 |
| 89 | 2.8 | 8.6 |
| 90 | 2.8 | 9.3 |
| 91 | 2.8 | 9.6 |
| 92 | 2.8 | 9.6 |
| 93 | 2.8 | 9.7 |
| 94 | 2.8 | 9.8 |
| 95 | 2.8 | 9.9 |
| 96 | 2.8 | 10.4 |
| 97 | 2.9 | 8.1 |
| 98 | 2.9 | 8.4 |
| 99 | 2.9 | 8.7 |
| 100 | 2.9 | 8.7 |
| 101 | 2.9 | 8.9 |
| 102 | 2.9 | 9.2 |
| 103 | 2.9 | 9.3 |
| 104 | 2.9 | 9.5 |
| 105 | 2.9 | 9.7 |
| 106 | 2.9 | 9.7 |
| 107 | 2.9 | 9.8 |
| 108 | 2.9 | 9.9 |
| 109 | 3 | 8.1 |
| 110 | 3 | 8.4 |
| 111 | 3 | 8.6 |
| 112 | 3 | 9.7 |
| 113 | 3 | 9.9 |
| 114 | 3 | 10.2 |
| 115 | 3 | 10.9 |
| 116 | 3.1 | 7.9 |
| 117 | 3.1 | 8.4 |
| 118 | 3.1 | 8.8 |
| 119 | 3.1 | 8.8 |
| 120 | 3.1 | 9 |
| 121 | 3.1 | 9.4 |
| 122 | 3.1 | 9.4 |
| 123 | 3.1 | 10.1 |
| 124 | 3.1 | 10.2 |
| 125 | 3.1 | 10.3 |
| 126 | 3.1 | 10.3 |
| 127 | 3.1 | 10.3 |
| 128 | 3.2 | 7.7 |
| 129 | 3.2 | 8.8 |
| 130 | 3.2 | 8.9 |
| 131 | 3.2 | 9.3 |
| 132 | 3.2 | 9.4 |
| 133 | 3.2 | 9.5 |
| 134 | 3.2 | 9.5 |
| 135 | 3.2 | 9.5 |
| 136 | 3.2 | 9.5 |
| 137 | 3.2 | 9.6 |
| 138 | 3.2 | 9.9 |
| 139 | 3.2 | 9.9 |
| 140 | 3.2 | 10.1 |
| 141 | 3.2 | 10.4 |
| 142 | 3.2 | 11.1 |
| 143 | 3.2 | 11.4 |
| 144 | 3.2 | 11.5 |
| 145 | 3.3 | 9 |
| 146 | 3.3 | 9.1 |
| 147 | 3.3 | 9.8 |
| 148 | 3.3 | 10 |
| 149 | 3.3 | 10 |
| 150 | 3.3 | 10.3 |
| 151 | 3.3 | 10.3 |
| 152 | 3.3 | 10.4 |
| 153 | 3.3 | 10.5 |
| 154 | 3.3 | 10.6 |
| 155 | 3.3 | 11 |
| 156 | 3.3 | 11.2 |
| 157 | 3.3 | 11.5 |
| 158 | 3.4 | 9.5 |
| 159 | 3.4 | 10.5 |
| 160 | 3.4 | 11.1 |
| 161 | 3.4 | 11.2 |
| 162 | 3.4 | 11.3 |
| 163 | 3.4 | 11.6 |
| 164 | 3.5 | 9.1 |
| 165 | 3.5 | 9.3 |
| 166 | 3.5 | 10.1 |
| 167 | 3.5 | 11.5 |
| 168 | 3.6 | 8.3 |
| 169 | 3.6 | 10.7 |
| 170 | 3.6 | 10.9 |
| 171 | 3.6 | 11.9 |
| 172 | 3.7 | 8.8 |
| 173 | 3.7 | 9.2 |
| 174 | 3.7 | 9.3 |
| 175 | 3.7 | 9.6 |
| 176 | 3.7 | 10.6 |
| 177 | 3.7 | 11 |
| 178 | 3.7 | 11.1 |
| 179 | 3.7 | 11.3 |
| 180 | 3.7 | 12 |
| 181 | 3.7 | 12.4 |
| 182 | 3.7 | 12.7 |
| 183 | 3.8 | 10.6 |
| 184 | 3.8 | 11 |
| 185 | 3.8 | 11.1 |
| 186 | 3.8 | 11.5 |
| 187 | 3.8 | 11.5 |
| 188 | 3.8 | 11.7 |
| 189 | 3.8 | 12.1 |
| 190 | 3.8 | 12.1 |
| 191 | 3.8 | 13.3 |
| 192 | 3.8 | 13.5 |
| 193 | 3.9 | 9.1 |
| 194 | 3.9 | 9.2 |
| 195 | 3.9 | 9.9 |
| 196 | 3.9 | 10 |
| 197 | 3.9 | 11.5 |
| 198 | 3.9 | 11.6 |
| 199 | 4 | 9.8 |
| 200 | 4 | 10.7 |
| 201 | 4 | 11.6 |
| 202 | 4 | 12.1 |
| 203 | 4.1 | 9.7 |
| 204 | 4.1 | 11.5 |
| 205 | 4.1 | 11.9 |
| 206 | 4.2 | 10.1 |
| 207 | 4.2 | 10.9 |
| 208 | 4.2 | 11.4 |
| 209 | 4.2 | 11.6 |
| 210 | 4.2 | 11.9 |
| 211 | 4.2 | 13.9 |
| 212 | 4.4 | 11 |
| 213 | 4.4 | 12.3 |
| 214 | 4.5 | 12.1 |
| 215 | 4.6 | 12.2 |
| 216 | 4.6 | 13.5 |
| 217 | 4.7 | 11.4 |
| 218 | 4.7 | 12.9 |
| 219 | 4.9 | 12.4 |
| 220 | 5 | 15.1 |
| 221 | 8 | 19.6 |
| 222 | 8.5 | 20 |
| 223 | 8.6 | 21.4 |
| 224 | 8.6 | 22.7 |
| 225 | 8.9 | 22.4 |
| 226 | 9 | 21.3 |
| 227 | 9.3 | 20 |
| 228 | 9.4 | 22 |
| 229 | 9.7 | 22.4 |
| 230 | 9.7 | 22.7 |
| 231 | 9.8 | 22.9 |
| 232 | 9.8 | 24.1 |
| 233 | 9.8 | 24.2 |
| 234 | 9.9 | 23.9 |
| 235 | 9.9 | 24.4 |
| 236 | 9.9 | 24.6 |
| 237 | 9.9 | 25.3 |
| 238 | 10 | 23.7 |
| 239 | 10.1 | 23.2 |
| 240 | 10.1 | 23.2 |
| 241 | 10.2 | 22.5 |
| 242 | 10.3 | 24.3 |
| 243 | 10.3 | 24.3 |
| 244 | 10.3 | 24.5 |
| 245 | 10.5 | 24.4 |
| 246 | 10.8 | 26 |
| 247 | 10.9 | 25.5 |
| 248 | 10.9 | 25.7 |
| 249 | 11 | 24.6 |
| 250 | 11 | 27 |
| 251 | 11 | 27.7 |
| 252 | 11.1 | 24.5 |
| 253 | 11.1 | 24.9 |
| 254 | 11.1 | 25.6 |
| 255 | 11.1 | 25.9 |
| 256 | 11.1 | 26 |
| 257 | 11.1 | 26.8 |
| 258 | 11.2 | 26.4 |
| 259 | 11.2 | 26.6 |
| 260 | 11.2 | 26.8 |
| 261 | 11.3 | 25.5 |
| 262 | 11.3 | 25.8 |
| 263 | 11.3 | 27.4 |
| 264 | 11.4 | 25.2 |
| 265 | 11.4 | 27.3 |
| 266 | 11.4 | 28.1 |
| 267 | 11.4 | 28.1 |
| 268 | 11.5 | 25.8 |
| 269 | 11.5 | 26.3 |
| 270 | 11.5 | 27.4 |
| 271 | 11.6 | 28.6 |
| 272 | 11.6 | 28.9 |
| 273 | 11.7 | 26.5 |
| 274 | 11.7 | 26.6 |
| 275 | 11.7 | 27.5 |
| 276 | 11.7 | 28 |
| 277 | 11.8 | 27 |
| 278 | 11.8 | 27.1 |
| 279 | 11.9 | 25.6 |
| 280 | 11.9 | 26.3 |
| 281 | 11.9 | 27.7 |
| 282 | 11.9 | 29 |
| 283 | 12 | 27.2 |
| 284 | 12 | 27.3 |
| 285 | 12 | 28.7 |
| 286 | 12 | 29.2 |
| 287 | 12 | 30.1 |
| 288 | 12.1 | 29.8 |
| 289 | 12.1 | 30 |
| 290 | 12.2 | 27.2 |
| 291 | 12.2 | 27.4 |
| 292 | 12.3 | 28.1 |
| 293 | 12.3 | 29 |
| 294 | 12.4 | 29.4 |
| 295 | 12.5 | 27.1 |
| 296 | 12.5 | 29.1 |
| 297 | 12.5 | 30.5 |
| 298 | 12.6 | 28.3 |
| 299 | 12.6 | 29.2 |
| 300 | 12.7 | 28.6 |
| 301 | 12.8 | 29.3 |
| 302 | 12.8 | 29.5 |
| 303 | 12.9 | 28.8 |
| 304 | 12.9 | 28.8 |
| 305 | 12.9 | 29.8 |
| 306 | 12.9 | 30.1 |
| 307 | 12.9 | 31.1 |
| 308 | 12.9 | 32.3 |
| 309 | 13 | 30.2 |
| 310 | 13 | 31.2 |
| 311 | 13 | 31.9 |
| 312 | 13 | 32.4 |
| 313 | 13.1 | 29.5 |
| 314 | 13.1 | 31.9 |
| 315 | 13.2 | 30.7 |
| 316 | 13.2 | 31 |
| 317 | 13.3 | 29.6 |
| 318 | 13.3 | 30.6 |
| 319 | 13.3 | 32.1 |
| 320 | 13.3 | 32.6 |
| 321 | 13.5 | 30.5 |
| 322 | 13.5 | 31.8 |
| 323 | 13.6 | 29.9 |
| 324 | 13.6 | 31.8 |
| 325 | 13.7 | 30.6 |
| 326 | 13.7 | 31.1 |
| 327 | 13.7 | 32.4 |
| 328 | 13.8 | 32.7 |
| 329 | 13.9 | 32.4 |
| 330 | 14 | 32.8 |
| 331 | 14 | 34.7 |
| 332 | 14.1 | 31.1 |
| 333 | 14.1 | 33.7 |
| 334 | 14.2 | 31.7 |
| 335 | 14.2 | 33.4 |
| 336 | 14.4 | 32.7 |
| 337 | 14.8 | 33.6 |
| 338 | 14.9 | 32.6 |
| 339 | 14.9 | 35.4 |
| 340 | 15.1 | 34.5 |
Radar
- Basic
- Plus
- Pro
| measure | Basic | Plus | Pro |
|---|---|---|---|
| Speed | 3 | 4 | 5 |
| Storage | 2 | 4 | 5 |
| Support | 2 | 3 | 5 |
| Price | 5 | 4 | 2 |
| Security | 3 | 4 | 5 |
| Sharing | 2 | 5 | 4 |
Waterfall
| Step | Change | Running total |
|---|---|---|
| Revenue | 500 (Total) | 500 |
| Costs | -220 (Fall) | 280 |
| Marketing | -80 (Fall) | 200 |
| Other income | +30 (Rise) | 230 |
| Tax | -46 (Fall) | 184 |
| Profit | 184 (Total) | 184 |
Funnel
| Step | Count | of the first step | of the step before |
|---|---|---|---|
| Visited | 1,200 | 100% | |
| Started | 640 | 53.3% | 53.3% |
| Confirmed email | 410 | 34.2% | 64.1% |
| Finished | 290 | 24.2% | 70.7% |
Bullet
| Measure | Value | Target | Bands |
|---|---|---|---|
| Revenue | 270 | 250 | 150, 225, 300 |
| New customers | 1,400 | 1,600 | 1,000, 1,500, 2,000 |
| Satisfaction | 4.1 | 4.3 | 3, 4, 5 |
Candlestick
| Period | Open | High | Low | Close |
|---|---|---|---|---|
| Mar 2, 2026 | 40 | 40.5 | 38.2 | 39.4 |
| Mar 3, 2026 | 39.4 | 40.8 | 39 | 39.7 |
| Mar 4, 2026 | 39.7 | 42.3 | 39.4 | 41.3 |
| Mar 5, 2026 | 41.3 | 41.4 | 39.2 | 40.2 |
| Mar 6, 2026 | 40.2 | 40.8 | 38.1 | 39 |
| Mar 7, 2026 | 39 | 40.7 | 38.6 | 40.1 |
| Mar 8, 2026 | 40.1 | 40.5 | 39.1 | 39.8 |
| Mar 9, 2026 | 39.8 | 40.1 | 38.6 | 39.7 |
| Mar 10, 2026 | 39.7 | 40.3 | 39.4 | 39.4 |
| Mar 11, 2026 | 39.4 | 40.5 | 39.1 | 40.2 |
| Mar 12, 2026 | 40.2 | 41.2 | 38.8 | 39.4 |
| Mar 13, 2026 | 39.4 | 41.5 | 38.3 | 40.8 |
| Mar 14, 2026 | 40.8 | 41.3 | 40.4 | 41.1 |
| Mar 15, 2026 | 41.1 | 41.7 | 40.8 | 41.5 |
| Mar 16, 2026 | 41.5 | 42.6 | 40.5 | 40.8 |
| Mar 17, 2026 | 40.8 | 41.7 | 39.9 | 40.2 |
| Mar 18, 2026 | 40.2 | 41.4 | 39.2 | 40.5 |
| Mar 19, 2026 | 40.5 | 41.2 | 39.5 | 41.1 |
| Mar 20, 2026 | 41.1 | 41.1 | 40.1 | 40.8 |
| Mar 21, 2026 | 40.8 | 42 | 40.3 | 41.7 |
| Mar 22, 2026 | 41.7 | 41.9 | 40.7 | 40.7 |
| Mar 23, 2026 | 40.7 | 42.5 | 40.7 | 41.9 |
| Mar 24, 2026 | 41.9 | 42.7 | 40.5 | 40.7 |
| Mar 25, 2026 | 40.7 | 40.8 | 39.6 | 39.8 |
| Mar 26, 2026 | 39.8 | 42.3 | 39 | 41.4 |
| Mar 27, 2026 | 41.4 | 41.5 | 41.1 | 41.1 |
| Mar 28, 2026 | 41.1 | 42 | 40.4 | 40.6 |
| Mar 29, 2026 | 40.6 | 40.8 | 39.5 | 40.1 |
| Mar 30, 2026 | 40.1 | 41.6 | 39 | 41.1 |
| Mar 31, 2026 | 41.1 | 41.9 | 40.3 | 40.5 |
Chord diagram
| From | To | Amount |
|---|---|---|
| North | South | 120 |
| North | East | 40 |
| North | West | 30 |
| North | Centre | 60 |
| South | North | 80 |
| South | East | 60 |
| South | West | 20 |
| South | Centre | 40 |
| East | North | 30 |
| East | South | 90 |
| East | West | 50 |
| East | Centre | 70 |
| West | North | 20 |
| West | South | 30 |
| West | East | 40 |
| West | Centre | 35 |
| Centre | North | 55 |
| Centre | South | 45 |
| Centre | East | 65 |
| Centre | West | 30 |
Parallel coordinates
- Power
- Light
- Value
| name | kind | Price | Weight (kg) | Battery (h) | Screen (in) |
|---|---|---|---|---|---|
| Model A | Power | 1,221 | 1.1 | 12 | 16.6 |
| Model B | Light | 1,466 | 1.8 | 13 | 15.6 |
| Model C | Value | 915 | 2.4 | 7 | 16.9 |
| Model D | Power | 1,596 | 1.9 | 12 | 15.5 |
| Model E | Light | 742 | 1.3 | 8 | 15.1 |
| Model F | Value | 1,454 | 1.2 | 7 | 15.8 |
| Model G | Power | 884 | 1.9 | 11 | 16 |
| Model H | Light | 707 | 1.3 | 17 | 14.3 |
| Model I | Value | 766 | 2 | 13 | 15.4 |
| Model J | Power | 1,253 | 1 | 8 | 14 |
| Model K | Light | 1,349 | 1.1 | 8 | 13.8 |
| Model L | Value | 1,500 | 1.8 | 11 | 14.6 |
| Model M | Power | 1,783 | 2.2 | 14 | 14.4 |
| Model N | Light | 1,604 | 2 | 13 | 14.5 |
Dot plot
- Before
- After
| team | Before | After |
|---|---|---|
| Support | 62 | 78 |
| Sales | 70 | 74 |
| Product | 55 | 71 |
| Finance | 66 | 63 |
| Design | 72 | 81 |
| # | region | Milliseconds |
|---|---|---|
| 15 | North | 89 |
| 25 | North | 90 |
| 27 | North | 93 |
| 37 | North | 99 |
| 23 | North | 100 |
| 29 | North | 105 |
| 40 | North | 105 |
| 16 | North | 107 |
| 12 | North | 108 |
| 31 | North | 108 |
| 14 | North | 112 |
| 17 | North | 112 |
| 18 | North | 112 |
| 33 | North | 113 |
| 38 | North | 113 |
| 19 | North | 114 |
| 21 | North | 116 |
| 5 | North | 117 |
| 35 | North | 117 |
| 1 | North | 119 |
| 7 | North | 119 |
| 22 | North | 120 |
| 4 | North | 121 |
| 24 | North | 121 |
| 13 | North | 125 |
| 3 | North | 126 |
| 6 | North | 126 |
| 9 | North | 126 |
| 11 | North | 126 |
| 34 | North | 126 |
| 32 | North | 128 |
| 28 | North | 129 |
| 2 | North | 130 |
| 36 | North | 130 |
| 26 | North | 131 |
| 30 | North | 132 |
| 39 | North | 132 |
| 8 | North | 136 |
| 20 | North | 140 |
| 10 | North | 144 |
| 161 | North | 260 |
| 63 | South | 109 |
| 77 | South | 113 |
| 57 | South | 115 |
| 78 | South | 117 |
| 80 | South | 123 |
| 71 | South | 129 |
| 42 | South | 131 |
| 69 | South | 131 |
| 43 | South | 132 |
| 46 | South | 132 |
| 74 | South | 132 |
| 48 | South | 134 |
| 68 | South | 136 |
| 45 | South | 138 |
| 76 | South | 139 |
| 50 | South | 140 |
| 58 | South | 140 |
| 59 | South | 140 |
| 67 | South | 142 |
| 51 | South | 144 |
| 44 | South | 145 |
| 72 | South | 145 |
| 75 | South | 145 |
| 55 | South | 146 |
| 66 | South | 146 |
| 64 | South | 147 |
| 62 | South | 148 |
| 49 | South | 150 |
| 60 | South | 150 |
| 52 | South | 152 |
| 65 | South | 153 |
| 41 | South | 154 |
| 56 | South | 154 |
| 54 | South | 158 |
| 61 | South | 158 |
| 73 | South | 158 |
| 79 | South | 159 |
| 70 | South | 172 |
| 53 | South | 173 |
| 47 | South | 174 |
| 90 | East | 136 |
| 108 | East | 144 |
| 118 | East | 144 |
| 84 | East | 147 |
| 81 | East | 149 |
| 114 | East | 149 |
| 93 | East | 150 |
| 107 | East | 153 |
| 110 | East | 154 |
| 109 | East | 156 |
| 112 | East | 157 |
| 85 | East | 161 |
| 92 | East | 163 |
| 94 | East | 164 |
| 89 | East | 167 |
| 86 | East | 168 |
| 88 | East | 168 |
| 96 | East | 168 |
| 113 | East | 169 |
| 99 | East | 170 |
| 104 | East | 172 |
| 97 | East | 173 |
| 102 | East | 173 |
| 103 | East | 174 |
| 91 | East | 175 |
| 119 | East | 176 |
| 95 | East | 178 |
| 100 | East | 178 |
| 87 | East | 180 |
| 101 | East | 180 |
| 98 | East | 185 |
| 115 | East | 185 |
| 120 | East | 185 |
| 111 | East | 187 |
| 82 | East | 193 |
| 83 | East | 193 |
| 105 | East | 193 |
| 116 | East | 194 |
| 106 | East | 196 |
| 117 | East | 200 |
| 162 | East | 330 |
| 140 | West | 140 |
| 126 | West | 141 |
| 145 | West | 149 |
| 146 | West | 150 |
| 136 | West | 156 |
| 131 | West | 160 |
| 144 | West | 165 |
| 134 | West | 167 |
| 149 | West | 168 |
| 137 | West | 170 |
| 138 | West | 172 |
| 143 | West | 178 |
| 124 | West | 179 |
| 123 | West | 183 |
| 156 | West | 186 |
| 157 | West | 186 |
| 125 | West | 187 |
| 151 | West | 187 |
| 133 | West | 189 |
| 135 | West | 190 |
| 141 | West | 193 |
| 147 | West | 193 |
| 128 | West | 195 |
| 127 | West | 200 |
| 129 | West | 204 |
| 121 | West | 206 |
| 130 | West | 206 |
| 148 | West | 206 |
| 139 | West | 209 |
| 154 | West | 212 |
| 132 | West | 213 |
| 155 | West | 213 |
| 160 | West | 215 |
| 153 | West | 219 |
| 150 | West | 221 |
| 159 | West | 222 |
| 122 | West | 224 |
| 152 | West | 225 |
| 142 | West | 226 |
| 158 | West | 234 |
Stream
- Jazz
- Folk
- Rock
- Electronic
| year | Jazz | Folk | Rock | Electronic |
|---|---|---|---|---|
| 2,015 | 20 | 30 | 53 | 15 |
| 2,016 | 26 | 34 | 50 | 18 |
| 2,017 | 29 | 37 | 45 | 21 |
| 2,018 | 28 | 38 | 41 | 24 |
| 2,019 | 27 | 37 | 40 | 27 |
| 2,020 | 29 | 35 | 41 | 30 |
| 2,021 | 34 | 31 | 41 | 33 |
| 2,022 | 40 | 27 | 38 | 36 |
| 2,023 | 44 | 24 | 34 | 39 |
| 2,024 | 44 | 22 | 29 | 42 |
| 2,025 | 43 | 22 | 27 | 45 |
| 2,026 | 44 | 24 | 28 | 48 |
Slope
| mode | 2016 | 2026 | Change |
|---|---|---|---|
| Car | 52 | 41 | -11 (Fell) |
| Bike | 9 | 18 | +9 (Rose) |
| Transit | 24 | 27 | +3 (Rose) |
| Walking | 13 | 12 | -1 (Fell) |
Brush
| day | Visits |
|---|---|
| May 1, 2026 | 334 |
| May 2, 2026 | 348 |
| May 3, 2026 | 344 |
| May 4, 2026 | 344 |
| May 5, 2026 | 331 |
| May 6, 2026 | 324 |
| May 7, 2026 | 326 |
| May 8, 2026 | 334 |
| May 9, 2026 | 328 |
| May 10, 2026 | 322 |
| May 11, 2026 | 313 |
| May 12, 2026 | 306 |
| May 13, 2026 | 311 |
| May 14, 2026 | 309 |
| May 15, 2026 | 289 |
| May 16, 2026 | 289 |
| May 17, 2026 | 287 |
| May 18, 2026 | 290 |
| May 19, 2026 | 285 |
| May 20, 2026 | 262 |
| May 21, 2026 | 279 |
| May 22, 2026 | 279 |
| May 23, 2026 | 265 |
| May 24, 2026 | 288 |
| May 25, 2026 | 278 |
| May 26, 2026 | 282 |
| May 27, 2026 | 283 |
| May 28, 2026 | 289 |
| May 29, 2026 | 303 |
| May 30, 2026 | 307 |
| May 31, 2026 | 315 |
| Jun 1, 2026 | 313 |
| Jun 2, 2026 | 335 |
| Jun 3, 2026 | 337 |
| Jun 4, 2026 | 345 |
| Jun 5, 2026 | 352 |
| Jun 6, 2026 | 363 |
| Jun 7, 2026 | 381 |
| Jun 8, 2026 | 351 |
| Jun 9, 2026 | 378 |
| Jun 10, 2026 | 354 |
| Jun 11, 2026 | 372 |
| Jun 12, 2026 | 371 |
| Jun 13, 2026 | 363 |
| Jun 14, 2026 | 366 |
| Jun 15, 2026 | 360 |
| Jun 16, 2026 | 350 |
| Jun 17, 2026 | 355 |
| Jun 18, 2026 | 347 |
| Jun 19, 2026 | 342 |
| Jun 20, 2026 | 339 |
| Jun 21, 2026 | 336 |
| Jun 22, 2026 | 303 |
| Jun 23, 2026 | 301 |
| Jun 24, 2026 | 317 |
| Jun 25, 2026 | 317 |
| Jun 26, 2026 | 313 |
| Jun 27, 2026 | 315 |
| Jun 28, 2026 | 308 |
| Jun 29, 2026 | 304 |
120–179
Add it
npx shadcn@latest add @rivier-ui/gantt-chart
The registry is named once in components.json: see Installation.
Example
Import it from @/components/viz/gantt-chart.
<GanttChart
label="Launch plan"
tasks={[
{ id: "design", label: "Design", start: "2026-03-02", end: "2026-03-13", group: "Product", progress: 1 },
{ id: "build", label: "Build", start: "2026-03-09", end: "2026-04-03", group: "Product", progress: 0.4, dependsOn: ["design"] },
{ id: "launch", label: "Launch", start: "2026-04-06", end: "2026-04-06", group: "Marketing", milestone: true, dependsOn: ["build"] },
]}
today="2026-03-20"
/>
What it needs
A client component: it uses state, effects or browser behaviour. Packages: d3-scale.
It imports
It is used by
Source
The whole file. Once copied it is yours: the registry item holds the same text.
"use client";
/**
* @name gantt-chart
* @category viz
* @description Tasks as bars along a time axis, one row each, under optional group headings: how far each has got, which must finish before another starts (arrows), milestones as diamonds and a line for today, with Up and Down reading each task.
* @when Planning or reporting work over time: a project plan, a release schedule, a timeline of events with lengths. For events without length use timeline (a list) or a line-chart annotation; for a calendar of single days use calendar or calendar-heatmap.
* @example
* <GanttChart
* label="Launch plan"
* tasks={[
* { id: "design", label: "Design", start: "2026-03-02", end: "2026-03-13", group: "Product", progress: 1 },
* { id: "build", label: "Build", start: "2026-03-09", end: "2026-04-03", group: "Product", progress: 0.4, dependsOn: ["design"] },
* { id: "launch", label: "Launch", start: "2026-04-06", end: "2026-04-06", group: "Marketing", milestone: true, dependsOn: ["build"] },
* ]}
* today="2026-03-20"
* />
*/
import { scaleUtc } from "d3-scale";
import { useMemo, type ComponentProps, type KeyboardEvent } from "react";
import { cn } from "@/lib/cn";
import { ChartContainer, ChartEmpty, ChartGrid, chartSeries, ChartSvg, ChartTooltip, dateFormatter, fitText, formatNumber, useChartCursor, widestText, type ChartFormat } from "@/components/viz/chart";
export type GanttTask = {
id: string;
label: string;
/** "YYYY-MM-DD", or "YYYY-MM-DDTHH:mm" for times (read as UTC unless it carries a zone). */
start: string;
/** The same form. A day-only end includes that whole day. */
end: string;
/** Tasks with the same group sit together under its name, in one colour. */
group?: string;
/** How much is done, 0 to 1. */
progress?: number;
/** Ids of tasks that must finish before this one starts. */
dependsOn?: readonly string[];
/** A moment rather than a span: a diamond at `start`. */
milestone?: boolean;
};
export type GanttChartLabels = {
task: string;
group: string;
start: string;
end: string;
progress: string;
length: (days: number, formatted: string) => string;
today: string;
after: string;
milestone: string;
};
export type GanttChartProps = Omit<ComponentProps<"div">, "children"> &
ChartFormat & {
tasks: readonly GanttTask[];
/** What the chart shows, for assistive technology. */
label: string;
/** "YYYY-MM-DD": a line for today. Left out, none is drawn (the server and the browser may not agree on the date). */
today?: string;
/** The height of a row in pixels. Default 32. */
rowHeight?: number;
labels?: Partial<GanttChartLabels>;
emptyLabel?: string;
};
const LABELS: GanttChartLabels = {
task: "Task",
group: "Group",
start: "Start",
end: "End",
progress: "Done",
length: (days, formatted) => `${formatted} ${days === 1 ? "day" : "days"}`,
today: "Today",
after: "After",
milestone: "Milestone",
};
const DAY = 86400000;
const ROUND = "[rx:min(var(--radius),4px)] [ry:min(var(--radius),4px)]";
function parseMoment(text: string, end: boolean): number | null {
if (/^\d{4}-\d{2}-\d{2}$/.test(text)) {
const at = Date.parse(`${text}T00:00:00Z`);
return Number.isFinite(at) ? at + (end ? DAY : 0) : null;
}
const at = Date.parse(/[zZ]|[+-]\d{2}:?\d{2}$/.test(text) ? text : `${text}Z`);
return Number.isFinite(at) ? at : null;
}
type Row = { kind: "group"; name: string; colour: number } | { kind: "task"; task: GanttTask; index: number; from: number; to: number; colour: number };
export function GanttChart({ tasks, label, today, rowHeight = 32, labels: given, emptyLabel, locale = "en-US", timeZone = "UTC", className, ...props }: GanttChartProps) {
const labels = { ...LABELS, ...given };
const model = useMemo(() => {
const groups = [...new Set(tasks.map((task) => task.group ?? ""))];
const rows: Row[] = [];
const placed: Extract<Row, { kind: "task" }>[] = [];
for (const [g, name] of groups.entries()) {
const colour = g < 5 ? g : -1;
if (name) rows.push({ kind: "group", name, colour });
for (const task of tasks.filter((item) => (item.group ?? "") === name)) {
const from = parseMoment(task.start, false);
const to = task.milestone ? from : parseMoment(task.end, true);
if (from === null || to === null) continue;
const row: Extract<Row, { kind: "task" }> = { kind: "task", task, index: placed.length, from, to: Math.max(from, to), colour };
rows.push(row);
placed.push(row);
}
}
return { rows, placed };
}, [tasks]);
const { rows, placed } = model;
const cursor = useChartCursor(placed.length);
const span = placed.length > 0 ? Math.max(...placed.map((row) => row.to)) - Math.min(...placed.map((row) => row.from)) : 0;
const fullDate = dateFormatter(Math.min(span, 300 * DAY), "full", locale, timeZone);
const axisDate = dateFormatter(span, "axis", locale, timeZone);
const hasTime = tasks.some((task) => task.start.includes("T") || task.end.includes("T"));
const dateText = (at: number, end: boolean): string => fullDate(hasTime || !end ? at : at - DAY);
const percent = (share: number): string => formatNumber(share, locale, { style: "percent", maximumFractionDigits: 0 });
const lengthText = (row: Extract<Row, { kind: "task" }>): string => {
const days = Math.round(((row.to - row.from) / DAY) * 10) / 10;
return labels.length(days, formatNumber(days, locale));
};
const nameOf = (id: string): string => tasks.find((task) => task.id === id)?.label ?? id;
const describe = (row: Extract<Row, { kind: "task" }>): { label: string; value: string }[] => [
...(row.task.milestone
? [{ label: labels.milestone, value: dateText(row.from, false) }]
: [
{ label: labels.start, value: dateText(row.from, false) },
{ label: labels.end, value: dateText(row.to, true) },
{ label: "", value: lengthText(row) },
]),
...(row.task.progress !== undefined ? [{ label: labels.progress, value: percent(row.task.progress) }] : []),
...(row.task.dependsOn && row.task.dependsOn.length > 0 ? [{ label: labels.after, value: row.task.dependsOn.map(nameOf).join(", ") }] : []),
];
const table = {
caption: label,
columns: [labels.task, labels.group, labels.start, labels.end, labels.progress, labels.after],
rows: placed.map((row) => [
row.task.label,
row.task.group ?? "",
dateText(row.from, false),
row.task.milestone ? labels.milestone : dateText(row.to, true),
row.task.progress === undefined ? "" : percent(row.task.progress),
(row.task.dependsOn ?? []).map(nameOf).join(", "),
]),
};
const current = cursor.active === null ? undefined : placed[cursor.active];
const todayAt = today ? parseMoment(today, false) : null;
const onKeyDown = (event: KeyboardEvent<SVGSVGElement>): void => {
// Rows run down the page, so Up and Down read them; Left and Right do the same for one-handed use.
if (event.key === "ArrowDown") {
event.preventDefault();
cursor.select(cursor.active === null ? 0 : cursor.active + 1);
} else if (event.key === "ArrowUp") {
event.preventDefault();
cursor.select(cursor.active === null ? placed.length - 1 : cursor.active - 1);
} else cursor.svgProps.onKeyDown(event);
};
const axis = 26;
const plotHeight = rows.length * rowHeight + axis + 4;
return (
<div data-slot="gantt-chart" className={cn("flex w-full min-w-0 flex-col gap-3", className)} {...props}>
<ChartContainer
height={Math.max(80, plotHeight)}
table={table}
announcement={
cursor.keyboard && current
? `${current.task.label}: ${describe(current)
.map((item) => `${item.label} ${item.value}`.trim())
.join(", ")}`
: ""
}
>
{({ width, height: measured }) => {
if (placed.length === 0) return <ChartEmpty>{emptyLabel}</ChartEmpty>;
const left = Math.min(Math.round(width * 0.34), widestText(placed.map((row) => row.task.label)) + 16);
const right = 12;
const first = Math.min(...placed.map((row) => row.from), ...(todayAt === null ? [] : [todayAt]));
const last = Math.max(...placed.map((row) => row.to), ...(todayAt === null ? [] : [todayAt]));
const sx = scaleUtc()
.domain([first, last === first ? first + DAY : last])
.range([left, width - right])
.nice();
const ticks = sx.ticks(Math.max(2, Math.floor((width - left) / 90)));
const yOf = (rowIndex: number): number => axis + rowIndex * rowHeight;
const bar = Math.min(18, rowHeight - 10);
const rowIndexOf = new Map(placed.map((row) => [row.task.id, rows.indexOf(row)]));
const shownRow = current ? rows.indexOf(current) : -1;
return (
<>
<ChartSvg label={label} width={width} height={measured} interactive {...cursor.svgProps} onKeyDown={onKeyDown}>
<ChartGrid offsets={ticks.map((tick) => sx(tick))} from={axis} to={measured - 4} vertical />
<g aria-hidden="true" className="fill-muted-foreground tabular-nums">
{ticks.map((tick) => (
<text key={tick.getTime()} x={sx(tick)} y={axis - 10} textAnchor="middle">
{axisDate(tick)}
</text>
))}
</g>
<g aria-hidden="true">
{rows.map((row, rowIndex) =>
row.kind === "group" ? (
<g key={`g:${row.name}`}>
<line x1={0} x2={width} y1={yOf(rowIndex)} y2={yOf(rowIndex)} className="stroke-border" shapeRendering="crispEdges" />
<text x={0} y={yOf(rowIndex) + rowHeight / 2} dy="0.32em" className="fill-foreground text-xs font-medium">
{fitText(row.name, width)}
</text>
</g>
) : (
<g
key={row.task.id}
onPointerEnter={() => cursor.point(row.index)}
className={cn("transition-opacity duration-instant motion-reduce:transition-none", current && current !== row && "opacity-55")}
>
<rect x={0} y={yOf(rowIndex)} width={width} height={rowHeight} fill="transparent" />
<text x={8} y={yOf(rowIndex) + rowHeight / 2} dy="0.32em" className="fill-muted-foreground text-xs">
{fitText(row.task.label, left - 16)}
</text>
{row.task.milestone ? (
<path
d={`M0,${-bar / 2} L${bar / 2},0 L0,${bar / 2} L${-bar / 2},0 Z`}
transform={`translate(${sx(row.from)},${yOf(rowIndex) + rowHeight / 2})`}
className={cn(chartSeries(row.colour).fill, "stroke-background")}
strokeWidth={2}
/>
) : (
<>
<rect
x={sx(row.from)}
y={yOf(rowIndex) + (rowHeight - bar) / 2}
width={Math.max(2, sx(row.to) - sx(row.from))}
height={bar}
className={cn(chartSeries(row.colour).fill, ROUND)}
fillOpacity={0.3}
/>
<rect
x={sx(row.from)}
y={yOf(rowIndex) + (rowHeight - bar) / 2}
width={Math.max(row.task.progress ? 2 : 0, (sx(row.to) - sx(row.from)) * Math.max(0, Math.min(1, row.task.progress ?? 0)))}
height={bar}
className={cn(chartSeries(row.colour).fill, ROUND)}
/>
</>
)}
</g>
),
)}
{placed.flatMap((row) =>
(row.task.dependsOn ?? []).flatMap((id) => {
const before = placed.find((other) => other.task.id === id);
const fromRow = rowIndexOf.get(id);
const toRow = rowIndexOf.get(row.task.id);
if (!before || fromRow === undefined || toRow === undefined) return [];
const x1 = sx(before.to);
const y1 = yOf(fromRow) + rowHeight / 2;
const x2 = sx(row.from) - (row.task.milestone ? bar / 2 : 0);
const y2 = yOf(toRow) + rowHeight / 2;
const bend = Math.max(x1 + 6, Math.min(x2 - 6, x1 + 10));
return [
<g key={`${id}>${row.task.id}`} className="stroke-muted-foreground" fill="none" strokeWidth={1.25}>
<path d={`M${x1},${y1} H${bend} V${y2} H${x2 - 1}`} />
<path d={`M${x2 - 6},${y2 - 4} L${x2 - 1},${y2} L${x2 - 6},${y2 + 4}`} />
</g>,
];
}),
)}
{todayAt !== null ? (
<g>
<line x1={sx(todayAt)} x2={sx(todayAt)} y1={axis - 4} y2={measured - 4} className="stroke-foreground" strokeDasharray="3 3" />
<text x={sx(todayAt) + 4} y={measured - 8} className="fill-foreground text-xs">
{labels.today}
</text>
</g>
) : null}
{current && shownRow >= 0 ? (
<rect x={1} y={yOf(shownRow) + 1} width={width - 2} height={rowHeight - 2} fill="none" className={cn("stroke-foreground", ROUND)} strokeWidth={2} />
) : null}
</g>
</ChartSvg>
{current && shownRow >= 0 ? (
<ChartTooltip
x={Math.min(width - 20, sx(current.to))}
y={yOf(shownRow) + rowHeight / 2}
side={sx(current.to) > width * 0.6 ? "left" : "right"}
title={current.task.label}
rows={describe(current)}
/>
) : null}
</>
);
}}
</ChartContainer>
</div>
);
}