seer 0.9.1 → 0.10.0
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/Rakefile +0 -16
- data/lib/seer/area_chart.rb +19 -19
- data/lib/seer/bar_chart.rb +2 -2
- data/lib/seer/column_chart.rb +1 -1
- data/lib/seer/geomap.rb +5 -6
- data/lib/seer/line_chart.rb +21 -21
- data/lib/seer/pie_chart.rb +1 -1
- metadata +8 -47
- data/spec/area_chart_spec.rb +0 -108
- data/spec/bar_chart_spec.rb +0 -51
- data/spec/chart_spec.rb +0 -62
- data/spec/column_chart_spec.rb +0 -51
- data/spec/custom_matchers.rb +0 -23
- data/spec/gauge_spec.rb +0 -59
- data/spec/geomap_spec.rb +0 -67
- data/spec/helpers.rb +0 -37
- data/spec/line_chart_spec.rb +0 -86
- data/spec/pie_chart_spec.rb +0 -51
data/Rakefile
CHANGED
@@ -38,22 +38,6 @@ rescue LoadError
|
|
38
38
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
39
39
|
end
|
40
40
|
|
41
|
-
require 'spec/rake/spectask'
|
42
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
43
|
-
spec.libs << 'lib' << 'spec'
|
44
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
-
end
|
46
|
-
|
47
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
48
|
-
spec.libs << 'lib' << 'spec'
|
49
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
50
|
-
spec.rcov = true
|
51
|
-
end
|
52
|
-
|
53
|
-
task :spec => :check_dependencies
|
54
|
-
|
55
|
-
task :default => :spec
|
56
|
-
|
57
41
|
require 'rake/rdoctask'
|
58
42
|
Rake::RDocTask.new do |rdoc|
|
59
43
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
data/lib/seer/area_chart.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Seer
|
2
2
|
|
3
3
|
# =USAGE
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# In your controller:
|
6
6
|
#
|
7
7
|
# @data = Widgets.all # Must be an array, and must respond
|
@@ -14,7 +14,7 @@ module Seer
|
|
14
14
|
# <div id="chart"></div>
|
15
15
|
#
|
16
16
|
# <%= Seer::visualize(
|
17
|
-
# @data,
|
17
|
+
# @data,
|
18
18
|
# :as => :area_chart,
|
19
19
|
# :in_element => 'chart',
|
20
20
|
# :series => {
|
@@ -23,7 +23,7 @@ module Seer
|
|
23
23
|
# :data_method => 'quantity',
|
24
24
|
# :data_series => @series
|
25
25
|
# },
|
26
|
-
# :chart_options => {
|
26
|
+
# :chart_options => {
|
27
27
|
# :height => 300,
|
28
28
|
# :width => 300,
|
29
29
|
# :axis_font_size => 11,
|
@@ -34,19 +34,19 @@ module Seer
|
|
34
34
|
# )
|
35
35
|
# -%>
|
36
36
|
#
|
37
|
-
# For details on the chart options, see the Google API docs at
|
37
|
+
# For details on the chart options, see the Google API docs at
|
38
38
|
# http://code.google.com/apis/visualization/documentation/gallery/areachart.html
|
39
39
|
#
|
40
40
|
class AreaChart
|
41
|
-
|
41
|
+
|
42
42
|
include Seer::Chart
|
43
|
-
|
43
|
+
|
44
44
|
# Graph options
|
45
45
|
attr_accessor :axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :data_table, :enable_tooltip, :focus_border_color, :height, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :number, :tooltip_width, :width
|
46
|
-
|
46
|
+
|
47
47
|
# Graph data
|
48
48
|
attr_accessor :series_label, :data_label, :data, :data_method, :data_series
|
49
|
-
|
49
|
+
|
50
50
|
def initialize(args={}) #:nodoc:
|
51
51
|
|
52
52
|
# Standard options
|
@@ -55,16 +55,16 @@ module Seer
|
|
55
55
|
# Chart options
|
56
56
|
args[:chart_options].each{ |method, arg| self.send("#{method}=",arg) if self.respond_to?(method) }
|
57
57
|
|
58
|
-
# Handle defaults
|
58
|
+
# Handle defaults
|
59
59
|
@colors ||= args[:chart_options][:colors] || DEFAULT_COLORS
|
60
60
|
@legend ||= args[:chart_options][:legend] || DEFAULT_LEGEND_LOCATION
|
61
61
|
@height ||= args[:chart_options][:height] || DEFAULT_HEIGHT
|
62
62
|
@width ||= args[:chart_options][:width] || DEFAULT_WIDTH
|
63
63
|
|
64
64
|
@data_table = []
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def data_columns #:nodoc:
|
69
69
|
_data_columns = " data.addRows(#{data_rows.size});\r"
|
70
70
|
_data_columns << " data.addColumn('string', 'Date');\r"
|
@@ -73,7 +73,7 @@ module Seer
|
|
73
73
|
end
|
74
74
|
_data_columns
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def data_table #:nodoc:
|
78
78
|
_rows = data_rows
|
79
79
|
_rows.each_with_index do |r,i|
|
@@ -86,7 +86,7 @@ module Seer
|
|
86
86
|
end
|
87
87
|
@data_table
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
def data_rows
|
91
91
|
data_series.inject([]) do |rows, element|
|
92
92
|
rows |= element.map { |e| e.send(data_label) }
|
@@ -96,11 +96,11 @@ module Seer
|
|
96
96
|
def nonstring_options #:nodoc:
|
97
97
|
[ :axis_font_size, :colors, :enable_tooltip, :height, :is_stacked, :legend_font_size, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width]
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
def string_options #:nodoc:
|
101
101
|
[ :axis_color, :axis_background_color, :background_color, :border_color, :focus_border_color, :legend, :legend_background_color, :legend_text_color, :title, :title_x, :title_y, :title_color ]
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
def to_js #:nodoc:
|
105
105
|
|
106
106
|
%{
|
@@ -110,7 +110,7 @@ module Seer
|
|
110
110
|
function drawChart() {
|
111
111
|
var data = new google.visualization.DataTable();
|
112
112
|
#{data_columns}
|
113
|
-
#{data_table.
|
113
|
+
#{data_table.join("\r")}
|
114
114
|
var options = {};
|
115
115
|
#{options}
|
116
116
|
var container = document.getElementById('#{self.chart_element}');
|
@@ -120,7 +120,7 @@ module Seer
|
|
120
120
|
</script>
|
121
121
|
}
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def self.render(data, args) #:nodoc:
|
125
125
|
graph = Seer::AreaChart.new(
|
126
126
|
:data => data,
|
@@ -133,7 +133,7 @@ module Seer
|
|
133
133
|
)
|
134
134
|
graph.to_js
|
135
135
|
end
|
136
|
-
|
137
|
-
end
|
136
|
+
|
137
|
+
end
|
138
138
|
|
139
139
|
end
|
data/lib/seer/bar_chart.rb
CHANGED
@@ -42,7 +42,7 @@ module Seer
|
|
42
42
|
include Seer::Chart
|
43
43
|
|
44
44
|
# Chart options accessors
|
45
|
-
attr_accessor :axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :data_table, :enable_tooltip, :focus_border_color, :height, :is_3_d, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :log_scale, :max, :min, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width
|
45
|
+
attr_accessor :axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :data_table, :enable_tooltip, :focus_border_color, :font_size, :height, :is_3_d, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :log_scale, :max, :min, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width
|
46
46
|
|
47
47
|
# Graph data
|
48
48
|
attr_accessor :data, :data_method, :label_method
|
@@ -97,7 +97,7 @@ module Seer
|
|
97
97
|
function drawChart() {
|
98
98
|
var data = new google.visualization.DataTable();
|
99
99
|
#{data_columns}
|
100
|
-
#{data_table.
|
100
|
+
#{data_table.join("\r")}
|
101
101
|
var options = {};
|
102
102
|
#{options}
|
103
103
|
var container = document.getElementById('#{self.chart_element}');
|
data/lib/seer/column_chart.rb
CHANGED
@@ -97,7 +97,7 @@ module Seer
|
|
97
97
|
function drawChart() {
|
98
98
|
var data = new google.visualization.DataTable();
|
99
99
|
#{data_columns}
|
100
|
-
#{data_table.
|
100
|
+
#{data_table.join("\r")}
|
101
101
|
var options = {};
|
102
102
|
#{options}
|
103
103
|
var container = document.getElementById('#{self.chart_element}');
|
data/lib/seer/geomap.rb
CHANGED
@@ -11,13 +11,13 @@ module Seer
|
|
11
11
|
# <div id="my_geomap_container" class="chart"></div>
|
12
12
|
#
|
13
13
|
# <%= Seer::visualize(
|
14
|
-
# @
|
14
|
+
# @locations,
|
15
15
|
# :as => :geomap,
|
16
16
|
# :in_element => 'my_geomap_container',
|
17
17
|
# :series => {
|
18
18
|
# :series_label => 'name',
|
19
19
|
# :data_label => '# widgets',
|
20
|
-
# :data_method => '
|
20
|
+
# :data_method => 'widget_count'
|
21
21
|
# },
|
22
22
|
# :chart_options => {
|
23
23
|
# :data_mode => 'regions',
|
@@ -26,7 +26,7 @@ module Seer
|
|
26
26
|
# )
|
27
27
|
# -%>
|
28
28
|
#
|
29
|
-
# ==@
|
29
|
+
# ==@locations==
|
30
30
|
#
|
31
31
|
# A collection of objects (ActiveRecord or otherwise) that must respond to the
|
32
32
|
# following methods:
|
@@ -90,8 +90,7 @@ module Seer
|
|
90
90
|
|
91
91
|
def data_table #:nodoc:
|
92
92
|
@data_table = []
|
93
|
-
data.each_with_index do |datum, column|
|
94
|
-
next unless datum.geocoded?
|
93
|
+
data.select{ |d| d.geocoded? }.each_with_index do |datum, column|
|
95
94
|
if data_mode == "markers"
|
96
95
|
@data_table << [
|
97
96
|
" data.setValue(#{column}, 0, #{datum.latitude});\r",
|
@@ -130,7 +129,7 @@ module Seer
|
|
130
129
|
function drawChart() {
|
131
130
|
var data = new google.visualization.DataTable();
|
132
131
|
#{data_columns}
|
133
|
-
#{data_table.
|
132
|
+
#{data_table.join("\r")}
|
134
133
|
var options = {};
|
135
134
|
#{options}
|
136
135
|
var container = document.getElementById('#{self.chart_element}');
|
data/lib/seer/line_chart.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Seer
|
2
2
|
|
3
3
|
# =USAGE
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# In your controller:
|
6
6
|
#
|
7
|
-
# @data = Widgets.all # Must be an array of objects that respond to the specidied data method
|
7
|
+
# @data = Widgets.all # Must be an array of objects that respond to the specidied data method
|
8
8
|
# # (In this example, 'quantity'
|
9
9
|
#
|
10
10
|
# @series = @data.map{|w| w.widget_stats} # An array of arrays
|
@@ -14,7 +14,7 @@ module Seer
|
|
14
14
|
# <div id="chart"></div>
|
15
15
|
#
|
16
16
|
# <%= Seer::visualize(
|
17
|
-
# @data,
|
17
|
+
# @data,
|
18
18
|
# :as => :line_chart,
|
19
19
|
# :in_element => 'chart',
|
20
20
|
# :series => {
|
@@ -23,7 +23,7 @@ module Seer
|
|
23
23
|
# :data_method => 'quantity',
|
24
24
|
# :data_series => @series
|
25
25
|
# },
|
26
|
-
# :chart_options => {
|
26
|
+
# :chart_options => {
|
27
27
|
# :height => 300,
|
28
28
|
# :width => 300,
|
29
29
|
# :axis_font_size => 11,
|
@@ -34,19 +34,19 @@ module Seer
|
|
34
34
|
# )
|
35
35
|
# -%>
|
36
36
|
#
|
37
|
-
# For details on the chart options, see the Google API docs at
|
37
|
+
# For details on the chart options, see the Google API docs at
|
38
38
|
# http://code.google.com/apis/visualization/documentation/gallery/linechart.html
|
39
39
|
#
|
40
40
|
class LineChart
|
41
|
-
|
41
|
+
|
42
42
|
include Seer::Chart
|
43
|
-
|
43
|
+
|
44
44
|
# Graph options
|
45
45
|
attr_accessor :axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :smooth_line, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :number, :tooltip_width, :width
|
46
|
-
|
46
|
+
|
47
47
|
# Graph data
|
48
48
|
attr_accessor :data, :data_label, :data_method, :data_series, :data_table, :series_label
|
49
|
-
|
49
|
+
|
50
50
|
def initialize(args={}) #:nodoc:
|
51
51
|
|
52
52
|
# Standard options
|
@@ -55,16 +55,16 @@ module Seer
|
|
55
55
|
# Chart options
|
56
56
|
args[:chart_options].each{ |method, arg| self.send("#{method}=",arg) if self.respond_to?(method) }
|
57
57
|
|
58
|
-
# Handle defaults
|
58
|
+
# Handle defaults
|
59
59
|
@colors ||= args[:chart_options][:colors] || DEFAULT_COLORS
|
60
60
|
@legend ||= args[:chart_options][:legend] || DEFAULT_LEGEND_LOCATION
|
61
61
|
@height ||= args[:chart_options][:height] || DEFAULT_HEIGHT
|
62
62
|
@width ||= args[:chart_options][:width] || DEFAULT_WIDTH
|
63
63
|
|
64
64
|
@data_table = []
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def data_columns #:nodoc:
|
69
69
|
_data_columns = " data.addRows(#{data_rows.size});\r"
|
70
70
|
_data_columns << " data.addColumn('string', 'Date');\r"
|
@@ -75,7 +75,7 @@ module Seer
|
|
75
75
|
end
|
76
76
|
_data_columns
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def data_table #:nodoc:
|
80
80
|
_rows = data_rows
|
81
81
|
_rows.each_with_index do |r,i|
|
@@ -88,7 +88,7 @@ module Seer
|
|
88
88
|
end
|
89
89
|
@data_table
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
def data_rows
|
93
93
|
data_series.inject([]) do |rows, element|
|
94
94
|
rows |= element.map { |e| e.send(data_label) }
|
@@ -98,11 +98,11 @@ module Seer
|
|
98
98
|
def nonstring_options #:nodoc:
|
99
99
|
[ :axis_font_size, :colors, :enable_tooltip, :height, :legend_font_size, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :smooth_line, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width]
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
def string_options #:nodoc:
|
103
103
|
[ :axis_color, :axis_background_color, :background_color, :border_color, :focus_border_color, :legend, :legend_background_color, :legend_text_color, :title, :title_x, :title_y, :title_color ]
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
def to_js #:nodoc:
|
107
107
|
|
108
108
|
%{
|
@@ -112,7 +112,7 @@ module Seer
|
|
112
112
|
function drawChart() {
|
113
113
|
var data = new google.visualization.DataTable();
|
114
114
|
#{data_columns}
|
115
|
-
#{data_table
|
115
|
+
#{data_table * "\r"}
|
116
116
|
var options = {};
|
117
117
|
#{options}
|
118
118
|
var container = document.getElementById('#{self.chart_element}');
|
@@ -122,9 +122,9 @@ module Seer
|
|
122
122
|
</script>
|
123
123
|
}
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
# ====================================== Class Methods =========================================
|
127
|
-
|
127
|
+
|
128
128
|
def self.render(data, args) #:nodoc:
|
129
129
|
graph = Seer::LineChart.new(
|
130
130
|
:data => data,
|
@@ -137,7 +137,7 @@ module Seer
|
|
137
137
|
)
|
138
138
|
graph.to_js
|
139
139
|
end
|
140
|
-
|
141
|
-
end
|
140
|
+
|
141
|
+
end
|
142
142
|
|
143
143
|
end
|
data/lib/seer/pie_chart.rb
CHANGED
@@ -89,7 +89,7 @@ module Seer
|
|
89
89
|
function drawChart() {
|
90
90
|
var data = new google.visualization.DataTable();
|
91
91
|
#{data_columns}
|
92
|
-
#{data_table.
|
92
|
+
#{data_table.join("\r")}
|
93
93
|
var options = {};
|
94
94
|
#{options}
|
95
95
|
var container = document.getElementById('#{self.chart_element}');
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 1
|
10
|
-
version: 0.9.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.10.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Corey Ehmke / SEO Logic
|
@@ -15,8 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
13
|
+
date: 2011-09-06 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
16
|
name: rspec
|
@@ -26,11 +20,6 @@ dependencies:
|
|
26
20
|
requirements:
|
27
21
|
- - ">="
|
28
22
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 9
|
34
23
|
version: 1.2.9
|
35
24
|
type: :development
|
36
25
|
version_requirements: *id001
|
@@ -61,23 +50,12 @@ files:
|
|
61
50
|
- spec/seer_spec.rb
|
62
51
|
- spec/spec.opts
|
63
52
|
- spec/spec_helper.rb
|
64
|
-
- spec/area_chart_spec.rb
|
65
|
-
- spec/bar_chart_spec.rb
|
66
|
-
- spec/chart_spec.rb
|
67
|
-
- spec/column_chart_spec.rb
|
68
|
-
- spec/custom_matchers.rb
|
69
|
-
- spec/gauge_spec.rb
|
70
|
-
- spec/geomap_spec.rb
|
71
|
-
- spec/helpers.rb
|
72
|
-
- spec/line_chart_spec.rb
|
73
|
-
- spec/pie_chart_spec.rb
|
74
|
-
has_rdoc: true
|
75
53
|
homepage: http://github.com/Bantik/seer
|
76
54
|
licenses: []
|
77
55
|
|
78
56
|
post_install_message:
|
79
|
-
rdoc_options:
|
80
|
-
|
57
|
+
rdoc_options: []
|
58
|
+
|
81
59
|
require_paths:
|
82
60
|
- lib
|
83
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -85,36 +63,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
63
|
requirements:
|
86
64
|
- - ">="
|
87
65
|
- !ruby/object:Gem::Version
|
88
|
-
hash: 3
|
89
|
-
segments:
|
90
|
-
- 0
|
91
66
|
version: "0"
|
92
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
68
|
none: false
|
94
69
|
requirements:
|
95
70
|
- - ">="
|
96
71
|
- !ruby/object:Gem::Version
|
97
|
-
hash: 3
|
98
|
-
segments:
|
99
|
-
- 0
|
100
72
|
version: "0"
|
101
73
|
requirements: []
|
102
74
|
|
103
75
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.5
|
105
77
|
signing_key:
|
106
78
|
specification_version: 3
|
107
79
|
summary: Seer is a lightweight, semantically rich wrapper for the Google Visualization API.
|
108
|
-
test_files:
|
109
|
-
|
110
|
-
- spec/bar_chart_spec.rb
|
111
|
-
- spec/chart_spec.rb
|
112
|
-
- spec/column_chart_spec.rb
|
113
|
-
- spec/custom_matchers.rb
|
114
|
-
- spec/gauge_spec.rb
|
115
|
-
- spec/geomap_spec.rb
|
116
|
-
- spec/helpers.rb
|
117
|
-
- spec/line_chart_spec.rb
|
118
|
-
- spec/pie_chart_spec.rb
|
119
|
-
- spec/seer_spec.rb
|
120
|
-
- spec/spec_helper.rb
|
80
|
+
test_files: []
|
81
|
+
|
data/spec/area_chart_spec.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::AreaChart" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::AreaChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:series_label => 'to_s',
|
9
|
-
:data_series => [[1,2,3],[3,4,5]],
|
10
|
-
:data_label => 'to_s',
|
11
|
-
:data_method => 'size',
|
12
|
-
:chart_options => {},
|
13
|
-
:chart_element => 'chart'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'defaults' do
|
18
|
-
it_should_behave_like 'it sets default values'
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'graph options' do
|
22
|
-
|
23
|
-
[:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :number, :tooltip_width, :width].each do |accessor|
|
24
|
-
it "sets its #{accessor} value" do
|
25
|
-
@chart.send("#{accessor}=", 'foo')
|
26
|
-
@chart.send(accessor).should == 'foo'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it_should_behave_like 'it has colors attribute'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'renders as JavaScript' do
|
34
|
-
(@chart.to_js =~ /javascript/).should be_true
|
35
|
-
(@chart.to_js =~ /areachart/).should be_true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'sets its data columns' do
|
39
|
-
@chart.data_columns.should =~ /addRows\(5\)/
|
40
|
-
@chart.data_columns.should add_column('string', 'Date')
|
41
|
-
@chart.data_columns.should add_column('number', '0')
|
42
|
-
@chart.data_columns.should add_column('number', '1')
|
43
|
-
@chart.data_columns.should add_column('number', '2')
|
44
|
-
@chart.data_columns.should add_column('number', '3')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'sets its data table' do
|
48
|
-
@chart.data_table.to_s.should set_cell(0, 0,'1')
|
49
|
-
@chart.data_table.to_s.should set_cell(1, 0,'2')
|
50
|
-
@chart.data_table.to_s.should set_cell(2, 0,'3')
|
51
|
-
@chart.data_table.to_s.should set_cell(3, 0,'4')
|
52
|
-
@chart.data_table.to_s.should set_cell(4, 0,'5')
|
53
|
-
@chart.data_table.to_s.should set_cell(0,1,8)
|
54
|
-
@chart.data_table.to_s.should set_cell(2,1,8)
|
55
|
-
@chart.data_table.to_s.should set_cell(0,2,8)
|
56
|
-
@chart.data_table.to_s.should set_cell(1,2,8)
|
57
|
-
@chart.data_table.to_s.should set_cell(2,2,8)
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'when data_series is an array of arrays of arrays/hashes' do
|
61
|
-
before(:each) do
|
62
|
-
data_series = Array.new(3) {|i| [[i, i+1], [i+1, i+2]]}
|
63
|
-
@chart = Seer::AreaChart.new(
|
64
|
-
:data => [0,1,2,3],
|
65
|
-
:series_label => 'to_s',
|
66
|
-
:data_series => data_series,
|
67
|
-
:data_label => 'first',
|
68
|
-
:data_method => 'size',
|
69
|
-
:chart_options => {},
|
70
|
-
:chart_element => 'chart'
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'calculates number of rows' do
|
75
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'sets its data table' do
|
79
|
-
@chart.data_table.to_s.should set_cell(0, 0,'0')
|
80
|
-
@chart.data_table.to_s.should set_cell(1, 0,'1')
|
81
|
-
@chart.data_table.to_s.should set_cell(2, 0,'2')
|
82
|
-
@chart.data_table.to_s.should set_cell(3, 0,'3')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe 'should receive options' do
|
87
|
-
before(:each) do
|
88
|
-
data_series = Array.new(3) {|i| [[i, i+1], [i+1, i+2]]}
|
89
|
-
@options = {
|
90
|
-
:data => [0,1,2,3],
|
91
|
-
:series_label => 'to_s',
|
92
|
-
:data_series => data_series,
|
93
|
-
:data_label => 'first',
|
94
|
-
:data_method => 'size',
|
95
|
-
:chart_options => {},
|
96
|
-
:chart_element => 'chart'
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should receive :is_stacked option' do
|
101
|
-
create_chart_with_option(:is_stacked => true).to_js.should =~ /options\['isStacked'\] = true/
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def create_chart_with_option(option)
|
107
|
-
Seer::AreaChart.new(@options.merge(option))
|
108
|
-
end
|
data/spec/bar_chart_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::BarChart" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::BarChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:label_method => 'to_s',
|
9
|
-
:data_method => 'size',
|
10
|
-
:chart_options => {},
|
11
|
-
:chart_element => 'chart'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'defaults' do
|
16
|
-
it_should_behave_like 'it sets default values'
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'graph options' do
|
20
|
-
|
21
|
-
[:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :is_3_d, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :log_scale, :max, :min, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width].each do |accessor|
|
22
|
-
it "sets its #{accessor} value" do
|
23
|
-
@chart.send("#{accessor}=", 'foo')
|
24
|
-
@chart.send(accessor).should == 'foo'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like 'it has colors attribute'
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'renders as JavaScript' do
|
32
|
-
(@chart.to_js =~ /javascript/).should be_true
|
33
|
-
(@chart.to_js =~ /barchart/).should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'sets its data columns' do
|
37
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'sets its data table' do
|
41
|
-
@chart.data_table.to_s.should set_value(0, 0,'0')
|
42
|
-
@chart.data_table.to_s.should set_value(0, 1, 8)
|
43
|
-
@chart.data_table.to_s.should set_value(1, 0,'1')
|
44
|
-
@chart.data_table.to_s.should set_value(1, 1, 8)
|
45
|
-
@chart.data_table.to_s.should set_value(2, 0,'2')
|
46
|
-
@chart.data_table.to_s.should set_value(2, 1, 8)
|
47
|
-
@chart.data_table.to_s.should set_value(3, 0,'3')
|
48
|
-
@chart.data_table.to_s.should set_value(3, 1, 8)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/chart_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::Chart" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@chart = Seer::AreaChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:series_label => 'to_s',
|
9
|
-
:data_series => [[1,2,3],[3,4,5]],
|
10
|
-
:data_label => 'to_s',
|
11
|
-
:data_method => 'size',
|
12
|
-
:chart_options => {
|
13
|
-
:legend => 'right',
|
14
|
-
:title_x => 'Something'
|
15
|
-
},
|
16
|
-
:chart_element => 'chart'
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets the chart element' do
|
21
|
-
@chart.in_element = 'foo'
|
22
|
-
@chart.chart_element.should == 'foo'
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'sets colors' do
|
26
|
-
|
27
|
-
it 'accepting valid values' do
|
28
|
-
@chart.colors = ["#ff0000", "#00ff00"]
|
29
|
-
@chart.colors.should == ["#ff0000", "#00ff00"]
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'raising an error on invalid values' do
|
33
|
-
lambda do
|
34
|
-
@chart.colors = 'fred'
|
35
|
-
end.should raise_error(ArgumentError)
|
36
|
-
lambda do
|
37
|
-
@chart.colors = [0,1,2]
|
38
|
-
end.should raise_error(ArgumentError)
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'formats colors' do
|
44
|
-
@chart.colors = ["#ff0000"]
|
45
|
-
@chart.formatted_colors.should == "['ff0000']"
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'sets its data columns' do
|
49
|
-
@chart.data_columns.should =~ /addRows\(5\)/
|
50
|
-
@chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
|
51
|
-
@chart.data_columns.should =~ /addColumn\('number', '0'\)/
|
52
|
-
@chart.data_columns.should =~ /addColumn\('number', '1'\)/
|
53
|
-
@chart.data_columns.should =~ /addColumn\('number', '2'\)/
|
54
|
-
@chart.data_columns.should =~ /addColumn\('number', '3'\)/
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'sets its options' do
|
58
|
-
@chart.options.should =~ /options\['titleX'\] = 'Something'/
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
end
|
data/spec/column_chart_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::ColumnChart" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::ColumnChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:label_method => 'to_s',
|
9
|
-
:data_method => 'size',
|
10
|
-
:chart_options => {},
|
11
|
-
:chart_element => 'chart'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'defaults' do
|
16
|
-
it_should_behave_like 'it sets default values'
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'graph options' do
|
20
|
-
|
21
|
-
[:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :is_3_d, :is_stacked, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :log_scale, :max, :min, :reverse_axis, :show_categories, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width].each do |accessor|
|
22
|
-
it "sets its #{accessor} value" do
|
23
|
-
@chart.send("#{accessor}=", 'foo')
|
24
|
-
@chart.send(accessor).should == 'foo'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like 'it has colors attribute'
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'renders as JavaScript' do
|
32
|
-
(@chart.to_js =~ /javascript/).should be_true
|
33
|
-
(@chart.to_js =~ /columnchart/).should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'sets its data columns' do
|
37
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'sets its data table' do
|
41
|
-
@chart.data_table.to_s.should set_value(0, 0,'0')
|
42
|
-
@chart.data_table.to_s.should set_value(0, 1, 8)
|
43
|
-
@chart.data_table.to_s.should set_value(1, 0,'1')
|
44
|
-
@chart.data_table.to_s.should set_value(1, 1, 8)
|
45
|
-
@chart.data_table.to_s.should set_value(2, 0,'2')
|
46
|
-
@chart.data_table.to_s.should set_value(2, 1, 8)
|
47
|
-
@chart.data_table.to_s.should set_value(3, 0,'3')
|
48
|
-
@chart.data_table.to_s.should set_value(3, 1, 8)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/custom_matchers.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module CustomMatcher
|
2
|
-
def set_cell(row, column, value)
|
3
|
-
value = "'#{value}'" if value.is_a?(String)
|
4
|
-
|
5
|
-
simple_matcher("setCell(#{row}, #{column}, #{value})") do |actual|
|
6
|
-
actual =~ /data\.setCell\(#{row},\s*#{column},\s*#{value}\)/
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_value(row, column, value)
|
11
|
-
value = "'#{value}'" if value.is_a?(String)
|
12
|
-
|
13
|
-
simple_matcher("setValue(#{row}, #{column}, #{value})") do |actual|
|
14
|
-
actual =~ /data\.setValue\(#{row},\s*#{column},\s*#{value}\)/
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_column(column_type, value)
|
19
|
-
simple_matcher("addColumn('#{column_type}', '#{value}')") do |actual|
|
20
|
-
actual =~ /data\.addColumn\('#{column_type}',\s*'#{value}'\)/
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/gauge_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::Gauge" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::Gauge.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:label_method => 'to_s',
|
9
|
-
:data_method => 'size',
|
10
|
-
:chart_options => {},
|
11
|
-
:chart_element => 'chart'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'defaults' do
|
16
|
-
|
17
|
-
it 'height' do
|
18
|
-
@chart.height.should == Seer::Chart::DEFAULT_HEIGHT
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'width' do
|
22
|
-
@chart.width.should == Seer::Chart::DEFAULT_WIDTH
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'graph options' do
|
28
|
-
|
29
|
-
[:green_from, :green_to, :height, :major_ticks, :max, :min, :minor_ticks, :red_from, :red_to, :width, :yellow_from, :yellow_to].each do |accessor|
|
30
|
-
it "sets its #{accessor} value" do
|
31
|
-
@chart.send("#{accessor}=", 'foo')
|
32
|
-
@chart.send(accessor).should == 'foo'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it_should_behave_like 'it has colors attribute'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'renders as JavaScript' do
|
40
|
-
(@chart.to_js =~ /javascript/).should be_true
|
41
|
-
(@chart.to_js =~ /gauge/).should be_true
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'sets its data columns' do
|
45
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'sets its data table' do
|
49
|
-
@chart.data_table.to_s.should set_value(0, 0,'0')
|
50
|
-
@chart.data_table.to_s.should set_value(0, 1, 8)
|
51
|
-
@chart.data_table.to_s.should set_value(1, 0,'1')
|
52
|
-
@chart.data_table.to_s.should set_value(1, 1, 8)
|
53
|
-
@chart.data_table.to_s.should set_value(2, 0,'2')
|
54
|
-
@chart.data_table.to_s.should set_value(2, 1, 8)
|
55
|
-
@chart.data_table.to_s.should set_value(3, 0,'3')
|
56
|
-
@chart.data_table.to_s.should set_value(3, 1, 8)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
data/spec/geomap_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::Geomap" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
|
7
|
-
class GeoThing
|
8
|
-
def initialize; end
|
9
|
-
def name; 'foo'; end
|
10
|
-
def latitude; -90; end
|
11
|
-
def longitude; -90; end
|
12
|
-
def count; 8; end
|
13
|
-
def geocoded?; true; end
|
14
|
-
end
|
15
|
-
|
16
|
-
@chart = Seer::Geomap.new(
|
17
|
-
:data => [GeoThing.new, GeoThing.new, GeoThing.new],
|
18
|
-
:label_method => 'name',
|
19
|
-
:data_method => 'count',
|
20
|
-
:chart_options => {},
|
21
|
-
:chart_element => 'geochart'
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'defaults' do
|
26
|
-
|
27
|
-
it 'height' do
|
28
|
-
@chart.height.should == Seer::Chart::DEFAULT_HEIGHT
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'width' do
|
32
|
-
@chart.width.should == Seer::Chart::DEFAULT_WIDTH
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'graph options' do
|
38
|
-
|
39
|
-
[:show_zoom_out, :zoom_out_label].each do |accessor|
|
40
|
-
it "sets its #{accessor} value" do
|
41
|
-
@chart.send("#{accessor}=", 'foo')
|
42
|
-
@chart.send(accessor).should == 'foo'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it_should_behave_like 'it has colors attribute'
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'renders as JavaScript' do
|
50
|
-
(@chart.to_js =~ /javascript/).should be_true
|
51
|
-
(@chart.to_js =~ /geomap/).should be_true
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'sets its data columns' do
|
55
|
-
@chart.data_columns.should =~ /addRows\(3\)/
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'sets its data table' do
|
59
|
-
@chart.data_table.to_s.should set_value(0, 0,'foo')
|
60
|
-
@chart.data_table.to_s.should set_value(0, 1, 8)
|
61
|
-
@chart.data_table.to_s.should set_value(1, 0,'foo')
|
62
|
-
@chart.data_table.to_s.should set_value(1, 1, 8)
|
63
|
-
@chart.data_table.to_s.should set_value(2, 0,'foo')
|
64
|
-
@chart.data_table.to_s.should set_value(2, 1, 8)
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
data/spec/helpers.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
describe "it has colors attribute", :shared => true do
|
2
|
-
it 'sets its colors value' do
|
3
|
-
color_list = ['#7e7587','#990000','#009900', '#3e5643', '#660000', '#003300']
|
4
|
-
@chart.colors = color_list
|
5
|
-
@chart.colors.should == color_list
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'colors should be an array' do
|
9
|
-
lambda {
|
10
|
-
@chart.colors = '#000000'
|
11
|
-
}.should raise_error(ArgumentError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'colors should be valid hex values' do
|
15
|
-
lambda {
|
16
|
-
@chart.colors = ['#000000', 'NOTHEX']
|
17
|
-
}.should raise_error(ArgumentError)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "it sets default values", :shared => true do
|
22
|
-
it 'colors' do
|
23
|
-
@chart.colors.should == Seer::Chart::DEFAULT_COLORS
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'legend' do
|
27
|
-
@chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'height' do
|
31
|
-
@chart.height.should == Seer::Chart::DEFAULT_HEIGHT
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'width' do
|
35
|
-
@chart.width.should == Seer::Chart::DEFAULT_WIDTH
|
36
|
-
end
|
37
|
-
end
|
data/spec/line_chart_spec.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::LineChart" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::LineChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:series_label => 'to_s',
|
9
|
-
:data_series => [[1,2,3],[3,4,5]],
|
10
|
-
:data_label => 'to_s',
|
11
|
-
:data_method => 'size',
|
12
|
-
:chart_options => {},
|
13
|
-
:chart_element => 'chart'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'defaults' do
|
18
|
-
it_should_behave_like 'it sets default values'
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'graph options' do
|
22
|
-
|
23
|
-
[:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :line_size, :log_scale, :max, :min, :point_size, :reverse_axis, :show_categories, :smooth_line, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :number, :tooltip_width, :width].each do |accessor|
|
24
|
-
it "sets its #{accessor} value" do
|
25
|
-
@chart.send("#{accessor}=", 'foo')
|
26
|
-
@chart.send(accessor).should == 'foo'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it_should_behave_like 'it has colors attribute'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'renders as JavaScript' do
|
34
|
-
(@chart.to_js =~ /javascript/).should be_true
|
35
|
-
(@chart.to_js =~ /linechart/).should be_true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'sets its data columns' do
|
39
|
-
@chart.data_columns.should =~ /addRows\(5\)/
|
40
|
-
@chart.data_columns.should add_column('string', 'Date')
|
41
|
-
@chart.data_columns.should add_column('number', '0')
|
42
|
-
@chart.data_columns.should add_column('number', '1')
|
43
|
-
@chart.data_columns.should add_column('number', '2')
|
44
|
-
@chart.data_columns.should add_column('number', '3')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'sets its data table' do
|
48
|
-
@chart.data_table.to_s.should set_cell(0, 0,'1')
|
49
|
-
@chart.data_table.to_s.should set_cell(1, 0,'2')
|
50
|
-
@chart.data_table.to_s.should set_cell(2, 0,'3')
|
51
|
-
@chart.data_table.to_s.should set_cell(3, 0,'4')
|
52
|
-
@chart.data_table.to_s.should set_cell(4, 0,'5')
|
53
|
-
@chart.data_table.to_s.should set_cell(0,1,8)
|
54
|
-
@chart.data_table.to_s.should set_cell(2,1,8)
|
55
|
-
@chart.data_table.to_s.should set_cell(0,2,8)
|
56
|
-
@chart.data_table.to_s.should set_cell(1,2,8)
|
57
|
-
@chart.data_table.to_s.should set_cell(2,2,8)
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'when data_series is an array of arrays of arrays/hashes' do
|
61
|
-
before(:each) do
|
62
|
-
data_series = Array.new(3) {|i| [[i, i+1], [i+1, i+2]]}
|
63
|
-
@chart = Seer::LineChart.new(
|
64
|
-
:data => [0,1,2,3],
|
65
|
-
:series_label => 'to_s',
|
66
|
-
:data_series => data_series,
|
67
|
-
:data_label => 'first',
|
68
|
-
:data_method => 'size',
|
69
|
-
:chart_options => {},
|
70
|
-
:chart_element => 'chart'
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'calculates number of rows' do
|
75
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'sets its data table' do
|
79
|
-
@chart.data_table.to_s.should set_cell(0, 0,'0')
|
80
|
-
@chart.data_table.to_s.should set_cell(1, 0,'1')
|
81
|
-
@chart.data_table.to_s.should set_cell(2, 0,'2')
|
82
|
-
@chart.data_table.to_s.should set_cell(3, 0,'3')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
data/spec/pie_chart_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "Seer::PieChart" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@chart = Seer::PieChart.new(
|
7
|
-
:data => [0,1,2,3],
|
8
|
-
:label_method => 'to_s',
|
9
|
-
:data_method => 'size',
|
10
|
-
:chart_options => {},
|
11
|
-
:chart_element => 'chart'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'defaults' do
|
16
|
-
it_should_behave_like 'it sets default values'
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'graph options' do
|
20
|
-
|
21
|
-
[:background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :is_3_d, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :pie_join_angle, :pie_minimal_angle, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width].each do |accessor|
|
22
|
-
it "sets its #{accessor} value" do
|
23
|
-
@chart.send("#{accessor}=", 'foo')
|
24
|
-
@chart.send(accessor).should == 'foo'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like 'it has colors attribute'
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'renders as JavaScript' do
|
32
|
-
(@chart.to_js =~ /javascript/).should be_true
|
33
|
-
(@chart.to_js =~ /piechart/).should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'sets its data columns' do
|
37
|
-
@chart.data_columns.should =~ /addRows\(4\)/
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'sets its data table' do
|
41
|
-
@chart.data_table.to_s.should set_value(0, 0,'0')
|
42
|
-
@chart.data_table.to_s.should set_value(0, 1, 8)
|
43
|
-
@chart.data_table.to_s.should set_value(1, 0,'1')
|
44
|
-
@chart.data_table.to_s.should set_value(1, 1, 8)
|
45
|
-
@chart.data_table.to_s.should set_value(2, 0,'2')
|
46
|
-
@chart.data_table.to_s.should set_value(2, 1, 8)
|
47
|
-
@chart.data_table.to_s.should set_value(3, 0,'3')
|
48
|
-
@chart.data_table.to_s.should set_value(3, 1, 8)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|