kenhirakawa-googlecharts 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/History.txt +48 -0
- data/License.txt +20 -0
- data/Manifest.txt +18 -0
- data/README +0 -0
- data/README.markdown +290 -0
- data/README.txt +9 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/config/hoe.rb +71 -0
- data/config/requirements.rb +16 -0
- data/lib/gchart/aliases.rb +14 -0
- data/lib/gchart/theme.rb +46 -0
- data/lib/gchart/version.rb +9 -0
- data/lib/gchart.rb +698 -0
- data/lib/googlecharts.rb +2 -0
- data/lib/themes.yml +45 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/fixtures/another_test_theme.yml +8 -0
- data/spec/fixtures/test_theme.yml +8 -0
- data/spec/gchart_spec.rb +595 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/theme_spec.rb +34 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +732 -0
- data/website/index.txt +570 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +139 -0
- data/website/template.rhtml +53 -0
- metadata +101 -0
data/.gitignore
ADDED
data/History.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
== 1.3.6
|
2
|
+
* support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer)
|
3
|
+
* allow a label to appear on a google-o-meter via the :legend option. (hallettj)
|
4
|
+
|
5
|
+
== 1.3.5
|
6
|
+
* added code to properly escape image tag URLs (mokolabs)
|
7
|
+
* added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow)
|
8
|
+
|
9
|
+
== 1.3.4
|
10
|
+
* updated documentation and cleaned it up (mokolabs)
|
11
|
+
* added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs)
|
12
|
+
|
13
|
+
== 1.3.2 - 1.3.3
|
14
|
+
* changes required by github
|
15
|
+
|
16
|
+
== 1.3.1
|
17
|
+
* added width and spacing options
|
18
|
+
|
19
|
+
== 1.3.0
|
20
|
+
* added support for google-o-meter
|
21
|
+
* fixed a bug when the max value of a data set was 0
|
22
|
+
|
23
|
+
== 1.2.0
|
24
|
+
* added support for sparklines
|
25
|
+
|
26
|
+
== 1.1.0
|
27
|
+
* fixed another bug fix related to the uri escaping required to download the file properly.
|
28
|
+
|
29
|
+
== 1.0.0
|
30
|
+
* fixed the (URI::InvalidURIError) issue
|
31
|
+
|
32
|
+
== 0.2.0
|
33
|
+
* added export options (file and image tag)
|
34
|
+
* added support for all arguments to be passed as a string or an array
|
35
|
+
|
36
|
+
== 0.1.0 2007-12-11
|
37
|
+
* fixed the axis labels
|
38
|
+
|
39
|
+
== 0.0.3 2007-12-11
|
40
|
+
* added :chart_background alias and fixed a bug related to the background colors.
|
41
|
+
|
42
|
+
== 0.0.2 2007-12-11
|
43
|
+
* added support for more features and aliases
|
44
|
+
|
45
|
+
== 0.0.1 2007-12-08
|
46
|
+
|
47
|
+
* 1 major enhancement:
|
48
|
+
* Initial release
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Matt Aimonetti
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
config/hoe.rb
|
7
|
+
config/requirements.rb
|
8
|
+
lib/gchart.rb
|
9
|
+
lib/gchart/aliases.rb
|
10
|
+
lib/gchart/theme.rb
|
11
|
+
lib/gchart/version.rb
|
12
|
+
setup.rb
|
13
|
+
spec/gchart_spec.rb
|
14
|
+
spec/theme_spec.rb
|
15
|
+
spec/spec.opts
|
16
|
+
spec/spec_helper.rb
|
17
|
+
tasks/environment.rake
|
18
|
+
tasks/rspec.rake
|
data/README
ADDED
File without changes
|
data/README.markdown
ADDED
@@ -0,0 +1,290 @@
|
|
1
|
+
The goal of this Gem is to make the creation of Google Charts a simple and easy task.
|
2
|
+
|
3
|
+
Gchart.line( :size => '200x300',
|
4
|
+
:title => "example title",
|
5
|
+
:bg => 'efefef',
|
6
|
+
:legend => ['first data set label', 'second data set label'],
|
7
|
+
:data => [10, 30, 120, 45, 72])
|
8
|
+
|
9
|
+
|
10
|
+
Check out the [full documentation over there](http://googlecharts.rubyforge.org/)
|
11
|
+
|
12
|
+
This gem is fully tested using Rspec, check the rspec folder for more examples.
|
13
|
+
|
14
|
+
See at the bottom of this file who reported using this gem.
|
15
|
+
|
16
|
+
Chart Type
|
17
|
+
-------------
|
18
|
+
|
19
|
+
This gem supports the following types of charts:
|
20
|
+
|
21
|
+
* line,
|
22
|
+
* line_xy
|
23
|
+
* sparkline
|
24
|
+
* scatter
|
25
|
+
* bar
|
26
|
+
* venn
|
27
|
+
* pie
|
28
|
+
* pie_3d
|
29
|
+
* google meter
|
30
|
+
|
31
|
+
Googlecharts also supports graphical themes and you can easily load your own.
|
32
|
+
|
33
|
+
To create a chart, simply require Gchart and call any of the existing type:
|
34
|
+
|
35
|
+
require 'gchart'
|
36
|
+
Gchart.pie
|
37
|
+
|
38
|
+
|
39
|
+
Chart Title
|
40
|
+
-------------
|
41
|
+
|
42
|
+
To add a title to a chart pass the title to your chart:
|
43
|
+
|
44
|
+
Gchart.line(:title => 'Sexy Charts!')
|
45
|
+
|
46
|
+
You can also specify the color and/or size
|
47
|
+
|
48
|
+
Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20')
|
49
|
+
|
50
|
+
Colors
|
51
|
+
-------------
|
52
|
+
|
53
|
+
Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example:
|
54
|
+
|
55
|
+
* FF0000 = red
|
56
|
+
* 00FF00 = green
|
57
|
+
* 0000FF = blue
|
58
|
+
* 000000 = black
|
59
|
+
* FFFFFF = white
|
60
|
+
|
61
|
+
You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example:
|
62
|
+
|
63
|
+
* 0000FFFF = solid blue
|
64
|
+
* 0000FF00 = transparent blue
|
65
|
+
|
66
|
+
If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00'
|
67
|
+
|
68
|
+
Some charts have more options than other, make sure to refer to the documentation.
|
69
|
+
|
70
|
+
Background options:
|
71
|
+
-------------
|
72
|
+
|
73
|
+
If you don't set the background option, your graph will be transparent.
|
74
|
+
|
75
|
+
* You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill
|
76
|
+
|
77
|
+
- solid
|
78
|
+
- gradient
|
79
|
+
- stripes
|
80
|
+
|
81
|
+
By default, if you set a background color, the fill will be solid:
|
82
|
+
|
83
|
+
Gchart.bar(:bg => 'efefef')
|
84
|
+
|
85
|
+
However you can specify another fill type such as:
|
86
|
+
|
87
|
+
Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})
|
88
|
+
|
89
|
+
In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows:
|
90
|
+
|
91
|
+
Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90})
|
92
|
+
|
93
|
+
For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient
|
94
|
+
|
95
|
+
Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'})
|
96
|
+
|
97
|
+
|
98
|
+
The same way you set the background color, you can also set the graph background:
|
99
|
+
|
100
|
+
Gchart.line(:graph_bg => 'cccccc')
|
101
|
+
|
102
|
+
or both
|
103
|
+
|
104
|
+
Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart')
|
105
|
+
|
106
|
+
|
107
|
+
Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes
|
108
|
+
|
109
|
+
Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})
|
110
|
+
|
111
|
+
You can customize the amount of stripes, colors and width by changing the color value.
|
112
|
+
|
113
|
+
|
114
|
+
Themes
|
115
|
+
--------
|
116
|
+
|
117
|
+
Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master)
|
118
|
+
|
119
|
+
|
120
|
+
Gchart.line(
|
121
|
+
:theme => :keynote,
|
122
|
+
:data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]],
|
123
|
+
:title => 'keynote'
|
124
|
+
)
|
125
|
+
|
126
|
+
* keynote
|
127
|
+
|
128
|
+
![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000)
|
129
|
+
|
130
|
+
* thirty7signals
|
131
|
+
|
132
|
+
![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF)
|
133
|
+
|
134
|
+
* pastel
|
135
|
+
|
136
|
+
![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo)
|
137
|
+
|
138
|
+
* greyscale
|
139
|
+
|
140
|
+
![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo)
|
141
|
+
|
142
|
+
|
143
|
+
You can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml
|
144
|
+
|
145
|
+
Load your theme(s):
|
146
|
+
|
147
|
+
Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml")
|
148
|
+
|
149
|
+
And use the standard method signature to use your own theme:
|
150
|
+
|
151
|
+
Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale')
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Legend & Labels
|
156
|
+
-------------
|
157
|
+
|
158
|
+
You probably will want to use a legend or labels for your graph.
|
159
|
+
|
160
|
+
Gchart.line(:legend => 'legend label')
|
161
|
+
or
|
162
|
+
Gchart.line(:legend => ['legend label 1', 'legend label 2'])
|
163
|
+
|
164
|
+
Will do the trick. You can also use the labels alias (makes more sense when using the pie charts)
|
165
|
+
|
166
|
+
chart = Gchart.pie(:labels => ['label 1', 'label 2'])
|
167
|
+
|
168
|
+
Multiple axis labels
|
169
|
+
-------------
|
170
|
+
|
171
|
+
Multiple axis labels are available for line charts, bar charts and scatter plots.
|
172
|
+
|
173
|
+
* x = bottom x-axis
|
174
|
+
* t = top x-axis
|
175
|
+
* y = left y-axis
|
176
|
+
* r = right y-axis
|
177
|
+
|
178
|
+
Gchart.line(:label_axis => 'x,y,r')
|
179
|
+
|
180
|
+
To add labels on these axis:
|
181
|
+
|
182
|
+
Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])
|
183
|
+
|
184
|
+
|
185
|
+
Data options
|
186
|
+
-------------
|
187
|
+
|
188
|
+
Data are passed using an array or a nested array.
|
189
|
+
|
190
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234])
|
191
|
+
|
192
|
+
Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]])
|
193
|
+
|
194
|
+
By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value.
|
195
|
+
|
196
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300)
|
197
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto')
|
198
|
+
|
199
|
+
or if you want to use the real values from your dataset:
|
200
|
+
|
201
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false)
|
202
|
+
|
203
|
+
|
204
|
+
You can also define a different encoding to add more granularity:
|
205
|
+
|
206
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple')
|
207
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended')
|
208
|
+
Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text')
|
209
|
+
|
210
|
+
|
211
|
+
Pies:
|
212
|
+
-------------
|
213
|
+
|
214
|
+
you have 2 type of pies:
|
215
|
+
- Gchart.pie() the standard 2D pie
|
216
|
+
_ Gchart.pie_3d() the fancy 3D pie
|
217
|
+
|
218
|
+
To set labels, you can use one of these two options:
|
219
|
+
|
220
|
+
@legend = ['Matt_fu', 'Rob_fu']
|
221
|
+
Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200')
|
222
|
+
Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200')
|
223
|
+
|
224
|
+
Bars:
|
225
|
+
-------------
|
226
|
+
|
227
|
+
A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash.
|
228
|
+
|
229
|
+
The Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order:
|
230
|
+
|
231
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6
|
232
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12
|
233
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6
|
234
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25
|
235
|
+
|
236
|
+
The hash lets you set these values directly, with the Google default values set for any options you don't include:
|
237
|
+
|
238
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19})
|
239
|
+
Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12})
|
240
|
+
|
241
|
+
Sparklines:
|
242
|
+
-------------
|
243
|
+
|
244
|
+
A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default.
|
245
|
+
|
246
|
+
|
247
|
+
Google-o-meter
|
248
|
+
-------------
|
249
|
+
|
250
|
+
A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label.
|
251
|
+
|
252
|
+
try yourself
|
253
|
+
-------------
|
254
|
+
|
255
|
+
Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]],
|
256
|
+
:title => 'SD Ruby Fu level',
|
257
|
+
:legend => ['matt','patrick'],
|
258
|
+
:bg => {:color => '76A4FB', :type => 'gradient'},
|
259
|
+
:bar_colors => 'ff0000,00ff00')
|
260
|
+
|
261
|
+
"http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00"
|
262
|
+
|
263
|
+
Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])
|
264
|
+
http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
|
265
|
+
|
266
|
+
|
267
|
+
People reported using this gem:
|
268
|
+
---------------------
|
269
|
+
|
270
|
+
![github](http://img.skitch.com/20080627-r14subqdx2ye3w13qefbx974gc.png)
|
271
|
+
|
272
|
+
* [http://github.com](http://github.com)
|
273
|
+
|
274
|
+
![stafftool.com](http://stafftool.com/images/masthead_screen.gif)
|
275
|
+
|
276
|
+
* [http://stafftool.com/](http://stafftool.com/) Takeo (contributor)
|
277
|
+
|
278
|
+
![graffletopia.com](http://img.skitch.com/20080627-g2pp89h7gdbh15m1rr8hx48jep.jpg)
|
279
|
+
|
280
|
+
* [graffleropia.com](http://graffletopia.com) Mokolabs (contributor)
|
281
|
+
|
282
|
+
![gumgum](http://img.skitch.com/20080627-kc1weqsbkmxeqhwiyriq3n6g8k.jpg)
|
283
|
+
|
284
|
+
* [http://gumgum.com](http://gumgum.com) Mattetti (Author)
|
285
|
+
|
286
|
+
![http://img.skitch.com/20080627-n48j8pb2r7irsewfeh4yp3da12.jpg]
|
287
|
+
|
288
|
+
* [http://feedflix.com/](http://feedflix.com/) [lifehacker article](http://lifehacker.com/395610/feedflix-creates-detailed-charts-from-your-netflix-use)
|
289
|
+
|
290
|
+
* [California State University, Chico](http://www.csuchico.edu/)
|
data/README.txt
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "kenhirakawa-googlecharts"
|
8
|
+
gemspec.summary = "Generate charts using Google API & Ruby"
|
9
|
+
gemspec.description = "Generate charts using Google API & Ruby"
|
10
|
+
gemspec.email = "k.hirakawa88@gmail.com"
|
11
|
+
gemspec.homepage = "http://github.com/kenhirakawa/googlecharts"
|
12
|
+
gemspec.authors = ["Matt Aimonetti, Ken Hirakawa"]
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
20
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.5.2
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'gchart/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Matt Aimonetti, Ken Hirakawa' # can also be an array of Authors
|
4
|
+
EMAIL = "k.hirakawa88@gmail.com"
|
5
|
+
DESCRIPTION = "description of gem"
|
6
|
+
GEM_NAME = 'kenhirakawa-googlecharts' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'kenhirakawa-googlecharts' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "matt_a"
|
14
|
+
def rubyforge_username
|
15
|
+
unless @config
|
16
|
+
begin
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
+
rescue
|
19
|
+
puts <<-EOS
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
+
EOS
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
REV = nil
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
+
VERS = GchartInfo::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'gchart documentation',
|
36
|
+
"--opname", "index.html",
|
37
|
+
"--line-numbers",
|
38
|
+
"--main", "README",
|
39
|
+
"--inline-source"]
|
40
|
+
|
41
|
+
class Hoe
|
42
|
+
def extra_deps
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
+
@extra_deps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generate all the Rake tasks
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
+
p.author = AUTHOR
|
52
|
+
p.description = DESCRIPTION
|
53
|
+
p.email = EMAIL
|
54
|
+
p.summary = DESCRIPTION
|
55
|
+
p.url = HOMEPATH
|
56
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
+
p.test_globs = ["test/**/test_*.rb"]
|
58
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
59
|
+
|
60
|
+
# == Optional
|
61
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
62
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
63
|
+
|
64
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
69
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
70
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
71
|
+
hoe.rsync_args = '-av --delete --ignore-errors'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile could use '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
15
|
+
|
16
|
+
require 'gchart'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Gchart
|
2
|
+
|
3
|
+
alias_method :background=, :bg=
|
4
|
+
alias_method :chart_bg=, :graph_bg=
|
5
|
+
alias_method :chart_color=, :graph_bg=
|
6
|
+
alias_method :chart_background=, :graph_bg=
|
7
|
+
alias_method :bar_color=, :bar_colors=
|
8
|
+
alias_method :line_colors=, :bar_colors=
|
9
|
+
alias_method :line_color=, :bar_colors=
|
10
|
+
alias_method :labels=, :legend=
|
11
|
+
alias_method :horizontal?, :horizontal
|
12
|
+
alias_method :grouped?, :grouped
|
13
|
+
|
14
|
+
end
|
data/lib/gchart/theme.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Chart
|
4
|
+
class Theme
|
5
|
+
class ThemeNotFound < RuntimeError; end
|
6
|
+
|
7
|
+
@@theme_files = ["#{File.dirname(__FILE__)}/../themes.yml"]
|
8
|
+
|
9
|
+
attr_accessor :colors
|
10
|
+
attr_accessor :bar_colors
|
11
|
+
attr_accessor :background
|
12
|
+
attr_accessor :chart_background
|
13
|
+
|
14
|
+
def self.load(theme_name)
|
15
|
+
theme = new(theme_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.theme_files
|
19
|
+
@@theme_files
|
20
|
+
end
|
21
|
+
|
22
|
+
# Allows you to specify paths for custom theme files in YAML format
|
23
|
+
def self.add_theme_file(file)
|
24
|
+
@@theme_files << file
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(theme_name)
|
28
|
+
themes = {}
|
29
|
+
@@theme_files.each {|f| themes.update YAML::load(File.open(f))}
|
30
|
+
theme = themes[theme_name]
|
31
|
+
if theme
|
32
|
+
self.colors = theme[:colors]
|
33
|
+
self.bar_colors = theme[:bar_colors]
|
34
|
+
self.background = theme[:background]
|
35
|
+
self.chart_background = theme[:chart_background]
|
36
|
+
self
|
37
|
+
else
|
38
|
+
raise(ThemeNotFound, "Could not locate the #{theme_name} theme ...")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_options
|
43
|
+
{:background => background, :chart_background => chart_background, :bar_colors => bar_colors.join(',')}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|