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(600,300, '/projects/open_flash_chart/y_right', true, '/projects/')     
end
def y_right
  g = Graph.new
  g.title( 'Users vs. Ram - 24h statistics', '{color: #7E97A6; font-size: 20; text-align: center}' )
  g.set_bg_color('#FFFFFF')
  g.set_data([289,198,143,126,98,96,124,164,213,238,256,263,265,294,291,289,306,341,353,353,402,419,404,366,309])
  g.line_dot( 2, 4, '#818D9D', 'Max Users', 10 )
  g.set_data([698,1101,1324,1396,1568,1571,1496,1349,1140,1045,966,926,906,754,766,757,672,510,431,436,227,533,566,744,1004])
  g.line_hollow( 2, 4, '#164166', 'Free Ram', 10 )
  g.attach_to_y_right_axis(2)
  g.set_y_max(600)
  g.set_y_right_max(1700)
  g.set_x_axis_color('#818D9D', '#F0F0F0' )
  g.set_y_axis_color( '#818D9D', '#ADB5C7' )
  g.y_right_axis_color('#164166' )
  g.set_x_legend( 'My IRC Server', 12, '#164166' )
  g.set_y_legend( 'Max Users', 12, '#164166' )
  g.set_y_legend_right( 'Free Ram (MB)' ,12 , '#164166' )
  tmp = []
  (0..25).to_a.each do |x|
          tmp << "#{x}:00"
  end
  g.set_x_labels(tmp)
  g.set_x_label_style(10, '#164166', 0, 3, '#818D9D' )
  g.set_y_label_steps(5)
  
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples