Skip to content

Instantly share code, notes, and snippets.

@pije76
Forked from rauch/django-chartit example
Created September 5, 2021 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pije76/e2234ef73f28e83f038fbf5e21d0b11f to your computer and use it in GitHub Desktop.
Save pije76/e2234ef73f28e83f038fbf5e21d0b11f 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment