Charts
TwGanttChart
TwGanttChart is a Blazor Gantt chart with summary tasks, progress, milestones, dependencies and zoom levels. Drag bars to move, resize or link them.
Last updated
Basic usage
TwGanttChart draws a bar per ChartTask from its start date to its end date, in the order given, so the schedule and any overlaps are visible. At the default zoom the whole plan fits the chart's width.Progress and milestones
Set
Progress on a task, from 0 to 1, to fill that share of its bar; the tooltip and table view give it as a percentage. A task that ends when it starts is a milestone, drawn as a diamond. ShowTaskLabels writes each task's name after its bar.- Milestone
Summary tasks
Give a task a
ParentId to list it under a summary task. A summary is drawn as a bracket that spans the tasks under it, and its progress is theirs weighted by length. The button beside its name shows or hides them, and the toolbar expands or collapses every summary. Bind CollapsedIds to keep which summaries are closed, or set DefaultExpandAll="false" to start with them all closed. Id defaults to the task's label, so it only needs setting when two tasks share a name.- Summary
- Milestone
DiscoveryInterviewsMarket reviewDeliveryDesignBuildBetaLaunch
Collapsed: none
Dependencies
Pass
Dependencies to draw an arrow from one task to another. A ChartTaskDependency names the two tasks by key and how they depend on each other: FinishToStart (the default), StartToStart, FinishToFinish or StartToFinish. Arrows turn at right angles and go round a task rather than through it. Hovering an arrow says what it means. An arrow into a collapsed summary points at the summary. Set ShowDependencies="false" to hide them.Zoom levels
Zoom sets how much time the chart shows. GanttZoom.Auto, the default, fits the whole plan. Hour, Day, Week, Month, Quarter and Year give each period a column of SlotWidth pixels. The plot then scrolls on its own, keeping the task names in view. The toolbar's zoom controls change it; bind it with @bind-Zoom to follow them. RowHeight gives each row a fixed height, so the chart grows with the plan instead of fitting its Height.- Summary
- Milestone
DiscoveryInterviewsMarket reviewDeliveryDesignBuildBetaLaunch
Zoom: Week
Today, working days and a fixed range
A red line marks today when it falls in the chart's range. A zoomed-in chart first scrolls to it, and the toolbar's Today button scrolls back. Click Today in the legend to hide or show the line. Set
Today to mark another moment, or ShowToday="false" to leave it out. At Day and Hour zoom, non-working days are shaded: Saturday and Sunday unless NonWorkingDays says otherwise. RangeStart and RangeEnd fix the dates shown instead of following the tasks. ColorIndex picks one of the theme's series colors for a bar.- Milestone
- Non-working day
Drag, resize and progress
AllowDrag lets a bar be dragged to new dates, keeping its length. AllowResize lets either end be dragged, and AllowProgressDrag adds a grip under the bar for its progress. Handles appear while the pointer is over a bar, and a dashed outline previews the change. Dates snap to the nearest column, or to midnight at Auto zoom, unless SnapToSlot="false". The chart never changes a task itself. OnTaskChange gives the new values in a ChartTaskChange. Store them to move the bar, or set Cancel to leave it where it was. Here a task cannot start before the plan begins. Summaries whose dates are rolled up cannot be dragged.- Milestone
Last change: none
Drawing and deleting dependencies
With
AllowLinking, a dot appears beside each end of a bar under the pointer. Drag from a dot to another bar to draw a dependency. The ends picked decide its type: from the end of one bar to the start of another is FinishToStart. OnDependencyCreate receives a ChartDependencyRequest. The arrow appears once the dependency is in Dependencies, or set Cancel to refuse it, for example to stop a loop. Clicking an arrow raises OnDependencyClick, which removes it here.1 dependencies. Click an arrow to remove it.
Clicking a task
OnTaskClick is raised with the task when its row is clicked, or when Enter or Space is pressed on it, for example to open an edit form. Dragging is pointer only, so a form like this is how keyboard users change a task's dates.Selected: none
Driving the chart from outside
Set
ShowToolbar="false" to hide the built-in controls and use your own. Through a reference, SetZoomAsync changes the zoom, ExpandAllAsync and CollapseAllAsync open or close every summary, and GoToTodayAsync and ScrollToAsync scroll a zoomed-in chart. ShowZoomControls="false" keeps the toolbar without the zoom controls.- Summary
- Milestone
DiscoveryInterviewsMarket reviewDeliveryDesignBuildBetaLaunch
Summaries with their own dates
By default a summary's dates and progress are rolled up from the tasks under it. Set
RollUpSummaries="false" when a summary keeps dates of its own, such as a baseline agreed separately from the work. The summary then shows its own dates even when the tasks under it run late.- Summary
Phase 1 (baseline)RequirementsPrototype
Date format and labels
DateFormat takes any .NET date format string and applies to the axis at Auto zoom, tooltips and the table view; by default it also shows the time at Hour zoom. StartLabel, EndLabel and LabelHeader rename the values in tooltips and the table view.RAZOR
<TwChart Title="Release plan">
<TwGanttChart Tasks="@_tasks" DateFormat="ddd d MMM" StartLabel="Begins" EndLabel="Due" LabelHeader="Phase" Height="ChartHeight.Small" />
</TwChart>Loading and empty states
While the plan loads, set
Loading on the surrounding TwChart to show a spinner with a "Loading chart" message, announced to screen readers. A chart with no tasks shows an empty state instead, whose message EmptyText changes. Both keep the chart's height, so the page does not jump when the tasks arrive.Loading chart
Nothing scheduled yet
RAZOR
<div class="grid gap-4 md:grid-cols-2">
<TwChart Title="Loading" Loading Height="ChartHeight.Small">
<TwGanttChart Tasks="@_tasks" />
</TwChart>
<TwChart Title="Empty" Height="ChartHeight.Small">
<TwGanttChart Tasks="@([])" EmptyText="Nothing scheduled yet" />
</TwChart>
</div>Accessibility
Each row is a data point named after its task, with its dates and progress, for example "Code: Start 5 Jan, End 15 Jan, Done 25%". The plot is one Tab stop and the arrow keys move between rows. Each expand button is named after its summary ("Show the tasks under Build") and reports whether it is open. The zoom controls are a toggle group, and the toolbar buttons are ordinary buttons. The table view lists every task, including those under collapsed summaries. Moving, resizing, setting progress and drawing dependencies are pointer only, so offer another way to edit, such as a form opened from
OnTaskClick. Text follows the app's language. The plot is drawn left to right in every language, as a calendar is, while the toolbar and task names follow the reading direction.
Theme configuration
Styling is controlled by
TwBlazorTheme.Components (a TwGanttTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
Scroller |
string | |
YAxisScrolling |
string | |
YAxis |
string | |
Clickable |
string | |
Toolbar |
string | |
Tick |
string | |
TickLabel |
string | |
Toggle |
string | |
ToggleIcon |
string | |
ToggleIconOpen |
string | |
ToggleSpacer |
string | |
Overlay |
string | |
Bar |
string | |
Handle |
string | |
HandleStart |
string | |
HandleEnd |
string | |
ProgressGrip |
string | |
LinkDot |
string | |
LinkDotStart |
string | |
LinkDotEnd |
string | |
Ghost |
string | |
LinkLine |
string | |
Links |
string | |
LinkHit |
string |
Full reference: TwGanttTheme on the API docs.