Skip to content

Instantly share code, notes, and snippets.

@pullmonkey
Created October 13, 2009 15:59
Show Gist options
  • Save pullmonkey/209310 to your computer and use it in GitHub Desktop.
Save pullmonkey/209310 to your computer and use it in GitHub Desktop.
def bar_event_severity
data = []
data_labels = []
%w(High Medium Low).each do |x|
sym = x.downcase.to_sym
unless params[sym].blank?
data << params[sym].to_i
data_labels << "#{x} Severity"
end
end
colours = ['#fb9c9c', '#f8f9a4', '#adffa2']
values = []
bar = Bar3d.new
[params[:high].to_i, params[:medium].to_i, params[:low].to_i].each_with_index do |v,i|
b = BarValue.new(v)
b.colour = colours[i]
b.tooltip = '#val# Events'
values << b
end
bar.values = values
x = XAxis.new
x.grid_colour= '#FFFFFF'
x.set_3d 5
x.offset= true
x.colour= '#909090'
x.labels = data_labels
y = YAxis.new
y.grid_colour= '#FFFFFF'
if params[:all].to_i >= 50000
y.set_range(0, params[:all].to_i, 10000)
elsif params[:all].to_i >= 10000
y.set_range(0, params[:all].to_i, 5000)
elsif params[:all].to_i >= 5000
y.set_range(0, params[:all].to_i, 1000)
elsif params[:all].to_i >= 1000
y.set_range(0, params[:all].to_i, 500)
elsif params[:all].to_i >= 100
y.set_range(0, params[:all].to_i, 100)
else
y.set_range(0, params[:all].to_i, 10)
end
chart = OpenFlashChart.new
chart.title= Title.new('Event Severity')
chart.bg_colour = '#FFFFFF'
chart.x_axis= x
chart.y_axis= y
chart.elements = [bar]
render :text => chart.render
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment