squid 0.0.0 → 1.0.0.beta1
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/.gitignore +11 -17
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +11 -0
- data/MIT-LICENSE +21 -0
- data/README.md +146 -2
- data/Rakefile +26 -1
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/examples/manual.rb +7 -0
- data/examples/readme/01-basic.rb +5 -0
- data/examples/readme/02-type-point.rb +5 -0
- data/examples/readme/03-type-line.rb +5 -0
- data/examples/readme/04-color.rb +5 -0
- data/examples/readme/05-gridlines.rb +5 -0
- data/examples/readme/06-ticks.rb +5 -0
- data/examples/readme/07-baseline.rb +5 -0
- data/examples/readme/08-every.rb +5 -0
- data/examples/readme/09-legend.rb +5 -0
- data/examples/readme/10-legend-offset.rb +5 -0
- data/examples/readme/11-format.rb +5 -0
- data/examples/readme/12-labels.rb +5 -0
- data/examples/readme/13-border.rb +5 -0
- data/examples/readme/14-height.rb +5 -0
- data/examples/readme/15-multiple-columns.rb +5 -0
- data/examples/readme/16-multiple-stacks.rb +5 -0
- data/examples/readme/17-two-axis.rb +7 -0
- data/examples/readme/readme.rb +28 -0
- data/examples/readme.rb +7 -0
- data/examples/screenshots/readme_00.png +0 -0
- data/examples/screenshots/readme_01.png +0 -0
- data/examples/screenshots/readme_02.png +0 -0
- data/examples/screenshots/readme_03.png +0 -0
- data/examples/screenshots/readme_04.png +0 -0
- data/examples/screenshots/readme_05.png +0 -0
- data/examples/screenshots/readme_06.png +0 -0
- data/examples/screenshots/readme_07.png +0 -0
- data/examples/screenshots/readme_08.png +0 -0
- data/examples/screenshots/readme_09.png +0 -0
- data/examples/screenshots/readme_10.png +0 -0
- data/examples/screenshots/readme_11.png +0 -0
- data/examples/screenshots/readme_12.png +0 -0
- data/examples/screenshots/readme_13.png +0 -0
- data/examples/screenshots/readme_14.png +0 -0
- data/examples/screenshots/readme_15.png +0 -0
- data/examples/screenshots/readme_16.png +0 -0
- data/examples/screenshots/readme_17.png +0 -0
- data/examples/squid/baseline.rb +9 -0
- data/examples/squid/basic.rb +9 -0
- data/examples/squid/border.rb +9 -0
- data/examples/squid/columns.rb +9 -0
- data/examples/squid/every.rb +11 -0
- data/examples/squid/format.rb +9 -0
- data/examples/squid/gridlines.rb +9 -0
- data/examples/squid/height.rb +9 -0
- data/examples/squid/labels.rb +9 -0
- data/examples/squid/legend.rb +9 -0
- data/examples/squid/legend_offset.rb +9 -0
- data/examples/squid/line.rb +9 -0
- data/examples/squid/line_width.rb +9 -0
- data/examples/squid/lines.rb +11 -0
- data/examples/squid/point.rb +9 -0
- data/examples/squid/points.rb +9 -0
- data/examples/squid/squid.rb +48 -0
- data/examples/squid/stacks.rb +10 -0
- data/examples/squid/ticks.rb +9 -0
- data/examples/squid/two_axis.rb +10 -0
- data/lib/squid/axis.rb +61 -0
- data/lib/squid/axis_label.rb +15 -0
- data/lib/squid/config.rb +46 -0
- data/lib/squid/configuration.rb +80 -0
- data/lib/squid/format.rb +22 -0
- data/lib/squid/graph.rb +113 -0
- data/lib/squid/gridline.rb +16 -0
- data/lib/squid/plotter.rb +187 -0
- data/lib/squid/point.rb +40 -0
- data/lib/squid/settings.rb +15 -0
- data/lib/squid/version.rb +1 -1
- data/lib/squid.rb +35 -3
- data/squid.gemspec +22 -14
- metadata +176 -23
- data/HISTORY.md +0 -1
- data/LICENSE.txt +0 -22
- data/bin/squid +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6df26faf36554dfaaae941ba20b4d73e8dced3b3
|
4
|
+
data.tar.gz: 69a3176e49028324269eb76fd1ebbc1977884e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 199f46e3f7d63dc58b473db627cc13ee0ee1517652a67199c51037345b4ba7d00e23b5796e14653e0862bd454221d523ba7e4e18e44deaf51ff8afe3fd565f80
|
7
|
+
data.tar.gz: 253d51d670c652531f11f2be4802abe04bd5c8337aaa70818bcd8a3f1638d81796992060becb376afaeec2d1a77e19744ba8da4dbf14296803562d11e04fa6df
|
data/.gitignore
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
manual.pdf
|
11
|
+
readme.pdf
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
For more information about changelogs, check
|
6
|
+
[Keep a Changelog](http://keepachangelog.com) and
|
7
|
+
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
|
+
|
9
|
+
## 1.0.0 - unreleased
|
10
|
+
|
11
|
+
* [FEATURE] Add `chart` method to Prawn::Document to draw graphs.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Fullscreen, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,3 +1,147 @@
|
|
1
|
-
|
1
|
+
Squid
|
2
|
+
=====
|
2
3
|
|
3
|
-
|
4
|
+
Squid helps you write Ruby code to draw graphs in PDF files.
|
5
|
+
|
6
|
+
The **source code** is available on [GitHub](https://github.com/Fullscreen/squid) and the **documentation** on [RubyDoc](http://www.rubydoc.info/github/Fullscreen/squid/master/Squid/Interface).
|
7
|
+
|
8
|
+
[](https://travis-ci.org/Fullscreen/squid)
|
9
|
+
[](https://coveralls.io/r/Fullscreen/squid)
|
10
|
+
[](https://gemnasium.com/Fullscreen/squid)
|
11
|
+
[](https://codeclimate.com/github/Fullscreen/squid)
|
12
|
+
[](http://www.rubydoc.info/github/Fullscreen/squid/master/Squid/Interface)
|
13
|
+
[](http://rubygems.org/gems/squid)
|
14
|
+
|
15
|
+
[Prawn](http://prawnpdf.org) is a great Ruby library to generate PDF files
|
16
|
+
but lacks high-level components to draw graphs.
|
17
|
+
|
18
|
+
Squid adds a single method `chart(data = {}, options = {})` to Prawn.
|
19
|
+
|
20
|
+
Provide the `data` to plot as a hash, with each key/value representing a series.
|
21
|
+
|
22
|
+
For instance, the following code generates the graph below:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
data = {views: {2013 => 182, 2014 => 46, 2015 => 134}}
|
26
|
+
chart data
|
27
|
+
```
|
28
|
+
|
29
|
+
")
|
30
|
+
|
31
|
+
|
32
|
+
Graph options
|
33
|
+
-------------
|
34
|
+
|
35
|
+
By providing `options` to the `chart` method, you can customize the format of the graph.
|
36
|
+
|
37
|
+
Multiple options can be combined. Here is a comprehensive list.
|
38
|
+
|
39
|
+
##### `:type` sets the type of graph. Can be `:column` (default), `:point`, or `:line`.
|
40
|
+
|
41
|
+
")
|
42
|
+
|
43
|
+
##### `:line_widths` changes the line width (default: `[3]`, only applies to line graphs).
|
44
|
+
|
45
|
+
")
|
46
|
+
|
47
|
+
##### `:colors` changes the colors of the chart (default: `%w(2e578c 5d9648 e7a13d bc2d30 6f3d79 7d807f)`).
|
48
|
+
|
49
|
+
")
|
50
|
+
|
51
|
+
##### `:steps` changes the number of gridlines (default: `4`).
|
52
|
+
|
53
|
+
")
|
54
|
+
|
55
|
+
##### `:ticks` shows/hides the ticks between the baseline and each category (default: `true`).
|
56
|
+
|
57
|
+
")
|
58
|
+
|
59
|
+
##### `:baseline` shows/hides the baseline (default: `true`).
|
60
|
+
|
61
|
+
")
|
62
|
+
|
63
|
+
##### `:every` specifies how often to show category labels on the baseline (default: `1`).
|
64
|
+
|
65
|
+
")
|
66
|
+
|
67
|
+
##### `:legend` shows/hides the legend (default: `true`).
|
68
|
+
|
69
|
+
")
|
70
|
+
|
71
|
+
##### `:legend` can also set the distance of the legend from the right margin (default: `{offset: 0}`).
|
72
|
+
|
73
|
+
")
|
74
|
+
|
75
|
+
##### `:format` changes the format of the label values. Can be `:integer` (default), `:float`, `:percentage`, `:currency`, or `:seconds`.
|
76
|
+
|
77
|
+
")
|
78
|
+
|
79
|
+
##### `:labels` shows/hides the value for each point in the graph (default: `false`).
|
80
|
+
|
81
|
+
")
|
82
|
+
|
83
|
+
##### `:border` shows/hides a border around the graph (default: `false`).
|
84
|
+
|
85
|
+
")
|
86
|
+
|
87
|
+
##### `:height` changes the height of the graph (default: `250`).
|
88
|
+
|
89
|
+
")
|
90
|
+
|
91
|
+
Multiple series
|
92
|
+
---------------
|
93
|
+
|
94
|
+
By providing multiple key/values `data` to the `chart` method, you can plot multiple series on a graph.
|
95
|
+
|
96
|
+
For instance, the following code generates the graph below:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
data = {safari: {2013 => 43.2, 2014 => 46.1, 2015 => 50.7},
|
100
|
+
firefox: {2013 => 56.8, 2014 => 53.9, 2015 => 49.3}}
|
101
|
+
chart data, labels: true, format: :percentage
|
102
|
+
```
|
103
|
+
|
104
|
+
")
|
105
|
+
|
106
|
+
When plotting multiple series, the option `type: :stack` can be set to display stacked columns:
|
107
|
+
|
108
|
+
")
|
109
|
+
|
110
|
+
Finally, the option `type: :two_axis` can be set to display two separate axes in your series belong to two different domains.
|
111
|
+
|
112
|
+
For instance, the following code generates the graph below:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
data = {views: {2013 => 182, 2014 => 46, 2015 => 88},
|
116
|
+
earnings: {2013 => 104_323, 2014 => 27_234, 2015 => 14_123}}
|
117
|
+
chart data, type: :two_axis
|
118
|
+
```
|
119
|
+
|
120
|
+
")
|
121
|
+
|
122
|
+
How to install
|
123
|
+
==============
|
124
|
+
|
125
|
+
Squid requires **Ruby 2.1 or higher**.
|
126
|
+
If used in a Rails project, requires **Rails 4.0 or higher**.
|
127
|
+
|
128
|
+
To include in your project, add `gem 'squid', github: 'fullscreen/squid'` to the `Gemfile` file of your Ruby project.
|
129
|
+
|
130
|
+
How to generate the manual
|
131
|
+
==========================
|
132
|
+
|
133
|
+
`rake manual`
|
134
|
+
|
135
|
+
How to contribute
|
136
|
+
=================
|
137
|
+
|
138
|
+
If you’ve made it this far in the README… thanks! :v:
|
139
|
+
|
140
|
+
I’m about to release version 1 of this gem.
|
141
|
+
Feel free to try it out and send issues or pull requests.
|
142
|
+
|
143
|
+
All pull requests will have to make Travis and Code Climate happy in order to be accepted. :kissing_smiling_eyes:
|
144
|
+
|
145
|
+
You can also run the tests locally with `bundle exec rspec`.
|
146
|
+
|
147
|
+
Happy hacking!
|
data/Rakefile
CHANGED
@@ -1 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
desc 'Generate the manual'
|
4
|
+
task :manual do
|
5
|
+
print 'Building manual... '
|
6
|
+
require_relative 'examples/manual'
|
7
|
+
puts 'DONE!'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Generate the readme'
|
11
|
+
task :readme do
|
12
|
+
print 'Building readme... '
|
13
|
+
require_relative 'examples/readme'
|
14
|
+
print 'Extracting screenshots...'
|
15
|
+
`convert -density 175 -colorspace sRGB readme.pdf -resize 50% -quality 100 -crop 744x320+0+280 examples/screenshots/readme_%02d.png`
|
16
|
+
puts 'DONE!'
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
require "rspec/core/rake_task"
|
21
|
+
require "rspec/core/version"
|
22
|
+
|
23
|
+
desc "Run all examples"
|
24
|
+
RSpec::Core::RakeTask.new :spec
|
25
|
+
|
26
|
+
task default: [:spec]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'squid'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/examples/manual.rb
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
2
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
3
|
+
data = {safari: {2013 => 43.2, 2014 => 46.1, 2015 => 50.7}, firefox: {2013 => 56.8, 2014 => 53.9, 2015 => 49.3}}
|
4
|
+
chart data, labels: true, format: :percentage
|
5
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
2
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
3
|
+
data = {safari: {2013 => 43.2, 2014 => 46.1, 2015 => 50.7}, firefox: {2013 => 56.8, 2014 => 53.9, 2015 => 49.3}}
|
4
|
+
chart data, type: :stack, format: :percentage
|
5
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Prawn::ManualBuilder::Example.generate 'readme.pdf' do
|
2
|
+
package 'readme' do |p|
|
3
|
+
p.name = 'Readme'
|
4
|
+
|
5
|
+
p.intro do
|
6
|
+
end
|
7
|
+
|
8
|
+
p.section 'Single series' do |s|
|
9
|
+
s.example '01-basic'
|
10
|
+
s.example '02-type-point'
|
11
|
+
s.example '03-type-line'
|
12
|
+
s.example '04-color'
|
13
|
+
s.example '05-gridlines'
|
14
|
+
s.example '06-ticks'
|
15
|
+
s.example '07-baseline'
|
16
|
+
s.example '08-every'
|
17
|
+
s.example '09-legend'
|
18
|
+
s.example '10-legend-offset'
|
19
|
+
s.example '11-format'
|
20
|
+
s.example '12-labels'
|
21
|
+
s.example '13-border'
|
22
|
+
s.example '14-height'
|
23
|
+
s.example '15-multiple-columns'
|
24
|
+
s.example '16-multiple-stacks'
|
25
|
+
s.example '17-two-axis'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/examples/readme.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> plots a baseline at the bottom of the graph.
|
2
|
+
#
|
3
|
+
# You can use the <code>:baseline</code> option to disable this behavior.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 182, 2014 => 46, 2015 => 802000000000000000}}
|
8
|
+
chart data, baseline: false, format: :float
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Creating graphs with Squid is easy. Just use the <code>chart</code> method.
|
2
|
+
#
|
3
|
+
# Provide a hash containing the data of the series and plot it with <code>chart</code>.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 182, 2014 => 46, 2015 => 134}}
|
8
|
+
chart data
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> is not plotted with an outer border.
|
2
|
+
#
|
3
|
+
# You can use the <code>:border</code> option to enable this behavior.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {Safari: 45.20001, Firefox: 33.3999, Chrome: 21.4}}
|
8
|
+
chart data, border: true
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> plots a graph for each series.
|
2
|
+
#
|
3
|
+
# Provide multiple key/value pairs to <code>:data</code> to plot multiple series.
|
4
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
5
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
6
|
+
data = {views: {2013 => 182, 2014 => 46, 2015 => 88},
|
7
|
+
uniques: {2013 => 104, 2014 => -27, 2015 => 14}}
|
8
|
+
chart data, labels: true
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# By default, <code>chart</code> plots every category on the baseline.
|
2
|
+
#
|
3
|
+
# You can use the <code>:every</code> option to change this behavior.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {'Jan 1' => 12, 'Jan 2' => 13, 'Jan 3' => 21, 'Jan 4' => 42,
|
8
|
+
'Jan 5' => 32, 'Jan 6' => 45, 'Jan 7' => 62, 'Jan 8' => 22, 'Jan 9' => 31,
|
9
|
+
'Jan 10' => 11, 'Jan 11' => 40, 'Jan 12' => 6, 'Jan 13' => 9}}
|
10
|
+
chart data, every: 3
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# You can specify the format of the axis values with the <code>:format</code> option.
|
2
|
+
#
|
3
|
+
# Valid options are: <code>:percentage</code>, <code>:currency</code>, <code>:seconds</code>, <code>:float</code>.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {Safari: 45.20001, Firefox: 33.3999, Chrome: 21.4}}
|
8
|
+
chart data, format: :percentage
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> plots 5 equidistant horizontal gridlines.
|
2
|
+
#
|
3
|
+
# You can use the <code>:steps</code> option to change this number.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 182000, 2014 => -46000, 2015 => 102000}}
|
8
|
+
chart data, steps: 8
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> generates charts with a height of 250.
|
2
|
+
#
|
3
|
+
# You can use the <code>:height</code> option to manually set the height.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 18.2, 2014 => 4.6, 2015 => 10.2}}
|
8
|
+
chart data, height: 350
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> does not write value labels on the chart.
|
2
|
+
#
|
3
|
+
# You can use the <code>:labels</code> option to enable this behavior.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {a_very_long_label_to_test_padding_with_labels: {2013 => 182000, 2014 => -182000, 2015 => 182000}}
|
8
|
+
chart data, labels: true
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> adds a legend in the top-right corner.
|
2
|
+
#
|
3
|
+
# You can use the <code>:legend</code> option to disable this behavior.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 182, 2014 => 46}, uniques: {2013 => 94, 2014 => 27}}
|
8
|
+
chart data, legend: false
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> adds a legend in the top-right corner.
|
2
|
+
#
|
3
|
+
# You can use the <code>:legend</code> option to change the position of the legend.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {2013 => 182, 2014 => 46}, uniques: {2013 => 94, 2014 => 27}}
|
8
|
+
chart data, legend: {offset: 50}
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# By default, <code>chart</code> plots a column chart.
|
2
|
+
#
|
3
|
+
# You can use the <code>:type</code> option to plot a line chart instead.
|
4
|
+
#
|
5
|
+
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
|
6
|
+
Prawn::ManualBuilder::Example.generate(filename) do
|
7
|
+
data = {views: {Safari: 45.20001, Firefox: 63.3999, Chrome: 21.4}}
|
8
|
+
chart data, type: :line
|
9
|
+
end
|