Treemap
Style-agnostic SVG treemap using CSS custom properties.
Preview
Arguments
treemap(data=[{'name': 'Search', 'size': 45}, {'name': 'Direct', 'size': 30}, {'name': 'Social', 'size': 15}])Usage
views.py
python
from djust import LiveView
from djust.components import Treemap
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = Treemap(data=[{'name': 'Search', 'size': 45}, {'name': 'Direct', 'size': 30}, {'name': 'Social', 'size': 15}])my_template.html
django
{{ component }}Parameters
| Name | Type | Default |
|---|---|---|
| data | list | None | None |
| value_key | str | 'size' |
| label_key | str | 'name' |
| title | str | None | None |
| width | int | 400 |
| height | int | 250 |
| colors | list | None | None |
| custom_class | str | '' |
| **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.treemap | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 4 of this component's classes at line 2055, 2056, 2058, 2457. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |