From 161cc16498a6fb1de50a9b4045d6efcb54545d70 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sat, 30 Apr 2016 06:41:59 +0200 Subject: [PATCH] continued work ok charts --- app/rollerverbrauch/static/main.js | 81 ++++++++++- app/rollerverbrauch/templates/layout.html | 1 + app/rollerverbrauch/templates/statistics.html | 129 ++++++------------ app/rollerverbrauch/tools.py | 1 + 4 files changed, 125 insertions(+), 87 deletions(-) diff --git a/app/rollerverbrauch/static/main.js b/app/rollerverbrauch/static/main.js index 8b13789..dc9ca89 100644 --- a/app/rollerverbrauch/static/main.js +++ b/app/rollerverbrauch/static/main.js @@ -1 +1,80 @@ - +function createChart(id, data, unit) { + return AmCharts.makeChart(id, { + "type": "serial", + //"theme": "chalk", + //"marginRight": 40, + //"marginLeft": 40, + //"autoMarginOffset": 20, + "mouseWheelZoomEnabled":true, + "dataDateFormat": "YYYY-MM-DD", + "valueAxes": [{ + "id": "v1", + "axisAlpha": 0, + "position": "left", + "ignoreAxisWidth":true, + "title": "Fuelled litres" + }], + "balloon": { + "borderThickness": 1, + "shadowAlpha": 10 + }, + "graphs": [{ + "id": "g1", + "balloon":{ + "drop":true, + "adjustBorderColor":false, + "color":"#ffffff" + }, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#000000", + "bulletSize": 5, + "hideBulletsCount": 50, + "lineThickness": 2, + "title": "Fuelled litres", + //"useLineColorForBulletBorder": true, + "valueField": "value", + "balloonText": "[[value]] "+unit+"" + }], + "chartScrollbar": { + "graph": "g1", + "oppositeAxis":false, + "offset":30, + "scrollbarHeight": 80, + "backgroundAlpha": 0, + "selectedBackgroundAlpha": 0.1, + "selectedBackgroundColor": "#888888", + "graphFillAlpha": 0, + "graphLineAlpha": 0.5, + "selectedGraphFillAlpha": 0, + "selectedGraphLineAlpha": 1, + "autoGridCount":true, + "color":"#AAAAAA" + }, + "chartCursor": { + "pan": true, + "valueLineEnabled": true, + "valueLineBalloonEnabled": true, + "cursorAlpha":1, + "cursorColor":"#258cbb", + "limitToGraph":"g1", + "valueLineAlpha":0.2, + "valueZoomable":true + }, + "valueScrollbar":{ + "oppositeAxis":false, + "offset":50, + "scrollbarHeight":10 + }, + "categoryField": "date", + "categoryAxis": { + "parseDates": true, + "dashLength": 1, +// "minorGridEnabled": true + }, + "export": { + "enabled": true + }, + "dataProvider": data + }); +} diff --git a/app/rollerverbrauch/templates/layout.html b/app/rollerverbrauch/templates/layout.html index e44af45..2f4f726 100644 --- a/app/rollerverbrauch/templates/layout.html +++ b/app/rollerverbrauch/templates/layout.html @@ -94,6 +94,7 @@ +