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

NameTypeDefault
datalist | NoneNone
x_labelslist | NoneNone
y_labelslist | NoneNone
titlestr | NoneNone
color_minstr'#f0f9ff'
color_maxstr'#1e40af'
cell_sizeint36
show_valuesboolTrue
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.heatmapSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 6 of this component's classes at line 2047, 2048, 2050, 2052, 2438. Override those rules, or the custom properties they read, in a stylesheet loaded after it.