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

NameTypeDefaultDescription
datalist | NoneNoneList of numeric values
variantstr'line'Chart type — "line" (default), "bar", "area"
widthint100SVG width (default: 100)
heightint24SVG height (default: 24)
colorstr''Stroke/fill color
stroke_widthfloat1.5Line stroke width (default: 1.5)
custom_classstr''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
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 2094, 2095, 2096. Override those rules, or the custom properties they read, in a stylesheet loaded after it.