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
def view
  @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bar_chart', true, '/projects/')     
end
def bar_chart
  bar = BarOutline.new(50, '#9933CC', '#8010A0')
  bar.key("Page VIEWS", 10)

  10.times do |t|
          bar.data << rand(7) + 3
  end

  g = Graph.new
  g.title("BAR CHART", "{font-size: 15px;}")

  g.data_sets << bar

  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(4)
  g.set_y_legend("OPENF LADF", 12, "#736AFF")
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples