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
def view
  @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bars_and_lines', true, '/projects/')     
end
def bars_and_lines
  data1 = []
  data2 = []
  data3 = []
  10.times do |t|
          data1 << rand(3) + 2
          data2 << rand(3) + 4
          data3 << rand(4) + 5
  end

  g = Graph.new

  g.title("Bar and Line Mixed", '{font-size: 35px; color: #800000}' )
  g.set_data(data1)
  g.bar(50, '#9933cc', 'Purple Bar', 10)
  g.set_data(data2)
  g.bar(50, '#339966', 'Green Bar', 10)
  g.set_data(data3)
  g.line_dot(3,5,'#cc3399', 'Line', 10)

  g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct))
  g.set_y_max(10)
  g.set_y_label_steps(2)
  g.set_y_legend('Legend', 12, '#736aff')
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples