gchartrb 0.5.2 → 0.5.3
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.
- data/CREDITS +2 -1
- data/History.txt +4 -0
- data/README.txt +101 -58
- data/Rakefile +1 -1
- data/lib/example.rb +1 -1
- data/lib/google_chart/bar_chart.rb +2 -1
- data/lib/google_chart/base.rb +38 -1
- data/lib/google_chart/line_chart.rb +2 -1
- data/lib/google_chart/pie_chart.rb +2 -1
- data/lib/google_chart/scatter_chart.rb +2 -1
- data/lib/google_chart/venn_diagram.rb +3 -2
- data/lib/test.rb +87 -68
- metadata +2 -2
data/CREDITS
CHANGED
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -29,20 +29,19 @@ Download the latest release from http://code.google.com/p/gchartrb/downloads/lis
|
|
29
29
|
== Problems/TODO
|
30
30
|
The following features are pending :
|
31
31
|
|
32
|
-
* Horizontal and Vertical range Markers
|
33
32
|
* Line Styles
|
34
|
-
* Shape Markers
|
35
33
|
* Fill Area
|
36
34
|
|
37
35
|
However, you can still make use of the API to insert arbitrary parameters
|
38
36
|
|
39
37
|
# Plotting a sparklines chart (using extra params)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
GoogleChart::LineChart.new('100x50', nil, false) do |sparklines|
|
39
|
+
sparklines.data "Test", [4,3,2,4,6,8,10]
|
40
|
+
sparklines.show_legend = false
|
41
|
+
sparklines.axis :x, :labels => [] # Empty labels
|
42
|
+
sparklines.axis :y, :labels => [] # Empty labels
|
43
|
+
puts sparklines.to_url(:chxs => "0,000000,10,0,_|1,000000,10,0,_")
|
44
|
+
end
|
46
45
|
|
47
46
|
== SYNOPSIS:
|
48
47
|
|
@@ -50,37 +49,50 @@ However, you can still make use of the API to insert arbitrary parameters
|
|
50
49
|
require 'google_chart'
|
51
50
|
|
52
51
|
# Pie Chart
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
|
53
|
+
pc.data "Apples", 40
|
54
|
+
pc.data "Banana", 20
|
55
|
+
pc.data "Peach", 30
|
56
|
+
pc.data "Orange", 60
|
57
|
+
puts "\nPie Chart"
|
58
|
+
puts pc.to_url
|
59
|
+
|
60
|
+
# Pie Chart with no labels
|
61
|
+
pc.show_labels = false
|
62
|
+
puts "\nPie Chart (with no labels)"
|
63
|
+
puts pc.to_url
|
64
|
+
end
|
65
|
+
|
59
66
|
|
60
67
|
# Line Chart
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
69
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
70
|
+
lc.show_legend = true
|
71
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
72
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
73
|
+
lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size => 16, :alignment => :center
|
74
|
+
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
75
|
+
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
76
|
+
puts "\nLine Chart"
|
77
|
+
puts lc.to_url
|
78
|
+
end
|
71
79
|
|
72
80
|
# Bar Chart
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
GoogleChart::BarChart.new('800x200', "Bar Chart", :vertical, false) do |bc|
|
82
|
+
bc.data "Trend 1", [5,4,3,1,3,5], '0000ff'
|
83
|
+
bc.data "Trend 2", [1,2,3,4,5,6], 'ff0000'
|
84
|
+
bc.data "Trend 3", [6,5,4,4,5,6], '00ff00'
|
85
|
+
puts "\nBar Chart"
|
86
|
+
puts bc.to_url
|
87
|
+
end
|
78
88
|
|
79
89
|
# Line XY Chart
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
90
|
+
line_chart_xy = GoogleChart::LineChart.new('320x200', "Line XY Chart", true) do |lcxy|
|
91
|
+
lcxy.data "Trend 1", [[1,1], [2,2], [3,3], [4,4]], '0000ff'
|
92
|
+
lcxy.data "Trend 2", [[4,5], [2,2], [1,1], [3,4]], '00ff00'
|
93
|
+
puts "\nLine XY Chart (inside a block)"
|
94
|
+
puts lcxy.to_url
|
95
|
+
end
|
84
96
|
|
85
97
|
# Venn Diagram
|
86
98
|
# Supply three vd.data statements of label, size, color for circles A, B, C
|
@@ -89,37 +101,68 @@ However, you can still make use of the API to insert arbitrary parameters
|
|
89
101
|
# the second value specifies the area of B intersecting C
|
90
102
|
# the third value specifies the area of C intersecting A
|
91
103
|
# the fourth value specifies the area of A intersecting B intersecting C
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
104
|
+
GoogleChart::VennDiagram.new("320x200", 'Venn Diagram') do |vd|
|
105
|
+
vd.data "Blue", 100, '0000ff'
|
106
|
+
vd.data "Green", 80, '00ff00'
|
107
|
+
vd.data "Red", 60, 'ff0000'
|
108
|
+
vd.intersections 30,30,30,10
|
109
|
+
puts "\nVenn Diagram"
|
110
|
+
puts vd.to_url
|
111
|
+
end
|
112
|
+
|
99
113
|
# Scatter Chart
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
114
|
+
GoogleChart::ScatterChart.new('320x200',"Scatter Chart") do |sc|
|
115
|
+
sc.data "Scatter Set", [[1,1,], [2,2], [3,3], [4,4]]
|
116
|
+
sc.max_value [5,5] # Setting the max value
|
117
|
+
sc.axis :x, :range => [0,5]
|
118
|
+
sc.axis :y, :range => [0,5], :labels => [0,1,2,3,4,5]
|
119
|
+
sc.point_sizes [10,15,30,55] # Optional
|
120
|
+
puts "\nScatter Chart"
|
121
|
+
puts sc.to_url
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
126
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
127
|
+
lc.show_legend = true
|
128
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
129
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
130
|
+
lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size => 16, :alignment => :center
|
131
|
+
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
132
|
+
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
133
|
+
puts "\nLine Chart"
|
134
|
+
end
|
135
|
+
|
107
136
|
# Solid fill
|
108
|
-
|
109
|
-
|
110
|
-
puts
|
137
|
+
line_chart_xy.fill(:background, :solid, {:color => 'fff2cc'})
|
138
|
+
line_chart_xy.fill(:chart, :solid, {:color => 'ffcccc'})
|
139
|
+
puts "\nLine Chart with Solid Fill"
|
140
|
+
puts line_chart_xy.to_url
|
111
141
|
|
112
142
|
# Gradient fill
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
puts
|
143
|
+
line_chart_xy.fill :background, :gradient, :angle => 0, :color => [['76A4FB',1],['ffffff',0]]
|
144
|
+
line_chart_xy.fill :chart, :gradient, :angle => 0, :color => [['76A4FB',1], ['ffffff',0]]
|
145
|
+
puts "\nLine Chart with Gradient Fill"
|
146
|
+
puts line_chart_xy.to_url
|
117
147
|
|
118
148
|
# Stripes Fill
|
119
|
-
|
120
|
-
|
121
|
-
puts
|
122
|
-
|
149
|
+
line_chart_xy.fill :chart, :stripes, :angle => 90, :color => [['76A4FB',0.2], ['ffffff',0.2]]
|
150
|
+
puts "\nLine Chart with Stripes Fill"
|
151
|
+
puts line_chart_xy.to_url
|
152
|
+
|
153
|
+
puts "\nLine Chart with range markers and shape markers"
|
154
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
155
|
+
lc.title_color = 'ff00ff'
|
156
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
157
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
158
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
159
|
+
lc.max_value 10 # Setting max value for simple line chart
|
160
|
+
lc.range_marker :horizontal, :color => 'E5ECF9', :start_point => 0.1, :end_point => 0.5
|
161
|
+
lc.range_marker :vertical, :color => 'a0bae9', :start_point => 0.1, :end_point => 0.5
|
162
|
+
# Draw an arrow shape marker against lowest value in dataset
|
163
|
+
lc.shape_marker :arrow, :color => '000000', :data_set_index => 0, :data_point_index => 3, :pixel_size => 10
|
164
|
+
puts lc.to_url
|
165
|
+
end
|
123
166
|
== LICENSE:
|
124
167
|
|
125
168
|
(The MIT License)
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ class Hoe
|
|
8
8
|
def extra_deps; @extra_deps.reject { |x| Array(x).first == "hoe" } end
|
9
9
|
end # copied from the Rakefile of the sup project
|
10
10
|
|
11
|
-
Hoe.new('gchartrb', "0.5.
|
11
|
+
Hoe.new('gchartrb', "0.5.3") do |p|
|
12
12
|
p.rubyforge_name = 'gchartrb'
|
13
13
|
p.author = 'Deepak Jois'
|
14
14
|
p.email = 'deepak.jois@gmail.com'
|
data/lib/example.rb
CHANGED
@@ -13,12 +13,13 @@ module GoogleChart
|
|
13
13
|
# * +chart_title+ as a string
|
14
14
|
# * +alignment+ as either <tt>:vertical</tt> or <tt>:horizontal</tt>
|
15
15
|
# * +stacked+ should be +true+ if you want the bars to be stacked, false otherwise
|
16
|
-
def initialize(chart_size='300x200', chart_title=nil, alignment=:vertical, stacked=false)
|
16
|
+
def initialize(chart_size='300x200', chart_title=nil, alignment=:vertical, stacked=false) # :yield: self
|
17
17
|
super(chart_size, chart_title)
|
18
18
|
@alignment = alignment
|
19
19
|
@stacked = stacked
|
20
20
|
set_chart_type
|
21
21
|
self.show_legend = true
|
22
|
+
yield self if block_given?
|
22
23
|
end
|
23
24
|
|
24
25
|
# Set the alignment to either <tt>:vertical</tt> or <tt>:horizontal</tt>
|
data/lib/google_chart/base.rb
CHANGED
@@ -12,6 +12,17 @@ module GoogleChart
|
|
12
12
|
@@complex_encoding[index_outer * 64 + index_inner] = outer + inner
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
SHAPE_MARKERS = {:arrow => "a",
|
17
|
+
:cross => "c",
|
18
|
+
:diamond => "d",
|
19
|
+
:circle => "o",
|
20
|
+
:square => "s",
|
21
|
+
:vline_segment => "v",
|
22
|
+
:vline_full => "V",
|
23
|
+
:hline_full => "h",
|
24
|
+
:x => "x"
|
25
|
+
}
|
15
26
|
|
16
27
|
# Size of the chart in WIDTHxHEIGHT format
|
17
28
|
attr_accessor :chart_size
|
@@ -44,6 +55,7 @@ module GoogleChart
|
|
44
55
|
@colors = []
|
45
56
|
@axis = []
|
46
57
|
@range_markers = []
|
58
|
+
@shape_markers = []
|
47
59
|
self.chart_size = chart_size
|
48
60
|
self.chart_title = chart_title
|
49
61
|
self.data_encoding = :simple
|
@@ -69,6 +81,7 @@ module GoogleChart
|
|
69
81
|
add_grid
|
70
82
|
add_data
|
71
83
|
add_range_markers unless @range_markers.empty?
|
84
|
+
add_shape_markers unless @shape_markers.empty?
|
72
85
|
add_labels(@labels) if [:p, :p3].member?(self.chart_type)
|
73
86
|
add_legend(@labels) if show_legend
|
74
87
|
add_title if chart_title.to_s.length > 0
|
@@ -211,7 +224,27 @@ module GoogleChart
|
|
211
224
|
str = (alignment == :horizontal ) ? "r" : "R"
|
212
225
|
str += ",#{options[:color]},0,#{options[:start_point]},#{options[:end_point]}"
|
213
226
|
@range_markers << str
|
214
|
-
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# Defines a shape marker. Applicable for line charts and scatter plots
|
230
|
+
#
|
231
|
+
# [+type+] can be <tt>:arrow</tt>, <tt>:cross</tt>, <tt>:diamond</tt>, <tt>:circle</tt>, <tt>:square</tt>, <tt>:vline_segment</tt>, <tt>:vline_full</tt>, <tt>:hline_full</tt>, <tt>:x</tt>
|
232
|
+
# [+options+] specifies the color, data set index, data point index and size in pixels
|
233
|
+
#
|
234
|
+
# ==== Options
|
235
|
+
# [<tt>:color</tt>] RRGGBB hex value for the color of the range marker
|
236
|
+
# [<tt>:data_set_index</tt>] the index of the line on which to draw the marker. This is 0 for the first data set, 1 for the second and so on.
|
237
|
+
# [<tt>:data_point_index</tt>] is a floating point value that specifies on which data point of the data set the marker will be drawn. This is 0 for the first data point, 1 for the second and so on. Specify a fraction to interpolate a marker between two points.
|
238
|
+
# [<tt>:size</tt>] is the size of the marker in pixels.
|
239
|
+
#
|
240
|
+
# ==== Examples
|
241
|
+
# lcxy.shape_marker :circle, :color => "000000", :data_set_index => 1, :data_point_index => 2, :pixel_size => 10
|
242
|
+
# lcxy.shape_marker :cross, :color => "E5ECF9", :data_set_index => 0, :data_point_index => 0.5, :pixel_size => 10
|
243
|
+
def shape_marker(type, options={})
|
244
|
+
raise "Invalid shape marker type specified" unless SHAPE_MARKERS.has_key?(type)
|
245
|
+
shape_marker_str = "#{SHAPE_MARKERS[type]},#{options[:color]},#{options[:data_set_index]},#{options[:data_point_index]},#{options[:pixel_size]}"
|
246
|
+
@shape_markers << shape_marker_str
|
247
|
+
end
|
215
248
|
|
216
249
|
protected
|
217
250
|
|
@@ -327,6 +360,10 @@ module GoogleChart
|
|
327
360
|
def add_range_markers
|
328
361
|
params.merge!({:chm => @range_markers.join("|")})
|
329
362
|
end
|
363
|
+
|
364
|
+
def add_shape_markers
|
365
|
+
params.merge!({:chm => @shape_markers.join("|")})
|
366
|
+
end
|
330
367
|
|
331
368
|
def add_data
|
332
369
|
converted_data = process_data
|
@@ -25,9 +25,10 @@ module GoogleChart
|
|
25
25
|
# * +chart_size+ in WIDTHxHEIGHT format
|
26
26
|
# * +chart_title+ as a string
|
27
27
|
# * +is_xy+ is <tt>false</tt> by default. Set it to <tt>true</tt> if you want to plot a Line XY chart
|
28
|
-
def initialize(chart_size='300x200', chart_title=nil, is_xy=false)
|
28
|
+
def initialize(chart_size='300x200', chart_title=nil, is_xy=false) # :yield: self
|
29
29
|
super(chart_size, chart_title)
|
30
30
|
self.is_xy = is_xy
|
31
|
+
yield self if block_given?
|
31
32
|
end
|
32
33
|
|
33
34
|
# Pass in <tt>true</tt> here to create a Line XY.
|
@@ -9,11 +9,12 @@ module GoogleChart
|
|
9
9
|
attr_accessor :show_labels
|
10
10
|
|
11
11
|
# Initializes a Pie Chart object with a +chart_size+ and +chart_title+. Specify <tt>is_3d</tt> as +true+ to generate a 3D Pie chart
|
12
|
-
def initialize(chart_size='300x200', chart_title=nil, is_3d = false)
|
12
|
+
def initialize(chart_size='300x200', chart_title=nil, is_3d = false) # :yield: self
|
13
13
|
super(chart_size, chart_title)
|
14
14
|
self.is_3d = is_3d
|
15
15
|
self.show_legend = false
|
16
16
|
self.show_labels = true
|
17
|
+
yield self if block_given?
|
17
18
|
end
|
18
19
|
|
19
20
|
# Set this value to <tt>true</tt> if you want the Pie Chart to be rendered as a 3D image
|
@@ -11,11 +11,12 @@ module GoogleChart
|
|
11
11
|
class ScatterChart < Base
|
12
12
|
|
13
13
|
# Initializes the Scatter Chart with a +chart_size+ (in WIDTHxHEIGHT format) and a +chart_title+
|
14
|
-
def initialize(chart_size='300x200', chart_title=nil)
|
14
|
+
def initialize(chart_size='300x200', chart_title=nil) # :yield: self
|
15
15
|
super(chart_size, chart_title)
|
16
16
|
self.chart_type = :s
|
17
17
|
self.show_legend = false
|
18
18
|
@point_sizes = []
|
19
|
+
yield self if block_given?
|
19
20
|
end
|
20
21
|
|
21
22
|
def process_data
|
@@ -17,10 +17,11 @@ module GoogleChart
|
|
17
17
|
class VennDiagram < Base
|
18
18
|
|
19
19
|
# Initializes the Venn Diagram with a +chart_size+ (in WIDTHxHEIGHT format) and a +chart_title+
|
20
|
-
def initialize(chart_size='300x200', chart_title=nil)
|
20
|
+
def initialize(chart_size='300x200', chart_title=nil) # :yield: self
|
21
21
|
super(chart_size, chart_title)
|
22
22
|
self.chart_type = :v
|
23
|
-
@intersections = []
|
23
|
+
@intersections = []
|
24
|
+
yield self if block_given?
|
24
25
|
end
|
25
26
|
|
26
27
|
def process_data
|
data/lib/test.rb
CHANGED
@@ -1,45 +1,50 @@
|
|
1
1
|
require 'google_chart'
|
2
2
|
|
3
3
|
# Pie Chart
|
4
|
-
|
5
|
-
pc.data "Apples", 40
|
6
|
-
pc.data "Banana", 20
|
7
|
-
pc.data "Peach", 30
|
8
|
-
pc.data "Orange", 60
|
9
|
-
puts "\nPie Chart"
|
10
|
-
puts pc.to_url
|
4
|
+
GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
|
5
|
+
pc.data "Apples", 40
|
6
|
+
pc.data "Banana", 20
|
7
|
+
pc.data "Peach", 30
|
8
|
+
pc.data "Orange", 60
|
9
|
+
puts "\nPie Chart"
|
10
|
+
puts pc.to_url
|
11
|
+
|
12
|
+
# Pie Chart with no labels
|
13
|
+
pc.show_labels = false
|
14
|
+
puts "\nPie Chart (with no labels)"
|
15
|
+
puts pc.to_url
|
16
|
+
end
|
11
17
|
|
12
|
-
# Pie Chart with no labels
|
13
|
-
pc.show_labels = false
|
14
|
-
puts "\nPie Chart (with no labels)"
|
15
|
-
puts pc.to_url
|
16
18
|
|
17
19
|
# Line Chart
|
18
|
-
|
19
|
-
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
20
|
-
lc.show_legend = true
|
21
|
-
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
22
|
-
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
23
|
-
lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size => 16, :alignment => :center
|
24
|
-
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
25
|
-
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
26
|
-
puts "\nLine Chart"
|
27
|
-
puts lc.to_url
|
20
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
21
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
22
|
+
lc.show_legend = true
|
23
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
24
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
25
|
+
lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size => 16, :alignment => :center
|
26
|
+
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
27
|
+
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
28
|
+
puts "\nLine Chart"
|
29
|
+
puts lc.to_url
|
30
|
+
end
|
28
31
|
|
29
32
|
# Bar Chart
|
30
|
-
|
31
|
-
bc.data "Trend 1", [5,4,3,1,3,5], '0000ff'
|
32
|
-
bc.data "Trend 2", [1,2,3,4,5,6], 'ff0000'
|
33
|
-
bc.data "Trend 3", [6,5,4,4,5,6], '00ff00'
|
34
|
-
puts "\nBar Chart"
|
35
|
-
puts bc.to_url
|
33
|
+
GoogleChart::BarChart.new('800x200', "Bar Chart", :vertical, false) do |bc|
|
34
|
+
bc.data "Trend 1", [5,4,3,1,3,5], '0000ff'
|
35
|
+
bc.data "Trend 2", [1,2,3,4,5,6], 'ff0000'
|
36
|
+
bc.data "Trend 3", [6,5,4,4,5,6], '00ff00'
|
37
|
+
puts "\nBar Chart"
|
38
|
+
puts bc.to_url
|
39
|
+
end
|
36
40
|
|
37
41
|
# Line XY Chart
|
38
|
-
|
39
|
-
lcxy.data "Trend 1", [[1,1], [2,2], [3,3], [4,4]], '0000ff'
|
40
|
-
lcxy.data "Trend 2", [[4,5], [2,2], [1,1], [3,4]], '00ff00'
|
41
|
-
puts "\nLine XY Chart"
|
42
|
-
puts lcxy.to_url
|
42
|
+
line_chart_xy = GoogleChart::LineChart.new('320x200', "Line XY Chart", true) do |lcxy|
|
43
|
+
lcxy.data "Trend 1", [[1,1], [2,2], [3,3], [4,4]], '0000ff'
|
44
|
+
lcxy.data "Trend 2", [[4,5], [2,2], [1,1], [3,4]], '00ff00'
|
45
|
+
puts "\nLine XY Chart (inside a block)"
|
46
|
+
puts lcxy.to_url
|
47
|
+
end
|
43
48
|
|
44
49
|
# Venn Diagram
|
45
50
|
# Supply three vd.data statements of label, size, color for circles A, B, C
|
@@ -48,54 +53,68 @@ puts lcxy.to_url
|
|
48
53
|
# the second value specifies the area of B intersecting C
|
49
54
|
# the third value specifies the area of C intersecting A
|
50
55
|
# the fourth value specifies the area of A intersecting B intersecting C
|
51
|
-
|
52
|
-
vd.data "Blue", 100, '0000ff'
|
53
|
-
vd.data "Green", 80, '00ff00'
|
54
|
-
vd.data "Red", 60, 'ff0000'
|
55
|
-
vd.intersections 30,30,30,10
|
56
|
-
puts "\nVenn Diagram"
|
57
|
-
puts vd.to_url
|
56
|
+
GoogleChart::VennDiagram.new("320x200", 'Venn Diagram') do |vd|
|
57
|
+
vd.data "Blue", 100, '0000ff'
|
58
|
+
vd.data "Green", 80, '00ff00'
|
59
|
+
vd.data "Red", 60, 'ff0000'
|
60
|
+
vd.intersections 30,30,30,10
|
61
|
+
puts "\nVenn Diagram"
|
62
|
+
puts vd.to_url
|
63
|
+
end
|
58
64
|
|
59
65
|
# Scatter Chart
|
60
|
-
|
61
|
-
sc.data "Scatter Set", [[1,1,], [2,2], [3,3], [4,4]]
|
62
|
-
sc.max_value [5,5] # Setting the max value
|
63
|
-
sc.axis :x, :range => [0,5]
|
64
|
-
sc.axis :y, :range => [0,5], :labels => [0,1,2,3,4,5]
|
65
|
-
sc.point_sizes [10,15,30,55] # Optional
|
66
|
-
puts "\nScatter Chart"
|
67
|
-
puts sc.to_url
|
66
|
+
GoogleChart::ScatterChart.new('320x200',"Scatter Chart") do |sc|
|
67
|
+
sc.data "Scatter Set", [[1,1,], [2,2], [3,3], [4,4]]
|
68
|
+
sc.max_value [5,5] # Setting the max value
|
69
|
+
sc.axis :x, :range => [0,5]
|
70
|
+
sc.axis :y, :range => [0,5], :labels => [0,1,2,3,4,5]
|
71
|
+
sc.point_sizes [10,15,30,55] # Optional
|
72
|
+
puts "\nScatter Chart"
|
73
|
+
puts sc.to_url
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
78
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
79
|
+
lc.show_legend = true
|
80
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
81
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
82
|
+
lc.axis :y, :range => [0,6], :color => 'ff00ff', :font_size => 16, :alignment => :center
|
83
|
+
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
84
|
+
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
85
|
+
puts "\nLine Chart"
|
86
|
+
end
|
68
87
|
|
69
88
|
# Solid fill
|
70
|
-
|
71
|
-
|
89
|
+
line_chart_xy.fill(:background, :solid, {:color => 'fff2cc'})
|
90
|
+
line_chart_xy.fill(:chart, :solid, {:color => 'ffcccc'})
|
72
91
|
puts "\nLine Chart with Solid Fill"
|
73
|
-
puts
|
92
|
+
puts line_chart_xy.to_url
|
74
93
|
|
75
94
|
# Gradient fill
|
76
|
-
|
77
|
-
|
78
|
-
['ffffff',0]]
|
95
|
+
line_chart_xy.fill :background, :gradient, :angle => 0, :color => [['76A4FB',1],['ffffff',0]]
|
96
|
+
line_chart_xy.fill :chart, :gradient, :angle => 0, :color => [['76A4FB',1], ['ffffff',0]]
|
79
97
|
puts "\nLine Chart with Gradient Fill"
|
80
|
-
puts
|
98
|
+
puts line_chart_xy.to_url
|
81
99
|
|
82
100
|
# Stripes Fill
|
83
|
-
|
84
|
-
['ffffff',0.2]]
|
101
|
+
line_chart_xy.fill :chart, :stripes, :angle => 90, :color => [['76A4FB',0.2], ['ffffff',0.2]]
|
85
102
|
puts "\nLine Chart with Stripes Fill"
|
86
|
-
puts
|
103
|
+
puts line_chart_xy.to_url
|
87
104
|
|
88
|
-
|
89
|
-
|
90
|
-
lc.title_color = 'ff00ff'
|
91
|
-
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
92
|
-
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
93
|
-
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
94
|
-
lc.max_value 10 # Setting max value for simple line chart
|
95
|
-
lc.range_marker :horizontal, :color => 'E5ECF9', :start_point => 0.1, :end_point => 0.5
|
96
|
-
lc.range_marker :vertical, :color => 'a0bae9', :start_point => 0.1, :end_point => 0.5
|
97
|
-
|
98
|
-
|
105
|
+
puts "\nLine Chart with range markers and shape markers"
|
106
|
+
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
107
|
+
lc.title_color = 'ff00ff'
|
108
|
+
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
109
|
+
lc.data "Trend 2", [1,2,3,4,5,6], '00ff00'
|
110
|
+
lc.data "Trend 3", [6,5,4,3,2,1], 'ff0000'
|
111
|
+
lc.max_value 10 # Setting max value for simple line chart
|
112
|
+
lc.range_marker :horizontal, :color => 'E5ECF9', :start_point => 0.1, :end_point => 0.5
|
113
|
+
lc.range_marker :vertical, :color => 'a0bae9', :start_point => 0.1, :end_point => 0.5
|
114
|
+
# Draw an arrow shape marker against lowest value in dataset
|
115
|
+
lc.shape_marker :arrow, :color => '000000', :data_set_index => 0, :data_point_index => 3, :pixel_size => 10
|
116
|
+
puts lc.to_url
|
117
|
+
end
|
99
118
|
|
100
119
|
# Bryan Error condition
|
101
120
|
lcxy = GoogleChart::LineChart.new('320x200', "Line XY Chart", true)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: gchartrb
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2007-12-
|
6
|
+
version: 0.5.3
|
7
|
+
date: 2007-12-19 00:00:00 +08:00
|
8
8
|
summary: Ruby Wrapper for the Google Chart API
|
9
9
|
require_paths:
|
10
10
|
- lib
|