From 3bd4880b30a1b12dbd9ed357e9e760585315c254 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 15 Apr 2016 15:44:59 +0200 Subject: [PATCH] show delays using deciles on a barchart and not just min/max deciles gives a better insight on the repartition of delays, i.e. "are long delays frequent or not". --- wcs/backoffice/management.py | 56 +++++++++++++++++++++++++++++++++++-- wcs/qommon/static/css/dc2/admin.css | 6 ++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/wcs/backoffice/management.py b/wcs/backoffice/management.py index 3d4198a..1a3fd42 100644 --- a/wcs/backoffice/management.py +++ b/wcs/backoffice/management.py @@ -21,6 +21,7 @@ import json import time import types import urllib +import math try: import xlwt @@ -1624,18 +1625,68 @@ class FormPage(Directory): if not res_time_forms: continue res_time_forms.sort() + deciles = [res_time_forms[0]] + for i in range(1, 10): + j = len(res_time_forms) * i / 10 + deciles.append(res_time_forms[j]) + deciles.append(res_time_forms[-1]) + + res_time_forms.sort() sum_times = sum(res_time_forms) len_times = len(res_time_forms) min_times = res_time_forms[0] max_times = res_time_forms[-1] r += htmltext('

%s

') % (_('To Status "%s"') % self.formdef.workflow.get_status(status_id).name) + r += htmltext('
' + % status_id) + r += htmltext('' + % (status_id, json.dumps( + [['%d' % (i * 10), math.ceil(v / 86400)] for i, v in + enumerate(deciles)][1:]))) + r += htmltext('' + % (status_id, json.dumps( + [['%d' % (i * 10), format_time(v)] for i, v in enumerate(deciles)][1:]))) + get_response().add_javascript_code(''' + $(function () { + $.jqplot ('chart_wf_%(status_id)s_delays', [wf_%(status_id)s_deciles,wf_%(status_id)s_deciles2], { + series: [{renderer: $.jqplot.BarRenderer},{yaxis: + 'y2axis'}], + legend: {show: false}, + axes: { + xaxis: { + tickOptions: { + angle: -30 + }, + renderer: $.jqplot.CategoryAxisRenderer, + label: 'pourcents', + tickRenderer:$.jqplot.CanvasAxisTickRenderer, + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, + }, + yaxis: { + label: 'jours', + tickRenderer:$.jqplot.CanvasAxisTickRenderer, + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, + tickOptions:{ + angle:-30 + } + } + }, + highlighter: { + show: true, + useAxesFormatters: false, + tooltipContentEditor: function(str, seriesIndex, pointIndex, jqPlot) { + return wf_%(status_id)s_deciles2[pointIndex][1]; + } + }, + }); +});''' % {'status_id': status_id}) + r += htmltext('