diff --git a/app/rollerverbrauch/filters.py b/app/rollerverbrauch/filters.py index 00a0e59..f3ce080 100644 --- a/app/rollerverbrauch/filters.py +++ b/app/rollerverbrauch/filters.py @@ -1,4 +1,5 @@ from rollerverbrauch import app +import hashlib @app.template_filter('none_filter') @@ -7,3 +8,15 @@ def none_filter(value): return '' else: return value + + +@app.template_filter('md5') +def md5_filter(value): + m = hashlib.md5() + m.update(str(value).encode('UTF-8')) + return m.hexdigest() + + +@app.template_filter('str') +def str_filter(value): + return str(value) diff --git a/app/rollerverbrauch/static/main.js b/app/rollerverbrauch/static/main.js index dc9ca89..0724e5d 100644 --- a/app/rollerverbrauch/static/main.js +++ b/app/rollerverbrauch/static/main.js @@ -12,18 +12,18 @@ function createChart(id, data, unit) { "axisAlpha": 0, "position": "left", "ignoreAxisWidth":true, - "title": "Fuelled litres" +// "title": unit }], "balloon": { "borderThickness": 1, - "shadowAlpha": 10 + "shadowAlpha": 10, }, "graphs": [{ "id": "g1", "balloon":{ "drop":true, "adjustBorderColor":false, - "color":"#ffffff" + "color":"#ffffff", }, "bullet": "round", "bulletBorderAlpha": 1, @@ -31,7 +31,7 @@ function createChart(id, data, unit) { "bulletSize": 5, "hideBulletsCount": 50, "lineThickness": 2, - "title": "Fuelled litres", + // "title": unit, //"useLineColorForBulletBorder": true, "valueField": "value", "balloonText": "[[value]] "+unit+"" diff --git a/app/rollerverbrauch/templates/layout.html b/app/rollerverbrauch/templates/layout.html index 2f4f726..8b7e982 100644 --- a/app/rollerverbrauch/templates/layout.html +++ b/app/rollerverbrauch/templates/layout.html @@ -59,6 +59,31 @@ {% endmacro %} +{% macro chartScript(divId, data, unit)%} + {% set hash = divId | md5 %} + + data_{{ hash }} = [{% for stop in data %}{ + "date": "{{stop.date}}", + "value": {{stop.value}} + }{% if not loop.last %},{%endif%} + {% endfor%} + ] + var chart_{{ hash }} = createChart('{{divId}}', data_{{ hash }}, '{{unit}}'); + + function zoom_chart_{{ hash }}() { + chart_{{ hash }}.zoomToIndexes( + chart_{{ hash }}.dataProvider.length - 40, + chart_{{ hash }}.dataProvider.length - 1 + ); + } + + chart_{{ hash }}.addListener("rendered", zoom_chart_{{ hash }}); + + zoom_chart_{{ hash }}() + +{% endmacro %} + + @@ -94,6 +119,9 @@ + + +
diff --git a/app/rollerverbrauch/templates/statistics.html b/app/rollerverbrauch/templates/statistics.html index b40700e..24fa010 100644 --- a/app/rollerverbrauch/templates/statistics.html +++ b/app/rollerverbrauch/templates/statistics.html @@ -57,13 +57,27 @@