charma 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +74 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/charma.gemspec +33 -0
- data/examples/bar_charts.pdf +4273 -0
- data/examples/bar_charts.rb +67 -0
- data/examples/line_charts.pdf +5645 -0
- data/examples/line_charts.rb +106 -0
- data/examples/runall.rb +6 -0
- data/examples/violin_charts.pdf +8020 -0
- data/examples/violin_charts.rb +65 -0
- data/lib/charma/bar_chart.rb +75 -0
- data/lib/charma/chart.rb +188 -0
- data/lib/charma/document.rb +27 -0
- data/lib/charma/error.rb +5 -0
- data/lib/charma/line_chart.rb +141 -0
- data/lib/charma/page.rb +58 -0
- data/lib/charma/rect.rb +52 -0
- data/lib/charma/version.rb +5 -0
- data/lib/charma/violin_chart.rb +121 -0
- data/lib/charma.rb +14 -0
- metadata +143 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'charma'
|
4
|
+
|
5
|
+
Charma::Document.new{ |doc|
|
6
|
+
[
|
7
|
+
{
|
8
|
+
series: [
|
9
|
+
{
|
10
|
+
name: "pi",
|
11
|
+
y: [3,1,4,1,5]
|
12
|
+
},
|
13
|
+
{
|
14
|
+
name: "sqrt(2)",
|
15
|
+
y: [1,4,1,4,2]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
name: "sqrt(5)",
|
19
|
+
y: [2,2,3,6,2]
|
20
|
+
},
|
21
|
+
],
|
22
|
+
title: "Lorem ipsum",
|
23
|
+
x_ticks: %w(foo bar baz qux quux),
|
24
|
+
},
|
25
|
+
{
|
26
|
+
series: [{y: [9,2,6,5,4,5,8,9,7,9]}],
|
27
|
+
},
|
28
|
+
{
|
29
|
+
series: [{y: [76, -28, -67, 155, 77, 160, 61, 48, -63, 26]}],
|
30
|
+
title: "Excepteur sint occaecat cupidatat non proident",
|
31
|
+
x_ticks:%w(foo bar baz qux quux corge grault garply waldo fred),
|
32
|
+
},
|
33
|
+
{
|
34
|
+
series: [{y: [7e+06, 2.8e+07, 1.2e+07, 1.5e+07, 2.7e+07, 2.5e+07, 1.3e+07]}],
|
35
|
+
x_ticks: %w(Alcyone Atlas Electra Maia Merope Taygeta Pleione),
|
36
|
+
y_label: "Random Number",
|
37
|
+
},
|
38
|
+
[
|
39
|
+
{
|
40
|
+
series: [{y:[6,8,3,17,-12,38]}],
|
41
|
+
title:"salamander",
|
42
|
+
},
|
43
|
+
{
|
44
|
+
series: [{y:[100,-4,-8,14,-17,57]}],
|
45
|
+
title:"gradius",
|
46
|
+
},
|
47
|
+
],
|
48
|
+
Array.new(11){ |n|
|
49
|
+
{
|
50
|
+
series: [{y: ->{ srand(n); m=rand+0.1; Array.new(7){ m*(rand+rand-rand) } }[]}],
|
51
|
+
title:"graph #{n}",
|
52
|
+
y_range: [-1.1, 2.2],
|
53
|
+
}
|
54
|
+
}
|
55
|
+
].each do |opts|
|
56
|
+
doc.new_page do |page|
|
57
|
+
case opts
|
58
|
+
when Hash
|
59
|
+
page.add_barchart( opts )
|
60
|
+
when Array
|
61
|
+
opts.each{ |o| page.add_barchart( o ) }
|
62
|
+
else
|
63
|
+
raise "unexpected input #{opts.inspect}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
}.render( File.basename(__FILE__, ".*")+".pdf" )
|