Commit 16614fc307795a858734d3cd7e0385cfc9654992
1 parent
8ab9e92c
Exists in
master
and in
2 other branches
modified cssand organization of category dashboard
Showing
9 changed files
with
113 additions
and
8 deletions
Show diff stats
analytics/views.py
@@ -244,8 +244,10 @@ def most_tags_inside_category(category_id): | @@ -244,8 +244,10 @@ def most_tags_inside_category(category_id): | ||
244 | 244 | ||
245 | def get_amount_of_comments(request): | 245 | def get_amount_of_comments(request): |
246 | params = request.GET | 246 | params = request.GET |
247 | - init_date = params.get('init_date') | ||
248 | - end_date = params.get('end_date') | 247 | + #init_date = params.get('init_date') |
248 | + #end_date = params.get('end_date') | ||
249 | + init_date = "04/20/2017" | ||
250 | + end_date = "06/09/2017" | ||
249 | init_date = datetime.strptime( init_date, '%m/%d/%Y') | 251 | init_date = datetime.strptime( init_date, '%m/%d/%Y') |
250 | end_date = datetime.strptime(end_time, '%m/%d/%Y') | 252 | end_date = datetime.strptime(end_time, '%m/%d/%Y') |
251 | day_count = (end_date - init_date).days + 1 | 253 | day_count = (end_date - init_date).days + 1 |
@@ -257,4 +259,6 @@ def get_amount_of_comments(request): | @@ -257,4 +259,6 @@ def get_amount_of_comments(request): | ||
257 | data[single_day] = Mural.objects.filter(space__id = category_id, create_date = single_day).count() | 259 | data[single_day] = Mural.objects.filter(space__id = category_id, create_date = single_day).count() |
258 | else: | 260 | else: |
259 | data[single_day] = Comment.objects.filter(create_date = single_day).count() | 261 | data[single_day] = Comment.objects.filter(create_date = single_day).count() |
260 | - return JsonResponse(data, safe=False) | ||
261 | \ No newline at end of file | 262 | \ No newline at end of file |
263 | + | ||
264 | + data_finished = [{date:key, count:value} for key, value in data.items()] | ||
265 | + return JsonResponse(data_finished, safe=False) | ||
262 | \ No newline at end of file | 266 | \ No newline at end of file |
dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/dashboards_category.sassc
No preview for this file type
dashboards/static/dashboards/css/dashboards_category.css
@@ -14,4 +14,8 @@ | @@ -14,4 +14,8 @@ | ||
14 | #category-selector option:hover { | 14 | #category-selector option:hover { |
15 | background: red; } | 15 | background: red; } |
16 | 16 | ||
17 | +.chart-side { | ||
18 | + float: left; | ||
19 | + width: 40%; } | ||
20 | + | ||
17 | /*# sourceMappingURL=dashboards_category.css.map */ | 21 | /*# sourceMappingURL=dashboards_category.css.map */ |
dashboards/static/dashboards/css/dashboards_category.css.map
1 | { | 1 | { |
2 | "version": 3, | 2 | "version": 3, |
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", | 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;;AAGhB,WAAW;EACV,KAAK,EAAE,IAAI;EACX,KAAK,EAAE,GAAG", |
4 | "sources": ["dashboards_category.sass"], | 4 | "sources": ["dashboards_category.sass"], |
5 | "names": [], | 5 | "names": [], |
6 | "file": "dashboards_category.css" | 6 | "file": "dashboards_category.css" |
dashboards/static/dashboards/css/dashboards_category.sass
dashboards/static/dashboards/js/behavior_categories.js
@@ -71,6 +71,17 @@ $(document).ready(function(){ | @@ -71,6 +71,17 @@ $(document).ready(function(){ | ||
71 | 71 | ||
72 | }); | 72 | }); |
73 | 73 | ||
74 | - | 74 | + $.get('/analytics/get_comments_count/', {category_id: $("#category-selector").val()}).done(function(dataset){ |
75 | + console.log(dataset); | ||
76 | + }); | ||
75 | 77 | ||
76 | }); | 78 | }); |
79 | + | ||
80 | + | ||
81 | +var filtering = { | ||
82 | + by_month: function(data){ | ||
83 | + | ||
84 | + }, | ||
85 | + by_year: function(data){}, | ||
86 | + by_week: function(data){} | ||
87 | +}; | ||
77 | \ No newline at end of file | 88 | \ No newline at end of file |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +var charts = { | ||
2 | + line_chart: function(data, target_id){ | ||
3 | + // 2. Use the margin convention practice | ||
4 | + | ||
5 | + var margin = {top: 50, right: 50, bottom: 50, left: 50} | ||
6 | + , width = 400 - margin.left - margin.right // Use the window's width | ||
7 | + , height = 400 - margin.top - margin.bottom; // Use the window's height | ||
8 | + | ||
9 | + var n = data.length; | ||
10 | + | ||
11 | + var xScale = d3.scaleTime().range([0, width]); | ||
12 | + | ||
13 | + var yScale = d3.scaleLinear().range([height, 0]); | ||
14 | + | ||
15 | + var line = d3.line() | ||
16 | + .x(function(d, i) { return xScale(d.date); }) // set the x values for the line generator | ||
17 | + .y(function(d) { return yScale(d.count); }) // set the y values for the line generator | ||
18 | + .curve(d3.curveMonotoneX) // apply smoothing to the line | ||
19 | + | ||
20 | + var svg = d3.select("#left-chart").append("svg") | ||
21 | + .attr("width", width) | ||
22 | + .attr("height", height) | ||
23 | + .append("g") | ||
24 | + .attr("transform", "translate("+margin.left+","+margin.right+")"); | ||
25 | + | ||
26 | + svg.append("g") | ||
27 | + .attr("class", "y axis") | ||
28 | + .call(d3.axisLeft(yScale)); | ||
29 | + | ||
30 | + | ||
31 | + svg.append("path") | ||
32 | + .datum(data) | ||
33 | + .attr("class", "line") | ||
34 | + .attr("d", line); | ||
35 | + | ||
36 | + svg.selectAll(".dot") | ||
37 | + .data(data) | ||
38 | + .enter().append("circle") | ||
39 | + .attr('class', "dot") | ||
40 | + .attr("cx", function(d,i ){ | ||
41 | + return xScale(i); | ||
42 | + }) | ||
43 | + .attr("cy", function(d){ | ||
44 | + return yScale(d.count); | ||
45 | + }) | ||
46 | + .attr("r", 5); | ||
47 | + }, | ||
48 | + | ||
49 | +}; | ||
0 | \ No newline at end of file | 50 | \ No newline at end of file |
dashboards/templates/dashboards/category.html
@@ -73,12 +73,45 @@ | @@ -73,12 +73,45 @@ | ||
73 | {% include "dashboards/tags_body.html" %} | 73 | {% include "dashboards/tags_body.html" %} |
74 | 74 | ||
75 | <div id="bottom-part"> | 75 | <div id="bottom-part"> |
76 | + | ||
77 | + <div id="left-side" class="chart-side"> | ||
78 | + <h2>{% trans "between" %}</h2> | ||
79 | + | ||
80 | + <div class='col-md-4'> | ||
81 | + <div class="form-group"> | ||
82 | + <div class='input-group date' id='init_date'> | ||
83 | + <input type='text' class="form-control" /> | ||
84 | + <span class="input-group-addon"> | ||
85 | + <span class="glyphicon glyphicon-calendar"></span> | ||
86 | + </span> | ||
87 | + </div> | ||
88 | + </div> | ||
89 | + </div> | ||
90 | + <div class='col-md-4'> | ||
91 | + <div class="form-group"> | ||
92 | + <div class='input-group date' id='end_date'> | ||
93 | + <input type='text' class="form-control" /> | ||
94 | + <span class="input-group-addon"> | ||
95 | + <span class="glyphicon glyphicon-calendar"></span> | ||
96 | + </span> | ||
97 | + </div> | ||
98 | + </div> | ||
99 | + </div> | ||
100 | + | ||
101 | + <div> | ||
102 | + <h4>{% trans "by" %}</h4> | ||
103 | + <select> | ||
104 | + <option>month</option> | ||
105 | + <option>year</option> | ||
106 | + </select> | ||
107 | + </div> | ||
76 | <div id="left-chart"> | 108 | <div id="left-chart"> |
77 | - | 109 | + |
78 | </div> | 110 | </div> |
111 | + </div> | ||
79 | 112 | ||
80 | 113 | ||
81 | - <div id="right-side-heatmaps"> | 114 | + <div id="right-side-heatmaps" class="chart-side"> |
82 | <div id="month_selector_div"> | 115 | <div id="month_selector_div"> |
83 | <h4>{% trans "Amount of access in: " %} | 116 | <h4>{% trans "Amount of access in: " %} |
84 | <select id="month_selector"> | 117 | <select id="month_selector"> |
dashboards/views.py
@@ -93,7 +93,8 @@ class CategoryView(LogMixin, generic.TemplateView): | @@ -93,7 +93,8 @@ class CategoryView(LogMixin, generic.TemplateView): | ||
93 | context['months'] = self.get_last_twelve_months() | 93 | context['months'] = self.get_last_twelve_months() |
94 | 94 | ||
95 | context['categories'] = self.categories_associated_with_user(self.request.user) | 95 | context['categories'] = self.categories_associated_with_user(self.request.user) |
96 | - context['javascript_files'] = ["analytics/js/charts.js", "dashboards/js/behavior_categories.js"] | 96 | + context['javascript_files'] = ["analytics/js/charts.js", "dashboards/js/behavior_categories.js", |
97 | + "dashboards/js/charts_category.js"] | ||
97 | context['style_files'] = ['dashboards/css/general.css', 'dashboards/css/dashboards_category.css'] | 98 | context['style_files'] = ['dashboards/css/general.css', 'dashboards/css/dashboards_category.css'] |
98 | return context | 99 | return context |
99 | 100 |