charma 0.1.0

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.
@@ -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" )