|
|
@@ -39,12 +39,31 @@ def home(request):
|
|
39
|
39
|
counter.lastReset.formatted_delta = format_timedelta(counter.lastReset.delta,locale='fr',threshold=1)
|
|
40
|
40
|
counter.isHidden = "hidden"
|
|
41
|
41
|
counters = sorted(counters,key=lambda t: -t.lastReset.delta)
|
|
42
|
|
- #Generate graph
|
|
|
42
|
+ #Column graph
|
|
43
|
43
|
lastResets.sort(key=lambda x: x[1]['v'])
|
|
44
|
44
|
lastResets.insert(0,['Trigramme','Jours sans seum'])
|
|
45
|
|
- data = SimpleDataSource(lastResets)
|
|
46
|
|
- chart = gchart.ColumnChart(data,options={'title' : '', 'legend' : 'none','vAxis' : { 'viewWindow' : { 'max' : max(maxJSS,1) , 'min' : 0} , 'ticks' : [1,2,3,4,5,6,7,8,9,10,11,12,13,14],'title' : 'Jours sans seum' }, 'hAxis' : {'title' : 'Trigramme' }})
|
|
47
|
|
- return render(request,'homeTemplate.html', {'counters' : counters, 'chart' : chart})
|
|
|
45
|
+ col_data = SimpleDataSource(lastResets)
|
|
|
46
|
+ col_chart = gchart.ColumnChart(col_data,options={'title' : '', 'legend' : 'none','vAxis' : { 'viewWindow' : { 'max' : max(maxJSS,1) , 'min' : 0} , 'ticks' : [1,2,3,4,5,6,7,8,9,10,11,12,13,14],'title' : 'Jours sans seum' }, 'hAxis' : {'title' : 'Trigramme' }})
|
|
|
47
|
+
|
|
|
48
|
+ ###Timeline graph
|
|
|
49
|
+ #Data pre-processing
|
|
|
50
|
+ resets = Reset.objects.filter(timestamp__gte=datetime.now() - timedelta(days=1))
|
|
|
51
|
+ for reset in resets:
|
|
|
52
|
+ reset.timestamp={'v' : reset.timestamp.timestamp(), 'f' : "Il y a "+format_timedelta(datetime.now()-reset.timestamp.replace(tzinfo=None),locale='fr',threshold=1) }
|
|
|
53
|
+ reset.Seum={'v' : 0, 'f' : reset.counter.trigramme+" : "+reset.reason}
|
|
|
54
|
+ #Drawing the graph
|
|
|
55
|
+ line_data = ModelDataSource(resets,fields=['timestamp','Seum'])
|
|
|
56
|
+ line_chart = gchart.LineChart(line_data, options={
|
|
|
57
|
+ 'lineWidth' : 0,
|
|
|
58
|
+ 'pointSize' : 10,
|
|
|
59
|
+ 'title' : '',
|
|
|
60
|
+ 'vAxis' : { 'ticks' : []},
|
|
|
61
|
+ 'hAxis' : {'ticks' : [{'v' : (datetime.now() - timedelta(days=1)).timestamp(), 'f' : 'Il y a 24 h' }, { 'v' :datetime.now().timestamp(), 'f' : 'Présent'}]},
|
|
|
62
|
+ 'legend' : 'none',
|
|
|
63
|
+ 'height' : 90
|
|
|
64
|
+ })
|
|
|
65
|
+
|
|
|
66
|
+ return render(request,'homeTemplate.html', {'counters' : counters, 'col_chart' : col_chart, 'line_chart' : line_chart})
|
|
48
|
67
|
|
|
49
|
68
|
def resetCounter(request):
|
|
50
|
69
|
#Update Form counter
|