Django Graphos Documentation: Release 0.0.2a0
Django Graphos Documentation: Release 0.0.2a0
Release 0.0.2a0
Agiliq
1 Intro to Django-graphos 3
i
ii
Django Graphos Documentation, Release 0.0.2a0
Contents:
Django-graphos is a tool to create Graphs. (doh). There are two things which Graphos gives you over a low level
graph manupulation.
It provides various data sources.
SimpleDataSource - Use a Python list
ModelDataSource
MongoDataSource
It provides various renderers.
Flot
Google charts
YUI
Morris.js
(And more)
Graphos makes it very easy to switch between different data source and renderers.
Are you building your charts with Flot but would like to later switch to Gchart? In many cases, it might be as easy as
switching an import statement.
Contents 1
Django Graphos Documentation, Release 0.0.2a0
2 Contents
CHAPTER 1
Intro to Django-graphos
3
Django Graphos Documentation, Release 0.0.2a0
Line
Bar
Point
5
Django Graphos Documentation, Release 0.0.2a0
Area chart
Bar chart
Candlestick charts
Column chart
Line chart
Pie chart
7
Django Graphos Documentation, Release 0.0.2a0
Graphos plays well with ajax interactions. There are two ways you can replace a graph object.
1. Render chart.as_html in the views. Return and replace the DOM.
2. Calculate the chart.get_data, return the JSON. Redraw the chart using $.plot or equivalent.
9
Django Graphos Documentation, Release 0.0.2a0
If you need your chart to get data from a data source we do not natively support, writing a custom data source is easy.
Once you do that, the data source can be used in any renderer.
To create a new data source
1. Create a class which extends BaseDataSource or SimpleDataSource
2. Make sure your class has implementation of get_data, get_header and get_first_column
3. get_data Should return a NxM matrix (see example data below).
Example Data:
data = [
['Year', 'Sales', 'Expenses', 'Items Sold', 'Net Profit'],
['2004', 1000, 400, 100, 600],
['2005', 1170, 460, 120, 310],
['2006', 660, 1120, 50, -460],
['2007', 1030, 540, 100, 200],
]
11
Django Graphos Documentation, Release 0.0.2a0
class CustomGchart(gchart.LineChart):
def get_template(self):
return "demo/gchart_line.html"
To create a chart for a new charting backend, create a new class extending BaseChart. This class needs to return
the rendrered htmls from as_html method.
However in most of the cases you will override the get_templates method.
13
Django Graphos Documentation, Release 0.0.2a0
genindex
modindex
search
15