From f946c83fbba7eee25ba7a91812ba332789968cfd Mon Sep 17 00:00:00 2001 From: ramesh Date: Mon, 5 Jun 2017 18:00:44 +0530 Subject: [PATCH] added area chart for flot --- demo_project/demo/templates/demo/flot.html | 15 +++++++++++++++ demo_project/demo/views.py | 5 ++++- graphos/renderers/flot.py | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/demo_project/demo/templates/demo/flot.html b/demo_project/demo/templates/demo/flot.html index d7fd9e4..3bde416 100644 --- a/demo_project/demo/templates/demo/flot.html +++ b/demo_project/demo/templates/demo/flot.html @@ -90,4 +90,19 @@

Pie Chart


+

Area Chart

+
+ {{ area_chart.as_html }} +
+        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"})
+    
+
{% endblock %} diff --git a/demo_project/demo/views.py b/demo_project/demo/views.py index 5f4291a..c3ed32a 100755 --- a/demo_project/demo/views.py +++ b/demo_project/demo/views.py @@ -278,8 +278,11 @@ def get_context_data(self, **kwargs): options={'title': "Sales Growth"}) pie_chart = flot.PieChart(context["simple_data_source"], options = {'title': "Sales Growth"}) + area_chart = flot.AreaChart(context["simple_data_source"], + options = {'title': "Sales Growth"}) context.update({'point_chart': point_chart, - "pie_chart": pie_chart}) + "pie_chart": pie_chart, + "area_chart": area_chart}) return context flot_demo = FlotDemo.as_view(renderer=flot) diff --git a/graphos/renderers/flot.py b/graphos/renderers/flot.py index 94081e1..d607da5 100644 --- a/graphos/renderers/flot.py +++ b/graphos/renderers/flot.py @@ -104,3 +104,12 @@ def get_options(self): def get_js_template(self): return 'graphos/flot/pie_chart.html' + + +class AreaChart(BaseFlotChart): + + def get_options(self): + options = get_default_options("lines") + options["series"]["lines"] = {"fill": "true"} + options.update(self.options) + return options