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
31
32
33
34
def view
  @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bar_chart_2', true, '/projects/')     
end
def bar_chart_2
  bar1 = Bar.new(50, '#0066CC')
  bar1.key('Me', 10)

  bar2 = Bar.new(50, '#9933CC')
  bar2.key('You', 10)

  bar3 = Bar.new(50, '#639F45')
  bar3.key('Them', 10)

  10.times do |t|
          bar1.data << rand(7) + 3
          bar2.data << rand(7) + 3
          bar3.data << rand(7) + 3
  end

  g = Graph.new
  g.title("Bar Graph", "{font-size: 26px;}")

  g.data_sets << bar1
  g.data_sets << bar2
  g.data_sets << bar3

  g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct))
  g.set_x_label_style(10, '#9933CC', 0, 2)
  g.set_x_axis_steps(2)
  g.set_y_max(10)
  g.set_y_label_steps(2)
  g.set_y_legend("Open Flash Chart", 12, "0x736AFF")
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples