Graphos is a Django app to plot data into a live graph.
- Python Nested lists
- CSV Files
- MongoDB
- Redis
- Django ORM
- Line chart
- Bar Chart
- Point Chart
- Line chart
- Column chart
- Bar chart
- Candlestick charts
- Pie chart
- Line chart
(More coming soon)
Install the requirements, manage.py runserver
.
The installed demo app shows the various suported chart types.
Generating a plot requires two things. A DataSource and a Chart object.
In your view, you do something like this:
data = [
['Year', 'Sales', 'Expenses'],
[2004, 1000, 400],
[2005, 1170, 460],
[2006, 660, 1120],
[2007, 1030, 540]
]
Chart = LineChart(SimpleDataSource(data=data), html_id="line_chart")
And then in the template:
{{ chart.as_html }}
data = [
['Year', 'Sales', 'Expenses'],
[2004, 1000, 400],
[2005, 1170, 460],
[2006, 660, 1120],
[2007, 1030, 540]
]
Chart = LineChart(SimpleDataSource(data=data))
csv_file = open("hello.csv")
LineChart(CSVDataSource(csv_file))
queryset = Accounts.objects.filter(foo=bar)
LineChart(ModelDataSource(queryset, fields=["year", "sales", "expenses"]))
Todo
Todo
Todo - need to publish the app at Pypi after competion
A backend is class which has these three methods.
get_data
get_header
get_first_column
get_header
is used by a Renderer
to create the labels.
get_first_column
is used to set the x axis labels
get_data
is used to get the data for display. It should always return a nested list. Eg:
[
['Year', 'Sales', 'Expenses'],
[2004, 1000, 400],
[2005, 1170, 460],
[2006, 660, 1120],
[2007, 1030, 540]
]
If you create a class extending SimpleDataSource, and implement get_data
. You get
get_header
and get_first_column
for free.
BSD