Class: DYI::Chart::Base Abstract
- Inherits:
-
Object
- Object
- DYI::Chart::Base
- Extended by:
- OptionCreator
- Defined in:
- lib/dyi/chart/base.rb
Overview
Base class of all the chart classes.
Constant Summary collapse
- DEFAULT_CHART_COLOR =
['#ff0f00', '#ff6600', '#ff9e01', '#fcd202', '#f8ff01', '#b0de09', '#04d215', '#0d8ecf', '#0d52d1', '#2a0cd0', '#8a0ccf', '#cd0d74']
Instance Attribute Summary collapse
-
#canvas ⇒ Canvas
readonly
Returns the canvas of the image body.
-
#data ⇒ Chart::ArrayReader
readonly
Returns the data for the chart.
Instance Method Summary collapse
-
#clear_real_size ⇒ Object
Clears real size of the chart image, and sets chart size as values of
width
andheight
properties. -
#height ⇒ Length
Returns height of the chart image on user unit.
-
#height=(height) ⇒ Object
Sets height of the chart image on user unit.
-
#initialize(width, height, options = {}) ⇒ Base
constructor
A new instance of Base.
-
#load_data(reader) ⇒ Object
Loads the data, and creates chart image.
-
#puts_in_io(format = nil, io = $>, options = {}) ⇒ Object
Outputs the chart image to IO stream.
-
#save(file_name, format = nil, options = {}) ⇒ Object
Save the chart image as a file.
-
#set_real_size(width, height) ⇒ Object
Sets size of the chart image.
-
#string(format = nil, options = {}) ⇒ Object
Outputs the chart image as a
String
(binary). -
#width ⇒ Length
Returns width of the chart image on user unit.
-
#width=(width) ⇒ Object
Sets width of the chart image on user unit.
Methods included from OptionCreator
opt_accessor, opt_reader, opt_writer
Constructor Details
#initialize(width, height, options = {}) ⇒ Base
Returns a new instance of Base.
255 256 257 258 259 260 261 |
# File 'lib/dyi/chart/base.rb', line 255 def initialize(width, height, ={}) @canvas = Canvas.new(width, height) @options = {} .each do |key, value| __send__("#{key}=", value) if respond_to?("#{key}=") end end |
Instance Attribute Details
#canvas ⇒ Canvas (readonly)
Returns the canvas of the image body.
210 211 212 |
# File 'lib/dyi/chart/base.rb', line 210 def canvas @canvas end |
#data ⇒ Chart::ArrayReader (readonly)
Returns the data for the chart.
206 207 208 |
# File 'lib/dyi/chart/base.rb', line 206 def data @data end |
Instance Method Details
#clear_real_size ⇒ Object
Clears real size of the chart image, and sets chart size as values of width
and height
properties. See #set_real_size, #width, #height, DYI::Canvas#real_width and DYI::Canvas#real_height.
298 299 300 301 |
# File 'lib/dyi/chart/base.rb', line 298 def clear_real_size @canvas.real_width = nil @canvas.real_height = nil end |
#height ⇒ Length
Returns height of the chart image on user unit.
277 278 279 |
# File 'lib/dyi/chart/base.rb', line 277 def height @canvas.height end |
#height=(height) ⇒ Object
Sets height of the chart image on user unit.
283 284 285 |
# File 'lib/dyi/chart/base.rb', line 283 def height=(height) @canvas.height = height end |
#load_data(reader) ⇒ Object
Loads the data, and creates chart image.
306 307 308 309 |
# File 'lib/dyi/chart/base.rb', line 306 def load_data(reader) @data = reader create_vector_image end |
#puts_in_io(format = nil, io = $>, options = {}) ⇒ Object
Outputs the chart image to IO stream.
340 341 342 |
# File 'lib/dyi/chart/base.rb', line 340 def puts_in_io(format=nil, io=$>, ={}) @canvas.puts_in_io(format, io, ) end |
#save(file_name, format = nil, options = {}) ⇒ Object
Save the chart image as a file.
324 325 326 |
# File 'lib/dyi/chart/base.rb', line 324 def save(file_name, format=nil, ={}) @canvas.save(file_name, format, ) end |
#set_real_size(width, height) ⇒ Object
Sets size of the chart image.
290 291 292 293 |
# File 'lib/dyi/chart/base.rb', line 290 def set_real_size(width, height) @canvas.real_width = Length.new(width) @canvas.real_height = Length.new(height) end |
#string(format = nil, options = {}) ⇒ Object
Outputs the chart image as a String
(binary).
355 356 357 |
# File 'lib/dyi/chart/base.rb', line 355 def string(format=nil, ={}) @canvas.string(format, ) end |
#width ⇒ Length
Returns width of the chart image on user unit.
265 266 267 |
# File 'lib/dyi/chart/base.rb', line 265 def width @canvas.width end |
#width=(width) ⇒ Object
Sets width of the chart image on user unit.
271 272 273 |
# File 'lib/dyi/chart/base.rb', line 271 def width=(width) @canvas.width = width end |