1 require 'rexml/document'
\r
2 require 'SVG/Graph/Graph'
\r
8 # A superclass for bar-style graphs. Do not attempt to instantiate
\r
9 # directly; use one of the subclasses instead.
\r
13 # Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom>
\r
15 # Copyright 2004 Sean E. Russell
\r
16 # This software is available under the Ruby license[LICENSE.txt]
\r
18 class BarBase < SVG::Graph::Graph
\r
19 # Ensures that :fields are provided in the configuration.
\r
20 def initialize config
\r
21 raise "fields was not supplied or is empty" unless config[:fields] &&
\r
22 config[:fields].kind_of?(Array) &&
\r
23 config[:fields].length > 0
\r
27 # In addition to the defaults set in Graph::initialize, sets
\r
31 init_with( :bar_gap => true, :stack => :overlap )
\r
34 # Whether to have a gap between the bars or not, default
\r
35 # is true, set to false if you don't want gaps.
\r
36 attr_accessor :bar_gap
\r
37 # How to stack data sets. :overlap overlaps bars with
\r
38 # transparent colors, :top stacks bars on top of one another,
\r
39 # :side stacks the bars side-by-side. Defaults to :overlap.
\r
40 attr_accessor :stack
\r
46 @data.collect{|x| x[:data].max}.max
\r
51 if min_scale_value.nil?
\r
52 min = @data.collect{|x| x[:data].min}.min
\r
53 min = min > 0 ? 0 : min
\r
55 min = min_scale_value
\r
62 /* default fill styles for multiple datasets (probably only use a single dataset on this graph though) */
\r
67 stroke-width: 0.5px;
\r
103 stroke-width: 1px;
\r
109 stroke-width: 1px;
\r
115 stroke-width: 1px;
\r
121 stroke-width: 1px;
\r
127 stroke-width: 1px;
\r
133 stroke-width: 1px;
\r