Permalink
Browse files

color style for measure workload

  • Loading branch information...
1 parent 12ccdee commit f1938663dc7b58ac6f4e80682fa1a5e5a41d6d09 @mwa mwa committed Oct 7, 2011
Showing with 81 additions and 22 deletions.
  1. +20 −0 assets/stylesheets/workload.css
  2. +61 −22 lib/workload/workload.rb
@@ -45,6 +45,26 @@ div.workload {
border: 1px solid #00A000;
}
+.workload_a {
+ background: #FFC000;
+ border: 1px solid #A05000;
+}
+
+.workload_b {
+ background: #FFFF00;
+ border: 1px solid #A0A000;
+}
+
+.workload_c {
+ background: #00FF00;
+ border: 1px solid #00A000;
+}
+
+.workload_d {
+ background: #FF0000;
+ border: 1px solid #A00000;
+}
+
.workload_empty {
background: #FF0000 url(/plugin_assets/redmine_workload/images/overflow.png);
border: 1px solid #000000;
@@ -247,8 +247,7 @@ def line_for_user(user, options={})
# workload[:value] = workload[:measure][:free_capacity] # FIXME: style for absolute values, show relative value for now
workload[:value] = workload[:measure][:availability]
when MEASURE_WORKLOAD
-# workload[:value] = workload[:measure][:workload]
- workload[:value] = workload[:measure][:availability]
+ workload[:value] = workload[:measure][:workload]
when MEASURE_AVAILABILITY
workload[:value] = workload[:measure][:availability]
else
@@ -775,12 +774,24 @@ def html_workload(params, workload)
if coords[:bar_start] && coords[:bar_end]
# calculate style bin
- bin = (value/25).floor * 25
- workload_class = "workload_#{bin}"
- if bin > 100
- workload_class = "workload_full"
- elsif bin < 0
- workload_class = "workload_empty"
+ if @measure == MEASURE_WORKLOAD
+ if value >= 0.0 && value < 90
+ workload_class = "workload_a"
+ elsif value >= 90 && value < 100
+ workload_class = "workload_b"
+ elsif value >= 100 && value < 110
+ workload_class = "workload_c"
+ else
+ workload_class = "workload_d"
+ end
+ else
+ bin = (value/25).floor * 25
+ workload_class = "workload_#{bin}"
+ if bin > 100
+ workload_class = "workload_full"
+ elsif bin < 0
+ workload_class = "workload_empty"
+ end
end
# bar
@@ -810,14 +821,28 @@ def image_workload(params, workload)
height = 6
if coords[:bar_start] && coords[:bar_end]
- colors = ['#FF0000', '#FFC000', '#FFFF00', '#C0FF00', '#00FF00', '#00FF00', '#FF0000']
- bin = (value/25).floor
- if bin > 4
- color = colors[5]
- elsif bin < 0
- color = colors[6]
+ if @measure == MEASURE_WORKLOAD
+ colors = ['#FFC000', '#FFFF00', '#00FF00', '#FF0000']
+ bin = 0
+ if value >= 0.0 && value < 90
+ color = colors[0]
+ elsif value >= 90 && value < 100
+ color = colors[1]
+ elsif value >= 100 && value < 110
+ color = colors[2]
+ else
+ color = colors[3]
+ end
else
- color = colors[bin]
+ colors = ['#FF0000', '#FFC000', '#FFFF00', '#C0FF00', '#00FF00', '#00FF00', '#FF0000']
+ bin = (value/25).floor
+ if bin > 4
+ color = colors[5]
+ elsif bin < 0
+ color = colors[6]
+ else
+ color = colors[bin]
+ end
end
# bar
@@ -849,14 +874,28 @@ def pdf_workload(params, workload)
height = 2
if coords[:bar_start] && coords[:bar_end]
- colors = [[255, 0, 0], [255, 192, 0], [255, 255, 0], [192, 255, 0], [0, 255, 0], [0, 255, 0], [255, 0, 0]]
- bin = (value/25).floor
- if bin > 4
- color = colors[5]
- elsif bin < 0
- color = colors[6]
+ if @measure == MEASURE_WORKLOAD
+ colors = [[255, 192, 0], [255, 255, 0], [0, 255, 0], [255, 0, 0]]
+ bin = 0
+ if value >= 0.0 && value < 90
+ color = colors[0]
+ elsif value >= 90 && value < 100
+ color = colors[1]
+ elsif value >= 100 && value < 110
+ color = colors[2]
+ else
+ color = colors[3]
+ end
else
- color = colors[bin]
+ colors = [[255, 0, 0], [255, 192, 0], [255, 255, 0], [192, 255, 0], [0, 255, 0], [0, 255, 0], [255, 0, 0]]
+ bin = (value/25).floor
+ if bin > 4
+ color = colors[5]
+ elsif bin < 0
+ color = colors[6]
+ else
+ color = colors[bin]
+ end
end
# bar

0 comments on commit f193866

Please sign in to comment.