Skip to content

Instantly share code, notes, and snippets.

@rauch
Created July 25, 2012 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rauch/3175635 to your computer and use it in GitHub Desktop.
Save rauch/3175635 to your computer and use it in GitHub Desktop.
django-chartit, DateTime as xAxis
@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
@egrachev
Copy link

egrachev commented Apr 2, 2013

smart solution, thanks

@ofraam
Copy link

ofraam commented Jul 9, 2014

For those who like me find this out of context, note that you have to modify the chartit python code as shown here: bastir85/django-chartit@aa47dc1

@pbassut
Copy link

pbassut commented Aug 22, 2014

thanks @ofraam. Coulnd't make it without your comment

@imscaradh
Copy link

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.

@7oas7er
Copy link

7oas7er commented Feb 15, 2016

Seems the patch code from @ofraam has been integrated at least into the django-chartit2-0.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment