Class: Ruport::Formatter::Graph::Amline
- Inherits:
-
Ruport::Formatter
- Object
- Ruport::Formatter
- Ruport::Formatter::Graph::Amline
- Defined in:
- lib/ruport/util/graph/amline.rb
Instance Method Summary collapse
- #apply_template ⇒ Object
- #build_graph ⇒ Object
- #data_out ⇒ Object
- #format_settings ⇒ Object
- #generate_config_file ⇒ Object
-
#initialize ⇒ Amline
constructor
A new instance of Amline.
- #output ⇒ Object
- #settings_out ⇒ Object
Constructor Details
Instance Method Details
#apply_template ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruport/util/graph/amline.rb', line 40 def apply_template .templated_settings_proc = lambda do |s| s.config do |c| c.values.y_left.max = template.y_max c.values.y_right.max = template.y_max c.values.y_left.min = template.y_min c.values.y_right.min = template.y_min c.width = template.width c.height = template.height c.legend.enabled = template.show_legend if template.config template.config[c] end end if template. default = template.[:_default] || lambda { } template..each do |k,v| next if k == :_default s.graph(k,&default) s.graph(k,&v) end end end end |
#build_graph ⇒ Object
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 36 37 38 |
# File 'lib/ruport/util/graph/amline.rb', line 10 def build_graph generate_config_file data_out << "<chart>" data_out << "<xaxis>" data.x_labels.each_with_index do |e,i| data_out << %Q{<value xid="#{i}" show="true">#{e}</value>} end data_out << "</xaxis>" data_out << "<graphs>" data.each do |r| data_out << %Q{<graph gid="#{r.gid}">} r.each_with_index do |e,i| data_out << %Q{<value xid="#{i}">#{e}</value>} end data_out << "</graph>" end data_out << "</graphs>" data_out << "</chart>" if .data_file File.open(.data_file,"w") { |f| f << data_out } end if .settings_file File.open(.settings_file,"w") { |f| f << settings_out } end end |
#data_out ⇒ Object
88 89 90 |
# File 'lib/ruport/util/graph/amline.rb', line 88 def data_out @data_out ||= "" end |
#format_settings ⇒ Object
80 81 82 |
# File 'lib/ruport/util/graph/amline.rb', line 80 def format_settings .format_settings || lambda {} end |
#generate_config_file ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ruport/util/graph/amline.rb', line 66 def generate_config_file settings = ::Amline::Settings.new data.each do |r| settings.add_graph(r.gid) settings.graph(r.gid) { |g| g.title = r.gid } end .templated_settings_proc[settings] if .templated_settings_proc format_settings[settings] settings_out << settings.to_xml end |
#output ⇒ Object
84 85 86 |
# File 'lib/ruport/util/graph/amline.rb', line 84 def output { :data => data_out, :settings => settings_out } end |
#settings_out ⇒ Object
92 93 94 |
# File 'lib/ruport/util/graph/amline.rb', line 92 def settings_out @settings_out ||= "" end |