Mercurial > hg > soundsoftware-site
comparison .svn/pristine/05/05cdc085e6ab746bd3734a56f879f137f280e27b.svn-base @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 require 'rexml/document' | |
2 require 'SVG/Graph/Graph' | |
3 | |
4 module SVG | |
5 module Graph | |
6 # = Synopsis | |
7 # | |
8 # A superclass for bar-style graphs. Do not attempt to instantiate | |
9 # directly; use one of the subclasses instead. | |
10 # | |
11 # = Author | |
12 # | |
13 # Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom> | |
14 # | |
15 # Copyright 2004 Sean E. Russell | |
16 # This software is available under the Ruby license[LICENSE.txt] | |
17 # | |
18 class BarBase < SVG::Graph::Graph | |
19 # Ensures that :fields are provided in the configuration. | |
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 | |
26 | |
27 # In addition to the defaults set in Graph::initialize, sets | |
28 # [bar_gap] true | |
29 # [stack] :overlap | |
30 def set_defaults | |
31 init_with( :bar_gap => true, :stack => :overlap ) | |
32 end | |
33 | |
34 # Whether to have a gap between the bars or not, default | |
35 # is true, set to false if you don't want gaps. | |
36 attr_accessor :bar_gap | |
37 # How to stack data sets. :overlap overlaps bars with | |
38 # transparent colors, :top stacks bars on top of one another, | |
39 # :side stacks the bars side-by-side. Defaults to :overlap. | |
40 attr_accessor :stack | |
41 | |
42 | |
43 protected | |
44 | |
45 def max_value | |
46 @data.collect{|x| x[:data].max}.max | |
47 end | |
48 | |
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 | |
59 | |
60 def get_css | |
61 return <<EOL | |
62 /* default fill styles for multiple datasets (probably only use a single dataset on this graph though) */ | |
63 .key1,.fill1{ | |
64 fill: #ff0000; | |
65 fill-opacity: 0.5; | |
66 stroke: none; | |
67 stroke-width: 0.5px; | |
68 } | |
69 .key2,.fill2{ | |
70 fill: #0000ff; | |
71 fill-opacity: 0.5; | |
72 stroke: none; | |
73 stroke-width: 1px; | |
74 } | |
75 .key3,.fill3{ | |
76 fill: #00ff00; | |
77 fill-opacity: 0.5; | |
78 stroke: none; | |
79 stroke-width: 1px; | |
80 } | |
81 .key4,.fill4{ | |
82 fill: #ffcc00; | |
83 fill-opacity: 0.5; | |
84 stroke: none; | |
85 stroke-width: 1px; | |
86 } | |
87 .key5,.fill5{ | |
88 fill: #00ccff; | |
89 fill-opacity: 0.5; | |
90 stroke: none; | |
91 stroke-width: 1px; | |
92 } | |
93 .key6,.fill6{ | |
94 fill: #ff00ff; | |
95 fill-opacity: 0.5; | |
96 stroke: none; | |
97 stroke-width: 1px; | |
98 } | |
99 .key7,.fill7{ | |
100 fill: #00ffff; | |
101 fill-opacity: 0.5; | |
102 stroke: none; | |
103 stroke-width: 1px; | |
104 } | |
105 .key8,.fill8{ | |
106 fill: #ffff00; | |
107 fill-opacity: 0.5; | |
108 stroke: none; | |
109 stroke-width: 1px; | |
110 } | |
111 .key9,.fill9{ | |
112 fill: #cc6666; | |
113 fill-opacity: 0.5; | |
114 stroke: none; | |
115 stroke-width: 1px; | |
116 } | |
117 .key10,.fill10{ | |
118 fill: #663399; | |
119 fill-opacity: 0.5; | |
120 stroke: none; | |
121 stroke-width: 1px; | |
122 } | |
123 .key11,.fill11{ | |
124 fill: #339900; | |
125 fill-opacity: 0.5; | |
126 stroke: none; | |
127 stroke-width: 1px; | |
128 } | |
129 .key12,.fill12{ | |
130 fill: #9966FF; | |
131 fill-opacity: 0.5; | |
132 stroke: none; | |
133 stroke-width: 1px; | |
134 } | |
135 EOL | |
136 end | |
137 end | |
138 end | |
139 end |