Calendar Heatmap
Style-agnostic SVG calendar heatmap (GitHub contribution style).
Preview
Arguments
calendar_heatmap(data={'2026-01-02': 1, '2026-01-03': 3, '2026-01-05': 5, '2026-01-06': 8, '2026-01-07': 2, '2026-01-09': 4, '2026-01-10': 11, '2026-01-11': 6, '2026-01-12': 1, '2026-01-14': 2, '2026-01-15': 7, '2026-01-16': 9, '2026-01-17': 3, '2026-01-19': 1, '2026-01-20': 5, '2026-01-21': 12, '2026-01-22': 8, '2026-01-23': 4, '2026-01-25': 2, '2026-01-26': 6, '2026-01-27': 10, '2026-01-28': 3, '2026-01-29': 1, '2026-01-31': 7}, year=2026, title='Contributions')Usage
views.py
python
from djust import LiveView
from djust.components import CalendarHeatmap
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = CalendarHeatmap(data={'2026-01-02': 1, '2026-01-03': 3, '2026-01-05': 5, '2026-01-06': 8, '2026-01-07': 2, '2026-01-09': 4, '2026-01-10': 11, '2026-01-11': 6, '2026-01-12': 1, '2026-01-14': 2, '2026-01-15': 7, '2026-01-16': 9, '2026-01-17': 3, '2026-01-19': 1, '2026-01-20': 5, '2026-01-21': 12, '2026-01-22': 8, '2026-01-23': 4, '2026-01-25': 2, '2026-01-26': 6, '2026-01-27': 10, '2026-01-28': 3, '2026-01-29': 1, '2026-01-31': 7}, year=2026, title='Contributions')my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| data | dict | None | None | Dict mapping "YYYY-MM-DD" strings to numeric values |
| year | int | None | None | Year to display (default: current year) |
| title | str | None | None | Optional chart title |
| color_empty | str | '#ebedf0' | Color for zero-value cells (default: "#ebedf0") |
| color_min | str | '#9be9a8' | Color for low values (default: "#9be9a8") |
| color_max | str | '#216e39' | Color for high values (default: "#216e39") |
| cell_size | int | 12 | Cell width/height in px (default: 12) |
| cell_gap | int | 2 | Gap between cells in px (default: 2) |
| show_month_labels | bool | True | Show month labels (default: True) |
| show_day_labels | bool | True | Show day-of-week labels (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.calendar_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 2116, 2117, 2118, 2119, 2121. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |