Gantt Chart
SVG Gantt chart for project management timelines.
Preview
Arguments
gantt_chart(title='Sprint plan', tasks=[{'name': 'Design', 'start': 0, 'duration': 3}, {'name': 'Build', 'start': 2, 'duration': 5}, {'name': 'Ship', 'start': 6, 'duration': 2}])Usage
views.py
python
from djust import LiveView
from djust.components import GanttChart
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = GanttChart(title='Sprint plan', tasks=[{'name': 'Design', 'start': 0, 'duration': 3}, {'name': 'Build', 'start': 2, 'duration': 5}, {'name': 'Ship', 'start': 6, 'duration': 2}])my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| tasks | list | None | None | List of dicts with ``name``, ``start`` (unit offset), ``duration`` (units), optional ``color``, ``progress`` (0-1) |
| title | str | None | None | Optional chart title |
| unit_label | str | 'Day' | Label for time units (default: "Day") |
| units | int | None | None | Number of time units to display (auto-calculated if omitted) |
| row_height | int | 32 | Height per row in px (default: 32) |
| width | int | 600 | SVG width (default: 600) |
| custom_class | str | '' | Additional CSS classes |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.gantt_chart | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 6 of this component's classes at line 2224, 2536, 2537, 2538, 2539, 2540. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |