Base object for generating SVG Graphs
Synopsis
module SVG::Graph::Graph_Type
include SVG::Graph
def set_defaults
default = { 'keys' => 'value }
default.each { |key, value|
this.config[ key ] = value
}
end
def get_template
template = 'set the template'
return template
end
def _init
# any testing you want to do
end
end
In your script…
require 'SVG/Graph/Graph_Type'
width = 500
height = 300
fields = %w{ field_1 field_2 field_3 )
graph = SVG::Graph::Graph_Type.new( {
:fields => fields,
# ... other config options
:height => height
})
data = [ 23, 56, 32 ]
graph.add_data( {
:data => data,
:title => 'Sales 2002'
})
config_value = graph.config_option
graph.config_option = config_value
graph.compress = true
print "Content-type: image/svg+xml\r\n"
print graph.burn
Description
This package should be used as a base for creating SVG graphs.
See SVG::Graph::Bar for an example.
This method allows you do add data to the graph object. It can be called
several times to add more data sets in.
data_sales_02 = [12, 45, 21];
graph.add_data({
:data => data_sales_02,
:title => 'Sales 2002'
})
This method processes the template with the data and config which has been
set and returns the resulting SVG.
This method will croak unless at least one data set has been added to the
graph object.
print graph.burn