Heatmap

Style-agnostic SVG heatmap using CSS custom properties.

python 10 params

Preview

MonTueWedWeek 1Week 2Week 3114422330055226611
Arguments
heatmap(data=[[1, 4, 2], [3, 0, 5], [2, 6, 1]], x_labels=['Mon', 'Tue', 'Wed'], y_labels=['Week 1', 'Week 2', 'Week 3'])

Usage

views.py
python
from djust import LiveView
from djust.components import Heatmap


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = Heatmap(data=[[1, 4, 2], [3, 0, 5], [2, 6, 1]], x_labels=['Mon', 'Tue', 'Wed'], y_labels=['Week 1', 'Week 2', 'Week 3'])
my_template.html
django
{{ component }}

Parameters

NameTypeDefaultDescription
datalist | NoneNone2D list (rows of columns) of numeric values
x_labelslist | NoneNoneColumn header labels
y_labelslist | NoneNoneRow header labels
titlestr | NoneNoneOptional chart title
color_minstr'#f0f9ff'Color for minimum value (default: "#f0f9ff")
color_maxstr'#1e40af'Color for maximum value (default: "#1e40af")
cell_sizeint36Cell width/height in px (default: 36)
show_valuesboolTrueShow numeric values in cells (default: True)
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.heatmapSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 6 of this component's classes at line 2101, 2102, 2104, 2106, 2541. Override those rules, or the custom properties they read, in a stylesheet loaded after it.