Created
July 25, 2012 11:26
-
-
Save rauch/3175635 to your computer and use it in GitHub Desktop.
django-chartit, DateTime as xAxis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def getJobStatChart(title, currentTime): | |
statistics =\ | |
DataPool( | |
series= | |
[{'options': { | |
'source': PBSServer.objects.order_by('-time')[:20] }, | |
'terms': [ | |
('time', lambda d: time.mktime(d.timetuple())), | |
'running_jobs', | |
'queued_jobs', | |
'total_jobs']} | |
]) | |
#Step 2: Create the Chart object | |
chart = Chart( | |
datasource=statistics, | |
series_options= | |
[{'options': { | |
'type': 'line', | |
'stacking': False}, | |
'terms': { | |
'time': [ | |
'running_jobs', | |
'queued_jobs', | |
'total_jobs'] | |
}}], | |
chart_options= | |
{'title': { | |
'text': title}, | |
'xAxis': { | |
'title': { | |
'text': 'Time'}}}, | |
x_sortf_mapf_mts=(None, lambda i: datetime.fromtimestamp(i).strftime("%H:%M"), False)) | |
return chart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @ofraam and @rauch! I had to write a patch to add this functionality.. Does anybody knows why this is not committed to Chartit? Perhaps it's a stupid question because I'm a newbie concerning Django and Python.