Skip to content

Commit

Permalink
Added demo graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jairus committed Feb 13, 2014
1 parent 7a740ee commit f79f432
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions demo_app/app/adminx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from xadmin.plugins.inline import Inline
from xadmin.plugins.batch import BatchChangeAction


class MainDashboard(object):
widgets = [
[
Expand Down Expand Up @@ -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',)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f79f432

Please sign in to comment.