molten-trunk/molten5_withgrid/app/helpers/solutions_helper.rb
def bar_graph(*data)
    width = 500
    height = 150
    colors = %w(#ce494a #efba29 #efe708 #5a7dd6 #73a25a)
    floor_cutoff = 24
    
    html = <<-"HTML"
    <style>
      #vertgraph {    				
          width: #{width}px; 
          height: #{height}px; 
          position: relative; 
          font-family: "Lucida Grande", Verdana, Arial;
      }
    
      #vertgraph dl dd {
        position: absolute;
        width: 28px;
        height: 103px;
        bottom: 34px;
        padding: 0 !important;
        margin: 0 !important;
        background-image: url('/images/css_graphs/colorbar.jpg') no-repeat !important;
        text-align: center;
        font-weight: bold;
        color: white;
        line-height: 1.5em;
      }

      #vertgraph dl dt {
        position: absolute;
        width: 48px;
        height: 25px;
        bottom: 0px;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center;
        color: #444444;
        font-size: 0.8em;
      }
    HTML

    bar_offset = 24
    bar_increment = 75
    bar_image_offset = 28
    
    data.each_with_index do |d, index|
      bar_left = bar_offset + (bar_increment * index)
      label_left = bar_left - 10
      background_offset = bar_image_offset * index
      
      html += <<-HTML
        #vertgraph dl dd.#{d[0].to_s.downcase} { left: #{bar_left}px; background-color: #{colors[index]}; background-position: -#{background_offset}px bottom !important; }
        #vertgraph dl dt.#{d[0].to_s.downcase} { left: #{label_left}px; background-position: -#{background_offset}px bottom !important; }
      HTML
    end
    
    html += <<-"HTML"
      </style>
      <div id="vertgraph">
        <dl>
    HTML
    
    data.each_with_index do |d, index|
      html += <<-"HTML"
        <dt class="#{d[0].to_s.downcase}">#{d[0].to_s.humanize}</dt>
        <dd class="#{d[0].to_s.downcase}" style="height: #{d[1]}px;" title="#{d[1]}">#{d[1] < floor_cutoff ? '' : d[1]}</dt>
      HTML
    end
        
    html += <<-"HTML"
        </dl>
      </div>
    HTML
    
    html
  end
# Makes a vertical bar graph.
#
#  bar_graph ["Stout", 10], ["IPA", 80], ["Pale Ale", 50], ["Milkshake", 30]
#
Makes a vertical bar graph.
Makes a vertical bar graph .
def bar_graph(*data)
    width = 500
    height = 150
    colors = %w(#ce494a #efba29 #efe708 #5a7dd6 #73a25a)
    floor_cutoff = 24
    html = <<-"HTML"
    <style>
      #vertgraph {    				
          width: #{width}px; 
          height: #{height}px; 
          position: relative; 
          font-family: "Lucida Grande", Verdana, Arial;
      }
      #vertgraph dl dd {
        position: absolute;
        width: 28px;
        height: 103px;
        bottom: 34px;
        padding: 0 !important;
        margin: 0 !important;
        background-image: url('/images/css_graphs/colorbar.jpg') no-repeat !important;
        text-align: center;
        font-weight: bold;
        color: white;
        line-height: 1.5em;
      }
      #vertgraph dl dt {
        position: absolute;
        width: 48px;
        height: 25px;
        bottom: 0px;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center;
        color: #444444;
        font-size: 0.8em;
      }
    HTML
    bar_offset = 24
    bar_increment = 75
    bar_image_offset = 28
    data.each_with_index do |d, index|
      bar_left = bar_offset + (bar_increment * index)
      label_left = bar_left - 10
      background_offset = bar_image_offset * index
      html += <<-HTML
        #vertgraph dl dd.#{d[0].to_s.downcase} { left: #{bar_left}px; background-color: #{colors[index]}; background-position: -#{background_offset}px bottom !important; }
        #vertgraph dl dt.#{d[0].to_s.downcase} { left: #{label_left}px; background-position: -#{background_offset}px bottom !important; }
      HTML
    end
    html += <<-"HTML"
      </style>
      <div id="vertgraph">
        <dl>
    HTML
    data.each_with_index do |d, index|
      html += <<-"HTML"
        <dt class="#{d[0].to_s.downcase}">#{d[0].to_s.humanize}</dt>
        <dd class="#{d[0].to_s.downcase}" style="height: #{d[1]}px;" title="#{d[1]}">#{d[1] < floor_cutoff ? '' : d[1]}</dt>
      HTML
    end
    html += <<-"HTML"
        </dl>
      </div>
    HTML
    html
  end
def bar_graph ( * data ) width = 500 height = 150 colors = %w( #ce494a #efba29 #efe708 #5a7dd6 #73a25a ) floor_cutoff = 24 html = <<-"HTML" 
    <style>
      #vertgraph {    				
          width:  #{ width } px; 
          height:  #{ height } px; 
          position: relative; 
          font-family: "Lucida Grande", Verdana, Arial;
      }
    
      #vertgraph dl dd {
        position: absolute;
        width: 28px;
        height: 103px;
        bottom: 34px;
        padding: 0 !important;
        margin: 0 !important;
        background-image: url('/images/css_graphs/colorbar.jpg') no-repeat !important;
        text-align: center;
        font-weight: bold;
        color: white;
        line-height: 1.5em;
      }

      #vertgraph dl dt {
        position: absolute;
        width: 48px;
        height: 25px;
        bottom: 0px;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center;
        color: #444444;
        font-size: 0.8em;
      }
     HTML bar_offset = 24 bar_increment = 75 bar_image_offset = 28 data . each_with_index do | d , index | bar_left = bar_offset + ( bar_increment * index ) label_left = bar_left - 10 background_offset = bar_image_offset * index html += <<-HTML 
        #vertgraph dl dd. #{ d [ 0 ] . to_s . downcase }  { left:  #{ bar_left } px; background-color:  #{ colors [ index ] } ; background-position: - #{ background_offset } px bottom !important; }
        #vertgraph dl dt. #{ d [ 0 ] . to_s . downcase }  { left:  #{ label_left } px; background-position: - #{ background_offset } px bottom !important; }
       HTML end html += <<-"HTML" 
      </style>
      <div id="vertgraph">
        <dl>
     HTML data . each_with_index do | d , index | html += <<-"HTML" 
        <dt class=" #{ d [ 0 ] . to_s . downcase } "> #{ d [ 0 ] . to_s . humanize } </dt>
        <dd class=" #{ d [ 0 ] . to_s . downcase } " style="height:  #{ d [ 1 ] } px;" title=" #{ d [ 1 ] } "> #{ d [ 1 ] < floor_cutoff ? '' : d [ 1 ] } </dt>
       HTML end html += <<-"HTML" 
        </dl>
      </div>
     HTML html end
Makes a vertical bar graph.
Makes a vertical bar graph .
data