From ae65ddcd46129558238b59e245cbc446773483e2 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Mon, 27 Jul 2015 13:04:31 +0000 Subject: [PATCH] Improved resource data history --- orchestra/contrib/resources/helpers.py | 4 ++-- .../admin/resources/resourcedata/history.html | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/orchestra/contrib/resources/helpers.py b/orchestra/contrib/resources/helpers.py index 042f4104..3611ad95 100644 --- a/orchestra/contrib/resources/helpers.py +++ b/orchestra/contrib/resources/helpers.py @@ -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) ) diff --git a/orchestra/contrib/resources/templates/admin/resources/resourcedata/history.html b/orchestra/contrib/resources/templates/admin/resources/resourcedata/history.html index c6b0a80d..0e7b98ce 100644 --- a/orchestra/contrib/resources/templates/admin/resources/resourcedata/history.html +++ b/orchestra/contrib/resources/templates/admin/resources/resourcedata/history.html @@ -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 '' + this.x + '
' + - this.series.name + ': ' + this.y.toFixed(2) + ' ' + resource['unit'] + '
' + - 'Total: ' + this.point.stackTotal.toFixed(2) + ' ' + resource['unit']; + this.series.name + ': ' + this.y.toFixed(3) + ' ' + resource['unit'] + '
' + + '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']; } } }