analytics_charts 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/analytics_charts/custom_pie.rb +17 -2
- data/lib/analytics_charts/pie_and_labels.rb +39 -24
- data/lib/analytics_charts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f29114a8beff4861cb697eac809bbb8f624266c
|
|
4
|
+
data.tar.gz: a2417f08e626a1c566ac7e63f8f9fcf09bb1ca2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ca8393d4cc654891666703b2455357ea385421956343ab93046079bd55d6169d9c37b4972f720de641db69afb154a2251ec04971c8eb57c18f6626c5391dd37
|
|
7
|
+
data.tar.gz: abd3bbb6f944fb54ebd42a9863d6a8402494e3a158099bb51528f3ce4157752829467a17858b71e911d733240057666f60c5ddbd11d0e467fd1cff76bcf93f4c
|
|
@@ -17,6 +17,7 @@ class AnalyticsCharts::CustomPie
|
|
|
17
17
|
@d = Draw.new
|
|
18
18
|
@data = Hash.new # Value is array with two items
|
|
19
19
|
@aggregate = Array([0,0,0,0]) # Cluster brands into categories
|
|
20
|
+
@thresholds = Array(["","","",""]) # Will populate with integer thresholds
|
|
20
21
|
@label_hash = Hash.new
|
|
21
22
|
@pie_label_hash = Hash.new
|
|
22
23
|
@label_hash = label_hash if label_hash
|
|
@@ -40,11 +41,25 @@ class AnalyticsCharts::CustomPie
|
|
|
40
41
|
@colors = list
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
def choose_color(rating)
|
|
45
|
+
return @colors[0]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def highest_score(index, score)
|
|
49
|
+
@thresholds[index] = score
|
|
50
|
+
end
|
|
43
51
|
def insert_pie_data(name, amount, quality)
|
|
44
52
|
#convert all '' instances to an apostrophe
|
|
45
53
|
name = name.gsub(/'/, "\'")
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
# Figure out whether to give name a 0,1,2, or 3
|
|
55
|
+
[0,1,2,3].each do |rank|
|
|
56
|
+
next if @thresholds[rank].is_a?(String)
|
|
57
|
+
if quality < @thresholds[rank]
|
|
58
|
+
@data[name] = [amount, rank]
|
|
59
|
+
@aggregate[rank] += amount
|
|
60
|
+
break
|
|
61
|
+
end
|
|
62
|
+
end
|
|
48
63
|
end
|
|
49
64
|
def insert_text_with_arrow(x_offset, y_offset, text, features = {})
|
|
50
65
|
features.each { |feature, attribute|
|
|
@@ -62,8 +62,21 @@ class AnalyticsCharts::PieAndLabels < AnalyticsCharts::CustomPie
|
|
|
62
62
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def insert_legend(label, quality)
|
|
66
|
-
|
|
65
|
+
def insert_legend(label, quality, color)
|
|
66
|
+
case color
|
|
67
|
+
when "green"
|
|
68
|
+
@legend_data[3] = label
|
|
69
|
+
highest_score(3, quality)
|
|
70
|
+
when "yellow"
|
|
71
|
+
@legend_data[2] = label
|
|
72
|
+
highest_score(2, quality)
|
|
73
|
+
when "orange"
|
|
74
|
+
@legend_data[1] = label
|
|
75
|
+
highest_score(1, quality)
|
|
76
|
+
when "red"
|
|
77
|
+
@legend_data[0] = label
|
|
78
|
+
highest_score(0, quality)
|
|
79
|
+
end
|
|
67
80
|
end
|
|
68
81
|
|
|
69
82
|
def draw_legend
|
|
@@ -74,29 +87,31 @@ class AnalyticsCharts::PieAndLabels < AnalyticsCharts::CustomPie
|
|
|
74
87
|
x_pos = 230
|
|
75
88
|
side_length = 15
|
|
76
89
|
@legend_data.each_with_index do |data, index|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
unless data.empty? # Allows us to use only three legends or less
|
|
91
|
+
case index
|
|
92
|
+
when 3
|
|
93
|
+
insert_text(x_pos + 20, y_offset + 12, data,
|
|
94
|
+
@label_hash.merge({'fill' => '#FFFFFF', 'pointsize'=> 10 }))
|
|
95
|
+
@d.fill('#1E753B')
|
|
96
|
+
@d.rectangle(x_pos,y_offset,x_pos + side_length, y_offset + side_length)
|
|
97
|
+
when 2
|
|
98
|
+
insert_text(x_pos + 20, y_offset + 12, data,
|
|
99
|
+
@label_hash.merge({'fill' => '#FFFFFF', 'pointsize'=> 10 }))
|
|
100
|
+
@d.fill('#C1B630')
|
|
101
|
+
@d.rectangle(x_pos,y_offset,x_pos + side_length, y_offset + side_length)
|
|
102
|
+
when 1
|
|
103
|
+
insert_text(x_pos + 20, y_offset + 12, data,
|
|
104
|
+
@label_hash.merge({'fill' => '#FFFFFF', 'pointsize'=> 10 }))
|
|
105
|
+
@d.fill('#BE6428')
|
|
106
|
+
@d.rectangle(x_pos,y_offset,x_pos + side_length, y_offset + side_length)
|
|
107
|
+
when 0
|
|
108
|
+
insert_text(x_pos + 20, y_offset + 12, data,
|
|
109
|
+
@label_hash.merge({'fill' => '#FFFFFF', 'pointsize'=> 10 }))
|
|
110
|
+
@d.fill('#AD1F25')
|
|
111
|
+
@d.rectangle(x_pos,y_offset,x_pos + side_length, y_offset + side_length)
|
|
112
|
+
end
|
|
113
|
+
y_offset -= side_length
|
|
98
114
|
end
|
|
99
|
-
y_offset -= side_length
|
|
100
115
|
end
|
|
101
116
|
end
|
|
102
117
|
def draw_line
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: analytics_charts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- STEPHEN YU
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|