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 = {}
for data in datas:
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)
serie[date] = value
else:
@ -42,7 +42,7 @@ def get_history_data(queryset):
for data in datas:
date = data.created_at.timestamp()
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(
(date, value)
)

View File

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