audit_rails 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/audit_rails/audit.js +1 -0
- data/app/assets/javascripts/audit_rails/page-view-user-contribution.js +106 -44
- data/app/assets/stylesheets/audit_rails/audit_rails.css +3 -0
- data/app/views/audit_rails/audits/_page_views_by_user_bar.html.erb +1 -1
- data/app/views/audit_rails/audits/_page_views_by_user_pie.html.erb +1 -1
- data/lib/audit_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e57ca2c04fe002da6cb8926fe248abcd4bcc665
|
4
|
+
data.tar.gz: 2a74a5654f6c7c14b5eed8eb36010ac6b47f21c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962fad30c9046a061dc79cf8f481f2c74652317c536461bfbb5268c7265ac515bfd046591879ac03881e06fcbb34beb117b415a7eb67da9f268c13775e6c31d6
|
7
|
+
data.tar.gz: b9de65ce03984955cf056421bfd3b0df227be48b303b55849f46111e71269bc92a89ac3f953ecff22962a55ea82ca35c9b0a2030c1264a75400b9e9d033c7743
|
@@ -19,6 +19,7 @@ $(document).ready(function(){
|
|
19
19
|
$('a[data-user]').on('click', function(){
|
20
20
|
var user = $(this).attr('data-user');
|
21
21
|
d3.select("div#pageViewsByUser>svg").remove();
|
22
|
+
d3.select('svg.legend').remove();
|
22
23
|
d3.select("div#pageViewsShareByUser>svg").remove();
|
23
24
|
$('a.list-group-item').removeClass('active-item');
|
24
25
|
$(this).addClass('active-item');
|
@@ -1,60 +1,122 @@
|
|
1
|
-
function pageViewsShareByUser(userName){
|
2
|
-
var margin = {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
.attr("height", height + margin.top + margin.bottom)
|
14
|
-
.append("svg:g") //make a group to hold our pie chart
|
15
|
-
.attr("transform", "translate(" + radius*2 + "," + radius*2 + ")") //move the center of the pie chart from 0, 0 to radius, radius
|
16
|
-
|
17
|
-
var arc = d3.svg.arc() //this will create <path> elements for us using arc data
|
18
|
-
.outerRadius(radius);
|
1
|
+
function pageViewsShareByUser(userName) {
|
2
|
+
var margin = {
|
3
|
+
top: 40,
|
4
|
+
right: 40,
|
5
|
+
bottom: 40,
|
6
|
+
left: 40
|
7
|
+
},
|
8
|
+
width = 500 - margin.left - margin.right,
|
9
|
+
height = 500 - margin.top - margin.bottom,
|
10
|
+
inner = 90,
|
11
|
+
radius = 180, //radius
|
12
|
+
color = d3.scale.category20c(); //builtin range of colors
|
19
13
|
|
14
|
+
var data = JSON.parse( $('a[data-user="'+ userName +'"]').attr('data-page-visits'));
|
15
|
+
var total = d3.sum(data, function (d) {
|
16
|
+
return d3.sum(d3.values(d));
|
17
|
+
});
|
20
18
|
var div = d3.select("body").append("div")
|
21
19
|
.attr("class", "tooltip")
|
22
20
|
.style("opacity", 0);
|
23
|
-
|
24
|
-
var
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
|
22
|
+
var vis = d3.select("div#pageViewsShareByUser")
|
23
|
+
.append("svg:svg") //create the SVG element inside the <body>
|
24
|
+
.data([data]) //associate our data with the document
|
25
|
+
.attr("width", width + margin.left + margin.right)
|
26
|
+
.attr("height", height + margin.top + margin.bottom)
|
27
|
+
.append("svg:g") //make a group to hold our pie chart
|
28
|
+
.attr("transform", "translate(" + radius * 1.5 + "," + radius * 1.5 + ")");
|
29
|
+
var textTop = vis.append("text")
|
30
|
+
.attr("dy", ".35em")
|
31
|
+
.style("text-anchor", "middle")
|
32
|
+
.attr("class", "textTop")
|
33
|
+
.text("TOTAL")
|
34
|
+
.attr("y", -10),
|
35
|
+
textBottom = vis.append("text")
|
36
|
+
.attr("dy", ".35em")
|
37
|
+
.style("text-anchor", "middle")
|
38
|
+
.attr("class", "textBottom")
|
39
|
+
.text(total + " Views")
|
40
|
+
.attr("y", 10);
|
41
|
+
|
42
|
+
var arc = d3.svg.arc()
|
43
|
+
.innerRadius(inner)
|
44
|
+
.outerRadius(radius);
|
45
|
+
var arcOver = d3.svg.arc()
|
46
|
+
.innerRadius(inner + 5)
|
47
|
+
.outerRadius(radius + 5);
|
48
|
+
|
49
|
+
var pie = d3.layout.pie() //this will create arc data for us given a list of values
|
50
|
+
.value(function (d) {
|
51
|
+
return d.count;
|
52
|
+
}); //we must tell it out to access the value of each element in our data array
|
53
|
+
|
54
|
+
var arcs = vis.selectAll("g.slice") //this selects all <g> elements with class slice (there aren't any yet)
|
55
|
+
.data(pie) //associate the generated pie data (an array of arcs, each having startAngle, endAngle and value properties)
|
56
|
+
.enter() //this will create <g> elements for every "extra" data element that should be associated with a selection. The result is creating a <g> for every object in the data array
|
57
|
+
.append("svg:g") //create a group to hold each slice (we will have a <path> and a <text> element associated with each slice)
|
58
|
+
.attr("class", "slice") //allow us to style things in the slices (like text)
|
32
59
|
.on('mousemove', function (d, i) {
|
60
|
+
d3.select(this).select("path").transition()
|
61
|
+
.duration(200)
|
62
|
+
.attr("d", arcOver);
|
63
|
+
|
64
|
+
textTop.text(d3.select(this).datum().data.page)
|
65
|
+
.attr("y", -10);
|
66
|
+
textBottom.text(d3.select(this).datum().data.count + " Views")
|
67
|
+
.attr("y", 10);
|
68
|
+
|
33
69
|
div.transition()
|
34
70
|
.duration(200)
|
35
71
|
.style("opacity", 0.9);
|
36
|
-
div.html("<strong>Page Views:</strong> <span style='color:red'>" + d.data.count + "</span>"
|
72
|
+
div.html("<strong>Page Views:</strong> <span style='color:red'>" + d.data.count + "</span>")
|
37
73
|
.style("left", (d3.event.pageX - 57) + "px")
|
38
74
|
.style("top", (d3.event.pageY - 50) + "px")
|
39
75
|
.style("z-index", 10000)
|
40
76
|
})
|
41
77
|
.on("mouseout", function (d) {
|
78
|
+
d3.select(this).select("path").transition()
|
79
|
+
.duration(100)
|
80
|
+
.attr("d", arc);
|
81
|
+
|
82
|
+
textTop.text("TOTAL")
|
83
|
+
.attr("y", -10);
|
84
|
+
textBottom.text(total + " Views");
|
85
|
+
|
42
86
|
div.transition()
|
43
87
|
.duration(500)
|
44
88
|
.style("opacity", 0);
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
89
|
+
});
|
90
|
+
|
91
|
+
arcs.append("svg:path")
|
92
|
+
.attr("fill", function (d, i) {
|
93
|
+
return color(i);
|
94
|
+
}) //set the color for each slice to be chosen from the color function defined above
|
95
|
+
.attr("d", arc); //this creates the actual SVG path using the associated data (pie) with the arc drawing function
|
96
|
+
|
97
|
+
var legend = d3.select("div#pageViewsShareByUser").append("svg")
|
98
|
+
.attr("class", "legend")
|
99
|
+
.attr("width", radius)
|
100
|
+
.attr("height", radius * 2)
|
101
|
+
.selectAll("g")
|
102
|
+
.data(data)
|
103
|
+
.enter().append("g")
|
104
|
+
.attr("transform", function (d, i) {
|
105
|
+
return "translate(0," + i * 20 + ")";
|
106
|
+
});
|
107
|
+
|
108
|
+
legend.append("rect")
|
109
|
+
.attr("width", 18)
|
110
|
+
.attr("height", 18)
|
111
|
+
.style("fill", function (d, i) {
|
112
|
+
return color(i);
|
113
|
+
});
|
114
|
+
|
115
|
+
legend.append("text")
|
116
|
+
.attr("x", 24)
|
117
|
+
.attr("y", 9)
|
118
|
+
.attr("dy", ".35em")
|
119
|
+
.text(function (d) {
|
120
|
+
return d.page;
|
121
|
+
});
|
122
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div id='per-user-by-pages-bar' class='group'>
|
2
2
|
<div class='clear'></div>
|
3
|
-
<div class='left page-views'>
|
3
|
+
<div class='left page-views left-navigation'>
|
4
4
|
<div class="list-group page-views">
|
5
5
|
<% JSON.parse(@analysis_by_user_name).each do |user_hsh| %>
|
6
6
|
<a href="#page-views-by-user" class="list-group-item" data-user='<%=user_hsh["user"]%>' data-page-visits='<%= page_visits_by_user(user_hsh['user'])%>'><%= user_hsh["user"] %> - <%= percentage_share(user_hsh["user"], user_hsh["count"], @total)%>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div id='per-user-by-pages-pie' class='group'>
|
2
2
|
<div class='clear'></div>
|
3
|
-
<div class='left page-views'>
|
3
|
+
<div class='left page-views left-navigation'>
|
4
4
|
<div class="list-group page-views">
|
5
5
|
<% JSON.parse(@analysis_by_user_name).each do |user_hsh| %>
|
6
6
|
<a href="#page-views-by-user" class="list-group-item" data-user='<%=user_hsh["user"]%>' data-page-visits='<%= page_visits_by_user(user_hsh['user'])%>'><%= user_hsh["user"] %> - <%= percentage_share(user_hsh["user"], user_hsh["count"], @total)%>
|
data/lib/audit_rails/version.rb
CHANGED