Method: SVG::Graph::Pie#add_data

Defined in:
lib/SVG/Graph/Pie.rb

#add_data(arg) ⇒ Object

Adds a data set to the graph.

graph.add_data( { :data => [1,2,3,4] } )

Note that the :title is not necessary. If multiple data sets are added to the graph, the pie chart will display the sums of the data. EG:

graph.add_data( { :data => [1,2,3,4] } )
graph.add_data( { :data => [2,3,5,9] } )

is the same as:

graph.add_data( { :data => [3,5,8,13] } )


111
112
113
114
115
116
# File 'lib/SVG/Graph/Pie.rb', line 111

def add_data arg
  arg[:data].each_index {|idx|
    @data[idx] = 0 unless @data[idx]
    @data[idx] += arg[:data][idx]
  }
end