File: single.rb

package info (click to toggle)
ruby-svg-graph 1.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 684 kB
  • ctags: 177
  • sloc: ruby: 2,939; xml: 453; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'SVG/Graph/BarHorizontal'
require 'SVG/Graph/Bar'
require 'SVG/Graph/Line'
require 'SVG/Graph/Pie'


File.open( "data.txt" ) { |fin|
  title = fin.readline
  fields = fin.readline.split( /,/ )
  female_data = fin.readline.split( " " ).collect{|x| x.to_i}
  male_data = fin.readline.split( " " ).collect{|x| x.to_i}

  graph = SVG::Graph::Pie.new( {
    :width => 640,
    :height => 480,
    :fields => fields,
    :graph_title => title,
    :show_graph_title => true,
    :no_css => true,
    :expanded => true,
    :show_data_labels => true
  })
  graph.add_data( {
      :data => female_data,
      :title => "Female"
    })
  graph.add_data( {
      :data => male_data,
      :title => "Male"
    })
  puts graph.burn
}