gchartrb 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Rakefile +1 -1
- data/TODO +0 -1
- data/lib/google_chart/bar_chart.rb +15 -0
- data/lib/google_chart/base.rb +8 -13
- data/lib/test.rb +16 -1
- metadata +42 -35
data/History.txt
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
+
== 0.5.4 / 2008-01-07
|
2
|
+
|
3
|
+
* Fixed a bug related to data encoding in Stacked Charts
|
4
|
+
* Fixed a bug in which title font and title font size values were being ignored
|
5
|
+
* Fixed a bug where shape markers and range markers were overriding each other
|
6
|
+
|
1
7
|
== 0.5.3 / 2007-12-19
|
8
|
+
|
2
9
|
* Added support for shape markers
|
3
10
|
* Added support for block based idiomatic ruby syntax
|
4
11
|
|
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.4") do |p|
|
12
12
|
p.rubyforge_name = 'gchartrb'
|
13
13
|
p.author = 'Deepak Jois'
|
14
14
|
p.email = 'deepak.jois@gmail.com'
|
data/TODO
CHANGED
@@ -35,6 +35,21 @@ module GoogleChart
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def process_data
|
38
|
+
if @stacked # Special handling of max value for stacked
|
39
|
+
unless @max_data # Unless max_data is explicitly set
|
40
|
+
@max_data = @data.inject([]) do |sum_arr, series|
|
41
|
+
series.each_with_index do |v,i|
|
42
|
+
if sum_arr[i] == nil
|
43
|
+
sum_arr[i] = v
|
44
|
+
else
|
45
|
+
sum_arr[i] += v
|
46
|
+
end
|
47
|
+
end
|
48
|
+
sum_arr
|
49
|
+
end.max
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
if @data.size > 1
|
39
54
|
join_encoded_data(@data.collect { |series|
|
40
55
|
encode_data(series, max_data_value)
|
data/lib/google_chart/base.rb
CHANGED
@@ -54,8 +54,7 @@ module GoogleChart
|
|
54
54
|
@data = []
|
55
55
|
@colors = []
|
56
56
|
@axis = []
|
57
|
-
@
|
58
|
-
@shape_markers = []
|
57
|
+
@markers = []
|
59
58
|
self.chart_size = chart_size
|
60
59
|
self.chart_title = chart_title
|
61
60
|
self.data_encoding = :simple
|
@@ -80,8 +79,7 @@ module GoogleChart
|
|
80
79
|
add_axis unless @axis.empty?
|
81
80
|
add_grid
|
82
81
|
add_data
|
83
|
-
|
84
|
-
add_shape_markers unless @shape_markers.empty?
|
82
|
+
add_markers unless @markers.empty?
|
85
83
|
add_labels(@labels) if [:p, :p3].member?(self.chart_type)
|
86
84
|
add_legend(@labels) if show_legend
|
87
85
|
add_title if chart_title.to_s.length > 0
|
@@ -170,7 +168,7 @@ module GoogleChart
|
|
170
168
|
# ==== Options
|
171
169
|
# Not all the options are mandatory.
|
172
170
|
# [<tt>:labels</tt>] An array containing the labels for the axis
|
173
|
-
# [<tt>:
|
171
|
+
# [<tt>:positions</tt>] An Array containing the positions for the labels
|
174
172
|
# [<tt>:range</tt>] An array containing 2 elements, the start value and end value
|
175
173
|
#
|
176
174
|
# axis styling options have to be specified as follows
|
@@ -223,7 +221,7 @@ module GoogleChart
|
|
223
221
|
raise "Invalid alignment specified" unless [:horizontal, :vertical].member?(alignment)
|
224
222
|
str = (alignment == :horizontal ) ? "r" : "R"
|
225
223
|
str += ",#{options[:color]},0,#{options[:start_point]},#{options[:end_point]}"
|
226
|
-
@
|
224
|
+
@markers << str
|
227
225
|
end
|
228
226
|
|
229
227
|
# Defines a shape marker. Applicable for line charts and scatter plots
|
@@ -243,7 +241,7 @@ module GoogleChart
|
|
243
241
|
def shape_marker(type, options={})
|
244
242
|
raise "Invalid shape marker type specified" unless SHAPE_MARKERS.has_key?(type)
|
245
243
|
shape_marker_str = "#{SHAPE_MARKERS[type]},#{options[:color]},#{options[:data_set_index]},#{options[:data_point_index]},#{options[:pixel_size]}"
|
246
|
-
@
|
244
|
+
@markers << shape_marker_str
|
247
245
|
end
|
248
246
|
|
249
247
|
protected
|
@@ -288,6 +286,7 @@ module GoogleChart
|
|
288
286
|
def add_title
|
289
287
|
params.merge!({:chtt => chart_title})
|
290
288
|
params.merge!({:chts => title_color}) if title_color
|
289
|
+
params.merge!({:chts => "#{title_color},#{title_font_size}"}) if title_color and title_font_size
|
291
290
|
end
|
292
291
|
|
293
292
|
def add_axis
|
@@ -357,14 +356,10 @@ module GoogleChart
|
|
357
356
|
params.merge!({ :chg => @grid_str }) if @grid_str
|
358
357
|
end
|
359
358
|
|
360
|
-
def
|
361
|
-
params.merge!({:chm => @
|
359
|
+
def add_markers
|
360
|
+
params.merge!({:chm => @markers.join("|")})
|
362
361
|
end
|
363
362
|
|
364
|
-
def add_shape_markers
|
365
|
-
params.merge!({:chm => @shape_markers.join("|")})
|
366
|
-
end
|
367
|
-
|
368
363
|
def add_data
|
369
364
|
converted_data = process_data
|
370
365
|
case data_encoding
|
data/lib/test.rb
CHANGED
@@ -73,7 +73,7 @@ GoogleChart::ScatterChart.new('320x200',"Scatter Chart") do |sc|
|
|
73
73
|
puts sc.to_url
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
# Grid Fills
|
77
77
|
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
78
78
|
lc.data "Trend 1", [5,4,3,1,3,5,6], '0000ff'
|
79
79
|
lc.show_legend = true
|
@@ -83,6 +83,7 @@ GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
|
83
83
|
lc.axis :x, :range => [0,6], :color => '00ffff', :font_size => 16, :alignment => :center
|
84
84
|
lc.grid :x_step => 100.0/6.0, :y_step => 100.0/6.0, :length_segment => 1, :length_blank => 0
|
85
85
|
puts "\nLine Chart"
|
86
|
+
puts lc.to_url
|
86
87
|
end
|
87
88
|
|
88
89
|
# Solid fill
|
@@ -102,6 +103,7 @@ line_chart_xy.fill :chart, :stripes, :angle => 90, :color => [['76A4FB',0.2], ['
|
|
102
103
|
puts "\nLine Chart with Stripes Fill"
|
103
104
|
puts line_chart_xy.to_url
|
104
105
|
|
106
|
+
# Range and Shape Markers
|
105
107
|
puts "\nLine Chart with range markers and shape markers"
|
106
108
|
GoogleChart::LineChart.new('320x200', "Line Chart", false) do |lc|
|
107
109
|
lc.title_color = 'ff00ff'
|
@@ -125,3 +127,16 @@ lcxy.data 'D', [[0, 4], [1, 39], [2, 0], [3, 5], [4, 11], [5, 14]], 'cc00ff'
|
|
125
127
|
puts "\nBryan Error Condition"
|
126
128
|
puts lcxy.to_url
|
127
129
|
|
130
|
+
# Stacked Chart error
|
131
|
+
stacked = GoogleChart::BarChart.new('320x200', "Stacked Chart", :vertical, true)
|
132
|
+
stacked.data_encoding = :text
|
133
|
+
stacked.data "Trend 1", [60,80,20], '0000ff'
|
134
|
+
stacked.data "Trend 2", [50,5,100], 'ff0000'
|
135
|
+
stacked.axis :y, :range => [0,120]
|
136
|
+
stacked.title_color='ff0000'
|
137
|
+
stacked.title_font_size=18
|
138
|
+
puts "\nStacked Chart with colored title"
|
139
|
+
puts stacked.to_url
|
140
|
+
|
141
|
+
|
142
|
+
|
metadata
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: gchartrb
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2007-12-19 00:00:00 +08:00
|
8
|
-
summary: Ruby Wrapper for the Google Chart API
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: deepak.jois@gmail.com
|
12
|
-
homepage: " by Deepak Jois"
|
13
|
-
rubyforge_project: gchartrb
|
14
|
-
description: "Visit http://code.google.com/p/gchartrb to track development regarding gchartrb. == FEATURES: * Provides an object oriented interface in Ruby to create Google Chart URLs for charts. == INSTALL: === Ruby Gem:"
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.5.4
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Deepak Jois
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-07 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "Visit http://code.google.com/p/gchartrb to track development regarding gchartrb. == FEATURES: * Provides an object oriented interface in Ruby to create Google Chart URLs for charts. == INSTALL: === Ruby Gem:"
|
17
|
+
email: deepak.jois@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- History.txt
|
24
|
+
- Manifest.txt
|
25
|
+
- README.txt
|
31
26
|
files:
|
32
27
|
- CREDITS
|
33
28
|
- History.txt
|
@@ -44,20 +39,32 @@ files:
|
|
44
39
|
- lib/google_chart/scatter_chart.rb
|
45
40
|
- lib/google_chart/venn_diagram.rb
|
46
41
|
- lib/test.rb
|
47
|
-
|
48
|
-
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: " by Deepak Jois"
|
44
|
+
post_install_message:
|
49
45
|
rdoc_options:
|
50
46
|
- --main
|
51
47
|
- README.txt
|
52
|
-
|
53
|
-
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
60
62
|
requirements: []
|
61
63
|
|
62
|
-
|
64
|
+
rubyforge_project: gchartrb
|
65
|
+
rubygems_version: 1.0.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: Ruby Wrapper for the Google Chart API
|
69
|
+
test_files: []
|
63
70
|
|