dashboard

pull/6/head
root 2015-02-27 23:18:40 +08:00
parent 9d44bc1593
commit cf8af114fe
2 changed files with 84 additions and 5 deletions

View File

@ -36,8 +36,8 @@ def index(request):
path1, path2 = u'仪表盘', 'Dashboard'
dic = {}
li_date, li_str = getDaysByNum(7)
li_str = json.dumps(li_str)
print li_str
# li_str = json.dumps(li_str)
# print li_str, type(li_str)
today = datetime.datetime.now().day
from_week = datetime.datetime.now() - datetime.timedelta(days=7)
week_data = Log.objects.filter(start_time__range=[from_week, datetime.datetime.now()])

View File

@ -58,13 +58,14 @@
</div>
</div>
</div>
<div>{{ li_str }}</div>
<div id="high" style="width:100%;height:400px;"></div>
</br>
<div id="dynamic" style="width:100%;height:400px;"></div>
</div>
</div>
<script>
var cate = {{ li_str }};
var cate = {{ li_str|safe }};
$(function () {
$('#high').highcharts({
title: {
@ -79,7 +80,8 @@ $(function () {
type: 'datetime',
categories: cate
},
yAxis: {
yAxis:{
min: 0,
title: {
text: '登录次数'
},
@ -105,6 +107,83 @@ $(function () {
{% endfor %}
]
});
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
$('#dynamic').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true, true);
}, 1000);
}
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: (function() {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
})()
}]
});
});
});
</script>