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
35
def view
  @graph = open_flash_chart_object(600,300, '/projects/open_flash_chart/extra_tt', true, '/projects/')     
end
def extra_tt
  data_1 = Line.new(2, '#9933CC')
  data_1.key('Page Views', 10)

  data_2 = LineHollow.new(2,5,'#CC3399')
  data_2.key("Downloads",10)

  data_3 = LineHollow.new(2,4,'#80a033')
  data_3.key("Bounces", 10)

  (0..12).each do |i|
    data_1.add_data_tip(rand(5) + 14, "(Extra: #{i})")
    data_2.add_data_tip(rand(5) + 8,  "(Extra: #{i})")
    data_3.add_data_tip(rand(6) + 1,  "(Extra: #{i})")
  end
  
  g = Graph.new
  g.title("Many Data lines and Extra tooltips", "{font-size: 20px; color: #736AFF}")
  g.data_sets << data_1
  g.data_sets << data_2
  g.data_sets << data_3

  g.set_tool_tip('#x_label# [#val#]<br>#tip#')
  g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec))
  g.set_x_label_style(10, '#000000', 0, 2)

  g.set_y_max(20)
  g.set_y_label_steps(4)
  g.set_y_legend("Open Flash Chart", 12, "#736AFF")
  
  render :text => g.render
end
And this code in the view:
1
<%= @graph %>

Back to other graph examples