prawn-graph 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/prawn/graph/chart_components/series_renderer.rb +1 -2
- data/lib/prawn/graph/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: 4d0a4c3175c0641db328c6713e13f86db27d04a2
|
4
|
+
data.tar.gz: 0604788d0fdfcba265040cc8f82cc2061fc3e86b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b22c30fc8ec27404d3cf5482ac90e8b23204929eadf7982014be9993ad0197cb77c04808ef99dd47a55bcfb2cc7ab9bed314343d7c8022cebbb6b8d011b3bd0
|
7
|
+
data.tar.gz: f4b3bae5bdc387dc4ce5e93871b924313a1f16c1ed630e42a2d1d0c489a2037b0f07ef8f3cbead3def6de31e9336dc5a288cb12f8e311a9f1eb7718f1ceff0b1
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ ability to change the colors used to render the graph.
|
|
52
52
|
To use prawn-graph, you can add the following to your `Gemfile`:
|
53
53
|
|
54
54
|
```Gemfile
|
55
|
-
gem 'prawn-graph', '0.9
|
55
|
+
gem 'prawn-graph', ' ~> 0.9'
|
56
56
|
```
|
57
57
|
|
58
58
|
Alternatively, you can use Rubygems directly: `gem install prawn-graph`.
|
@@ -104,16 +104,19 @@ Option | Data type | Description
|
|
104
104
|
require 'prawn-graph'
|
105
105
|
|
106
106
|
series = []
|
107
|
-
series << Prawn::Graph::Series.new([5,4,3,2,1,1,2,8,7,5,4,9,2], title: "
|
108
|
-
series << Prawn::Graph::Series.new([5,4,3,2,1,1,2,8,7,5,4,9,2].reverse, title: "
|
109
|
-
series << Prawn::Graph::Series.new([1,2,3,4,5,9,6,4,5,6,3,2,9], title: "
|
110
|
-
series << Prawn::Graph::Series.new([1,2,3,4,5,9,6,4,5,6,3,2,9].shuffle, title: "
|
107
|
+
series << Prawn::Graph::Series.new([5,4,3,2,1,1,2,8,7,5,4,9,2], title: "A label for a series", type: :bar)
|
108
|
+
series << Prawn::Graph::Series.new([5,4,3,2,1,1,2,8,7,5,4,9,2].reverse, title: "Another label", type: :bar)
|
109
|
+
series << Prawn::Graph::Series.new([1,2,3,4,5,9,6,4,5,6,3,2,9], title: "Yet another label", type: :bar)
|
110
|
+
series << Prawn::Graph::Series.new([1,2,3,4,5,9,6,4,5,6,3,2,9].shuffle, title: "One final label", type: :line)
|
111
111
|
|
112
112
|
Prawn::Document.generate('test.pdf') do
|
113
|
-
graph series, width: 500, height: 200, title: "A
|
113
|
+
graph series, width: 500, height: 200, title: "A Title for the chart", at: [10,700]
|
114
114
|
end
|
115
115
|
```
|
116
116
|
|
117
|
+
### Output
|
118
|
+
<img src="http://prawn-graph.ryanstenhouse.jp/img/prawn-graph-output.png" alt="Prawn Graph Example Output" width="933" height="420">
|
119
|
+
|
117
120
|
## Development
|
118
121
|
|
119
122
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
|
@@ -123,7 +123,6 @@ module Prawn
|
|
123
123
|
num_points = @series[0].size
|
124
124
|
width_per_point = (@plot_area_width / num_points).round(2).to_f
|
125
125
|
width = ((width_per_point * BigDecimal('0.9')) / @series.size).round(2).to_f
|
126
|
-
spacing = (width_per_point - (width * @series.size).to_f / 2.0)
|
127
126
|
|
128
127
|
num_points.times do |point|
|
129
128
|
|
@@ -160,7 +159,7 @@ module Prawn
|
|
160
159
|
# the series.
|
161
160
|
#
|
162
161
|
def point_height_percentage(value)
|
163
|
-
((BigDecimal(value, 10)/BigDecimal(@series
|
162
|
+
((BigDecimal(value, 10)/BigDecimal(@series.collect(&:max).max, 10)) * BigDecimal(1)).round(2)
|
164
163
|
end
|
165
164
|
|
166
165
|
def prawn
|
data/lib/prawn/graph/version.rb
CHANGED