From 16614fc307795a858734d3cd7e0385cfc9654992 Mon Sep 17 00:00:00 2001 From: Felipe Bormann Date: Tue, 13 Jun 2017 13:04:37 -0300 Subject: [PATCH] modified cssand organization of category dashboard --- analytics/views.py | 10 +++++++--- dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc | Bin 5125 -> 0 bytes dashboards/static/dashboards/css/dashboards_category.css | 4 ++++ dashboards/static/dashboards/css/dashboards_category.css.map | 2 +- dashboards/static/dashboards/css/dashboards_category.sass | 3 +++ dashboards/static/dashboards/js/behavior_categories.js | 13 ++++++++++++- dashboards/static/dashboards/js/charts_category.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ dashboards/templates/dashboards/category.html | 37 +++++++++++++++++++++++++++++++++++-- dashboards/views.py | 3 ++- 9 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 dashboards/static/dashboards/js/charts_category.js diff --git a/analytics/views.py b/analytics/views.py index a829f55..8a4a23c 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -244,8 +244,10 @@ def most_tags_inside_category(category_id): def get_amount_of_comments(request): params = request.GET - init_date = params.get('init_date') - end_date = params.get('end_date') + #init_date = params.get('init_date') + #end_date = params.get('end_date') + init_date = "04/20/2017" + end_date = "06/09/2017" init_date = datetime.strptime( init_date, '%m/%d/%Y') end_date = datetime.strptime(end_time, '%m/%d/%Y') day_count = (end_date - init_date).days + 1 @@ -257,4 +259,6 @@ def get_amount_of_comments(request): data[single_day] = Mural.objects.filter(space__id = category_id, create_date = single_day).count() else: data[single_day] = Comment.objects.filter(create_date = single_day).count() - return JsonResponse(data, safe=False) \ No newline at end of file + + data_finished = [{date:key, count:value} for key, value in data.items()] + return JsonResponse(data_finished, safe=False) \ No newline at end of file diff --git a/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc b/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc index 0ae59aa..bd3dde5 100644 Binary files a/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc and b/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc differ diff --git a/dashboards/static/dashboards/css/dashboards_category.css b/dashboards/static/dashboards/css/dashboards_category.css index 0558fa8..e9e8391 100644 --- a/dashboards/static/dashboards/css/dashboards_category.css +++ b/dashboards/static/dashboards/css/dashboards_category.css @@ -14,4 +14,8 @@ #category-selector option:hover { background: red; } +.chart-side { + float: left; + width: 40%; } + /*# sourceMappingURL=dashboards_category.css.map */ diff --git a/dashboards/static/dashboards/css/dashboards_category.css.map b/dashboards/static/dashboards/css/dashboards_category.css.map index 7e5989c..9ffeab8 100644 --- a/dashboards/static/dashboards/css/dashboards_category.css.map +++ b/dashboards/static/dashboards/css/dashboards_category.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,kBAAkB;EACjB,UAAU,EAAE,WAAW;EACvB,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,GAAG;EAChB,KAAK,EAAE,OAAO;EACd,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,SAAS;EACvB,WAAW,EAAE,SAAS;;AAEvB,yBAAyB;EACxB,UAAU,EAAE,OAAO;EACnB,KAAK,EAAE,OAAO;;AAEf,+BAA+B;EAC9B,UAAU,EAAE,GAAG", +"mappings": "AAAA,kBAAkB;EACjB,UAAU,EAAE,WAAW;EACvB,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,GAAG;EAChB,KAAK,EAAE,OAAO;EACd,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,SAAS;EACvB,WAAW,EAAE,SAAS;;AAEvB,yBAAyB;EACxB,UAAU,EAAE,OAAO;EACnB,KAAK,EAAE,OAAO;;AAEf,+BAA+B;EAC9B,UAAU,EAAE,GAAG;;AAGhB,WAAW;EACV,KAAK,EAAE,IAAI;EACX,KAAK,EAAE,GAAG", "sources": ["dashboards_category.sass"], "names": [], "file": "dashboards_category.css" diff --git a/dashboards/static/dashboards/css/dashboards_category.sass b/dashboards/static/dashboards/css/dashboards_category.sass index 037a2d3..5410509 100644 --- a/dashboards/static/dashboards/css/dashboards_category.sass +++ b/dashboards/static/dashboards/css/dashboards_category.sass @@ -15,3 +15,6 @@ background: red +.chart-side + float: left + width: 40% \ No newline at end of file diff --git a/dashboards/static/dashboards/js/behavior_categories.js b/dashboards/static/dashboards/js/behavior_categories.js index 908602b..886d097 100644 --- a/dashboards/static/dashboards/js/behavior_categories.js +++ b/dashboards/static/dashboards/js/behavior_categories.js @@ -71,6 +71,17 @@ $(document).ready(function(){ }); - + $.get('/analytics/get_comments_count/', {category_id: $("#category-selector").val()}).done(function(dataset){ + console.log(dataset); + }); }); + + +var filtering = { + by_month: function(data){ + + }, + by_year: function(data){}, + by_week: function(data){} +}; \ No newline at end of file diff --git a/dashboards/static/dashboards/js/charts_category.js b/dashboards/static/dashboards/js/charts_category.js new file mode 100644 index 0000000..b313b49 --- /dev/null +++ b/dashboards/static/dashboards/js/charts_category.js @@ -0,0 +1,49 @@ +var charts = { + line_chart: function(data, target_id){ + // 2. Use the margin convention practice + + var margin = {top: 50, right: 50, bottom: 50, left: 50} + , width = 400 - margin.left - margin.right // Use the window's width + , height = 400 - margin.top - margin.bottom; // Use the window's height + + var n = data.length; + + var xScale = d3.scaleTime().range([0, width]); + + var yScale = d3.scaleLinear().range([height, 0]); + + var line = d3.line() + .x(function(d, i) { return xScale(d.date); }) // set the x values for the line generator + .y(function(d) { return yScale(d.count); }) // set the y values for the line generator + .curve(d3.curveMonotoneX) // apply smoothing to the line + + var svg = d3.select("#left-chart").append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate("+margin.left+","+margin.right+")"); + + svg.append("g") + .attr("class", "y axis") + .call(d3.axisLeft(yScale)); + + + svg.append("path") + .datum(data) + .attr("class", "line") + .attr("d", line); + + svg.selectAll(".dot") + .data(data) + .enter().append("circle") + .attr('class', "dot") + .attr("cx", function(d,i ){ + return xScale(i); + }) + .attr("cy", function(d){ + return yScale(d.count); + }) + .attr("r", 5); + }, + +}; \ No newline at end of file diff --git a/dashboards/templates/dashboards/category.html b/dashboards/templates/dashboards/category.html index eee5484..ce1f52d 100644 --- a/dashboards/templates/dashboards/category.html +++ b/dashboards/templates/dashboards/category.html @@ -73,12 +73,45 @@ {% include "dashboards/tags_body.html" %}
+ +
+

{% trans "between" %}

+ +
+
+
+ + + + +
+
+
+
+
+
+ + + + +
+
+
+ +
+

{% trans "by" %}

+ +
- +
+
-
+

{% trans "Amount of access in: " %}