From f79f4324f773abe5df18ee33655bf6288c43aa84 Mon Sep 17 00:00:00 2001 From: Jairus Date: Wed, 12 Feb 2014 19:47:17 -0500 Subject: [PATCH] Added demo graphs --- demo_app/app/adminx.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/demo_app/app/adminx.py b/demo_app/app/adminx.py index 0e0ff4548..8e13dfa0c 100644 --- a/demo_app/app/adminx.py +++ b/demo_app/app/adminx.py @@ -5,7 +5,6 @@ from xadmin.plugins.inline import Inline from xadmin.plugins.batch import BatchChangeAction - class MainDashboard(object): widgets = [ [ @@ -116,8 +115,16 @@ def open_web(self, instance): ) inlines = [MaintainInline] reversion_enable = True - - + + data_charts = { + "host_service_type_counts": {'title': u"Host service type count", "x-field": "service_type", "y-field": ("service_type",), + "option": { + "series": {"bars": {"align": "center", "barWidth": 0.8,'show':True}}, + "xaxis": {"aggregate": "count", "mode": "categories"}, + }, + }, + } + class HostGroupAdmin(object): list_display = ('name', 'description') list_display_links = ('name',) @@ -172,8 +179,18 @@ def avg_count(self, instance): refresh_times = (3, 5, 10) data_charts = { "user_count": {'title': u"User Report", "x-field": "date", "y-field": ("user_count", "view_count"), "order": ('date',)}, - "avg_count": {'title': u"Avg Report", "x-field": "date", "y-field": ('avg_count',), "order": ('date',)} + "avg_count": {'title': u"Avg Report", "x-field": "date", "y-field": ('avg_count',), "order": ('date',)}, + "per_month": {'title': u"Monthly Users", "x-field": "_chart_month", "y-field": ("user_count", ), + "option": { + "series": {"bars": {"align": "center", "barWidth": 0.8,'show':True}}, + "xaxis": {"aggregate": "sum", "mode": "categories"}, + }, + }, } + + def _chart_month(self,obj): + return obj.date.strftime("%B") + xadmin.site.register(Host, HostAdmin) xadmin.site.register(HostGroup, HostGroupAdmin)