Class SVG::Graph::BarBase
In: lib/SVG/Graph/BarBase.rb
Parent: SVG::Graph::Graph
Graph Pie Plot BarBase Schedule Line TimeSeries Bar BarHorizontal REXML Graph SVG dot/f_0.png

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 lib/SVG/Graph/BarBase.rb, line 20
      def initialize config
        raise "fields was not supplied or is empty" unless config[:fields] &&
        config[:fields].kind_of?(Array) &&
        config[:fields].length > 0
                                super
                        end

Public Instance methods

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

bar_gap
true
stack
:overlap

[Source]

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

Protected Instance methods

[Source]

# File lib/SVG/Graph/BarBase.rb, line 60
      def get_css
        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"
      end

[Source]

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

[Source]

# File lib/SVG/Graph/BarBase.rb, line 49
      def min_value
        min = 0
        if min_scale_value.nil? 
          min = @data.collect{|x| x[:data].min}.min
          min = min > 0 ? 0 : min
        else
          min = min_scale_value
        end
        return min
      end

[Validate]