Charts for Django using Google Charts API.
Install django-charting
using pip
pip install django-charting
- Add "django_charting" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = (
# ...
"django_charting",
# ...
)
- Create a basic chart like this:
from django_charting import Chart, NumberColumn, StringColumn
class DemoChart(Chart):
queryset = [
{"project": "Project 1", "count": 75},
{"project": "Project 2", "count": 25},
]
type = "PieChart"
title = "My demo"
project = StringColumn()
count = NumberColumn(accessor="count")
- Render the chart in a template like this:
{% load django_charting %}
{% render_chart chart %}