Treemap

Style-agnostic SVG treemap using CSS custom properties.

python 9 params

Preview

Search: 45SearchDirect: 30DirectSocial: 15Social
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

NameTypeDefault
datalist | NoneNone
value_keystr'size'
label_keystr'name'
titlestr | NoneNone
widthint400
heightint250
colorslist | NoneNone
custom_classstr''
**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
FilePathNotes
moduledjust.components.components.treemapSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 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.