Heatmap
Style-agnostic SVG heatmap using CSS custom properties.
Preview
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
| Name | Type | Default | Description |
|---|---|---|---|
| data | list | None | None | 2D list (rows of columns) of numeric values |
| x_labels | list | None | None | Column header labels |
| y_labels | list | None | None | Row header labels |
| title | str | None | None | Optional chart title |
| color_min | str | '#f0f9ff' | Color for minimum value (default: "#f0f9ff") |
| color_max | str | '#1e40af' | Color for maximum value (default: "#1e40af") |
| cell_size | int | 36 | Cell width/height in px (default: 36) |
| show_values | bool | True | Show numeric values in cells (default: True) |
| custom_class | str | '' | 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
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.heatmap | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |