Class SVG::Graph::BarBase
In: SVG/Graph/BarBase.rb
Parent: SVG::Graph::Graph

Synopsis

A superclass for bar-style graphs. Do not attempt to instantiate directly; use one of the subclasses instead.

Author

Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom>

Copyright 2004 Sean E. Russell This software is available under the Ruby license

Methods

Attributes

bar_gap  [RW]  Whether to have a gap between the bars or not, default is true, set to false if you don‘t want gaps.
stack  [RW]  How to stack data sets. :overlap overlaps bars with transparent colors, :top stacks bars on top of one another, :side stacks the bars side-by-side. Defaults to :overlap.

Public Class methods

Ensures that :fields are provided in the configuration.

[Source]

    # File SVG/Graph/BarBase.rb, line 20
20:       def initialize config
21:         raise "fields was not supplied or is empty" unless config[:fields] &&
22:         config[:fields].kind_of?(Array) &&
23:         config[:fields].length > 0
24:                                 super
25:                         end

Public Instance methods

In addition to the defaults set in Graph::initialize, sets

bar_gap
true
stack
:overlap

[Source]

    # File SVG/Graph/BarBase.rb, line 30
30:                         def set_defaults
31:         init_with( :bar_gap => true, :stack => :overlap )
32:       end

Protected Instance methods

[Source]

    # File SVG/Graph/BarBase.rb, line 60
60:       def get_css
61:         return "/* default fill styles for multiple datasets (probably only use a single dataset on this graph though) */\n.key1,.fill1{\n        fill: #ff0000;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 0.5px;   \n}\n.key2,.fill2{\n        fill: #0000ff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key3,.fill3{\n        fill: #00ff00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key4,.fill4{\n        fill: #ffcc00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key5,.fill5{\n        fill: #00ccff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key6,.fill6{\n        fill: #ff00ff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key7,.fill7{\n        fill: #00ffff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key8,.fill8{\n        fill: #ffff00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key9,.fill9{\n        fill: #cc6666;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key10,.fill10{\n        fill: #663399;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key11,.fill11{\n        fill: #339900;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key12,.fill12{\n        fill: #9966FF;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n"
62:       end

[Source]

    # File SVG/Graph/BarBase.rb, line 45
45:       def max_value
46:         @data.collect{|x| x[:data].max}.max
47:       end

[Source]

    # File SVG/Graph/BarBase.rb, line 49
49:       def min_value
50:         min = 0
51:         if min_scale_value.nil? 
52:           min = @data.collect{|x| x[:data].min}.min
53:           min = min > 0 ? 0 : min
54:         else
55:           min = min_scale_value
56:         end
57:         return min
58:       end

[Validate]