Note: Version 2 of Open Flash Chart is available. Examples for version 2 are here.

Back to other graph examples

The Graph:



The Code:

This code in the controller:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def view
  @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bar_glass', true, '/projects/')     
end
def bar_glass
  bar1 = BarGlass.new(55, '#D54C78', '#C31812')
  bar1.key('2006', 10)

  bar2 = BarGlass.new(55, '#5E83BF', '#424581')
  bar2.key('2007', 10)

  10.times do |t|
          bar1.data << rand(3) + 2
          bar2.data << rand(14) - 5
  end

  g = Graph.new
  g.title("Glass Bars", '{font-size:20px; color: #bcd6ff; margin:10px; background-color: #5E83BF; padding: 5px 15px 5px 15px;}')
  g.data_sets << bar1
  g.data_sets << bar2

  g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct))
  g.set_x_axis_color('#909090', '#D2D2FB')
  g.set_y_axis_color('#909090', '#D2D2FB')
  g.set_y_min(-5)
  g.set_y_max(10)

  g.set_y_label_steps(6)
  g.set_y_legend("OFC", 12, '#736AFF')
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples