Line Chart
Style-agnostic SVG line chart using CSS custom properties.
Preview
Arguments
line_chart(series=[{'name': 'This year', 'data': [4, 8, 6, 11]}, {'name': 'Last year', 'data': [3, 5, 7, 8]}], labels=['Q1', 'Q2', 'Q3', 'Q4'])Usage
views.py
python
from djust import LiveView
from djust.components import LineChart
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = LineChart(series=[{'name': 'This year', 'data': [4, 8, 6, 11]}, {'name': 'Last year', 'data': [3, 5, 7, 8]}], labels=['Q1', 'Q2', 'Q3', 'Q4'])my_template.html
django
{{ component }}Parameters
| Name | Type | Default |
|---|---|---|
| series | list | None | None |
| labels | list | None | None |
| title | str | None | None |
| width | int | 400 |
| height | int | 250 |
| area | bool | False |
| show_dots | bool | True |
| show_legend | 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.line_chart | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 5 of this component's classes at line 2024, 2025, 2027, 2028, 2030. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |