google_visualr 0.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +3 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +25 -0
  6. data/MIT-LICENSE +15 -14
  7. data/README.rdoc +59 -48
  8. data/Rakefile +9 -30
  9. data/google_visualr.gemspec +24 -0
  10. data/lib/google_visualr.rb +39 -0
  11. data/lib/google_visualr/base_chart.rb +40 -0
  12. data/lib/google_visualr/data_table.rb +277 -0
  13. data/lib/google_visualr/formatters.rb +78 -0
  14. data/lib/google_visualr/image/spark_line.rb +13 -0
  15. data/lib/google_visualr/interactive/annotated_time_line.rb +11 -0
  16. data/lib/google_visualr/interactive/area_chart.rb +13 -0
  17. data/lib/google_visualr/interactive/bar_chart.rb +13 -0
  18. data/lib/google_visualr/interactive/candlestick_chart.rb +13 -0
  19. data/lib/google_visualr/interactive/column_chart.rb +13 -0
  20. data/lib/google_visualr/interactive/combo_chart.rb +13 -0
  21. data/lib/google_visualr/interactive/gauge.rb +11 -0
  22. data/lib/google_visualr/interactive/geo_chart.rb +11 -0
  23. data/lib/google_visualr/interactive/intensity_map.rb +11 -0
  24. data/lib/google_visualr/interactive/line_chart.rb +13 -0
  25. data/lib/google_visualr/interactive/map.rb +11 -0
  26. data/lib/google_visualr/interactive/motion_chart.rb +11 -0
  27. data/lib/google_visualr/interactive/org_chart.rb +11 -0
  28. data/lib/google_visualr/interactive/pie_chart.rb +13 -0
  29. data/lib/google_visualr/interactive/scatter_chart.rb +13 -0
  30. data/lib/google_visualr/interactive/table.rb +11 -0
  31. data/lib/google_visualr/interactive/treemap.rb +11 -0
  32. data/lib/google_visualr/packages.rb +30 -0
  33. data/lib/google_visualr/param_helpers.rb +50 -0
  34. data/lib/google_visualr/version.rb +3 -0
  35. data/spec/google_visualr/base_chart_spec.rb +55 -0
  36. data/spec/google_visualr/data_table_spec.rb +251 -0
  37. data/spec/google_visualr/formatters_spec.rb +104 -0
  38. data/spec/spec_helper.rb +8 -0
  39. data/test/google_visualr_spec.rb +7 -0
  40. data/test/helper.rb +18 -0
  41. metadata +73 -36
  42. data/VERSION +0 -1
  43. data/init.rb +0 -17
  44. data/install.rb +0 -1
  45. data/lib/annotated_time_line.rb +0 -50
  46. data/lib/area_chart.rb +0 -54
  47. data/lib/bar_chart.rb +0 -53
  48. data/lib/base_chart.rb +0 -285
  49. data/lib/column_chart.rb +0 -53
  50. data/lib/formatters.rb +0 -184
  51. data/lib/gauge.rb +0 -36
  52. data/lib/geo_map.rb +0 -32
  53. data/lib/image_spark_line.rb +0 -36
  54. data/lib/intensity_map.rb +0 -29
  55. data/lib/line_chart.rb +0 -54
  56. data/lib/map.rb +0 -31
  57. data/lib/motion_chart.rb +0 -36
  58. data/lib/org_chart.rb +0 -29
  59. data/lib/pie_chart.rb +0 -44
  60. data/lib/scatter_chart.rb +0 -52
  61. data/lib/table.rb +0 -39
  62. data/uninstall.rb +0 -1
