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,57 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require 'trafgen'
4
-
5
- # Test scaling options :auto, :auto_0, [min,max]
6
-
7
- class TestChartsScaling < Test::Unit::TestCase
8
-
9
-
10
- # test scaling
11
- def test_scale_1
12
-
13
- tend = Time.now
14
- tbegin = tend - 3600*24
15
-
16
- # random between 2M and 6M
17
- model1 = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new( "eth0", 3600 )
18
- TimeSeriesDataGenerator.new(tbegin,tend,300,2000000, 6000000).each_tuple do |t,v|
19
- model1.add(t,v)
20
- end
21
-
22
- # random between 4M and 10M
23
- model2 = GerbilCharts::Models::BucketizedTimeSeriesGraphModel.new( "wan1", 3600 )
24
- TimeSeriesDataGenerator.new(tbegin,tend,300,4000000, 10000000).each_tuple do |t,v|
25
- model2.add(t,v)
26
- end
27
-
28
- modelgroup = GerbilCharts::Models::GraphModelGroup.new( "External Traffic")
29
- modelgroup.add model2
30
- modelgroup.add model1
31
-
32
-
33
- # area chart with auto scaling
34
- myareachart = GerbilCharts::Charts::AreaChart.new( :width => 450, :height => 200, :style => 'brushmetal.css',
35
- :scaling_y => :auto )
36
- myareachart.modelgroup=modelgroup
37
- myareachart.render('/tmp/n_scale_auto.svg')
38
-
39
- # line chart with auto_0 scaling
40
- myareachart = GerbilCharts::Charts::LineChart.new( :width => 450, :height => 200, :style => 'brushmetal.css',
41
- :scaling_y => :auto_0 )
42
- myareachart.modelgroup=modelgroup
43
- myareachart.render('/tmp/n_scale_auto_0.svg')
44
-
45
- # impulse chart with manual scaling
46
- myareachart = GerbilCharts::Charts::ImpulseChart.new( :width => 450, :height => 200, :style => 'brushmetal.css',
47
- :scaling_y => [2000000,8000000] )
48
- myareachart.modelgroup=modelgroup
49
- myareachart.render('/tmp/n_scale_manual.svg')
50
-
51
- end
52
-
53
-
54
-
55
- end
56
-
57
-
@@ -1,221 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestSVGDC < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def teardown
9
- end
10
-
11
-
12
- # basic test
13
- # a circle, rectangle, save
14
- def test_basic
15
-
16
- g=GerbilCharts::SVGDC::SVGDC.new(300,200)
17
- g.circle(40,50,20)
18
- 1.upto(10) do |w|
19
- g.rectangle(80+w*4,10+w*4,10*w,45)
20
- end
21
- g.render( :file => "/tmp/tbasic1.svg")
22
-
23
- end
24
-
25
-
26
- # with presentation
27
- # select a pen and brush for this DC, all drawing will use it !
28
- def test_presentation
29
-
30
- g=GerbilCharts::SVGDC::SVGDC.new(350,200)
31
-
32
- # will show up clear black
33
- g.rectangle(0,0,50,40)
34
-
35
- g.select_presentation(:pen => GerbilCharts::SVGDC::PPen.new(:color=>"red", :width=>3) )
36
- g.select_presentation(:brush => GerbilCharts::SVGDC::PBrush.new(:color=>"blue") )
37
-
38
- # these will be stroked with new pen and brush selected above
39
- g.rectangle(10,10,300,100)
40
- g.line(200,0,100,200)
41
- g.render( :file => "/tmp/tbasic3.svg")
42
-
43
- end
44
-
45
- # test a polyline
46
- def test_polyline
47
- g=GerbilCharts::SVGDC::SVGDC.new(400,200)
48
-
49
- # will show up clear black
50
- g.rectangle(0,0,400,200)
51
-
52
- # points
53
- g.lineto(10,10)
54
- g.lineto(11,40)
55
- g.lineto(12,80)
56
- g.lineto(80,70)
57
- g.lineto(56,10)
58
- g.lineto(255,80)
59
- g.endline
60
-
61
- # thick and purple
62
- 10.times do
63
- g.lineto( rand * 400, 100 + rand * 100)
64
- end
65
- g.endline( "stroke" => 'purple', 'stroke-width' => 5 )
66
-
67
- g.render( :file => "/tmp/tpolyline1.svg")
68
- end
69
-
70
- # test a polygon
71
- def test_polygon
72
- g=GerbilCharts::SVGDC::SVGDC.new(100,100)
73
-
74
- [ [10,10], [16,19], [45, 70], [80,75], [17,80] ].each do |c|
75
- g.polygon_point(c[0],c[1])
76
- end
77
- g.end_polygon( 'stroke-width' => 4 )
78
- g.render( :file => "/tmp/tpolygon1.svg")
79
-
80
- end
81
-
82
-
83
- # test with a stylesheet
84
- def test_css1
85
- g=GerbilCharts::SVGDC::SVGDC.new(400,500)
86
- g.set_stylesheet "teststyle1.css"
87
- g.rectangle(10,10,100,300, {:class => "surface"})
88
- g.render( :file => "/tmp/tcss1.svg")
89
- end
90
-
91
-
92
- # test with stylesheet and a bunch of transformations
93
- def test_css2
94
-
95
- g=GerbilCharts::SVGDC::SVGDC.new(400,200)
96
- g.set_stylesheet "teststyle1.css"
97
-
98
- # this window is rotated (2.4 radians)
99
- w=g.newwin("rot_1")
100
- w.add_transformation(GerbilCharts::SVGDC::TRotate.new(2.4))
101
- g.setactivewindow(w)
102
- g.rectangle(10,10,300,50, {:class => "surface"})
103
- g.setactivewindow
104
-
105
- # this window is rotated -15 and shifted 25 x 10 y
106
- w=g.newwin("rot_2")
107
- w.add_transformation(GerbilCharts::SVGDC::TRotate.new(-15.0))
108
- w.add_transformation(GerbilCharts::SVGDC::TTranslate.new(25,10))
109
- g.setactivewindow(w)
110
- g.rectangle(0,80,300,50, :fill => 'yellow' )
111
- g.setactivewindow
112
-
113
-
114
- g.render( :file => "/tmp/tcss2.svg")
115
-
116
- end
117
-
118
-
119
- # test subwindows , these show up as group (g) elements in the svg
120
- def test_group2
121
-
122
- g=GerbilCharts::SVGDC::SVGDC.new(400,500)
123
- g.set_stylesheet "teststyle1.css"
124
-
125
- # group 1
126
- w1=g.newwin("xaxisgroup")
127
- w1.add_transformation(GerbilCharts::SVGDC::TRotate.new(1.4))
128
- g.setactivewindow(w1)
129
- g.rectangle(0,0,100,60, {:class => "surface"})
130
- g.setactivewindow
131
-
132
- # group 2
133
- w2=g.newwin("yaxisgroup")
134
- w2.add_transformation(GerbilCharts::SVGDC::TRotate.new(2.4))
135
- w2.add_transformation(GerbilCharts::SVGDC::TTranslate.new(50,10))
136
- g.setactivewindow(w2)
137
- g.rectangle(0,0,100,60, {:class => "surface"})
138
-
139
- g.line(10,10,30,10, {:id => "item1"})
140
- g.setactivewindow
141
-
142
-
143
- g.render( :file => "/tmp/tg2.svg")
144
-
145
-
146
- end
147
-
148
-
149
-
150
- # basic text output
151
- # No stylesheet
152
- def test_text1
153
- g=GerbilCharts::SVGDC::SVGDC.new(800,200)
154
-
155
-
156
- # group wise all textouts will inherit the font family
157
- w1=g.newwin("fixed_font_win", "stroke" => "none", "fill" => "black" , "font-family" => "monospace" )
158
- g.setactivewindow(w1)
159
- g.rectangle(0,0,800,60,'fill' => 'gray')
160
- g.textout(10,15,"Fixed font test 1 (font family = fixed)")
161
- g.textout(10,25,"second line of monospace ")
162
- g.textout(10,40,"third line of monospace font (larger size) ", "font-size" => "14" )
163
- g.setactivewindow(nil)
164
-
165
-
166
- # unknown font ?
167
- w1=g.newwin("lucida_win", "font-face" => "Lucida Console", "font-size" => 18 )
168
- g.setactivewindow(w1)
169
- g.textout(10,80,"Fixed font test 2 hollow (font face = lucida console)")
170
- g.setactivewindow(nil)
171
-
172
-
173
- # directly draw a font (no containing window)
174
- g.textout(10,100,"Directly textout with size 10, red monospace", "font-family" => "monospace", "stroke" => "none", "fill" =>'red' )
175
-
176
- # using the monospace helper
177
- g.textout_monospace(10,120,"Using the monospace helper with defaults" )
178
-
179
- # using the monospace helper (override color and size)
180
- g.textout_monospace(10,140,"Monospace helper blue size 14", "fill" => "blue", "font-size" => "14" )
181
-
182
- g.render( :file => "/tmp/ttxt1.svg")
183
-
184
-
185
- end
186
-
187
-
188
- # text output with a rotation
189
- def test_text1rot
190
-
191
- g=GerbilCharts::SVGDC::SVGDC.new(200,250)
192
- g.set_stylesheet "teststyle1.css"
193
-
194
- # group 1
195
- w1=g.newwin("xaxisgroup")
196
- w1.add_transformation(GerbilCharts::SVGDC::TRotate.new(90.0))
197
- g.setactivewindow(w1)
198
- g.rectangle(0,0,100,60, {:class => "surface"})
199
- g.textout(40,40,"Text rotated +90 degrees ?", {:class => "axislabel"})
200
- g.setactivewindow
201
-
202
- g.render( :file => "/tmp/ttxt1rot.svg")
203
-
204
- end
205
-
206
- # text output with css
207
- def test_text2
208
-
209
- g=GerbilCharts::SVGDC::SVGDC.new(400,500)
210
- g.set_stylesheet "teststyle1.css"
211
-
212
- # group 1
213
- g.rectangle(0,0,100,60, {:class => "surface"})
214
- g.textout(40,40,"Om !", {:class => "axislabel"})
215
- g.textout(40,240,"Host: 192.168.1.1 (18%)", {:class => "axislabel"})
216
-
217
- g.render( :file => "/tmp/ttxtcss.svg")
218
-
219
-
220
- end
221
- end
@@ -1,25 +0,0 @@
1
- # generate time series data for test purposes
2
- class TimeSeriesDataGenerator
3
-
4
- attr_reader :tuples_array
5
-
6
- # allows you to generate controlled random data
7
- def initialize(tm_from, tm_to, avg_resolution_secs, min_val, max_val)
8
- @tuples_array=[]
9
- tm_tmp = tm_from
10
-
11
- while tm_tmp < tm_to
12
- @tuples_array << [ tm_tmp, min_val + (max_val - min_val)*rand ]
13
- tm_tmp = tm_tmp + avg_resolution_secs *( 1 + (rand-0.5)/4)
14
- end
15
- end
16
-
17
- # iterator
18
- def each_tuple
19
- @tuples_array.each do |t,v|
20
- yield t,v
21
- end
22
- end
23
-
24
-
25
- end