Sparkline

Style-agnostic inline sparkline using SVG.

python 8 params

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

NameTypeDefault
datalist | NoneNone
variantstr'line'
widthint100
heightint24
colorstr''
stroke_widthfloat1.5
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.sparklineSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 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.