Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions demo_project/demo/templates/demo/flot.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,21 @@ <h2>Column Chart</h2>
</pre>
</div>
<br />

<h2>Area Chart</h2>
<div id="area_chart" class="well">
{{ area_chart.as_html }}
<pre class="code">
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],
]
data_source = SimpleDataSource(data)
chart = flot.AreaChart(data_source, options={'title': "Sales/ Expense"})
</pre>
</div>
<br />
{% endblock %}
5 changes: 4 additions & 1 deletion demo_project/demo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ def get_context_data(self, **kwargs):
data_source = context["data_source"]
point_chart = self.renderer.PointChart(data_source,
options={'title': "Sales Growth"})
context["point_chart"] = point_chart
area_chart = flot.AreaChart(SimpleDataSource(data=data),
options={'title': "Sales Growth"})
context.update({'point_chart': point_chart,
'area_chart': area_chart})
return context

flot_demo = FlotDemo.as_view(renderer=flot)
Expand Down
9 changes: 9 additions & 0 deletions graphos/renderers/flot.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def get_options(self):
options["horizontal"] = True
return options

class AreaChart(BaseFlotChart):

def get_options(self):
options = get_default_options("lines")
options.update({"series": {"lines": {"fill": "true"}}})
options.update(self.options)
options["horizontal"] = True
return options


class PieChart(BaseFlotChart):
pass # TODO