prawn_charts 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/data_collectors/container/container_data_collector.rb +57 -55
- data/lib/data_collectors/container/graph_title_data_collector.rb +12 -10
- data/lib/data_collectors/graph/horizontal_lines_data_collector.rb +16 -14
- data/lib/data_collectors/graph/linear_y_pdf_data_collector.rb +17 -15
- data/lib/data_collectors/graph/log_y_pdf_data_collector.rb +16 -14
- data/lib/data_collectors/graph/pdf_data_collector.rb +20 -18
- data/lib/data_collectors/graph/x_labels_data_collector.rb +22 -20
- data/lib/data_collectors/graph/x_pdf_data_collector.rb +12 -10
- data/lib/data_collectors/graph/y_labels_data_collector.rb +27 -25
- data/lib/data_collectors/graph/y_pdf_data_collector.rb +17 -15
- data/lib/examples/log_example.rb +124 -122
- data/lib/examples/simple_linear_example.rb +56 -54
- data/lib/examples/simple_log_example.rb +56 -54
- data/lib/prawn_charts/version.rb +1 -1
- data/lib/renderers/prawn_chart_renderer.rb +21 -19
- data/spec/data_collectors/container/container_data_collector_spec.rb +43 -41
- data/spec/data_collectors/graph/horizontal_lines_data_collector_spec.rb +13 -11
- data/spec/data_collectors/graph/linear_y_pdf_data_collector_spec.rb +13 -11
- data/spec/data_collectors/graph/log_y_pdf_data_collector_spec.rb +19 -17
- data/spec/data_collectors/graph/pdf_data_collector_spec.rb +38 -36
- data/spec/data_collectors/graph/x_labels_data_collector_spec.rb +14 -12
- data/spec/data_collectors/graph/x_pdf_data_collector_spec.rb +15 -13
- data/spec/data_collectors/graph/y_labels_data_collector_spec.rb +15 -13
- metadata +1 -1
data/lib/examples/log_example.rb
CHANGED
@@ -1,131 +1,133 @@
|
|
1
1
|
require_relative "./../prawn_charts"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
pdf
|
103
|
-
pdf.
|
104
|
-
pdf.fill_color = light_blue
|
105
|
-
pdf.fill_rectangle([0, pdf.cursor], container_data_collector.width, container_data_collector.height)
|
106
|
-
pdf.fill_color = black
|
107
|
-
|
108
|
-
pdf.draw_title(graph_title_data, graph_title_options)
|
109
|
-
pdf.draw_title(y_title_data, y_title_options)
|
110
|
-
pdf.draw_title(x_title_data, x_title_options)
|
111
|
-
|
112
|
-
pdf.bounding_box(container_data_collector.graph_top_left, :width => graph_width_pdf, :height => graph_height_pdf) do
|
3
|
+
module PrawnCharts
|
4
|
+
##################################
|
5
|
+
#Graph Data Collectors
|
6
|
+
##################################
|
7
|
+
input_data = [["Apr-11", 5_000_000],
|
8
|
+
["May-11", nil],
|
9
|
+
["Jun-11", nil],
|
10
|
+
["Jul-11", nil],
|
11
|
+
["Aug-11", 1_000_000],
|
12
|
+
["Sep-11", nil],
|
13
|
+
["Oct-11", nil],
|
14
|
+
["Dec-11", 10_000],
|
15
|
+
["Jan-12", nil],
|
16
|
+
["Feb-12", nil],
|
17
|
+
["Mar-12", 150_000],
|
18
|
+
["Apr-12", nil],
|
19
|
+
["May-12", nil],
|
20
|
+
["Jun-12", 7_500_000]]
|
21
|
+
scale = :log
|
22
|
+
graph_height_pdf = 200
|
23
|
+
graph_width_pdf = graph_height_pdf * 1.7
|
24
|
+
dot_radius = 4
|
25
|
+
|
26
|
+
x_label_width = 50
|
27
|
+
x_label_height = 35
|
28
|
+
x_label_text_box_options = { overflow: :shrink_to_fit, align: :center, rotate: 45 }
|
29
|
+
|
30
|
+
y_labels = [0, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000]
|
31
|
+
y_label_height = 30
|
32
|
+
y_label_width = 65
|
33
|
+
y_label_offset = 10
|
34
|
+
y_label_text_box_options = { align: :right, valign: :center }
|
35
|
+
|
36
|
+
graph_title_text = "Cool Prawn Graph"
|
37
|
+
graph_title_height = 40
|
38
|
+
|
39
|
+
y_title_width = 30
|
40
|
+
y_title_text = "HCV Viral Load"
|
41
|
+
|
42
|
+
x_title_height = 40
|
43
|
+
x_title_text = "Month"
|
44
|
+
|
45
|
+
pdf_data = PdfDataCollector.new(scale, input_data, graph_width_pdf, graph_height_pdf, y_labels).collect
|
46
|
+
x_label_data = XLabelsDataCollector.new(input_data, graph_width_pdf, x_label_height, x_label_width).collect
|
47
|
+
y_label_data = YLabelsDataCollector.new(y_labels, graph_height_pdf, y_label_width, y_label_height, y_label_offset).collect
|
48
|
+
horizontal_lines_data = HorizontalLinesDataCollector.new(graph_height_pdf, graph_width_pdf, y_labels).collect
|
49
|
+
|
50
|
+
##################################
|
51
|
+
#Container Data Collectors
|
52
|
+
##################################
|
53
|
+
|
54
|
+
container_inputs = {
|
55
|
+
container_left_padding: 0,
|
56
|
+
y_label_offset: y_label_offset,
|
57
|
+
y_label_width: y_label_width,
|
58
|
+
y_title_width: y_title_width,
|
59
|
+
container_right_padding: 20,
|
60
|
+
container_top_padding: 20,
|
61
|
+
graph_title_height: graph_title_height,
|
62
|
+
container_bottom_padding: 0,
|
63
|
+
x_label_height: x_label_height,
|
64
|
+
x_title_height: x_title_height,
|
65
|
+
graph_height: graph_height_pdf,
|
66
|
+
graph_width: graph_width_pdf
|
67
|
+
}
|
68
|
+
|
69
|
+
container_data_collector = ContainerDataCollector.new(container_inputs)
|
70
|
+
|
71
|
+
graph_title_position = container_data_collector.graph_title_top_left
|
72
|
+
graph_title_options = { align: :center, valign: :center}
|
73
|
+
graph_title_data = GraphTitleDataCollector.new(graph_title_text, graph_title_position, graph_title_height, graph_width_pdf).collect
|
74
|
+
|
75
|
+
y_title_position = container_data_collector.y_title_top_left
|
76
|
+
# specifying width is a temp hack solution because of a Prawn bug: https://github.com/prawnpdf/prawn/pull/505
|
77
|
+
y_title_options = { align: :center, valign: :center, rotate: 90, rotate_around: :center, width: 65 }
|
78
|
+
y_title_data = GraphTitleDataCollector.new(y_title_text, y_title_position, graph_height_pdf, y_title_width).collect
|
79
|
+
|
80
|
+
x_title_position = container_data_collector.x_title_top_left
|
81
|
+
x_title_options = { align: :center, valign: :center }
|
82
|
+
x_title_data = GraphTitleDataCollector.new(x_title_text, x_title_position, x_title_height, graph_width_pdf).collect
|
83
|
+
|
84
|
+
graph_top_left = container_data_collector.graph_top_left
|
85
|
+
|
86
|
+
##################################
|
87
|
+
#Colors
|
88
|
+
##################################
|
89
|
+
|
90
|
+
orange = "D95D2E"
|
91
|
+
green = "62C545"
|
92
|
+
light_blue = "EDF1F7"
|
93
|
+
white = "FFFFFF"
|
94
|
+
black = "000000"
|
95
|
+
|
96
|
+
##################################
|
97
|
+
#Create PDF
|
98
|
+
##################################
|
99
|
+
|
100
|
+
Prawn::Document.extensions << PrawnChartRenderer
|
101
|
+
|
102
|
+
pdf = Prawn::Document.new
|
103
|
+
pdf.bounding_box([0, pdf.cursor], :width => container_data_collector.width, :height => container_data_collector.height) do
|
113
104
|
pdf.stroke_bounds
|
114
|
-
pdf.fill_color =
|
115
|
-
pdf.fill_rectangle([0, pdf.cursor],
|
105
|
+
pdf.fill_color = light_blue
|
106
|
+
pdf.fill_rectangle([0, pdf.cursor], container_data_collector.width, container_data_collector.height)
|
107
|
+
pdf.fill_color = black
|
116
108
|
|
117
|
-
pdf.
|
118
|
-
pdf.
|
119
|
-
pdf.
|
120
|
-
pdf.draw_dots(pdf_data, dot_radius)
|
109
|
+
pdf.draw_title(graph_title_data, graph_title_options)
|
110
|
+
pdf.draw_title(y_title_data, y_title_options)
|
111
|
+
pdf.draw_title(x_title_data, x_title_options)
|
121
112
|
|
122
|
-
pdf.
|
123
|
-
|
113
|
+
pdf.bounding_box(container_data_collector.graph_top_left, :width => graph_width_pdf, :height => graph_height_pdf) do
|
114
|
+
pdf.stroke_bounds
|
115
|
+
pdf.fill_color = white
|
116
|
+
pdf.fill_rectangle([0, pdf.cursor], graph_width_pdf, graph_height_pdf)
|
117
|
+
|
118
|
+
pdf.stroke_color = green
|
119
|
+
pdf.draw_chart(pdf_data)
|
120
|
+
pdf.fill_color = orange
|
121
|
+
pdf.draw_dots(pdf_data, dot_radius)
|
122
|
+
|
123
|
+
pdf.fill_color = black
|
124
|
+
pdf.draw_labels(x_label_data, x_label_width, x_label_height, x_label_text_box_options)
|
124
125
|
|
125
|
-
|
126
|
+
pdf.draw_labels(y_label_data, y_label_width, y_label_height, y_label_text_box_options)
|
126
127
|
|
127
|
-
|
128
|
-
|
128
|
+
pdf.stroke_color = black
|
129
|
+
pdf.draw_horizontal_lines(horizontal_lines_data)
|
130
|
+
end
|
129
131
|
end
|
132
|
+
pdf.render_file(Dir.home + "/desktop/log_prawn_graph.pdf")
|
130
133
|
end
|
131
|
-
pdf.render_file(Dir.home + "/desktop/log_prawn_graph.pdf")
|
@@ -1,57 +1,59 @@
|
|
1
1
|
require_relative "./../prawn_charts"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
pdf.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
3
|
+
module PrawnCharts
|
4
|
+
##################################
|
5
|
+
#Graph Data Collectors
|
6
|
+
##################################
|
7
|
+
input_data = [["Apr-11", 10],
|
8
|
+
["May-11", 30],
|
9
|
+
["Jun-11", 50],
|
10
|
+
["Jul-11", 3],
|
11
|
+
["Aug-11", 40],
|
12
|
+
["Sep-11", nil],
|
13
|
+
["Oct-11", nil],
|
14
|
+
["Dec-11", 100],
|
15
|
+
["Jan-12", nil],
|
16
|
+
["Feb-12", nil],
|
17
|
+
["Mar-12", 5],
|
18
|
+
["Apr-12", nil],
|
19
|
+
["May-12", nil],
|
20
|
+
["Jun-12", 75]]
|
21
|
+
scale = :linear
|
22
|
+
graph_height_pdf = 200
|
23
|
+
graph_width_pdf = graph_height_pdf * 1.7
|
24
|
+
dot_radius = 4
|
25
|
+
|
26
|
+
x_label_width = 50
|
27
|
+
x_label_height = 35
|
28
|
+
x_label_text_box_options = { overflow: :shrink_to_fit, align: :center, rotate: 45 }
|
29
|
+
|
30
|
+
y_labels = [0, 25, 50, 75, 100, 125]
|
31
|
+
y_label_height = 30
|
32
|
+
y_label_width = 65
|
33
|
+
y_label_offset = 10
|
34
|
+
y_label_text_box_options = { align: :right, valign: :center }
|
35
|
+
|
36
|
+
pdf_data = PdfDataCollector.new(scale, input_data, graph_width_pdf, graph_height_pdf, y_labels).collect
|
37
|
+
x_label_data = XLabelsDataCollector.new(input_data, graph_width_pdf, x_label_height, x_label_width).collect
|
38
|
+
y_label_data = YLabelsDataCollector.new(y_labels, graph_height_pdf, y_label_width, y_label_height, y_label_offset).collect
|
39
|
+
horizontal_lines_data = HorizontalLinesDataCollector.new(graph_height_pdf, graph_width_pdf, y_labels).collect
|
40
|
+
|
41
|
+
##################################
|
42
|
+
#Create PDF
|
43
|
+
##################################
|
44
|
+
|
45
|
+
Prawn::Document.extensions << PrawnChartRenderer
|
46
|
+
|
47
|
+
pdf = Prawn::Document.new
|
48
|
+
|
49
|
+
pdf.bounding_box([50, pdf.cursor], :width => graph_width_pdf, :height => graph_height_pdf) do
|
50
|
+
pdf.stroke_bounds
|
51
|
+
pdf.draw_chart(pdf_data)
|
52
|
+
pdf.draw_dots(pdf_data, dot_radius)
|
53
|
+
pdf.draw_labels(x_label_data, x_label_width, x_label_height, x_label_text_box_options)
|
54
|
+
pdf.draw_labels(y_label_data, y_label_width, y_label_height, y_label_text_box_options)
|
55
|
+
pdf.draw_horizontal_lines(horizontal_lines_data)
|
56
|
+
end
|
57
|
+
|
58
|
+
pdf.render_file(Dir.home + "/desktop/simple_linear_prawn_graph.pdf")
|
55
59
|
end
|
56
|
-
|
57
|
-
pdf.render_file(Dir.home + "/desktop/simple_linear_prawn_graph.pdf")
|
@@ -1,57 +1,59 @@
|
|
1
1
|
require_relative "./../prawn_charts"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
pdf.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
3
|
+
module PrawnCharts
|
4
|
+
##################################
|
5
|
+
#Graph Data Collectors
|
6
|
+
##################################
|
7
|
+
input_data = [["Apr-11", 5_000_000],
|
8
|
+
["May-11", nil],
|
9
|
+
["Jun-11", nil],
|
10
|
+
["Jul-11", nil],
|
11
|
+
["Aug-11", 1_000_000],
|
12
|
+
["Sep-11", nil],
|
13
|
+
["Oct-11", nil],
|
14
|
+
["Dec-11", 10_000],
|
15
|
+
["Jan-12", nil],
|
16
|
+
["Feb-12", nil],
|
17
|
+
["Mar-12", 150_000],
|
18
|
+
["Apr-12", nil],
|
19
|
+
["May-12", nil],
|
20
|
+
["Jun-12", 7_500_000]]
|
21
|
+
scale = :log
|
22
|
+
graph_height_pdf = 200
|
23
|
+
graph_width_pdf = graph_height_pdf * 1.7
|
24
|
+
dot_radius = 4
|
25
|
+
|
26
|
+
x_label_width = 50
|
27
|
+
x_label_height = 35
|
28
|
+
x_label_text_box_options = { overflow: :shrink_to_fit, align: :center, rotate: 45 }
|
29
|
+
|
30
|
+
y_labels = [0, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000]
|
31
|
+
y_label_height = 30
|
32
|
+
y_label_width = 65
|
33
|
+
y_label_offset = 10
|
34
|
+
y_label_text_box_options = { align: :right, valign: :center }
|
35
|
+
|
36
|
+
pdf_data = PdfDataCollector.new(scale, input_data, graph_width_pdf, graph_height_pdf, y_labels).collect
|
37
|
+
x_label_data = XLabelsDataCollector.new(input_data, graph_width_pdf, x_label_height, x_label_width).collect
|
38
|
+
y_label_data = YLabelsDataCollector.new(y_labels, graph_height_pdf, y_label_width, y_label_height, y_label_offset).collect
|
39
|
+
horizontal_lines_data = HorizontalLinesDataCollector.new(graph_height_pdf, graph_width_pdf, y_labels).collect
|
40
|
+
|
41
|
+
##################################
|
42
|
+
#Create PDF
|
43
|
+
##################################
|
44
|
+
|
45
|
+
Prawn::Document.extensions << PrawnChartRenderer
|
46
|
+
|
47
|
+
pdf = Prawn::Document.new
|
48
|
+
|
49
|
+
pdf.bounding_box([50, pdf.cursor], :width => graph_width_pdf, :height => graph_height_pdf) do
|
50
|
+
pdf.stroke_bounds
|
51
|
+
pdf.draw_chart(pdf_data)
|
52
|
+
pdf.draw_dots(pdf_data, dot_radius)
|
53
|
+
pdf.draw_labels(x_label_data, x_label_width, x_label_height, x_label_text_box_options)
|
54
|
+
pdf.draw_labels(y_label_data, y_label_width, y_label_height, y_label_text_box_options)
|
55
|
+
pdf.draw_horizontal_lines(horizontal_lines_data)
|
56
|
+
end
|
57
|
+
|
58
|
+
pdf.render_file(Dir.home + "/desktop/simple_log_prawn_graph.pdf")
|
55
59
|
end
|
56
|
-
|
57
|
-
pdf.render_file(Dir.home + "/desktop/simple_log_prawn_graph.pdf")
|
data/lib/prawn_charts/version.rb
CHANGED
@@ -1,29 +1,31 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
pdf_data
|
4
|
-
|
1
|
+
module PrawnCharts
|
2
|
+
module PrawnChartRenderer
|
3
|
+
def draw_chart(pdf_data)
|
4
|
+
pdf_data.each_index do |i|
|
5
|
+
stroke_line(pdf_data[i], pdf_data[i + 1]) unless pdf_data[i + 1].nil?
|
6
|
+
end
|
5
7
|
end
|
6
|
-
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def draw_dots(pdf_data, dot_radius)
|
10
|
+
pdf_data.each do |point|
|
11
|
+
fill_circle(point, dot_radius)
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def draw_horizontal_lines(horizontal_lines_data)
|
16
|
+
horizontal_lines_data.each do |start_x, end_x, y|
|
17
|
+
stroke_horizontal_line start_x, end_x, at: y
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def draw_labels(label_data, width, height, options = {})
|
22
|
+
label_data.each do |label, pdf_point|
|
23
|
+
text_box(label, { at: pdf_point, width: width, height: height }.merge(options))
|
24
|
+
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def draw_title(inputs, options = {})
|
28
|
+
text_box(inputs[:title], { at: inputs[:at], width: inputs[:width], height: inputs[:height] }.merge(options))
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,57 +1,59 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
3
|
+
module PrawnCharts
|
4
|
+
describe ContainerDataCollector do
|
5
|
+
before do
|
6
|
+
container_inputs = {
|
7
|
+
container_left_padding: 7,
|
8
|
+
y_label_offset: 50,
|
9
|
+
y_label_width: 25,
|
10
|
+
y_title_width: 30,
|
11
|
+
container_right_padding: 20,
|
12
|
+
container_top_padding: 9,
|
13
|
+
graph_title_height: 25,
|
14
|
+
container_bottom_padding: 40,
|
15
|
+
x_label_height: 22,
|
16
|
+
x_title_height: 43,
|
17
|
+
graph_height: 400,
|
18
|
+
graph_width: 500
|
19
|
+
}
|
20
|
+
@container_data_collector = ContainerDataCollector.new(container_inputs)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
context "#height" do
|
24
|
+
it "returns the pdf_height of the graph container" do
|
25
|
+
expect(@container_data_collector.height).to eq(539)
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
context "#width" do
|
30
|
+
it "returns the pdf_width of the graph container" do
|
31
|
+
expect(@container_data_collector.width).to eq(632)
|
32
|
+
end
|
31
33
|
end
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
context "#graph_top_left_corner" do
|
36
|
+
it "returns the point for the top-left corner of the graph" do
|
37
|
+
expect(@container_data_collector.graph_top_left).to eq([112, 505])
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
context "#graph_title_top_left" do
|
42
|
+
it "returns x, y coordinate for placement of graph title" do
|
43
|
+
expect(@container_data_collector.graph_title_top_left).to eq([112, 530])
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
context "#y_title_top_left" do
|
48
|
+
it "returns x, y coordinate for placement of y title" do
|
49
|
+
expect(@container_data_collector.y_title_top_left).to eq([7, 505])
|
50
|
+
end
|
49
51
|
end
|
50
|
-
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
context "#x_title_top_left" do
|
54
|
+
it "returns x, y coordinate for placement of x title" do
|
55
|
+
expect(@container_data_collector.x_title_top_left).to eq([112, 83])
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|