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

NameTypeDefaultDescription
datalist | NoneNoneList of dicts with label_key and value_key fields
value_keystr'size'Key for numeric value (default: "size")
label_keystr'name'Key for label text (default: "name")
titlestr | NoneNoneOptional chart title
widthint400SVG width (default: 400)
heightint250SVG height (default: 250)
colorslist | NoneNoneList of fill colors (cycles)
custom_classstr''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
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 2109, 2110, 2112, 2560. Override those rules, or the custom properties they read, in a stylesheet loaded after it.