Org Chart
Hierarchical org chart / tree visualization.
Preview
- ALAda LovelaceCEO
- GHGrace HopperCTO
- ATAlan TuringEngineer
Arguments
org_chart(nodes=[{'id': 'ceo', 'name': 'Ada Lovelace', 'title': 'CEO'}, {'id': 'cto', 'name': 'Grace Hopper', 'title': 'CTO', 'parent': 'ceo'}, {'id': 'eng', 'name': 'Alan Turing', 'title': 'Engineer', 'parent': 'cto'}])Usage
views.py
python
from djust import LiveView
from djust.components import OrgChart
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = OrgChart(nodes=[{'id': 'ceo', 'name': 'Ada Lovelace', 'title': 'CEO'}, {'id': 'cto', 'name': 'Grace Hopper', 'title': 'CTO', 'parent': 'ceo'}, {'id': 'eng', 'name': 'Alan Turing', 'title': 'Engineer', 'parent': 'cto'}])my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| nodes | list | None | None | List of dicts with ``id``, ``name``, ``title``, optional ``parent``, ``avatar`` |
| root | str | None | None | ID of root node (auto-detected if omitted) |
| event | str — renames the event; identity is `name` | '' | djust click event for node selection |
| direction | str | 'vertical' | "vertical" (default) or "horizontal" |
| 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.org_chart | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 9 of this component's classes at line 2251, 2252, 2253, 2254, 2257, 2258, 2259, 2260, 2261. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |