mokolabs-googlecharts 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.3.4
2
+ * updated documentation and cleaned it up (mokolabs)
3
+ * 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)
4
+
5
+ == 1.3.2 - 1.3.3
6
+ * changes required by github
7
+
1
8
  == 1.3.1
2
9
  * added width and spacing options
3
10
 
data/README.txt CHANGED
@@ -1,180 +1,9 @@
1
- The goal of this Gem is to make the creation of Google Charts a simple and easy task.
1
+ CHECK README.markdown (open as a text file)
2
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
-
3
+ Or check:
9
4
 
5
+ http://googlecharts.rubyforge.org
10
6
 
11
- ==Chart Type
7
+ and/or
12
8
 
13
- This gem supports the following types of charts:
14
-
15
- * line,
16
- * line_xy
17
- * sparkline
18
- * scatter
19
- * bar
20
- * venn
21
- * pie
22
- * pie_3d
23
-
24
- To create a chart, simply require Gchart and call any of the existing type:
25
-
26
- require 'gchart'
27
- Gchart.pie
28
-
29
-
30
- ==Chart Title
31
-
32
- To add a title to a chart pass the title to your chart:
33
-
34
- Gchart.line(:title => 'Sexy Charts!')
35
-
36
- You can also specify the color and/or size
37
-
38
- Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20')
39
-
40
- ==Colors
41
-
42
- Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example:
43
-
44
- * FF0000 = red
45
- * 00FF00 = green
46
- * 0000FF = blue
47
- * 000000 = black
48
- * FFFFFF = white
49
-
50
- You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example:
51
-
52
- * 0000FFFF = solid blue
53
- * 0000FF00 = transparent blue
54
-
55
- If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00'
56
-
57
- Some charts have more options than other, make sure to refer to the documentation.
58
-
59
- ===Background options:
60
-
61
- If you don't set the background option, your graph will be transparent.
62
-
63
- * You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill
64
-
65
- - solid
66
- - gradient
67
- - stripes
68
-
69
- By default, if you set a background color, the fill will be solid:
70
-
71
- Gchart.bar(:bg => 'efefef')
72
-
73
- However you can specify another fill type such as:
74
-
75
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})
76
-
77
- 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:
78
-
79
- Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90})
80
-
81
- For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient
82
-
83
- Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'})
84
-
85
-
86
- The same way you set the background color, you can also set the graph background:
87
-
88
- Gchart.line(:graph_bg => 'cccccc')
89
-
90
- or both
91
-
92
- Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart')
93
-
94
-
95
- Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes
96
-
97
- Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})
98
-
99
- You can customize the amount of stripes, colors and width by changing the color value.
100
-
101
-
102
- == Legend & Labels
103
-
104
- You probably will want to use a legend or labels for your graph.
105
-
106
- Gchart.line(:legend => 'legend label')
107
- or
108
- Gchart.line(:legend => ['legend label 1', 'legend label 2'])
109
-
110
- Will do the trick. You can also use the labels alias (makes more sense when using the pie charts)
111
-
112
- chart = Gchart.pie(:labels => ['label 1', 'label 2'])
113
-
114
- == Multiple axis labels
115
-
116
- Multiple axis labels are available for line charts, bar charts and scatter plots.
117
-
118
- * x = bottom x-axis
119
- * t = top x-axis
120
- * y = left y-axis
121
- * r = right y-axis
122
-
123
- Gchart.line(:label_axis => 'x,y,r')
124
-
125
- To add labels on these axis:
126
-
127
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])
128
-
129
-
130
- == Data options
131
-
132
- Data are passed using an array or a nested array.
133
-
134
- Gchart.bar(:data => [1,2,4,67,100,41,234])
135
-
136
- Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]])
137
-
138
- 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.
139
-
140
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300)
141
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto')
142
-
143
- or if you want to use the real values from your dataset:
144
-
145
- Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false)
146
-
147
-
148
- You can also define a different encoding to add more granularity:
149
-
150
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple')
151
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended')
152
- Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text')
153
-
154
-
155
- ==Pies:
156
-
157
- you have 2 type of pies:
158
- - Gchart.pie() the standard 2D pie
159
- _ Gchart.pie_3d() the fancy 3D pie
160
-
161
- To set labels, you can use one of these two options:
162
-
163
- @legend = ['Matt_fu', 'Rob_fu']
164
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200')
165
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200')
166
-
167
-
168
-
169
- === try yourself
170
-
171
- Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]],
172
- :title => 'SDRuby Fu level',
173
- :legend => ['matt','patrick'],
174
- :bg => {:color => '76A4FB', :type => 'gradient'},
175
- :bar_colors => 'ff0000,00ff00')
176
-
177
- "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"
178
-
179
- Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])
180
- http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
9
+ http://github.com/mattetti/googlecharts
@@ -2,7 +2,7 @@ module GchartInfo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 2
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/gchart.rb CHANGED
@@ -15,27 +15,24 @@ class Gchart
15
15
  @@file_name = 'chart.png'
16
16
 
17
17
  attr_accessor :title, :type, :width, :height, :horizontal, :grouped, :legend, :data, :encoding, :max_value, :bar_colors,
18
- :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing
18
+ :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :class
19
19
 
