Skip to content

Instantly share code, notes, and snippets.

@rauch
Created July 25, 2012 11:26
Show Gist options
  • Select an option

  • Save rauch/3175635 to your computer and use it in GitHub Desktop.

Select an option

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

egrachev commented Apr 2, 2013

Copy link
Copy Markdown

smart solution, thanks

@ofraam

ofraam commented Jul 9, 2014

Copy link
Copy Markdown

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

pbassut commented Aug 22, 2014

Copy link
Copy Markdown

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

@imscaradh

Copy link
Copy Markdown

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

7oas7er commented Feb 15, 2016

Copy link
Copy Markdown

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