google_visualr 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/lib/google_visualr.rb +3 -0
- data/lib/google_visualr/app/helpers/view_helper.rb +2 -4
- data/lib/google_visualr/image/bar_chart.rb +47 -0
- data/lib/google_visualr/image/line_chart.rb +47 -0
- data/lib/google_visualr/image/pie_chart.rb +47 -0
- data/lib/google_visualr/image/spark_line.rb +23 -2
- data/lib/google_visualr/packages.rb +82 -0
- data/lib/google_visualr/version.rb +1 -1
- data/spec/google_visualr/image_charts_spec.rb +65 -0
- data/spec/support/common.rb +113 -0
- metadata +6 -2
data/README.rdoc
CHANGED
@@ -94,6 +94,13 @@ Please submit all feedback, bugs and feature-requests to {GitHub Issues Tracker}
|
|
94
94
|
|
95
95
|
= Change Log
|
96
96
|
|
97
|
+
<em>Version 2.1.2</em>
|
98
|
+
* {Pull Request 28}[https://github.com/winston/google_visualr/pull/28] Removed InstanceMethods as it's deprecated in Rails 3.2.x.
|
99
|
+
* {Pull Request 26}[https://github.com/winston/google_visualr/pull/26] Added 3 more image charts and #uri method to all image charts.
|
100
|
+
|
101
|
+
<em>Version 2.1.1</em>
|
102
|
+
* Added support for +role+ and +pattern+ attributes in +#new_column+ and +#new_columns+ methods.
|
103
|
+
|
97
104
|
<em>Version 2.1.0</em>
|
98
105
|
* Added +#render_chart+ as a helper method in Rails views.
|
99
106
|
|
data/lib/google_visualr.rb
CHANGED
@@ -37,6 +37,9 @@ require "#{lib_path}/google_visualr/interactive/org_chart"
|
|
37
37
|
|
38
38
|
# Image Charts
|
39
39
|
require "#{lib_path}/google_visualr/image/spark_line"
|
40
|
+
require "#{lib_path}/google_visualr/image/bar_chart"
|
41
|
+
require "#{lib_path}/google_visualr/image/line_chart"
|
42
|
+
require "#{lib_path}/google_visualr/image/pie_chart"
|
40
43
|
|
41
44
|
|
42
45
|
# Rails Helper
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GoogleVisualr
|
2
|
+
module Image
|
3
|
+
|
4
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html
|
5
|
+
class BarChart < BaseChart
|
6
|
+
include GoogleVisualr::Packages::ImageChart
|
7
|
+
|
8
|
+
# For Configuration Options, please refer to:
|
9
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html
|
10
|
+
|
11
|
+
# Create URI for image bar chart. Override parameters by passing in a hash.
|
12
|
+
# (see http://code.google.com/apis/chart/image/docs/chart_params.html)
|
13
|
+
#
|
14
|
+
# Parameters:
|
15
|
+
# *params [Optional] Hash of url query parameters
|
16
|
+
def uri(params = {})
|
17
|
+
query_params = {}
|
18
|
+
|
19
|
+
# isStacked/isVertical, Chart Type
|
20
|
+
chart_type = "b"
|
21
|
+
chart_type += @options["isVertical"] ? "v" : "h"
|
22
|
+
chart_type += @options["isStacked"] == false ? "g" : "s"
|
23
|
+
query_params[:cht] = chart_type
|
24
|
+
|
25
|
+
# showCategoryLabels (works as long as :chxt => "x,y")
|
26
|
+
labels = ""
|
27
|
+
val_column = @options["isVertical"] ? 1 : 0
|
28
|
+
cat_column = @options["isVertical"] ? 0 : 1
|
29
|
+
if @options["showCategoryLabels"] == false
|
30
|
+
labels = "#{cat_column}:||"
|
31
|
+
else
|
32
|
+
labels = "#{cat_column}:|" + data_table.get_column(0).join('|') + "|"
|
33
|
+
end
|
34
|
+
|
35
|
+
# showValueLabels (works as long as :chxt => "x,y")
|
36
|
+
if @options["showValueLabels"] == false
|
37
|
+
labels += "#{val_column}:||"
|
38
|
+
end
|
39
|
+
|
40
|
+
query_params[:chxl] = labels unless labels.blank?
|
41
|
+
|
42
|
+
chart_image_url(query_params.merge(params))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GoogleVisualr
|
2
|
+
module Image
|
3
|
+
|
4
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagelinechart.html
|
5
|
+
class LineChart < BaseChart
|
6
|
+
include GoogleVisualr::Packages::ImageChart
|
7
|
+
|
8
|
+
# For Configuration Options, please refer to:
|
9
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagelinechart.html
|
10
|
+
|
11
|
+
# Create URI for image line chart. Override parameters by passing in a hash.
|
12
|
+
# (see http://code.google.com/apis/chart/image/docs/chart_params.html)
|
13
|
+
#
|
14
|
+
# Parameters:
|
15
|
+
# *params [Optional] Hash of url query parameters
|
16
|
+
def uri(params = {})
|
17
|
+
query_params = {}
|
18
|
+
|
19
|
+
# Chart type: line
|
20
|
+
query_params[:cht] = "lc"
|
21
|
+
|
22
|
+
# showAxisLines
|
23
|
+
if @options["showAxisLines"] == false
|
24
|
+
query_params[:cht] = "lc:nda"
|
25
|
+
end
|
26
|
+
|
27
|
+
# showCategoryLabels (works as long as :chxt => "x,y")
|
28
|
+
labels = ""
|
29
|
+
if @options["showCategoryLabels"] == false
|
30
|
+
labels = "0:||"
|
31
|
+
else
|
32
|
+
labels = "0:|" + data_table.get_column(0).join('|') + "|"
|
33
|
+
end
|
34
|
+
|
35
|
+
# showValueLabels (works as long as :chxt => "x,y")
|
36
|
+
if @options["showValueLabels"] == false
|
37
|
+
labels += "1:||"
|
38
|
+
end
|
39
|
+
|
40
|
+
query_params[:chxl] = labels unless labels.blank?
|
41
|
+
|
42
|
+
chart_image_url(query_params.merge(params))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GoogleVisualr
|
2
|
+
module Image
|
3
|
+
|
4
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagepiechart.html
|
5
|
+
class PieChart < BaseChart
|
6
|
+
include GoogleVisualr::Packages::ImageChart
|
7
|
+
|
8
|
+
# For Configuration Options, please refer to:
|
9
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagepiechart.html
|
10
|
+
|
11
|
+
# Create URI for image pie chart. Override parameters by passing in a hash.
|
12
|
+
# (see http://code.google.com/apis/chart/image/docs/chart_params.html)
|
13
|
+
#
|
14
|
+
# Parameters:
|
15
|
+
# *params [Optional] Hash of url query parameters
|
16
|
+
def uri(params = {})
|
17
|
+
query_params = {}
|
18
|
+
|
19
|
+
# Chart Type: normal or 3D
|
20
|
+
query_params[:cht] = @options["is3D"] ? "p3" : "p"
|
21
|
+
|
22
|
+
# Legend (override generic image chart behavior)
|
23
|
+
query_params[:chdl] = @data_table.get_column(0).join('|')
|
24
|
+
|
25
|
+
# Labels
|
26
|
+
case options["labels"]
|
27
|
+
when "name"
|
28
|
+
query_params[:chl] = @data_table.get_column(0).join('|')
|
29
|
+
when "value"
|
30
|
+
query_params[:chl] = @data_table.get_column(1).join('|')
|
31
|
+
else
|
32
|
+
query_params[:chl] = ""
|
33
|
+
end
|
34
|
+
|
35
|
+
# data (override generic chart behavior)
|
36
|
+
query_params[:chd] = "t:" + @data_table.get_column(1).join(',')
|
37
|
+
|
38
|
+
# Chart Colors (override generic chart default)
|
39
|
+
query_params[:chco] = @options["colors"].join('|').gsub(/#/, '') if @options["colors"]
|
40
|
+
|
41
|
+
chart_image_url(query_params.merge(params))
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -6,8 +6,29 @@ module GoogleVisualr
|
|
6
6
|
include GoogleVisualr::Packages::ImageChart
|
7
7
|
|
8
8
|
# For Configuration Options, please refer to:
|
9
|
-
# http://code.google.com/apis/chart/interactive/docs/gallery/imagesparkline.html
|
10
|
-
|
9
|
+
# http://code.google.com/apis/chart/interactive/docs/gallery/imagesparkline.html
|
10
|
+
|
11
|
+
# Create URI for sparkline. Override parameters by passing in a hash.
|
12
|
+
# (see http://code.google.com/apis/chart/image/docs/chart_params.html)
|
13
|
+
#
|
14
|
+
# Parameters:
|
15
|
+
# *params [Optional] Hash of url query parameters
|
16
|
+
def uri(params = {})
|
17
|
+
query_params = {}
|
18
|
+
|
19
|
+
# Chart type: line
|
20
|
+
query_params[:cht] = "ls"
|
21
|
+
|
22
|
+
# showValueLabels (works as long as :chxt => "x,y")
|
23
|
+
labels = "0:||"
|
24
|
+
if @options["showValueLabels"] == false || !@options["showAxisLines"]
|
25
|
+
labels += "1:||"
|
26
|
+
end
|
27
|
+
|
28
|
+
query_params[:chxl] = labels
|
11
29
|
|
30
|
+
chart_image_url(query_params.merge(params))
|
31
|
+
end
|
32
|
+
end
|
12
33
|
end
|
13
34
|
end
|
@@ -17,12 +17,94 @@ module GoogleVisualr
|
|
17
17
|
end
|
18
18
|
|
19
19
|
module ImageChart
|
20
|
+
include GoogleVisualr::ParamHelpers
|
21
|
+
|
20
22
|
def package_name
|
21
23
|
"image#{self.class.to_s.split("::").last.downcase}"
|
22
24
|
end
|
23
25
|
def class_name
|
24
26
|
"Image#{self.class.to_s.split('::').last}"
|
25
27
|
end
|
28
|
+
|
29
|
+
# Set defaults according to http://code.google.com/apis/chart/interactive/docs/gallery/genericimagechart.html#Configuration_Options
|
30
|
+
IMAGE_DEFAULTS = {
|
31
|
+
# Automatic Scaling
|
32
|
+
:chds => "a",
|
33
|
+
# Size
|
34
|
+
:chs => "400x200",
|
35
|
+
# Axes
|
36
|
+
:chxt => "x,y"
|
37
|
+
}
|
38
|
+
|
39
|
+
# Generates HTTP GET URL for the chart image
|
40
|
+
#
|
41
|
+
# Parameters:
|
42
|
+
# *opts [Optional] Hash of standard chart options (see http://code.google.com/apis/chart/image/docs/chart_params.html)
|
43
|
+
def chart_image_url(superseding_params = {})
|
44
|
+
|
45
|
+
#####
|
46
|
+
# Generic image chart defaults
|
47
|
+
query_params = IMAGE_DEFAULTS.clone
|
48
|
+
|
49
|
+
# backgroundColor
|
50
|
+
query_params[:chf] = "bg,s," + options["backgroundColor"].gsub(/#/, '') if options["backgroundColor"]
|
51
|
+
|
52
|
+
# color, colors ('color' param is ignored if 'colors' is present)
|
53
|
+
if options["colors"]
|
54
|
+
query_params[:chco] = options["colors"].join(',').gsub(/#/, '')
|
55
|
+
elsif options["color"]
|
56
|
+
query_params[:chco] = options["color"].gsub(/#/, '')
|
57
|
+
end
|
58
|
+
|
59
|
+
# fill (this will often not look good - better for user to override this parameter)
|
60
|
+
query_params[:chm] = "B,#{query_params[:chco].split(',').first},0,0,0" if options["fill"] && query_params[:chco]
|
61
|
+
|
62
|
+
# firstHiddenColumn, singleColumnDisplay, data
|
63
|
+
firstHiddenColumn = options["firstHiddenColumn"] ? options["firstHiddenColumn"] : data_table.cols.size - 1
|
64
|
+
query_params[:chd] = "t:"
|
65
|
+
unless options["singleColumnDisplay"]
|
66
|
+
for i in 1..firstHiddenColumn do
|
67
|
+
query_params[:chd] += "|" if i > 1
|
68
|
+
query_params[:chd] += data_table.get_column(i).join(',')
|
69
|
+
end
|
70
|
+
else
|
71
|
+
query_params[:chd] += data_dable.get_column(options["singleColumnDisplay"])
|
72
|
+
end
|
73
|
+
|
74
|
+
# height, width
|
75
|
+
if options["height"] && options["width"]
|
76
|
+
query_params[:chs] = "#{options["width"]}x#{options["height"]}"
|
77
|
+
end
|
78
|
+
|
79
|
+
# title
|
80
|
+
query_params[:chtt] = options["title"] if options["title"]
|
81
|
+
|
82
|
+
# legend
|
83
|
+
unless options["legend"] == 'none'
|
84
|
+
query_params[:chdlp] = options["legend"].first unless options["legend"].blank?
|
85
|
+
query_params[:chdl] = data_table.cols[1..-1].map{|col| col[:label] }.join('|')
|
86
|
+
else
|
87
|
+
query_params.delete(:chdlp)
|
88
|
+
query_params.delete(:chdl)
|
89
|
+
end
|
90
|
+
|
91
|
+
# min, max, valueLabelsInterval (works as long as :chxt => "x,y" and both 'min' and 'max' are set)
|
92
|
+
if options["min"] && options["max"]
|
93
|
+
query_params[:chxr] = "1,#{options['min']},#{options['max']}"
|
94
|
+
query_params[:chxr] += ",#{options['valueLabelsInterval']}" if options['valueLabelsInterval']
|
95
|
+
query_params[:chds] = "#{options['min']},#{options['max']}"
|
96
|
+
end
|
97
|
+
#####
|
98
|
+
|
99
|
+
query_params = stringify_keys!(query_params.merge(superseding_params))
|
100
|
+
base_url = "https://chart.googleapis.com/chart"
|
101
|
+
query = ""
|
102
|
+
query_params.each_with_index do |(k,v),i|
|
103
|
+
query += (i == 0) ? "?" : "&"
|
104
|
+
query += "#{k}=#{CGI.escape(v)}"
|
105
|
+
end
|
106
|
+
URI.parse(base_url + query)
|
107
|
+
end
|
26
108
|
end
|
27
109
|
|
28
110
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoogleVisualr::Image::PieChart do
|
4
|
+
describe "#uri" do
|
5
|
+
let(:chart){ GoogleVisualr::Image::PieChart.new( data_table, {} )}
|
6
|
+
image_pie_options.each_with_index do |opts, i|
|
7
|
+
context "#{opts.inspect}" do
|
8
|
+
it "generates correct URI" do
|
9
|
+
chart.options = opts
|
10
|
+
uri = chart.uri
|
11
|
+
#puts uri.to_s
|
12
|
+
CGI.parse(uri.query).should == CGI.parse(image_pie_chart_uris[i].query)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe GoogleVisualr::Image::LineChart do
|
20
|
+
describe "#uri" do
|
21
|
+
let(:chart){ GoogleVisualr::Image::LineChart.new( data_table, {} )}
|
22
|
+
image_line_options.each_with_index do |opts, i|
|
23
|
+
context "#{opts.inspect}" do
|
24
|
+
it "generates correct URI" do
|
25
|
+
chart.options = opts
|
26
|
+
uri = chart.uri
|
27
|
+
#puts uri.to_s
|
28
|
+
CGI.parse(uri.query).should == CGI.parse(image_line_chart_uris[i].query)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe GoogleVisualr::Image::BarChart do
|
36
|
+
describe "#uri" do
|
37
|
+
let(:chart){ GoogleVisualr::Image::BarChart.new( data_table, {} )}
|
38
|
+
image_bar_options.each_with_index do |opts, i|
|
39
|
+
context "#{opts.inspect}" do
|
40
|
+
it "generates correct URI" do
|
41
|
+
chart.options = opts
|
42
|
+
uri = chart.uri
|
43
|
+
#puts uri.to_s
|
44
|
+
CGI.parse(uri.query).should == CGI.parse(image_bar_chart_uris[i].query)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe GoogleVisualr::Image::SparkLine do
|
52
|
+
describe "#uri" do
|
53
|
+
let(:chart){ GoogleVisualr::Image::SparkLine.new( data_table, {} )}
|
54
|
+
sparkline_options.each_with_index do |opts, i|
|
55
|
+
context "#{opts.inspect}" do
|
56
|
+
it "generates correct URI" do
|
57
|
+
chart.options = opts
|
58
|
+
uri = chart.uri
|
59
|
+
#puts uri.to_s
|
60
|
+
CGI.parse(uri.query).should == CGI.parse(sparkline_uris[i].query)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/support/common.rb
CHANGED
@@ -31,3 +31,116 @@ def base_chart_js(div_class="div_class")
|
|
31
31
|
js << "\n</script>"
|
32
32
|
|
33
33
|
end
|
34
|
+
|
35
|
+
# Helpers for image chart specs
|
36
|
+
|
37
|
+
def pie_data_table
|
38
|
+
@cols = [
|
39
|
+
{ :type => "string", :label => "Favorite Dessert" },
|
40
|
+
{ :type => "number", :label => "Count" }
|
41
|
+
]
|
42
|
+
@rows = [
|
43
|
+
{ :c => [ {:v => "Pie"}, {:v => 100} ] },
|
44
|
+
{ :c => [ {:v => "Cake"}, {:v => 120} ] },
|
45
|
+
{ :c => [ {:v => "Ice Cream"}, {:v => 150} ] },
|
46
|
+
{ :c => [ {:v => "Cookies"}, {:v => 80 } ] }
|
47
|
+
]
|
48
|
+
GoogleVisualr::DataTable.new(:cols => @cols, :rows => @rows)
|
49
|
+
end
|
50
|
+
|
51
|
+
def image_pie_options
|
52
|
+
[
|
53
|
+
{ :title => "Favorite Desserts", :is3D => false, :labels => "name", :backgroundColor => "#EFEFEF", :legend => "left" },
|
54
|
+
{ :title => "Favorite Desserts", :width => 650, :height => 300, :is3D => true, :labels => "value", :backgroundColor => "#FFFFFF",
|
55
|
+
:legend => "bottom" },
|
56
|
+
{ :title => "Favorite Desserts", :width => 650, :height => 300, :is3D => false, :labels => "none", :backgroundColor => "#FFFFFF",
|
57
|
+
:color => "#444D92", :legend => "top" },
|
58
|
+
{ :title => "Favorite Desserts", :width => 650, :height => 300, :is3D => true, :labels => "none", :backgroundColor => "#FFFFFF",
|
59
|
+
:colors => ['#444D92', '#4c56a2', '#5E67AB', '#7078B5', '#8289BE', '#949AC7',
|
60
|
+
'#A6AAD0', '#B7BBDA', '#C9CCE3', '#DBDDEC', '#EDEEF6'], :legend => "none" }
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
def image_pie_chart_uris
|
65
|
+
[
|
66
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CEFEFEF&chdl=2004%7C2005%7C2006%7C2007&chs=400x200&cht=p&chdlp=l&chtt=Favorite+Desserts&chl=2004%7C2005%7C2006%7C2007&chd=t%3A1000%2C1200%2C1500%2C800&chds=a"),
|
67
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=2004%7C2005%7C2006%7C2007&chs=650x300&cht=p3&chdlp=b&chtt=Favorite+Desserts&chl=1000%7C1200%7C1500%7C800&chd=t%3A1000%2C1200%2C1500%2C800&chds=a"),
|
68
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=2004%7C2005%7C2006%7C2007&chs=650x300&cht=p&chdlp=t&chtt=Favorite+Desserts&chco=444D92&chl=&chd=t%3A1000%2C1200%2C1500%2C800&chds=a"),
|
69
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=2004%7C2005%7C2006%7C2007&chs=650x300&cht=p3&chtt=Favorite+Desserts&chco=444D92%7C4c56a2%7C5E67AB%7C7078B5%7C8289BE%7C949AC7%7CA6AAD0%7CB7BBDA%7CC9CCE3%7CDBDDEC%7CEDEEF6&chl=&chd=t%3A1000%2C1200%2C1500%2C800&chds=a")
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def image_line_options
|
74
|
+
[
|
75
|
+
{ :title => "Test1 Line Chart", :colors => ['#437E9D', '#E6A65A'], :legend => "left",
|
76
|
+
:backgroundColor => "#EFEFEF", :showCategoryLabels => true, :showValueLabels => false },
|
77
|
+
{ :title => "Test2 Line Chart", :width => 500, :height => 200, :color => '#437E9D', :legend => "right",
|
78
|
+
:backgroundColor => "#FFFFFF", :showCategoryLabels => false, :showValueLabels => true },
|
79
|
+
{ :title => "Test3 Line Chart", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "top",
|
80
|
+
:showCategoryLabels => false, :showValueLabels => false, :showAxisLines => false },
|
81
|
+
{ :title => "Test4 Line Chart", :width => 500, :height => 200, :color => '#437E9D', :legend => "bottom",
|
82
|
+
:showCategoryLabels => true, :showValueLabels => true, :showAxisLines => true },
|
83
|
+
{ :title => "Test5 Line Chart", :width => 500, :height => 200, :color => '#437E9D', :legend => "none",
|
84
|
+
:showCategoryLabels => true, :showValueLabels => true, :min => 200, :max => 2000, :valueLabelsInterval => 200 }
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
def image_line_chart_uris
|
89
|
+
[
|
90
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CEFEFEF&chdl=Sales%7CExpenses&chs=400x200&chxl=0%3A%7C2004%7C2005%7C2006%7C2007%7C1%3A%7C%7C&cht=lc&chdlp=l&chtt=Test1+Line+Chart&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
91
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C%7C&cht=lc&chdlp=r&chtt=Test2+Line+Chart&chco=437E9D&chds=a&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500"),
|
92
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C%7C1%3A%7C%7C&cht=lc%3Anda&chdlp=t&chtt=Test3+Line+Chart&chco=437E9D%2CE6A65A&chds=a&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500"),
|
93
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C2004%7C2005%7C2006%7C2007%7C&cht=lc&chdlp=b&chtt=Test4+Line+Chart&chco=437E9D&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
94
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chs=500x200&chxl=0%3A%7C2004%7C2005%7C2006%7C2007%7C&cht=lc&chtt=Test5+Line+Chart&chco=437E9D&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chxr=1%2C200%2C2000%2C200&chds=200%2C2000")
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
def image_bar_options
|
99
|
+
[
|
100
|
+
{ :title => "Test1 Bar Chart", :colors => ['#437E9D', '#E6A65A'], :legend => "left",
|
101
|
+
:backgroundColor => "#EFEFEF", :showCategoryLabels => true, :showValueLabels => false },
|
102
|
+
{ :title => "Test2 Bar Chart", :width => 500, :height => 200, :color => '#437E9D', :legend => "right",
|
103
|
+
:backgroundColor => "#FFFFFF", :showCategoryLabels => false, :showValueLabels => true },
|
104
|
+
{ :title => "Test3 Bar Chart", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "top",
|
105
|
+
:showCategoryLabels => false, :showValueLabels => false },
|
106
|
+
{ :title => "Test4 Bar Chart", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "bottom",
|
107
|
+
:showCategoryLabels => true, :showValueLabels => true, :isStacked => false, :isVertical => true },
|
108
|
+
{ :title => "Test5 Bar Chart", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "none",
|
109
|
+
:isStacked => true, :isVertical => true, :min => 200, :max => 2000, :valueLabelsInterval => 200 }
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
def image_bar_chart_uris
|
114
|
+
[
|
115
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CEFEFEF&chdl=Sales%7CExpenses&chs=400x200&chxl=1%3A%7C2004%7C2005%7C2006%7C2007%7C0%3A%7C%7C&cht=bhs&chdlp=l&chtt=Test1+Bar+Chart&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
116
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=Sales%7CExpenses&chs=500x200&chxl=1%3A%7C%7C&cht=bhs&chdlp=r&chtt=Test2+Bar+Chart&chco=437E9D&chds=a&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500"),
|
117
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=1%3A%7C%7C0%3A%7C%7C&cht=bhs&chdlp=t&chtt=Test3+Bar+Chart&chco=437E9D%2CE6A65A&chds=a&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500"),
|
118
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C2004%7C2005%7C2006%7C2007%7C&cht=bvg&chdlp=b&chtt=Test4+Bar+Chart&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
119
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chs=500x200&chxl=0%3A%7C2004%7C2005%7C2006%7C2007%7C&cht=bvs&chtt=Test5+Bar+Chart&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chxr=1%2C200%2C2000%2C200&chds=200%2C2000")
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def sparkline_options
|
124
|
+
[
|
125
|
+
{ :title => "Test1 Sparkline", :colors => ['#437E9D', '#E6A65A'], :legend => "left",
|
126
|
+
:backgroundColor => "#EFEFEF", :showAxisLines => false },
|
127
|
+
{ :title => "Test2 Sparkline", :width => 500, :height => 200, :color => '#437E9D', :legend => "right",
|
128
|
+
:backgroundColor => "#FFFFFF", :showAxisLines => true },
|
129
|
+
{ :title => "Test3 Sparkline", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "top",
|
130
|
+
:showAxisLines => false },
|
131
|
+
{ :title => "Test4 Sparkline", :width => 500, :height => 200, :color => '#437E9D', :legend => "bottom",
|
132
|
+
:showAxisLines => false },
|
133
|
+
{ :title => "Test5 Sparkline", :width => 500, :height => 200, :colors => ['#437E9D', '#E6A65A'], :legend => "none",
|
134
|
+
:showAxisLines => false }
|
135
|
+
]
|
136
|
+
end
|
137
|
+
|
138
|
+
def sparkline_uris
|
139
|
+
[
|
140
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CEFEFEF&chdl=Sales%7CExpenses&chs=400x200&chxl=0%3A%7C%7C1%3A%7C%7C&cht=ls&chdlp=l&chtt=Test1+Sparkline&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
141
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chf=bg%2Cs%2CFFFFFF&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C%7C&cht=ls&chdlp=r&chtt=Test2+Sparkline&chco=437E9D&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
142
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C%7C1%3A%7C%7C&cht=ls&chdlp=t&chtt=Test3+Sparkline&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
143
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chdl=Sales%7CExpenses&chs=500x200&chxl=0%3A%7C%7C1%3A%7C%7C&cht=ls&chdlp=b&chtt=Test4+Sparkline&chco=437E9D&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a"),
|
144
|
+
URI.parse("https://chart.googleapis.com/chart?chxt=x%2Cy&chs=500x200&chxl=0%3A%7C%7C1%3A%7C%7C&cht=ls&chtt=Test5+Sparkline&chco=437E9D%2CE6A65A&chd=t%3A1000%2C1200%2C1500%2C800%7C400%2C450%2C600%2C500&chds=a")
|
145
|
+
]
|
146
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: google_visualr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.1.
|
5
|
+
version: 2.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Winston Teo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-01
|
13
|
+
date: 2012-03-01 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -71,6 +71,9 @@ files:
|
|
71
71
|
- lib/google_visualr/base_chart.rb
|
72
72
|
- lib/google_visualr/data_table.rb
|
73
73
|
- lib/google_visualr/formatters.rb
|
74
|
+
- lib/google_visualr/image/bar_chart.rb
|
75
|
+
- lib/google_visualr/image/line_chart.rb
|
76
|
+
- lib/google_visualr/image/pie_chart.rb
|
74
77
|
- lib/google_visualr/image/spark_line.rb
|
75
78
|
- lib/google_visualr/interactive/annotated_time_line.rb
|
76
79
|
- lib/google_visualr/interactive/area_chart.rb
|
@@ -143,6 +146,7 @@ files:
|
|
143
146
|
- spec/google_visualr/base_chart_spec.rb
|
144
147
|
- spec/google_visualr/data_table_spec.rb
|
145
148
|
- spec/google_visualr/formatters_spec.rb
|
149
|
+
- spec/google_visualr/image_charts_spec.rb
|
146
150
|
- spec/google_visualr/param_helpers_spec.rb
|
147
151
|
- spec/spec_helper.rb
|
148
152
|
- spec/support/common.rb
|