Improved resource data history

This commit is contained in:
Marc Aymerich 2015-07-27 13:04:31 +00:00
parent 671da932eb
commit ae65ddcd46
2 changed files with 8 additions and 6 deletions

View File

@ -34,7 +34,7 @@ def get_history_data(queryset):
serie = {} serie = {}
for data in datas: for data in datas:
date = date_filter(data.date) date = date_filter(data.date)
value = round(float(data.value or 0)/scale, 2) value = round(float(data.value)/scale, 3) if data.value is not None else None
all_dates.add(date) all_dates.add(date)
serie[date] = value serie[date] = value
else: else:
@ -42,7 +42,7 @@ def get_history_data(queryset):
for data in datas: for data in datas:
date = data.created_at.timestamp() date = data.created_at.timestamp()
date = int(str(date).split('.')[0] + '000') date = int(str(date).split('.')[0] + '000')
value = round(float(data.value or 0)/scale, 2) value = round(float(data.value)/scale, 3) if data.value is not None else None
serie.append( serie.append(
(date, value) (date, value)
) )

View File

@ -46,7 +46,6 @@
}); });
}, },
columns: function (div, i, seriesOptions, resource){ columns: function (div, i, seriesOptions, resource){
console.log(div);
$(div).highcharts({ $(div).highcharts({
chart: { chart: {
type: 'column', type: 'column',
@ -68,6 +67,9 @@
style: { style: {
fontWeight: 'bold', fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
},
formatter: function () {
return this.total + ' ' + resource['unit'];
} }
} }
}, },
@ -85,8 +87,8 @@
tooltip: { tooltip: {
formatter: function () { formatter: function () {
return '<b>' + this.x + '</b><br/>' + return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y.toFixed(2) + ' ' + resource['unit'] + '<br/>' + this.series.name + ': ' + this.y.toFixed(3) + ' ' + resource['unit'] + '<br/>' +
'Total: ' + this.point.stackTotal.toFixed(2) + ' ' + resource['unit']; 'Total: ' + this.point.stackTotal.toFixed(3) + ' ' + resource['unit'];
} }
}, },
plotOptions: { plotOptions: {
@ -99,7 +101,7 @@
textShadow: '0 0 3px black' textShadow: '0 0 3px black'
}, },
formatter: function () { formatter: function () {
return this.series.name + ': ' + this.y.toFixed(2) + ' ' + resource['unit']; return this.series.name + ': ' + this.y.toFixed(3) + ' ' + resource['unit'];
} }
} }
} }