seer 0.4.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.
@@ -0,0 +1,73 @@
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
+
19
+ it 'colors' do
20
+ @chart.colors.should == Seer::Chart::DEFAULT_COLORS
21
+ end
22
+
23
+ it 'legend' do
24
+ @chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
25
+ end
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
+ [:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :colors, :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|
40
+ it "sets its #{accessor} value" do
41
+ @chart.send("#{accessor}=", 'foo')
42
+ @chart.send(accessor).should == 'foo'
43
+ end
44
+ end
45
+ end
46
+
47
+ it 'renders as JavaScript' do
48
+ (@chart.to_js =~ /javascript/).should be_true
49
+ (@chart.to_js =~ /areachart/).should be_true
50
+ end
51
+
52
+ it 'sets its data columns' do
53
+ @chart.data_columns.should =~ /addRows\(3\)/
54
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
55
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
56
+ @chart.data_columns.should =~ /addColumn\('number', '0'\)/
57
+ @chart.data_columns.should =~ /addColumn\('number', '1'\)/
58
+ @chart.data_columns.should =~ /addColumn\('number', '2'\)/
59
+ @chart.data_columns.should =~ /addColumn\('number', '3'\)/
60
+ end
61
+
62
+ it 'sets its data table' do
63
+ @chart.data_table.to_s.should =~ /data\.setCell\(0, 0,'1'\)/
64
+ @chart.data_table.to_s.should =~ /data\.setCell\(1, 0,'2'\)/
65
+ @chart.data_table.to_s.should =~ /data\.setCell\(2, 0,'3'\)/
66
+ @chart.data_table.to_s.should =~ /data\.setCell\(0,1,8\)/
67
+ @chart.data_table.to_s.should =~ /data\.setCell\(2,1,8\)/
68
+ @chart.data_table.to_s.should =~ /data\.setCell\(0,2,8\)/
69
+ @chart.data_table.to_s.should =~ /data\.setCell\(1,2,8\)/
70
+ @chart.data_table.to_s.should =~ /data\.setCell\(2,2,8\)/
71
+ end
72
+
73
+ end
@@ -0,0 +1,65 @@
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
+
17
+ it 'colors' do
18
+ @chart.colors.should == Seer::Chart::DEFAULT_COLORS
19
+ end
20
+
21
+ it 'legend' do
22
+ @chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
23
+ end
24
+
25
+ it 'height' do
26
+ @chart.height.should == Seer::Chart::DEFAULT_HEIGHT
27
+ end
28
+
29
+ it 'width' do
30
+ @chart.width.should == Seer::Chart::DEFAULT_WIDTH
31
+ end
32
+
33
+ end
34
+
35
+ describe 'graph options' do
36
+
37
+ [:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :colors, :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|
38
+ it "sets its #{accessor} value" do
39
+ @chart.send("#{accessor}=", 'foo')
40
+ @chart.send(accessor).should == 'foo'
41
+ end
42
+ end
43
+ end
44
+
45
+ it 'renders as JavaScript' do
46
+ (@chart.to_js =~ /javascript/).should be_true
47
+ (@chart.to_js =~ /barchart/).should be_true
48
+ end
49
+
50
+ it 'sets its data columns' do
51
+ @chart.data_columns.should =~ /addRows\(4\)/
52
+ end
53
+
54
+ it 'sets its data table' do
55
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 0,'0'\)/
56
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 1, 8\)/
57
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 0,'1'\)/
58
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 1, 8\)/
59
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 0,'2'\)/
60
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 1, 8\)/
61
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 0,'3'\)/
62
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 1, 8\)/
63
+ end
64
+
65
+ end
@@ -0,0 +1,63 @@
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\(3\)/
50
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
51
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
52
+ @chart.data_columns.should =~ /addColumn\('number', '0'\)/
53
+ @chart.data_columns.should =~ /addColumn\('number', '1'\)/
54
+ @chart.data_columns.should =~ /addColumn\('number', '2'\)/
55
+ @chart.data_columns.should =~ /addColumn\('number', '3'\)/
56
+ end
57
+
58
+ it 'sets its options' do
59
+ puts @chart.options.should =~ /options\['titleX'\] = 'Something'/
60
+ end
61
+
62
+
63
+ end
@@ -0,0 +1,65 @@
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
+
17
+ it 'colors' do
18
+ @chart.colors.should == Seer::Chart::DEFAULT_COLORS
19
+ end
20
+
21
+ it 'legend' do
22
+ @chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
23
+ end
24
+
25
+ it 'height' do
26
+ @chart.height.should == Seer::Chart::DEFAULT_HEIGHT
27
+ end
28
+
29
+ it 'width' do
30
+ @chart.width.should == Seer::Chart::DEFAULT_WIDTH
31
+ end
32
+
33
+ end
34
+
35
+ describe 'graph options' do
36
+
37
+ [:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :colors, :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|
38
+ it "sets its #{accessor} value" do
39
+ @chart.send("#{accessor}=", 'foo')
40
+ @chart.send(accessor).should == 'foo'
41
+ end
42
+ end
43
+ end
44
+
45
+ it 'renders as JavaScript' do
46
+ (@chart.to_js =~ /javascript/).should be_true
47
+ (@chart.to_js =~ /columnchart/).should be_true
48
+ end
49
+
50
+ it 'sets its data columns' do
51
+ @chart.data_columns.should =~ /addRows\(4\)/
52
+ end
53
+
54
+ it 'sets its data table' do
55
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 0,'0'\)/
56
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 1, 8\)/
57
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 0,'1'\)/
58
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 1, 8\)/
59
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 0,'2'\)/
60
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 1, 8\)/
61
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 0,'3'\)/
62
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 1, 8\)/
63
+ end
64
+
65
+ end
@@ -0,0 +1,57 @@
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
+ end
36
+
37
+ it 'renders as JavaScript' do
38
+ (@chart.to_js =~ /javascript/).should be_true
39
+ (@chart.to_js =~ /gauge/).should be_true
40
+ end
41
+
42
+ it 'sets its data columns' do
43
+ @chart.data_columns.should =~ /addRows\(4\)/
44
+ end
45
+
46
+ it 'sets its data table' do
47
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 0,'0'\)/
48
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 1, 8\)/
49
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 0,'1'\)/
50
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 1, 8\)/
51
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 0,'2'\)/
52
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 1, 8\)/
53
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 0,'3'\)/
54
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 1, 8\)/
55
+ end
56
+
57
+ end
@@ -0,0 +1,73 @@
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
+
19
+ it 'colors' do
20
+ @chart.colors.should == Seer::Chart::DEFAULT_COLORS
21
+ end
22
+
23
+ it 'legend' do
24
+ @chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
25
+ end
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
+ [:axis_color, :axis_background_color, :axis_font_size, :background_color, :border_color, :colors, :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|
40
+ it "sets its #{accessor} value" do
41
+ @chart.send("#{accessor}=", 'foo')
42
+ @chart.send(accessor).should == 'foo'
43
+ end
44
+ end
45
+ end
46
+
47
+ it 'renders as JavaScript' do
48
+ (@chart.to_js =~ /javascript/).should be_true
49
+ (@chart.to_js =~ /linechart/).should be_true
50
+ end
51
+
52
+ it 'sets its data columns' do
53
+ @chart.data_columns.should =~ /addRows\(3\)/
54
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
55
+ @chart.data_columns.should =~ /addColumn\('string', 'Date'\)/
56
+ @chart.data_columns.should =~ /addColumn\('number', '0'\)/
57
+ @chart.data_columns.should =~ /addColumn\('number', '1'\)/
58
+ @chart.data_columns.should =~ /addColumn\('number', '2'\)/
59
+ @chart.data_columns.should =~ /addColumn\('number', '3'\)/
60
+ end
61
+
62
+ it 'sets its data table' do
63
+ @chart.data_table.to_s.should =~ /data\.setCell\(0, 0,'1'\)/
64
+ @chart.data_table.to_s.should =~ /data\.setCell\(1, 0,'2'\)/
65
+ @chart.data_table.to_s.should =~ /data\.setCell\(2, 0,'3'\)/
66
+ @chart.data_table.to_s.should =~ /data\.setCell\(0,1,8\)/
67
+ @chart.data_table.to_s.should =~ /data\.setCell\(2,1,8\)/
68
+ @chart.data_table.to_s.should =~ /data\.setCell\(0,2,8\)/
69
+ @chart.data_table.to_s.should =~ /data\.setCell\(1,2,8\)/
70
+ @chart.data_table.to_s.should =~ /data\.setCell\(2,2,8\)/
71
+ end
72
+
73
+ end
@@ -0,0 +1,65 @@
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
+
17
+ it 'colors' do
18
+ @chart.colors.should == Seer::Chart::DEFAULT_COLORS
19
+ end
20
+
21
+ it 'legend' do
22
+ @chart.legend.should == Seer::Chart::DEFAULT_LEGEND_LOCATION
23
+ end
24
+
25
+ it 'height' do
26
+ @chart.height.should == Seer::Chart::DEFAULT_HEIGHT
27
+ end
28
+
29
+ it 'width' do
30
+ @chart.width.should == Seer::Chart::DEFAULT_WIDTH
31
+ end
32
+
33
+ end
34
+
35
+ describe 'graph options' do
36
+
37
+ [:background_color, :border_color, :colors, :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|
38
+ it "sets its #{accessor} value" do
39
+ @chart.send("#{accessor}=", 'foo')
40
+ @chart.send(accessor).should == 'foo'
41
+ end
42
+ end
43
+ end
44
+
45
+ it 'renders as JavaScript' do
46
+ (@chart.to_js =~ /javascript/).should be_true
47
+ (@chart.to_js =~ /piechart/).should be_true
48
+ end
49
+
50
+ it 'sets its data columns' do
51
+ @chart.data_columns.should =~ /addRows\(4\)/
52
+ end
53
+
54
+ it 'sets its data table' do
55
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 0,'0'\)/
56
+ @chart.data_table.to_s.should =~ /data\.setValue\(0, 1, 8\)/
57
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 0,'1'\)/
58
+ @chart.data_table.to_s.should =~ /data\.setValue\(1, 1, 8\)/
59
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 0,'2'\)/
60
+ @chart.data_table.to_s.should =~ /data\.setValue\(2, 1, 8\)/
61
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 0,'3'\)/
62
+ @chart.data_table.to_s.should =~ /data\.setValue\(3, 1, 8\)/
63
+ end
64
+
65
+ end