Sparkline
Style-agnostic inline sparkline using SVG.
Preview
Arguments
sparkline(data=[3, 5, 4, 8, 6, 9, 7], variant='line')
Usage
views.py
python
from djust import LiveView
from djust.components import Sparkline
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = Sparkline(data=[3, 5, 4, 8, 6, 9, 7], variant='line')my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| data | list | None | None | List of numeric values |
| variant | str | 'line' | Chart type — "line" (default), "bar", "area" |
| width | int | 100 | SVG width (default: 100) |
| height | int | 24 | SVG height (default: 24) |
| color | str | '' | Stroke/fill color |
| stroke_width | float | 1.5 | Line stroke width (default: 1.5) |
| 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.sparkline | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 3 of this component's classes at line 2094, 2095, 2096. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |