gerbilcharts 0.5.9 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/{License.txt → LICENSE.txt} +0 -0
  2. data/{README.txt → README.rdoc} +0 -0
  3. data/lib/gerbilcharts/charts.rb +2 -0
  4. data/lib/gerbilcharts/charts/chart_base.rb +1 -1
  5. data/lib/gerbilcharts/charts/line_chart_table.rb +38 -0
  6. data/lib/gerbilcharts/charts/stacked_area_chart_table.rb +31 -0
  7. data/lib/gerbilcharts/models/bucketized_timeseries_graph_model.rb +10 -7
  8. data/lib/gerbilcharts/models/graph_model_group.rb +1 -1
  9. data/lib/gerbilcharts/models/presets.rb +2 -2
  10. data/lib/gerbilcharts/models/raw_range.rb +1 -0
  11. data/lib/gerbilcharts/surfaces/area_surface.rb +46 -39
  12. data/lib/gerbilcharts/surfaces/conversation_ring.rb +7 -3
  13. data/lib/gerbilcharts/surfaces/detailed_legend.rb +15 -4
  14. data/lib/gerbilcharts/surfaces/impulse_surface.rb +10 -4
  15. data/lib/gerbilcharts/surfaces/line_surface.rb +31 -34
  16. data/lib/gerbilcharts/surfaces/square_line_surface.rb +27 -30
  17. data/lib/gerbilcharts/surfaces/surface.rb +27 -1
  18. data/lib/gerbilcharts/svgdc/svg_polygon.rb +14 -7
  19. data/lib/gerbilcharts/svgdc/svg_polyline.rb +8 -2
  20. data/lib/gerbilcharts/svgdc/svgdc.rb +8 -0
  21. data/lib/gerbilcharts/version.rb +2 -2
  22. metadata +118 -97
  23. data/History.txt +0 -105
  24. data/Manifest.txt +0 -92
  25. data/PostInstall.txt +0 -2
  26. data/Rakefile +0 -4
  27. data/lib/gerbilcharts/public/brushmetal.css +0 -284
  28. data/lib/gerbilcharts/public/gerbil.js +0 -421
  29. data/setup.rb +0 -1585
  30. data/test/test_Scratch.rb +0 -21
  31. data/test/test_bar.rb +0 -39
  32. data/test/test_bubble.rb +0 -52
  33. data/test/test_charts.rb +0 -122
  34. data/test/test_conversation.rb +0 -34
  35. data/test/test_embed_styles.rb +0 -35
  36. data/test/test_gerbilcharts.rb +0 -11
  37. data/test/test_helper.rb +0 -2
  38. data/test/test_lines.rb +0 -46
  39. data/test/test_matrix.rb +0 -34
  40. data/test/test_models.rb +0 -118
  41. data/test/test_negatives.rb +0 -39
  42. data/test/test_noob.rb +0 -86
  43. data/test/test_pie.rb +0 -43
  44. data/test/test_ranges.rb +0 -169
  45. data/test/test_render_string.rb +0 -38
  46. data/test/test_sa.rb +0 -88
  47. data/test/test_scaling.rb +0 -57
  48. data/test/test_svgdc.rb +0 -221
  49. data/test/trafgen.rb +0 -25
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestLines < Test::Unit::TestCase
4
-
5
- attr_reader :test_vector_tm1
6
- attr_reader :test_vector_tm2
7
- attr_reader :mod1, :mod2, :modbucket1
8
-
9
- def setup
10
- @test_vector_tm3 = []
11
- tbeg = Time.local( 1978, "jun", 5, 9, 10, 0, 0)
12
- sbeg = tbeg
13
- sec_inc = 50
14
-
15
- range = (-7000..+4000)
16
- for i in (0..20)
17
- @test_vector_tm3 << [sbeg + i*sec_inc, range.min + range.count * rand() ]
18
- end
19
-
20
-
21
- @mod3 = GerbilCharts::Models::TimeSeriesGraphModel.new("udldev Print Server")
22
- @mod3.add_tuples @test_vector_tm3
23
-
24
- @modgroup = GerbilCharts::Models::GraphModelGroup.new("Hosts")
25
- @modgroup.add(@mod3)
26
-
27
- end
28
-
29
- # test a line chart
30
- def test_line_1
31
-
32
- mychart = GerbilCharts::Charts::AreaChart.new( :width => 350, :height => 200, :style => 'inline:brushmetal.css',
33
- :enabletimetracker => true )
34
- mychart.setmodelgroup(@modgroup)
35
- mychart.render('/tmp/neg_linechart1.svg')
36
-
37
- end
38
-
39
- end
@@ -1,86 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require './trafgen'
4
-
5
- # tests some easy to use mods
6
- # newbies enter here
7
- class TestChartsNoob < Test::Unit::TestCase
8
-
9
-
10
- # test sales figures of 3 sales people
11
- # use a simple timeseries model
12
- def test_monthly_sales
13
-
14
- mychart = GerbilCharts::Charts::SquareLineChart.new( :width => 350, :height => 200, :style => 'inline:brushmetal.css',
15
- :circle_data_points => true, :scaling_y => :auto,
16
- :javascripts => ['/tmp/gerbil.js','/tmp/prototype.js'] )
17
-
18
- modelgroup = GerbilCharts::Models::SimpleTimeSeriesModelGroup.new(
19
- :title => "Sales figures",
20
- :timeseries => (1..6).collect { |month| Time.local(2008,month) },
21
- :models => [ ["Bruce", 1, 10, 18, 28, 80, 122],
22
- ["Rex" , 112,22, 45, 70, 218, 309],
23
- ["Buzo" , 0, 23, 25, 40, 18, 59]
24
- ]
25
- )
26
-
27
- mychart.modelgroup=modelgroup
28
-
29
- mychart.render('/tmp/n_monthly_sales.svg')
30
-
31
- end
32
-
33
- # test daily traffic
34
- def test_daily_traf_1
35
-
36
- mychart = GerbilCharts::Charts::ImpulseChart.new( :width => 450, :height => 200, :style => 'brushmetal.css')
37
-
38
- tend = Time.now
39
- tbegin = tend - 3600*24
40
-
41
- model1 = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new( "eth0", 3600 )
42
- TimeSeriesDataGenerator.new(tbegin,tend,300,200000, 6000000).each_tuple do |t,v|
43
- model1.add(t,v)
44
- end
45
-
46
- model2 = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new( "wan1", 3600 )
47
- TimeSeriesDataGenerator.new(tbegin,tend,300,200000, 6000000).each_tuple do |t,v|
48
- model2.add(t,v)
49
- end
50
-
51
- modelgroup = GerbilCharts::Models::GraphModelGroup.new( "External Traffic")
52
- modelgroup.add model2
53
- # modelgroup.add model1
54
-
55
- mychart.modelgroup=modelgroup
56
- mychart.render('/tmp/n_daily_traffic.svg')
57
-
58
- # demo resuses the model in a different view (an area chart this time)
59
- myareachart = GerbilCharts::Charts::AreaChart.new( :width => 450, :height => 200, :style => 'inline:brushmetal.css',
60
- :scaling_y => :auto, :auto_tooltips => true ,
61
- :javascripts => ['/tmp/gerbil.js' , '/tmp/prototype.js' ],
62
- :filter => 'LikeButton' )
63
- myareachart.modelgroup=modelgroup
64
- myareachart.render('/tmp/n_daily_traffic_area.svg')
65
-
66
- # demo to reuse the model ina bar
67
- mybarchart = GerbilCharts::Charts::BarChart.new( :width => 450, :height => 200, :style => 'brushmetal.css', :auto_tooltips => true)
68
- mybarchart.modelgroup=modelgroup
69
- mybarchart.render('/tmp/n_daily_traffic_bar.svg')
70
-
71
-
72
- # demo stacked area
73
- mysachart = GerbilCharts::Charts::StackedAreaChart.new( :width => 450, :height => 200, :style => 'inline:brushmetal.css',
74
- :scaling_y => :auto, :auto_tooltips => true ,
75
- :javascripts => ['/tmp/gerbil.js' , '/tmp/prototype.js' ])
76
- mysachart.modelgroup=modelgroup
77
- mysachart.render('/tmp/n_daily_traffic_sa.svg')
78
-
79
-
80
- end
81
-
82
-
83
-
84
- end
85
-
86
-
@@ -1,43 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require 'trafgen'
4
-
5
- # test pie chart
6
- class TestPie < Test::Unit::TestCase
7
-
8
-
9
- # test sales figures of 3 sales people
10
- # show in a pie chart
11
- def test_monthly_sales
12
-
13
-
14
- modelgroup = GerbilCharts::Models::SimpleTimeSeriesModelGroup.new(
15
- :title => "Sales figures",
16
- :timeseries => (1..6).collect { |month| Time.local(2008,month) },
17
- :models => [ ["Bruce", 1, 10, 18, 28, 80, 1340.7890]
18
- #["Rex" , 112,22, 45, 70, 218, 3098.98]
19
- # ["Sharmila", 112,22, 45, 70, 218, 245]
20
- #["Wasim", 112,22, 45, 70, 218, 145],
21
- # ["Buzo" , 0, 23, 25, 40, 18, 59],
22
- #["Vipin", 145,112, 22, 45, 18, 70],
23
- # ["label", 145,112, 22, 45, 18, 240],
24
- # ["9th item ", 145,112, 22, 45, 18, 45],
25
- # ["Others ", 145,112, 22, 45, 18, 15],
26
- # ["VIVEK", 145,112, 22, 45, 18, 170]
27
- ]
28
- )
29
-
30
- mychart = GerbilCharts::Charts::PieChart.new( :width => 350, :height => 200,
31
- :style => 'inline:brushmetal.css', :auto_tooltips => true ,
32
- :javascripts => ['/tmp/gerbil.js' , '/tmp/prototype.js' ],
33
- :filter => 'LikeButton'
34
- )
35
- mychart.modelgroup=modelgroup
36
- mychart.render("/tmp/pie_monthly_sales.svg")
37
- end
38
-
39
-
40
-
41
- end
42
-
43
-
@@ -1,169 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestRanges < Test::Unit::TestCase
4
-
5
- def setup
6
- # test vector
7
- @tvector = []
8
- @tvector << [ Time.local(1973,"Apr",2,8,30,0), 0 ]
9
- @tvector << [ Time.local(1973,"Apr",2,8,30,10), 0.5 ]
10
- @tvector << [ Time.local(1973,"Apr",2,8,30,11), 18 ]
11
- @tvector << [ Time.local(1973,"Apr",2,8,30,15), 911 ]
12
- @tvector << [ Time.local(1973,"Apr",2,8,30,18), 100 ]
13
- @tvector << [ Time.local(1973,"Apr",2,8,30,19), 80 ]
14
- @tvector << [ Time.local(1973,"Apr",2,8,30,20), 98 ]
15
- @tvector << [ Time.local(1973,"Apr",2,8,30,45), 1002 ]
16
- @tvector << [ Time.local(1973,"Apr",2,8,30,58), 3014 ]
17
- @tvector << [ Time.local(1973,"Apr",2,8,31,0), 1002 ]
18
- @tvector << [ Time.local(1973,"Apr",2,8,32,0), 88 ]
19
- @tvector << [ Time.local(1973,"Apr",2,8,32,20), 882]
20
- @tvector << [ Time.local(1973,"Apr",2,8,32,21), 3015 ]
21
- @tvector << [ Time.local(1973,"Apr",2,8,36,0), 10 ]
22
- @tvector << [ Time.local(1973,"Apr",2,8,46,0), 1 ]
23
- @tvector << [ Time.local(1973,"Apr",2,8,47,0), 2 ]
24
- @tvector << [ Time.local(1973,"Apr",2,8,47,1), 3 ]
25
- @tvector << [ Time.local(1973,"Apr",2,8,47,5), 4 ]
26
- @tvector << [ Time.local(1973,"Apr",2,8,50,0), 59 ]
27
- @tvector << [ Time.local(1973,"Apr",2,8,58,0), 188 ]
28
- @tvector << [ Time.local(1973,"Apr",2,9,00,17), 4017 ]
29
- @tvector << [ Time.local(1973,"Apr",2,9,20,18), 18 ]
30
- @tvector << [ Time.local(1973,"Apr",2,9,40,20), 10 ]
31
- @tvector << [ Time.local(1973,"Apr",2,10,13,7), 100 ]
32
- @tvector << [ Time.local(1973,"Apr",2,10,14,7), 100 ]
33
- @tvector << [ Time.local(1973,"Apr",2,10,15,7), 100 ]
34
- @tvector << [ Time.local(1973,"Apr",2,10,17,7), 100 ]
35
-
36
- end
37
-
38
- # test raw range - simple version
39
- def test_raw_range_1
40
- r = GerbilCharts::Models::RawRange.new
41
-
42
- [10,20,10,0,0,1001,19920,882991.22].each do |v|
43
- r.update v
44
- end
45
-
46
- r.min_max do |mn,mx|
47
- assert mn==0
48
- assert mx==882991.22
49
- end
50
- end
51
-
52
- # test - various methods
53
- def test_raw_range_2
54
- r = GerbilCharts::Models::RawRange.new
55
- [10,20,10,0,0,1001,19920,20001].each do |v|
56
- r.update v
57
- end
58
-
59
- # update from another range
60
- r2 = GerbilCharts::Models::RawRange.new
61
- r2.update(-10)
62
- r2.update 20002
63
- r.update_r r2
64
-
65
- # check if updated correctly
66
- assert r.rmax == 20002
67
- assert r.rmin == -10
68
-
69
- # check scaling
70
- fv = r.scale_factor(20002)
71
- assert_in_delta(fv,1,0.001)
72
- fv = r.scale_factor(10000)
73
- assert_in_delta(fv,0.5,0.001)
74
-
75
- # check if reset works
76
- r.reset
77
- assert_nil(r.rmax)
78
- assert_nil(r.rmin)
79
- end
80
-
81
- # test round range
82
- def test_round_range_1
83
- r = GerbilCharts::Models::RawRange.new
84
- [10,20,10,0,0,1001,19920,20001].each do |v|
85
- r.update v
86
- end
87
-
88
- rr = GerbilCharts::Models::RoundRange.new(r)
89
- assert_equal(rr.rmax,50000)
90
- assert_equal(rr.rmin,0)
91
- assert_equal(rr.lmax,10000,"checking ideal label interval")
92
-
93
- r.update(50001)
94
- rr = GerbilCharts::Models::RoundRange.new(r)
95
- assert_equal(rr.rmax,100000)
96
- assert_equal(rr.lmax,25000,"checking ideal label interval for a 100K interval")
97
-
98
- end
99
-
100
- # test time hours
101
- def test_round_time_range_1
102
- r = GerbilCharts::Models::RawRange.new
103
- tbase = Time.local(1973,"Apr",2,8,30,0)
104
-
105
- @tvector.each do |t|
106
- r.update t[0]
107
- end
108
-
109
- rr = GerbilCharts::Models::RoundTimeRange.new(r)
110
- rr.each_label do |v,s|
111
- # p "v = #{v} s=#{s}"
112
- end
113
- assert_equal(rr.rdelta,7200) # 3 hr range
114
- assert_equal(rr.ldelta,1800) # label every 30 mins
115
-
116
- # add a 4 hr gap (9hr range + 2 hr labels)
117
- r.update( @tvector.last[0] + 4*3600)
118
- rr = GerbilCharts::Models::RoundTimeRange.new(r)
119
- rr.each_label do |v,s|
120
- # p "v = #{v} s=#{s}"
121
- end
122
- assert_equal(rr.rdelta,6*3600)
123
- assert_equal(rr.ldelta,2*3600)
124
-
125
- # add a new 10hr gap
126
- r.update( @tvector.last[0] + 10*3600)
127
- rr = GerbilCharts::Models::RoundTimeRange.new(r)
128
- rr.each_label do |v,s|
129
- # p "v = #{v} s=#{s}"
130
- end
131
- assert_equal(rr.rdelta,43200)
132
- assert_equal(rr.ldelta,10800)
133
- end
134
-
135
- def test_negative_range
136
-
137
- r = GerbilCharts::Models::RawRange.new
138
- [-11000,19920,20001].each do |v|
139
- r.update v
140
- end
141
-
142
- rr = GerbilCharts::Models::RoundRange.new(r)
143
- assert_equal(rr.rmax,50000)
144
- assert_equal(rr.rmin,-20000)
145
- assert_equal(rr.lmax,25000,"checking ideal label interval")
146
-
147
- r.update(-18000)
148
- rr = GerbilCharts::Models::RoundRange.new(r)
149
- assert_equal(rr.lmax,25000,"checking ideal label interval for a 100K interval")
150
-
151
- end
152
-
153
- def test_long_time_range
154
-
155
- r = GerbilCharts::Models::RawRange.new
156
- tbase = Time.local(1973,"Apr",2,8,30,0)
157
- r.update tbase
158
- r.update(tbase+100000)
159
-
160
- rr = GerbilCharts::Models::RoundTimeRange.new(r)
161
-
162
- rr.each_label do |v,s|
163
- p "v = #{v} s=#{s}"
164
- end
165
-
166
- end
167
-
168
-
169
- end
@@ -1,38 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require 'trafgen'
4
-
5
- # test if render to string works correctly
6
- class TestRenderString < Test::Unit::TestCase
7
-
8
-
9
- # test sales figures of 3 sales people
10
- # use a simple timeseries model
11
- # output to string finally
12
- def test_string_render
13
-
14
- mychart = GerbilCharts::Charts::LineChart.new( :width => 350, :height => 200, :style => 'brushmetal.css',
15
- :circle_data_points => true )
16
-
17
- modelgroup = GerbilCharts::Models::SimpleTimeSeriesModelGroup.new(
18
- :title => "Sales figures",
19
- :timeseries => (1..6).collect { |month| Time.local(2008,month) },
20
- :models => [ ["Bruce", 1, 10, 18, 28, 80, 122],
21
- ["Rex" , 112,22, 45, 70, 218, 309],
22
- ["Buzo" , 0, 23, 25, 40, 18, 59]
23
- ]
24
- )
25
-
26
- mychart.modelgroup=modelgroup
27
-
28
- strout = mychart.render_string
29
-
30
- # a large enough string (basic test a large enough string generated)
31
- assert strout.size > 1000
32
-
33
- # the string SVG is present in the out (very basic test)
34
- assert strout.match("SVG")
35
- end
36
-
37
- end
38
-
@@ -1,88 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require './trafgen'
4
-
5
- # tests some easy to use mods
6
- # newbies enter here
7
- class TestChartsNoob < Test::Unit::TestCase
8
-
9
- def setup
10
-
11
- @test_vectors = {
12
- "eth0"=> [100, 200, 4000,4001, 2001, 2999,8000, 19000,38000,3173000, 78000,1200,1000010] ,
13
- "wlan0"=> [600,1200,84000,14001,22001,2209,48000,1900, 3800, 873000,478000,1121200,4000010] ,
14
- }
15
-
16
- @tbegin = Time.local( 1978, "jun", 5, 9, 10, 0, 0)
17
- @tend = @tbegin + 10000 # for more than 1 hour
18
- #@tend = @tbegin + 4000 # for more than 1 hour
19
- #@tend = @tbegin + 22*86400 # for more than 1 hour
20
- end
21
-
22
- def mk_models1
23
- modelarr = []
24
- @test_vectors.each_pair do |k,v|
25
- tb = @tbegin.clone
26
- mod = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new( k, 300 )
27
- v.each do | val |
28
- mod.add(tb,val)
29
- tb = tb + 300
30
- end
31
- modelarr << mod
32
- end
33
- modelarr
34
- end
35
-
36
- def mk_models2
37
-
38
- # between 200K and 6M
39
- %w(eth0 eth1 eth2 wlan0 wlan1 br0:1 bridge0:2).collect do |n|
40
- mk_mod(n,200000,6000000)
41
- end
42
-
43
- end
44
-
45
- def mk_mod(name,min,max)
46
- model1 = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new(name, 300 )
47
- TimeSeriesDataGenerator.new(@tbegin,@tend,300,min, max).each_tuple do |t,v|
48
- model1.add(t,v)
49
- end
50
- return model1
51
- end
52
-
53
-
54
-
55
- # test daily traffic
56
- def test_daily_traf_1
57
-
58
-
59
- modelarr = []
60
- #modelarr = mk_models2
61
- modelarr << mk_mod("fixed-11",11000000,11000000)
62
- modelarr << mk_mod("fixed-3", 3000000, 3000000)
63
-
64
- refmod = mk_mod("ref", 60000000, 75000000)
65
-
66
- # modelgroup
67
- modelgroup = GerbilCharts::Models::GraphModelGroup.new( "External Traffic")
68
- modelarr.each { |m| modelgroup.add(m) }
69
- #modelgroup.ref_model=refmod
70
-
71
- # stacked area
72
- mysachart = GerbilCharts::Charts::StackedAreaChart.new( :width => 750, :height => 400,
73
- :style => 'inline:brushmetal.css',
74
- :javascripts => ['/tmp/gerbil.js' , '/tmp/prototype.js' ],
75
- :toolhrefs => [ ["View Trends", "/trends"],
76
- ["Retro analysis", "/retro"],
77
- ] )
78
- mysachart.modelgroup=modelgroup
79
- mysachart.render('/tmp/n_daily_traffic_sa.svg')
80
-
81
-
82
- end
83
-
84
-
85
-
86
- end
87
-
88
-