data/lib/column_chart.rb DELETED
@@ -1,53 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/columnchart.html
4
- class ColumnChart < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/columnchart.html#Configuration_Options
9
- attr_accessor :axisColor
10
- attr_accessor :axisBackgroundColor
11
- attr_accessor :axisFontSize
12
- attr_accessor :backgroundColor
13
- attr_accessor :borderColor
14
- attr_accessor :colors
15
- attr_accessor :enableTooltip
16
- attr_accessor :focusBorderColor
17
- attr_accessor :height
18
- attr_accessor :is3D
19
- attr_accessor :isStacked
20
- attr_accessor :legend
21
- attr_accessor :legendBackgroundColor
22
- attr_accessor :legendFontSize
23
- attr_accessor :legendTextColor
24
- attr_accessor :logScale
25
- attr_accessor :max
26
- attr_accessor :min
27
- attr_accessor :reverseAxis
28
- attr_accessor :showCategories
29
- attr_accessor :title
30
- attr_accessor :titleX
31
- attr_accessor :titleY
32
- attr_accessor :titleColor
33
- attr_accessor :titleFontSize
34
- attr_accessor :tooltipFontSize
35
- attr_accessor :tooltipHeight
36
- attr_accessor :tooltipWidth
37
- attr_accessor :width
38
-
39
- def render (element_id)
40
-
41
- options = Hash.new
42
-
43
- options[:package] = self.class.to_s.split('::').last
44
- options[:element_id] = element_id
45
- options[:chart_style] = collect_parameters
46
-
47
- super(options)
48
-
49
- end
50
-
51
- end
52
-
53
- end
data/lib/formatters.rb DELETED
@@ -1,184 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/reference.html#formatters
4
- class Formatter
5
-
6
- attr_accessor :columns
7
-
8
- def initialize(options={})
9
-
10
- options.each_pair do | key, value |
11
- self.send "#{key}=", value
12
- end
13
-
14
- end
15
-
16
- def columns(*columns)
17
- @columns = columns.flatten
18
- end
19
-
20
- def script(options)
21
-
22
- script = "var formatter = new google.visualization.#{options[:formatter]}("
23
- script << options[:formatter_options]
24
- script << ");"
25
-
26
- @columns.each do |column|
27
- script << "formatter.format(chart_data, #{column});"
28
- end
29
-
30
- return script
31
-
32
- end
33
-
34
- def collect_parameters
35
-
36
- attributes = Array.new
37
- instance_variable_names.each do |instance_variable|
38
- next if instance_variable == "@columns"
39
- key = instance_variable.gsub("@", "")
40
- value = instance_variable_get(instance_variable)
41
- attribute = key + ":" + (value.is_a?(String) ? "'" + value + "'" : value.to_s)
42
- attributes << attribute
43
- end
44
-
45
- return "{" + attributes.join(",") + "}"
46
-
47
- end
48
-
49
- end
50
-
51
- class ArrowFormat < Formatter
52
-
53
- attr_accessor :base
54
-
55
- def script
56
-
57
- options = Hash.new
58
- options[:formatter] = self.class.to_s.split('::').last
59
- options[:formatter_options] = collect_parameters
60
-
61
- super(options)
62
-
63
- end
64
-
65
- end
66
-
67
- class BarFormat < Formatter
68
-
69
- attr_accessor :base
70
- attr_accessor :colorNegative
71
- attr_accessor :colorPositive
72
- attr_accessor :drawZeroLine
73
- attr_accessor :max
74
- attr_accessor :min
75
- attr_accessor :showValue
76
- attr_accessor :width
77
-
78
- def script
79
-
80
- options = Hash.new
81
- options[:formatter] = self.class.to_s.split('::').last
82
- options[:formatter_options] = collect_parameters
83
-
84
- super(options)
85
-
86
- end
87
-
88
- end
89
-
90
- class ColorFormat < Formatter
91
-
92
- attr_accessor :ranges
93
- attr_accessor :gradient_ranges
94
-
95
- def initialize
96
- @ranges = Array.new
97
- @gradient_ranges = Array.new
98
- end
99
-
100
- def add_range(from, to, color, bgcolor)
101
-
102
- options = { :from => from, :to => to, :color => color, :bgcolor => bgcolor }
103
- [:from, :to].each do |attr|
104
- options[attr] ||= 'null'
105
- end
106
-
107
- @ranges << options
108
-
109
- end
110
-
111
- def add_gradient_range(from, to, color, fromBgColor, toBgColor)
112
-
113
- options = { :from => from, :to => to, :color => color, :fromBgColor => fromBgColor, :toBgColor => toBgColor }
114
- [:from, :to].each do |attr|
115
- options[attr] ||= 'null'
116
- end
117
-
118
- @gradient_ranges << options
119
-
120
- end
121
-
122
- def script
123
-
124
- script = "var formatter = new google.visualization.ColorFormat();"
125
-
126
- @ranges.each do |r|
127
- script << "formatter.addRange( #{r[:from]}, #{r[:to]}, '#{r[:color]}', '#{r[:bgcolor]}' );"
128
- end
129
-
130
- @gradient_ranges.each do |r|
131
- script << "formatter.addGradientRange( #{r[:from]}, #{r[:to]}, '#{r[:color]}', '#{r[:fromBgColor]}', '#{r[:toBgColor]}' );"
132
- end
133
-
134
- @columns.each do |column|
135
- script << "formatter.format(chart_data, #{column});"
136
- end
137
-
138
- return script
139
-
140
- end
141
-
142
- end
143
-
144
- class DateFormat < Formatter
145
-
146
- attr_accessor :formatType
147
- attr_accessor :pattern
148
- attr_accessor :timeZone
149
-
150
- def script
151
-
152
- options = Hash.new
153
- options[:formatter] = self.class.to_s.split('::').last
154
- options[:formatter_options] = collect_parameters
155
-
156
- super(options)
157
-
158
- end
159
-
160
- end
161
-
162
- class NumberFormat < Formatter
163
-
164
- attr_accessor :decimalSymbol
165
- attr_accessor :fractionDigits
166
- attr_accessor :groupingSymbol
167
- attr_accessor :negativeColor
168
- attr_accessor :negativeParens
169
- attr_accessor :prefix
170
- attr_accessor :suffix
171
-
172
- def script
173
-
174
- options = Hash.new
175
- options[:formatter] = self.class.to_s.split('::').last
176
- options[:formatter_options] = collect_parameters
177
-
178
- super(options)
179
-
180
- end
181
-
182
- end
183
-
184
- end
data/lib/gauge.rb DELETED
@@ -1,36 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/gauge.html
4
- class Gauge < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/gauge.html#Configuration_Options
9
- attr_accessor :greenFrom
10
- attr_accessor :greenTo
11
- attr_accessor :height
12
- attr_accessor :majorTicks
13
- attr_accessor :max
14
- attr_accessor :min
15
- attr_accessor :minorTicks
16
- attr_accessor :redFrom
17
- attr_accessor :redTo
18
- attr_accessor :width
19
- attr_accessor :yellowFrom
20
- attr_accessor :yellowTo
21
-
22
- def render (element_id)
23
-
24
- options = Hash.new
25
-
26
- options[:package] = self.class.to_s.split('::').last
27
- options[:element_id] = element_id
28
- options[:chart_style] = collect_parameters
29
-
30
- super(options)
31
-
32
- end
33
-
34
- end
35
-
36
- end
data/lib/geo_map.rb DELETED
@@ -1,32 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/geomap.html
4
- class GeoMap < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/geomap.html#Configuration_Options
9
- attr_accessor :region
10
- attr_accessor :dataMode
11
- attr_accessor :width
12
- attr_accessor :height
13
- attr_accessor :colors
14
- attr_accessor :showLegend
15
- attr_accessor :showZoomOut
16
- attr_accessor :zoomOutLabel
17
-
18
- def render (element_id)
19
-
20
- options = Hash.new
21
-
22
- options[:package] = self.class.to_s.split('::').last
23
- options[:element_id] = element_id
24
- options[:chart_style] = collect_parameters
25
-
26
- super(options)
27
-
28
- end
29
-
30
- end
31
-
32
- end
@@ -1,36 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/imagesparkline.html
4
- class ImageSparkLine < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/imagesparkline.html#Configuration_Options
9
- attr_accessor :color
10
- attr_accessor :colors
11
- attr_accessor :fill
12
- attr_accessor :height
13
- attr_accessor :labelPosition
14
- attr_accessor :max
15
- attr_accessor :min
16
- attr_accessor :showAxisLines
17
- attr_accessor :showValueLabels
18
- attr_accessor :title
19
- attr_accessor :width
20
- attr_accessor :layout
21
-
22
- def render (element_id)
23
-
24
- options = Hash.new
25
-
26
- options[:package] = self.class.to_s.split('::').last
27
- options[:element_id] = element_id
28
- options[:chart_style] = collect_parameters
29
-
30
- super(options)
31
-
32
- end
33
-
34
- end
35
-
36
- end
data/lib/intensity_map.rb DELETED
@@ -1,29 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/intensitymap.html
4
- class IntensityMap < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/intensitymap.html#Configuration_Options
9
- attr_accessor :colors
10
- attr_accessor :height
11
- attr_accessor :region
12
- attr_accessor :showOneTab
13
- attr_accessor :width
14
-
15
- def render (element_id)
16
-
17
- options = Hash.new
18
-
19
- options[:package] = self.class.to_s.split('::').last
20
- options[:element_id] = element_id
21
- options[:chart_style] = collect_parameters
22
-
23
- super(options)
24
-
25
- end
26
-
27
- end
28
-
29
- end
data/lib/line_chart.rb DELETED
@@ -1,54 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/linechart.html
4
- class LineChart < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/linechart.html#Configuration_Options
9
- attr_accessor :axisColor
10
- attr_accessor :axisBackgroundColor
11
- attr_accessor :axisFontSize
12
- attr_accessor :backgroundColor
13
- attr_accessor :borderColor
14
- attr_accessor :colors
15
- attr_accessor :enableTooltip
16
- attr_accessor :focusBorderColor
17
- attr_accessor :height
18
- attr_accessor :legend
19
- attr_accessor :legendBackgroundColor
20
- attr_accessor :legendFontSize
21
- attr_accessor :legendTextColor
22
- attr_accessor :lineSize
23
- attr_accessor :logScale
24
- attr_accessor :max
25
- attr_accessor :min
26
- attr_accessor :pointSize
27
- attr_accessor :reverseAxis
28
- attr_accessor :showCategories
29
- attr_accessor :smoothLine
30
- attr_accessor :title
31
- attr_accessor :titleX
32
- attr_accessor :titleY
33
- attr_accessor :titleColor
34
- attr_accessor :titleFontSize
35
- attr_accessor :tooltipFontSize
36
- attr_accessor :tooltipHeight
37
- attr_accessor :tooltipWidth
38
- attr_accessor :width
39
-
40
- def render (element_id)
41
-
42
- options = Hash.new
43
-
44
- options[:package] = self.class.to_s.split('::').last
45
- options[:element_id] = element_id
46
- options[:chart_style] = collect_parameters
47
-
48
- super(options)
49
-
50
- end
51
-
52
- end
53
-
54
- end
data/lib/map.rb DELETED
@@ -1,31 +0,0 @@
1
- module GoogleVisualr
2
-
3
- # http://code.google.com/apis/visualization/documentation/gallery/map.html
4
- class Map < BaseChart
5
-
6
- attr_accessor :element_id
7
-
8
- # http://code.google.com/apis/visualization/documentation/gallery/map.html#Configuration_Options
9
- attr_accessor :enableScrollWheel
10
- attr_accessor :showTip
11
- attr_accessor :showLine
12
- attr_accessor :lineColor
13
- attr_accessor :lineWidth
14
- attr_accessor :mapType
15
- attr_accessor :zoomLevel
16
-
17
- def render (element_id)
18
-
19
- options = Hash.new
20
-
21
- options[:package] = self.class.to_s.split('::').last
22
- options[:element_id] = element_id
23
- options[:chart_style] = collect_parameters
24
-
25
- super(options)
26
-
27
- end
28
-
29
- end
30
-
31
- end