mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-26 08:39:08 +01:00
Migrate charts to jqPlot. Needs a bit of clean-up, especially separating out date & non-date reports.
This commit is contained in:
parent
b42026ec33
commit
9175203fb1
@ -2,6 +2,16 @@
|
||||
|
||||
{% block helpdesk_title %}{% trans "Reports & Statistics" %}{% endblock %}
|
||||
|
||||
{% block helpdesk_head %}
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="{{ MEDIA_URL }}helpdesk/jquery.jqplot/excanvas.min.js"></script><![endif]-->
|
||||
<script src='{{ MEDIA_URL }}helpdesk/jquery.jqplot/jquery.jqplot.min.js' type='text/javascript' language='javascript'></script>
|
||||
<link rel='stylesheet' typ='text/css' href='{{ MEDIA_URL }}helpdesk/jquery.jqplot/jquery.jqplot.min.css' />
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}helpdesk/jquery.jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}helpdesk/jquery.jqplot/plugins/jqplot.barRenderer.min.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}helpdesk/jquery.jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block helpdesk_body %}
|
||||
<h2>{% trans "Reports & Statistics" %}</h2>
|
||||
|
||||
@ -12,6 +22,69 @@
|
||||
<tr class='row_{% cycle odd,even %}'>{% for f in d %}<td>{{ f }}</td>{% endfor %}</tr>{% endfor %}
|
||||
</table>
|
||||
|
||||
{% if chart %}<img src='{{ chart }}' />{% endif %}
|
||||
<div class='jqPlot' id='placeholder' style='width: 600px; height: 400px;'></div>
|
||||
{% ifequal charttype "date" %}
|
||||
<script type='text/javascript'>
|
||||
$.jqplot.config.enablePlugins = true;
|
||||
var dataset = [];
|
||||
|
||||
{% for d in data %}
|
||||
dataset[{{ forloop.counter0 }}] = [{% for f in d %}{% if not forloop.first %}['{% for h in headings %}{% ifequal forloop.counter0 forloop.parentloop.counter0 %}{{ h }}{% endifequal %}{% endfor %}', {{ f }}]{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}];{% endfor %}
|
||||
|
||||
plot = $.jqplot('placeholder', dataset, {
|
||||
legend: {show: true, location: 'nw', xoffset: 55},
|
||||
title: "{{ title }}",
|
||||
series: [{% for d in data %}
|
||||
{
|
||||
label:'{{ d.0 }}',
|
||||
lineWidth: 4,
|
||||
markerOptions: { style: 'square'}
|
||||
}{% if not forloop.last %},{% endif %}{% endfor %}
|
||||
],
|
||||
axes: {
|
||||
xaxis: {
|
||||
renderer: $.jqplot.DateAxisRenderer
|
||||
},
|
||||
yaxis: {
|
||||
min: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endifequal %}
|
||||
{% ifequal charttype "bar" %}
|
||||
<script type='text/javascript'>
|
||||
$.jqplot.config.enablePlugins = true;
|
||||
var dataset = [];
|
||||
|
||||
{% for d in data %}
|
||||
dataset[{{ forloop.counter0 }}] = [{% for f in d %}{% if not forloop.first %}{{ f }}{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}];{% endfor %}
|
||||
|
||||
plot = $.jqplot('placeholder', dataset, {
|
||||
legend: {show: true, location: 'nw', xoffset: 55},
|
||||
title: "{{ title }}",
|
||||
seriesDefaults: {
|
||||
renderer: $.jqplot.BarRenderer,
|
||||
rendererOptions: {barPadding: 8, barMargin: 20}
|
||||
},
|
||||
series: [{% for d in data %}
|
||||
{label:'{{ d.0 }}'}{% if not forloop.last %},{% endif %}{% endfor %}
|
||||
],
|
||||
axes: {
|
||||
xaxis: {
|
||||
renderer: $.jqplot.CategoryAxisRenderer,
|
||||
ticks: [{% for h in headings %}{% if not forloop.first %}'{{ h }}'{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}]
|
||||
},
|
||||
yaxis: {
|
||||
min: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endifequal %}
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -896,10 +896,13 @@ def run_report(request, report):
|
||||
|
||||
if report in ('queuemonth', 'usermonth'):
|
||||
chart_url = line_chart([columns] + data)
|
||||
charttype = 'date'
|
||||
elif report in ('queuestatus', 'queuepriority', 'userstatus', 'userpriority'):
|
||||
chart_url = bar_chart([columns] + data)
|
||||
charttype = 'bar'
|
||||
else:
|
||||
chart_url = ''
|
||||
charttype = ''
|
||||
|
||||
return render_to_response('helpdesk/report_output.html',
|
||||
RequestContext(request, {
|
||||
@ -907,6 +910,7 @@ def run_report(request, report):
|
||||
'data': data,
|
||||
'chart': chart_url,
|
||||
'title': title,
|
||||
'charttype': charttype,
|
||||
}))
|
||||
run_report = staff_member_required(run_report)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user