20
- class << self
21
- # Support for Gchart.line(:title => 'my title', :size => '400x600')
22
- def method_missing(m, options={})
23
- # Extract the format and optional filename, then clean the hash
24
- format = options[:format] || 'url'
25
- @@file_name = options[:filename] unless options[:filename].nil?
26
- options.delete(:format)
27
- options.delete(:filename)
28
- # create the chart and return it in the format asked for
29
- if @@types.include?(m.to_s)
30
- chart = new(options.merge!({:type => m}))
31
- chart.send(format)
32
- elsif m.to_s == 'version'
33
- Gchart::VERSION::STRING
34
- else
35
- "#{m} is not a supported chart format, please use one of the following: #{supported_types}."
36
- end
37
- end
38
-
20
+ # Support for Gchart.line(:title => 'my title', :size => '400x600')
21
+ def self.method_missing(m, options={})
22
+ # Extract the format and optional filename, then clean the hash
23
+ format = options[:format] || 'url'
24
+ @@file_name = options[:filename] unless options[:filename].nil?
25
+ options.delete(:format)
26
+ options.delete(:filename)
27
+ # create the chart and return it in the format asked for
28
+ if @@types.include?(m.to_s)
29
+ chart = new(options.merge!({:type => m}))
30
+ chart.send(format)
31
+ elsif m.to_s == 'version'
32
+ Gchart::VERSION::STRING
33
+ else
34
+ "#{m} is not a supported chart format, please use one of the following: #{supported_types}."
35
+ end
39
36
  end
40
37
 
41
38
  def initialize(options={})
@@ -47,8 +44,11 @@ class Gchart
47
44
  @grouped = false
48
45
  @encoding = 'simple'
49
46
  @max_value = 'auto'
47
+ # Sets the alt tag when chart is exported as image tag
50
48
  @alt = 'Google Chart'
49
+ # Sets the CSS id selector when chart is exported as image tag
51
50
  @id = false
51
+ # Sets the CSS class selector when chart is exported as image tag
52
52
  @class = false
53
53
 
54
54
  # set the options value if definable
@@ -71,33 +71,6 @@ class Gchart
71
71
  "#{@width}x#{@height}"
72
72
  end
73
73
 
74
- # Sets the alt tag when chart is exported as image tag
75
- def alt=(alt='Google Chart')
76
- @alt = alt
77
- end
78
-
79
- def alt
80
- @alt
81
- end
82
-
83
- # Sets the CSS id selector when chart is exported as image tag
84
- def id=(id=false)
85
- @id = id
86
- end
87
-
88
- def id
89
- @id
90
- end
91
-
92
- # Sets the CSS class selector when chart is exported as image tag
93
- def class=(klass=false)
94
- @class = klass
95
- end
96
-
97
- def class
98
- @class
99
- end
100
-
101
74
  # Sets the orientation of a bar graph
102
75
  def orientation=(orientation='h')
103
76
  if orientation == 'h' || orientation == 'horizontal'
data/website/index.txt CHANGED
@@ -6,6 +6,7 @@ h2. &#x2192; 'Sexy Charts using Google API & Ruby'
6
6
  h2. What
7
7
 
8
8
  A nice and simple wrapper for "Google Chart API":http://code.google.com/apis/chart/
9
+ (Fully tested using RSpec, check the specs for more usage examples)
9
10
 
10
11
  h2. Installing
11
12
 
@@ -472,11 +473,39 @@ Gchart.line(:data => [100, 20, 30, 20, 10, 14, 30, 10], :max_value => false )
472
473
  !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:_UeUKOeK(real size)!
473
474
 
474
475
 
475
-
476
476
  h2. Repository
477
477
 
478
478
  The trunk repository is <code>http://github.com/mattetti/googlecharts/</code> for anonymous access.
479
479
 
480
+ h2. People reported using this gem
481
+
482
+
483
+ <div>
484
+ <img src="http://img.skitch.com/20080627-r14subqdx2ye3w13qefbx974gc.png" alt="github"/><br/>
485
+ <li><a href="http://github.com">http://github.com</a></li><br/>
486
+ </div>
487
+
488
+ <div>
489
+ <img src="http://stafftool.com/images/masthead_screen.gif" alt="stafftool"/><br/>
490
+ <li><a href="http://stafftool.com/">Takeo(contributor)</a></li><br/>
491
+ </div>
492
+
493
+ <div>
494
+ <img src="http://img.skitch.com/20080627-g2pp89h7gdbh15m1rr8hx48jep.jpg" alt="graffletopia"/><br/>
495
+ <li><a href="http://graffletopia.com"> http://graffletopia.com Mokolabs(contributor)</a></li><br/>
496
+ </div>
497
+
498
+ <div>
499
+ <img src="http://img.skitch.com/20080627-kc1weqsbkmxeqhwiyriq3n6g8k.jpg" alt="gumgum"/><br/>
500
+ <li><a href="http://gumgum.com"> http://gumgum.com Mattetti(contributor)</a></li><br/>
501
+ </div>
502
+
503
+ <div>
504
+ <img src="http://img.skitch.com/20080627-n48j8pb2r7irsewfeh4yp3da12.jpg" alt="gumgum"/><br/>
505
+ <li><a href="http://feedflix.com/"> http://feedflix.com/</a></li><br/>
506
+ </div>
507
+
508
+
480
509
  h2. License
481
510
 
482
511
  This code is free to use under the terms of the MIT license.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mokolabs-googlecharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aimonetti