From 7dc8868361e0f174e211c9a3d158082df5c21a3c Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 17 Jan 2014 00:36:10 +0100 Subject: First statistics :) --- static/js/kosten.ls | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'static/js/kosten.ls') diff --git a/static/js/kosten.ls b/static/js/kosten.ls index 9d8e097..acfb38f 100644 --- a/static/js/kosten.ls +++ b/static/js/kosten.ls @@ -3,6 +3,17 @@ jQuery.fn.extend do jq = (f) -> !-> $ f +# Call this to localize HighCharts +set_lang = -> + Highcharts .setOptions do + lang: + months: [\Januar, \Februar, \März, \April, \Mai, \Juni, \Juli, \August, \September, \Oktober, \November, \Dezember] + shortMonths: [\Jan, \Feb, \Mär, \Apr, \Mai, \Jun, \Jul, \Aug, \Sep, \Okt, \Nov, \Dez] + weekdays: [\Sonntag, \Montag, \Dienstag, \Mittwoch, \Donnerstag, \Freitag, \Samstag] + rangeSelectorFrom: \von + rangeSelectorTo: \bis + rangeSelectorZoom: null + # Add export addJS = jq -> $ 'input[name=date]' .datepicker do @@ -11,6 +22,8 @@ export addJS = jq -> # Show export showJS = jq -> + set_lang! + $ ".detail .heading" .click -> $ @ .closest \.detail .children \.mark:first .click! @@ -50,6 +63,38 @@ export showJS = jq -> for k,v of ..data \pie ] ] +# Statistics +export statJS = jq -> + set_lang! + + month = 30 * 24 * 60 * 60 * 1000 + + <- $ \.stats .each + $ @ + ..highcharts 'StockChart' do + title: text: null + credits: enabled: false + rangeSelector: + buttons: null + inputDateFormat: "%d. %b %Y" + inputEditDateFormat: "%d.%m.%Y" + inputDateParser: (value) -> + value .= split /\./ + Date.UTC(value[2], # year + value[1] - 1, # month ... 0-based -.- + value[0], #day + 0,0,0,0 # time + ) + xAxis: + minTickInterval: month + minRange: month + series: [ + data : ..data \stats + ] + tooltip: + pointFormat: "{point.y} €
" + + # Categories export catsJS = jq -> counter = 0 -- cgit v1.2.3-70-g09d2