Bar Chart
Style-agnostic SVG bar chart using CSS custom properties.
Preview
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
| Name | Type | Default |
|---|---|---|
| data | list | None | None |
| labels | list | None | None |
| title | str | None | None |
| width | int | 400 |
| height | int | 250 |
| color | str | '' |
| show_values | bool | True |
| 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.bar_chart | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |