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
def view
  @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bar_sketch', true, '/projects/')     
end
def bar_sketch
  bar = BarSketch.new(55,6,'#d070ac', '#000000')
  bar.key('2006', 10)

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

  g = Graph.new
  g.title("Sketch Bar", '{font-size:20px; color: #ffffff; margin:10px; background-color: #d070ac; padding: 5px 15px 5px 15px;}' )
  g.set_bg_color('#fdfdfd')
  g.data_sets << bar

  g.set_x_axis_color('#e0e0e0', '#e0e0e0')
  g.set_x_tick_size(9)
  g.set_y_axis_color('#e0e0e0', '#e0e0e0')
  g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct))
  g.set_x_label_style(11,'#303030')
  g.set_y_label_style(11,'#303030')
  g.set_y_max(10)
  g.set_y_label_steps(5)
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples