gerbilcharts 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/History.txt +11 -0
  2. data/License.txt +21 -0
  3. data/Manifest.txt +75 -0
  4. data/PostInstall.txt +7 -0
  5. data/README.txt +174 -0
  6. data/Rakefile +4 -0
  7. data/lib/gerbilcharts.rb +18 -0
  8. data/lib/gerbilcharts/charts.rb +16 -0
  9. data/lib/gerbilcharts/charts/area_chart.rb +36 -0
  10. data/lib/gerbilcharts/charts/bar_chart.rb +33 -0
  11. data/lib/gerbilcharts/charts/bar_chart_compact.rb +26 -0
  12. data/lib/gerbilcharts/charts/chart_base.rb +123 -0
  13. data/lib/gerbilcharts/charts/impulse_chart.rb +30 -0
  14. data/lib/gerbilcharts/charts/line_chart.rb +35 -0
  15. data/lib/gerbilcharts/charts/stacked_area_chart.rb +31 -0
  16. data/lib/gerbilcharts/models.rb +19 -0
  17. data/lib/gerbilcharts/models/bucketized_timeseries_graph_model.rb +138 -0
  18. data/lib/gerbilcharts/models/discrete_time_range.rb +63 -0
  19. data/lib/gerbilcharts/models/graph_model.rb +89 -0
  20. data/lib/gerbilcharts/models/graph_model_group.rb +240 -0
  21. data/lib/gerbilcharts/models/monotonous_graph_model.rb +192 -0
  22. data/lib/gerbilcharts/models/presets.rb +94 -0
  23. data/lib/gerbilcharts/models/raw_range.rb +68 -0
  24. data/lib/gerbilcharts/models/round_range.rb +104 -0
  25. data/lib/gerbilcharts/models/round_time_range.rb +105 -0
  26. data/lib/gerbilcharts/models/sampled_timeseries_graph_model.rb +80 -0
  27. data/lib/gerbilcharts/models/simple_timeseries_model_group.rb +68 -0
  28. data/lib/gerbilcharts/models/time_series_graph_model.rb +34 -0
  29. data/lib/gerbilcharts/public/brushmetal.css +197 -0
  30. data/lib/gerbilcharts/public/gerbil.js +327 -0
  31. data/lib/gerbilcharts/surfaces.rb +32 -0
  32. data/lib/gerbilcharts/surfaces/area_surface.rb +46 -0
  33. data/lib/gerbilcharts/surfaces/axis.rb +31 -0
  34. data/lib/gerbilcharts/surfaces/bar_surface.rb +62 -0
  35. data/lib/gerbilcharts/surfaces/basic_grid.rb +17 -0
  36. data/lib/gerbilcharts/surfaces/chart.rb +132 -0
  37. data/lib/gerbilcharts/surfaces/graph_element.rb +170 -0
  38. data/lib/gerbilcharts/surfaces/grid.rb +38 -0
  39. data/lib/gerbilcharts/surfaces/horizontal_axis.rb +32 -0
  40. data/lib/gerbilcharts/surfaces/horizontal_name_axis.rb +28 -0
  41. data/lib/gerbilcharts/surfaces/horizontal_time_axis.rb +25 -0
  42. data/lib/gerbilcharts/surfaces/impulse_surface.rb +47 -0
  43. data/lib/gerbilcharts/surfaces/legend.rb +59 -0
  44. data/lib/gerbilcharts/surfaces/line_surface.rb +53 -0
  45. data/lib/gerbilcharts/surfaces/mark_band.rb +17 -0
  46. data/lib/gerbilcharts/surfaces/panel.rb +17 -0
  47. data/lib/gerbilcharts/surfaces/pie_surface.rb +16 -0
  48. data/lib/gerbilcharts/surfaces/rect.rb +86 -0
  49. data/lib/gerbilcharts/surfaces/stacked_area_surface.rb +66 -0
  50. data/lib/gerbilcharts/surfaces/stacked_grid.rb +15 -0
  51. data/lib/gerbilcharts/surfaces/surface.rb +20 -0
  52. data/lib/gerbilcharts/surfaces/surface_background.rb +13 -0
  53. data/lib/gerbilcharts/surfaces/title_panel.rb +44 -0
  54. data/lib/gerbilcharts/surfaces/tracker.rb +62 -0
  55. data/lib/gerbilcharts/surfaces/vertical_axis.rb +46 -0
  56. data/lib/gerbilcharts/svgdc.rb +22 -0
  57. data/lib/gerbilcharts/svgdc/filters.rb +40 -0
  58. data/lib/gerbilcharts/svgdc/presentation_attributes.rb +50 -0
  59. data/lib/gerbilcharts/svgdc/svg_circle.rb +22 -0
  60. data/lib/gerbilcharts/svgdc/svg_custom_win.rb +36 -0
  61. data/lib/gerbilcharts/svgdc/svg_element.rb +87 -0
  62. data/lib/gerbilcharts/svgdc/svg_line.rb +26 -0
  63. data/lib/gerbilcharts/svgdc/svg_polygon.rb +34 -0
  64. data/lib/gerbilcharts/svgdc/svg_polyline.rb +27 -0
  65. data/lib/gerbilcharts/svgdc/svg_rect.rb +29 -0
  66. data/lib/gerbilcharts/svgdc/svg_shape.rb +10 -0
  67. data/lib/gerbilcharts/svgdc/svg_text.rb +21 -0
  68. data/lib/gerbilcharts/svgdc/svg_win.rb +52 -0
  69. data/lib/gerbilcharts/svgdc/svgdc.rb +335 -0
  70. data/lib/gerbilcharts/svgdc/transformations.rb +66 -0
  71. data/lib/gerbilcharts/version.rb +9 -0
  72. data/setup.rb +1585 -0
  73. data/test/test_Scratch.rb +21 -0
  74. data/test/test_charts.rb +119 -0
  75. data/test/test_gerbilcharts.rb +11 -0
  76. data/test/test_helper.rb +2 -0
  77. data/test/test_models.rb +118 -0
  78. data/test/test_noob.rb +81 -0
  79. data/test/test_ranges.rb +135 -0
  80. data/test/test_svgdc.rb +221 -0
  81. data/test/trafgen.rb +25 -0
  82. metadata +156 -0
@@ -0,0 +1,221 @@
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
data/test/trafgen.rb ADDED
@@ -0,0 +1,25 @@
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
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gerbilcharts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Vivek Rajagopalan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-10 00:00:00 +05:30
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
24
+ version:
25
+ description: SVG based charting library for timeseries data
26
+ email:
27
+ - vivek at unleashnetworks
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - License.txt
35
+ - Manifest.txt
36
+ - PostInstall.txt
37
+ - README.txt
38
+ files:
39
+ - History.txt
40
+ - License.txt
41
+ - Manifest.txt
42
+ - PostInstall.txt
43
+ - README.txt
44
+ - Rakefile
45
+ - setup.rb
46
+ - test/trafgen.rb
47
+ - test/test_noob.rb
48
+ - test/test_helper.rb
49
+ - lib/gerbilcharts.rb
50
+ - lib/gerbilcharts/version.rb
51
+ - lib/gerbilcharts/models.rb
52
+ - lib/gerbilcharts/svgdc.rb
53
+ - lib/gerbilcharts/surfaces.rb
54
+ - lib/gerbilcharts/charts.rb
55
+ - lib/gerbilcharts/public/brushmetal.css
56
+ - lib/gerbilcharts/public/gerbil.js
57
+ - lib/gerbilcharts/models/bucketized_timeseries_graph_model.rb
58
+ - lib/gerbilcharts/models/graph_model_group.rb
59
+ - lib/gerbilcharts/models/graph_model.rb
60
+ - lib/gerbilcharts/models/monotonous_graph_model.rb
61
+ - lib/gerbilcharts/models/presets.rb
62
+ - lib/gerbilcharts/models/raw_range.rb
63
+ - lib/gerbilcharts/models/round_range.rb
64
+ - lib/gerbilcharts/models/round_time_range.rb
65
+ - lib/gerbilcharts/models/discrete_time_range.rb
66
+ - lib/gerbilcharts/models/sampled_timeseries_graph_model.rb
67
+ - lib/gerbilcharts/models/time_series_graph_model.rb
68
+ - lib/gerbilcharts/models/simple_timeseries_model_group.rb
69
+ - lib/gerbilcharts/surfaces/area_surface.rb
70
+ - lib/gerbilcharts/surfaces/axis.rb
71
+ - lib/gerbilcharts/surfaces/bar_surface.rb
72
+ - lib/gerbilcharts/surfaces/basic_grid.rb
73
+ - lib/gerbilcharts/surfaces/chart.rb
74
+ - lib/gerbilcharts/surfaces/graph_element.rb
75
+ - lib/gerbilcharts/surfaces/grid.rb
76
+ - lib/gerbilcharts/surfaces/horizontal_axis.rb
77
+ - lib/gerbilcharts/surfaces/horizontal_name_axis.rb
78
+ - lib/gerbilcharts/surfaces/horizontal_time_axis.rb
79
+ - lib/gerbilcharts/surfaces/impulse_surface.rb
80
+ - lib/gerbilcharts/surfaces/legend.rb
81
+ - lib/gerbilcharts/surfaces/line_surface.rb
82
+ - lib/gerbilcharts/surfaces/mark_band.rb
83
+ - lib/gerbilcharts/surfaces/panel.rb
84
+ - lib/gerbilcharts/surfaces/pie_surface.rb
85
+ - lib/gerbilcharts/surfaces/rect.rb
86
+ - lib/gerbilcharts/surfaces/stacked_area_surface.rb
87
+ - lib/gerbilcharts/surfaces/stacked_grid.rb
88
+ - lib/gerbilcharts/surfaces/surface_background.rb
89
+ - lib/gerbilcharts/surfaces/surface.rb
90
+ - lib/gerbilcharts/surfaces/title_panel.rb
91
+ - lib/gerbilcharts/surfaces/tracker.rb
92
+ - lib/gerbilcharts/surfaces/vertical_axis.rb
93
+ - lib/gerbilcharts/charts/area_chart.rb
94
+ - lib/gerbilcharts/charts/bar_chart_compact.rb
95
+ - lib/gerbilcharts/charts/bar_chart.rb
96
+ - lib/gerbilcharts/charts/chart_base.rb
97
+ - lib/gerbilcharts/charts/impulse_chart.rb
98
+ - lib/gerbilcharts/charts/line_chart.rb
99
+ - lib/gerbilcharts/charts/stacked_area_chart.rb
100
+ - lib/gerbilcharts/svgdc/svgdc.rb
101
+ - lib/gerbilcharts/svgdc/svg_element.rb
102
+ - lib/gerbilcharts/svgdc/filters.rb
103
+ - lib/gerbilcharts/svgdc/transformations.rb
104
+ - lib/gerbilcharts/svgdc/presentation_attributes.rb
105
+ - lib/gerbilcharts/svgdc/svg_win.rb
106
+ - lib/gerbilcharts/svgdc/svg_custom_win.rb
107
+ - lib/gerbilcharts/svgdc/svg_shape.rb
108
+ - lib/gerbilcharts/svgdc/svg_circle.rb
109
+ - lib/gerbilcharts/svgdc/svg_line.rb
110
+ - lib/gerbilcharts/svgdc/svg_polygon.rb
111
+ - lib/gerbilcharts/svgdc/svg_polyline.rb
112
+ - lib/gerbilcharts/svgdc/svg_rect.rb
113
+ - lib/gerbilcharts/svgdc/svg_text.rb
114
+ has_rdoc: true
115
+ homepage: http://gerbilcharts.rubyforge.org
116
+ post_install_message: |+
117
+
118
+ For more information on gerbilcharts, see http://gerbilcharts.rubyforge.org
119
+
120
+ NOTE: Change this information in PostInstall.txt
121
+ You can also delete it if you don't want it.
122
+
123
+
124
+ rdoc_options:
125
+ - --main
126
+ - README.txt
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ version:
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: "0"
140
+ version:
141
+ requirements: []
142
+
143
+ rubyforge_project: gerbilcharts
144
+ rubygems_version: 1.3.0
145
+ signing_key:
146
+ specification_version: 2
147
+ summary: SVG based charting library for timeseries data
148
+ test_files:
149
+ - test/test_charts.rb
150
+ - test/test_ranges.rb
151
+ - test/test_gerbilcharts.rb
152
+ - test/test_noob.rb
153
+ - test/test_svgdc.rb
154
+ - test/test_models.rb
155
+ - test/test_helper.rb
156
+ - test/test_Scratch.rb