21 |
21 |
import time
|
22 |
22 |
import types
|
23 |
23 |
import urllib
|
|
24 |
import math
|
24 |
25 |
|
25 |
26 |
try:
|
26 |
27 |
import xlwt
|
... | ... | |
1624 |
1625 |
if not res_time_forms:
|
1625 |
1626 |
continue
|
1626 |
1627 |
res_time_forms.sort()
|
|
1628 |
deciles = [res_time_forms[0]]
|
|
1629 |
for i in range(1, 10):
|
|
1630 |
j = len(res_time_forms) * i / 10
|
|
1631 |
deciles.append(res_time_forms[j])
|
|
1632 |
deciles.append(res_time_forms[-1])
|
|
1633 |
|
|
1634 |
res_time_forms.sort()
|
1627 |
1635 |
sum_times = sum(res_time_forms)
|
1628 |
1636 |
len_times = len(res_time_forms)
|
1629 |
1637 |
min_times = res_time_forms[0]
|
1630 |
1638 |
max_times = res_time_forms[-1]
|
1631 |
1639 |
r += htmltext('<h3>%s</h3>') % (_('To Status "%s"') % self.formdef.workflow.get_status(status_id).name)
|
|
1640 |
r += htmltext('<div id="chart_wf_%s_delays" style="height:160px; width:100%%;"></div>'
|
|
1641 |
% status_id)
|
|
1642 |
r += htmltext('<script>wf_%s_deciles = %s;</script>'
|
|
1643 |
% (status_id, json.dumps(
|
|
1644 |
[['%d' % (i * 10), math.ceil(v / 86400)] for i, v in
|
|
1645 |
enumerate(deciles)][1:])))
|
|
1646 |
r += htmltext('<script>wf_%s_deciles2 = %s;</script>'
|
|
1647 |
% (status_id, json.dumps(
|
|
1648 |
[['%d' % (i * 10), format_time(v)] for i, v in enumerate(deciles)][1:])))
|
|
1649 |
get_response().add_javascript_code('''
|
|
1650 |
$(function () {
|
|
1651 |
$.jqplot ('chart_wf_%(status_id)s_delays', [wf_%(status_id)s_deciles,wf_%(status_id)s_deciles2], {
|
|
1652 |
series: [{renderer: $.jqplot.BarRenderer},{yaxis:
|
|
1653 |
'y2axis'}],
|
|
1654 |
legend: {show: false},
|
|
1655 |
axes: {
|
|
1656 |
xaxis: {
|
|
1657 |
tickOptions: {
|
|
1658 |
angle: -30
|
|
1659 |
},
|
|
1660 |
renderer: $.jqplot.CategoryAxisRenderer,
|
|
1661 |
label: 'pourcents',
|
|
1662 |
tickRenderer:$.jqplot.CanvasAxisTickRenderer,
|
|
1663 |
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
|
|
1664 |
},
|
|
1665 |
yaxis: {
|
|
1666 |
label: 'jours',
|
|
1667 |
tickRenderer:$.jqplot.CanvasAxisTickRenderer,
|
|
1668 |
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
|
|
1669 |
tickOptions:{
|
|
1670 |
angle:-30
|
|
1671 |
}
|
|
1672 |
}
|
|
1673 |
},
|
|
1674 |
highlighter: {
|
|
1675 |
show: true,
|
|
1676 |
useAxesFormatters: false,
|
|
1677 |
tooltipContentEditor: function(str, seriesIndex, pointIndex, jqPlot) {
|
|
1678 |
return wf_%(status_id)s_deciles2[pointIndex][1];
|
|
1679 |
}
|
|
1680 |
},
|
|
1681 |
});
|
|
1682 |
});''' % {'status_id': status_id})
|
|
1683 |
|
1632 |
1684 |
r += htmltext('<ul>')
|
1633 |
1685 |
r += htmltext(' <li>%s %s</li>') % (_('Count:'), len_times)
|
1634 |
|
r += htmltext(' <li>%s %s</li>') % (_('Minimum Time:'), format_time(min_times))
|
1635 |
|
r += htmltext(' <li>%s %s</li>') % (_('Maximum Time:'), format_time(max_times))
|
1636 |
1686 |
r += htmltext(' <li>%s %s</li>') % (_('Range:'), format_time(max_times - min_times))
|
1637 |
1687 |
mean = sum_times / len_times
|
1638 |
1688 |
r += htmltext(' <li>%s %s</li>') % (_('Mean:'), format_time(mean))
|
|
1689 |
r += htmltext(' <li>%s %s</li>') % (_('Count:'), len(res_time_forms))
|
1639 |
1690 |
if len_times % 2:
|
1640 |
1691 |
median = res_time_forms[len_times/2]
|
1641 |
1692 |
else:
|
... | ... | |
1960 |
2011 |
'jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js',
|
1961 |
2012 |
'jqplot/plugins/jqplot.categoryAxisRenderer.min.js',
|
1962 |
2013 |
'jqplot/plugins/jqplot.barRenderer.min.js',
|
|
2014 |
'jqplot/plugins/jqplot.highlighter.js',
|
1963 |
2015 |
])
|
1964 |
2016 |
|
1965 |
2017 |
get_response().add_javascript_code('''
|