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 |
|---|---|---|
| data | list | None | None |
| variant | str | 'line' |
| width | int | 100 |
| height | int | 24 |
| color | str | '' |
| stroke_width | float | 1.5 |
| custom_class | str | '' |
| **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 2040, 2041, 2042. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |