Bar Chart

Style-agnostic SVG bar chart using CSS custom properties.

python 9 params

Preview

Quarterly revenueQ1: 12.012Q1Q2: 19.019Q2Q3: 8.08Q3Q4: 15.015Q4
Arguments
bar_chart(data=[12, 19, 8, 15], labels=['Q1', 'Q2', 'Q3', 'Q4'], title='Quarterly revenue')

Usage

views.py
python
from djust import LiveView
from djust.components import BarChart


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = BarChart(data=[12, 19, 8, 15], labels=['Q1', 'Q2', 'Q3', 'Q4'], title='Quarterly revenue')
my_template.html
django
{{ component }}

Parameters

NameTypeDefault
datalist | NoneNone
labelslist | NoneNone
titlestr | NoneNone
widthint400
heightint250
colorstr''
show_valuesboolTrue
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.bar_chartSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 6 of this component's classes at line 2015, 2016, 2017, 2018, 2020, 2021. Override those rules, or the custom properties they read, in a stylesheet loaded after it.