prawn-graph 1.0.0.pre1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/README.md +72 -36
- data/Rakefile +6 -0
- data/lib/prawn-graph.rb +6 -1
- data/lib/prawn/graph/calculations.rb +1 -0
- data/lib/prawn/graph/calculations/layout_calculator.rb +109 -0
- data/lib/prawn/graph/chart_components.rb +4 -0
- data/lib/prawn/graph/chart_components/bar_chart_renderer.rb +94 -0
- data/lib/prawn/graph/chart_components/canvas.rb +128 -0
- data/lib/prawn/graph/chart_components/line_chart_renderer.rb +92 -0
- data/lib/prawn/graph/chart_components/series_renderer.rb +120 -0
- data/lib/prawn/graph/extension.rb +16 -23
- data/lib/prawn/graph/series.rb +57 -8
- data/lib/prawn/graph/theme.rb +23 -6
- data/lib/prawn/graph/version.rb +1 -1
- data/prawn-graph.gemspec +8 -2
- metadata +44 -15
- data/lib/prawn/graph/charts.rb +0 -4
- data/lib/prawn/graph/charts/bar.rb +0 -18
- data/lib/prawn/graph/charts/base.rb +0 -69
- data/lib/prawn/graph/charts/legacy.rb +0 -4
- data/lib/prawn/graph/charts/legacy/bar.rb +0 -28
- data/lib/prawn/graph/charts/legacy/base.rb +0 -195
- data/lib/prawn/graph/charts/legacy/grid.rb +0 -51
- data/lib/prawn/graph/charts/legacy/line.rb +0 -39
- data/lib/prawn/graph/charts/line.rb +0 -18
@@ -1,51 +0,0 @@
|
|
1
|
-
module Prawn
|
2
|
-
module Graph
|
3
|
-
module Charts
|
4
|
-
module Legacy
|
5
|
-
|
6
|
-
class Grid
|
7
|
-
|
8
|
-
attr_accessor :width, :height, :point, :spacing, :document
|
9
|
-
|
10
|
-
def initialize(grid_x_start, grid_y_start, grid_width, grid_height, spacing, document, theme = Prawn::Graph::Theme::Default)
|
11
|
-
@point = [grid_x_start, grid_y_start]
|
12
|
-
@width = grid_width
|
13
|
-
@height = grid_height
|
14
|
-
@spacing = spacing
|
15
|
-
@document = document
|
16
|
-
@theme = Prawn::Graph::Theme::Default
|
17
|
-
end
|
18
|
-
|
19
|
-
def start_x; @point.first; end
|
20
|
-
def start_y; @point.last; end
|
21
|
-
|
22
|
-
# Draws the Grid on the specified Prawn::Document
|
23
|
-
#
|
24
|
-
def draw
|
25
|
-
@document.stroke_color @theme.markers
|
26
|
-
if @theme.stroke_grid_markers
|
27
|
-
(@height / @spacing).times do |x|
|
28
|
-
offset = @spacing * (x + 1)
|
29
|
-
@document.move_to [@point.first, (@point.last + offset)]
|
30
|
-
@document.line_width(0.5)
|
31
|
-
@document.stroke_line_to([(@point.first + @width), (@point.last + offset)])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
@document.move_to @point
|
35
|
-
@document.line_width(2)
|
36
|
-
@document.stroke_line_to([@point.first, @point.last + @height])
|
37
|
-
@document.move_to @point
|
38
|
-
@document.line_width(2)
|
39
|
-
@document.stroke_line_to([(@point.first + @width), @point.last])
|
40
|
-
@document.move_to @point.first, (@point.last + height)
|
41
|
-
@document.stroke_color '000000'
|
42
|
-
@document.line_width(1)
|
43
|
-
@document.move_to @point
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Prawn
|
2
|
-
module Graph
|
3
|
-
module Charts
|
4
|
-
module Legacy
|
5
|
-
class Line < Prawn::Graph::Charts::Legacy::Base
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def plot_values
|
10
|
-
base_x = @grid.start_x + 1
|
11
|
-
base_y = @grid.start_y + 1
|
12
|
-
p = [ [base_x, base_y] ]
|
13
|
-
bar_width = calculate_bar_width
|
14
|
-
@document.line_width bar_width
|
15
|
-
last_position = base_x + bar_width
|
16
|
-
point_spacing = calculate_plot_spacing
|
17
|
-
@values.each do |value|
|
18
|
-
@document.move_to [base_x + last_position, base_y]
|
19
|
-
bar_height = calculate_point_height_from value
|
20
|
-
point = [base_x + last_position, base_y + bar_height]
|
21
|
-
p << point
|
22
|
-
@document.fill_color @theme.series.last
|
23
|
-
@document.fill_circle_at point, :radius => 1
|
24
|
-
last_position += point_spacing
|
25
|
-
end
|
26
|
-
@document.line_width 2
|
27
|
-
@document.stroke_color @theme.series.last
|
28
|
-
p.each_with_index do |point,i|
|
29
|
-
next if point == p.last
|
30
|
-
@document.move_to point
|
31
|
-
@document.stroke_line_to p[i+1]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Prawn
|
2
|
-
module Graph
|
3
|
-
module Charts
|
4
|
-
class Line < Base
|
5
|
-
|
6
|
-
private
|
7
|
-
|
8
|
-
def chart_object
|
9
|
-
Prawn::Graph::Charts::Legacy::Line.new(@series.collect(&:to_a), @prawn, @options)
|
10
|
-
end
|
11
|
-
|
12
|
-
def series_type
|
13
|
-
:line
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|