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AAE,eAAe;4BACrB,WAAW,EAAE;gCACT,uBAAuB;6BAC1B;4BACD,eAAe,EAAE;gCACb,kBAAkB;6BACrB;4BACD,WAAW,EAAE,CAAC;yBACjB,EAAE;4BACC,KAAK,EAAE,SAAS;4BAChB,IAAI,EAAE,kBAAkB;4BACxB,WAAW,EAAE;gCACT,sBAAsB;6BACzB;4BACD,eAAe,EAAE;gCACb,kBAAkB;6BACrB;4BACD,WAAW,EAAE,CAAC;yBACjB,EAAE;4BACC,KAAK,EAAE,SAAS;4BAChB,IAAI,EAAE,kBAAkB;4BACxB,WAAW,EAAE;gCACT,uBAAuB;6BAC1B;4BACD,eAAe,EAAE;gCACb,kBAAkB;6BACrB;4BACD,WAAW,EAAE,CAAC;yBACjB,CAAC;iBACL;gBACD,OAAO,EAAE;oBACL,MAAM,EAAE;wBACJ,KAAK,EAAE,CAAC;gCACJ,KAAK,EAAE;oCACH,WAAW,EAAE,IAAI;iCACpB;6BACJ,CAAC;qBACL;iBACJ;aACJ,CAAC,CAAC;QACP,CAAC,CAAC;QAEF,IAAI,IAAI,GAAG;YACP,iBAAiB,EAAE,CAAC;QACxB,CAAC,CAAC;QAEF,IAAI,EAAE,CAAC;IACX,CAAC,EApGa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoGlB;AAAD,CAAC,EApGM,MAAM,KAAN,MAAM,QAoGZ","file":"kaliaa.stats.js","sourcesContent":["/// \r\n\r\nmodule Kaliaa.Stats {\r\n var retrieveChartData = () => {\r\n $.ajax({\r\n url: \"/api/stats/addition/\",\r\n async: true,\r\n dataType: 'json',\r\n type: \"get\"\r\n }).done(function (data) {\r\n initAccumulationCharts(data);\r\n });\r\n }\r\n\r\n var getAccumulation = function (values) {\r\n let accumulation = 0;\r\n return values.map(v => {\r\n accumulation += v;\r\n return accumulation;\r\n });\r\n };\r\n\r\n var initAccumulationCharts = function (data) {\r\n initYearlyAccumulationChart(data);\r\n initMonthlyAccumulationChart(data);\r\n };\r\n\r\n var initYearlyAccumulationChart = function (data) {\r\n let labels = data.yearly.map(item => item.year);\r\n initAccumulationChart(\"#accumulation-yearly-chart\", labels, data.yearly);\r\n };\r\n\r\n var initMonthlyAccumulationChart = function (data) {\r\n let labels = data.monthly.map(item => item.month);\r\n initAccumulationChart(\"#accumulation-monthly-chart\", labels, data.monthly);\r\n };\r\n \r\n var initAccumulationChart = function (selector, labels, values) {\r\n let $container = $(selector);\r\n let ctx = $(\"canvas\", $container).get(0).getContext('2d');\r\n\r\n labels = [\"\"].concat(labels);\r\n let reviews = [0].concat(values.map(item => item.reviews));\r\n let reviewsAccumulated = getAccumulation(reviews);\r\n let ratings = [0].concat(values.map(item => item.ratings));\r\n let ratingsAccumulated = getAccumulation(ratings);\r\n let beers = [0].concat(values.map(item => item.beers));\r\n let beerAccumulated = getAccumulation(beers);\r\n\r\n let myChart = new Chart(ctx, {\r\n type: 'line',\r\n data: {\r\n labels: labels,\r\n datasets: [{\r\n label: 'Beers',\r\n data: beerAccumulated,\r\n borderColor: [\r\n 'rgba(255, 99, 132, 1)'\r\n ],\r\n backgroundColor: [\r\n 'rgba(0, 0, 0, 0)'\r\n ],\r\n borderWidth: 1\r\n }, {\r\n label: 'Reviews',\r\n data: reviewsAccumulated,\r\n borderColor: [\r\n 'rgba(50, 255, 60, 1)'\r\n ],\r\n backgroundColor: [\r\n 'rgba(0, 0, 0, 0)'\r\n ],\r\n borderWidth: 1\r\n }, {\r\n label: 'Ratings',\r\n data: ratingsAccumulated,\r\n borderColor: [\r\n 'rgba(255, 99, 255, 1)'\r\n ],\r\n backgroundColor: [\r\n 'rgba(0, 0, 0, 0)'\r\n ],\r\n borderWidth: 1\r\n }]\r\n },\r\n options: {\r\n scales: {\r\n yAxes: [{\r\n ticks: {\r\n beginAtZero: true\r\n }\r\n }]\r\n }\r\n }\r\n });\r\n };\r\n \r\n var init = function () {\r\n retrieveChartData();\r\n };\r\n\r\n init();\r\n}"]}