analytics_charts 1.4.2 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1aee1598609af56b20328ccc22451913d4095d
|
4
|
+
data.tar.gz: 3873937e937b37ff6fd7de8bbd0565306d928723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed00db05c185e80ea38552936d3eb99b9f67c682519a7af245d77a39cde1b0ac83a233d19052c4011b69aedd3017da27ccee86b3317592ff553e91b86befdf28
|
7
|
+
data.tar.gz: 5d2b51fe68eeaed5790253a51574effd6dbe52355a3526c3f0b7ab45b006c097afae2766302a9e4937769cae425794d6720aaa37d494f0c584503204a9ee36f8
|
@@ -6,7 +6,7 @@ class AnalyticsCharts::CustomModule
|
|
6
6
|
@d = Draw.new
|
7
7
|
@d.fill = 'white'
|
8
8
|
@d.font = 'Helvetica'
|
9
|
-
@pointsize =
|
9
|
+
@pointsize = 14
|
10
10
|
@d.pointsize = @pointsize
|
11
11
|
@d.font_weight = 500
|
12
12
|
@composite_image = Image.read(image_path)[0]
|
@@ -19,7 +19,9 @@ class AnalyticsCharts::CustomModule
|
|
19
19
|
puts "Had some error in CustomModule, probably a nil calling each"
|
20
20
|
return
|
21
21
|
end
|
22
|
-
|
22
|
+
num_separators = @rows_of_text.count {|row| row.empty? }
|
23
|
+
@sep_offset = 7
|
24
|
+
@height = @composite_rows + (@rows_of_text.size - num_separators) * @pointsize + num_separators * @sep_offset
|
23
25
|
@base_image = Image.new(@composite_columns, @height) {
|
24
26
|
self.background_color = "black"
|
25
27
|
}
|
@@ -33,11 +35,17 @@ class AnalyticsCharts::CustomModule
|
|
33
35
|
text = text.gsub(/['%]/, '%' => '%%', "'" => "\'")
|
34
36
|
if text.include? "@$$" # No paragraph break if we insert this uncommonly used word
|
35
37
|
text.sub!("@$$", "")
|
38
|
+
y_offset -= @sep_offset
|
36
39
|
@d.annotate(@base_image, 0 ,0, @pointsize, y_offset, text)
|
40
|
+
y_offset += @pointsize
|
37
41
|
next
|
38
42
|
else
|
39
43
|
@d.annotate(@base_image, 0 ,0, @pointsize, y_offset, text)
|
40
|
-
|
44
|
+
if text.empty?
|
45
|
+
y_offset += @sep_offset
|
46
|
+
else
|
47
|
+
y_offset += @pointsize
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
@base_image.write(output_path)
|
@@ -49,7 +57,7 @@ class AnalyticsCharts::CustomModule
|
|
49
57
|
carriage_split_lines.each do |carriage_split_line|
|
50
58
|
line_wrap_lines = line_wrap(carriage_split_line)
|
51
59
|
line_wrap_lines.each { |line| line_tokens.push(line) }
|
52
|
-
line_tokens.push("
|
60
|
+
line_tokens.push("")
|
53
61
|
end
|
54
62
|
line_tokens
|
55
63
|
end
|
@@ -70,7 +78,7 @@ class AnalyticsCharts::CustomModule
|
|
70
78
|
end
|
71
79
|
|
72
80
|
def fits_in_a_line(text)
|
73
|
-
return @d.get_type_metrics(@dummy_image,text).width < @composite_image.columns -
|
81
|
+
return @d.get_type_metrics(@dummy_image,text).width < @composite_image.columns - 36
|
74
82
|
end
|
75
83
|
end
|
76
84
|
#Reference: Draw defaults[ font: "Helvetica", pointsize:12, x/y resolution 72 DPI, font_weight: 400]
|
@@ -95,8 +95,8 @@ class AnalyticsCharts::CustomPie
|
|
95
95
|
# If we don't refresh draw, future "@d.draw(@base_image)" will redraw the circle,
|
96
96
|
# overlapping on the text written below
|
97
97
|
@d = Draw.new
|
98
|
-
insert_text(@pie_center_x - 30, @pie_center_y, "No
|
99
|
-
@label_hash.merge({'fill'=> '#000000', 'font_weight'=> 700 }))
|
98
|
+
insert_text(@pie_center_x - 30, @pie_center_y, "No Data",
|
99
|
+
@label_hash.merge({'fill'=> ' #000000', 'font_weight'=> 700 }))
|
100
100
|
return
|
101
101
|
end
|
102
102
|
if @data.size > 0
|
@@ -233,7 +233,7 @@ class AnalyticsCharts::CustomPie
|
|
233
233
|
y_offset += @label_offset
|
234
234
|
end
|
235
235
|
insert_text_with_circle(x_offset, y_offset, '= purchased by you',
|
236
|
-
@label_hash.merge({'fill'=> '#
|
236
|
+
@label_hash.merge({'fill'=> '#252525', 'font_weight'=> 900 }))
|
237
237
|
end
|
238
238
|
|
239
239
|
def draw_pie_label(center_x, center_y, angle, radius, percent, index)
|
@@ -251,16 +251,16 @@ class AnalyticsCharts::CustomPie
|
|
251
251
|
# Imagine the text box around the text
|
252
252
|
# Shift text box so a corner is tangent to circle
|
253
253
|
if x > center_x
|
254
|
-
x += width / 2.0
|
254
|
+
x += width / 2.0 + 6
|
255
255
|
end
|
256
256
|
if x < center_x
|
257
|
-
x -= width / 2.0
|
257
|
+
x -= width / 2.0 + 6
|
258
258
|
end
|
259
259
|
if y > center_y
|
260
|
-
y += ascent / 2.0
|
260
|
+
y += ascent / 2.0 + 6
|
261
261
|
end
|
262
262
|
if y < center_y
|
263
|
-
y -=
|
263
|
+
y -= ascent / 2.0 + 6
|
264
264
|
# descent value retrieved is negative, so sub instead of add
|
265
265
|
end
|
266
266
|
@d.align = CenterAlign
|
@@ -12,9 +12,11 @@ class AnalyticsCharts::PieAndLabels < AnalyticsCharts::CustomPie
|
|
12
12
|
@d.font_weight = 700
|
13
13
|
@dummy_image = Image.new(1,1)
|
14
14
|
@composite_columns = @composite_image.columns
|
15
|
+
puts @composite_columns
|
15
16
|
@composite_rows = @composite_image.rows
|
16
|
-
@org_texts = tokenize_text_by_lines(organization)
|
17
17
|
@org_text_size = 14
|
18
|
+
@org_texts = tokenize_text_by_lines(organization,
|
19
|
+
{'fill' => '#FFFFFF', 'pointsize'=> @org_text_size, 'font_weight'=> 500 })
|
18
20
|
@label_size = 16
|
19
21
|
org_text_offset = @org_texts.size * @org_text_size
|
20
22
|
# (num_labels + 1) to account for white key on bottom of labels
|
@@ -129,7 +131,10 @@ class AnalyticsCharts::PieAndLabels < AnalyticsCharts::CustomPie
|
|
129
131
|
@d.line(0,@height_with_no_disclaimer,@composite_columns,@height_with_no_disclaimer)
|
130
132
|
end
|
131
133
|
|
132
|
-
def tokenize_text_by_lines(text)
|
134
|
+
def tokenize_text_by_lines(text, features = {})
|
135
|
+
features.each { |feature, attribute|
|
136
|
+
set_feature(feature, attribute)
|
137
|
+
}
|
133
138
|
# First split the text by the line carriage element
|
134
139
|
carriage_split_lines = text.split("\r\n")
|
135
140
|
line_tokens = Array.new
|