lib/SVG/Graph/Graph.rb in svg-graph-1.0.0 vs lib/SVG/Graph/Graph.rb in svg-graph-1.0.1
- old
+ new
@@ -97,11 +97,11 @@
# [key_font_size] 10
# [no_css] false
# [add_popups] false
def initialize( config )
@config = config
-
+ @data = nil
self.top_align = self.top_font = self.right_align = self.right_font = 0
init_with({
:width => 500,
:height => 300,
@@ -146,13 +146,11 @@
:key_font_size =>10,
:no_css =>false,
:add_popups =>false,
})
-
- set_defaults if methods.include? "set_defaults"
-
+ set_defaults if self.respond_to? :set_defaults
init_with config
end
# This method allows you do add data to the graph object.
@@ -163,11 +161,11 @@
# graph.add_data({
# :data => data_sales_02,
# :title => 'Sales 2002'
# })
def add_data conf
- @data = [] unless defined? @data
+ @data = [] unless (defined? @data and !@data.nil?)
if conf[:data] and conf[:data].kind_of? Array
@data << conf
else
raise "No data provided by #{conf.inspect}"
@@ -352,10 +350,10 @@
# Overwrite configuration options with supplied options. Used
# by subclasses.
def init_with config
config.each { |key, value|
- self.send( key.to_s+"=", value ) if methods.include? key.to_s
+ self.send( key.to_s+"=", value ) if self.respond_to? key
}
end
attr_accessor :top_align, :top_font, :right_align, :right_font