Class: OmfEc::Graph::GraphDescription
- Inherits:
-
Object
- Object
- OmfEc::Graph::GraphDescription
- Defined in:
- lib/omf_ec/graph/graph_description.rb
Overview
Describes a graph which can be displayed through the web interface or any other defined graph visualiser.
Constant Summary collapse
- @@gds =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #_report ⇒ Object
- #_report_meta ⇒ Object
- #caption(text) ⇒ Object
-
#mapping(mhash) ⇒ Object
Defines the mapping of columns in the measurement tuples to properties of the visualization.
-
#ms(ms_name, context = :default) ⇒ Object
Define the measurement stream to be visualized in the graph.
- #opts(additional_opts = {}) ⇒ Object
-
#postfix(text) ⇒ Object
Define text to be shown above the graph.
-
#sql(raw_sql, context = :default) ⇒ Object
Define the measurement stream to be visualized in the graph through a raw SQL query string.
- #type(gtype) ⇒ Object
- #xaxis(props) ⇒ Object
- #yaxis(props) ⇒ Object
Class Method Details
.create(name = nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/omf_ec/graph/graph_description.rb', line 14 def self.create(name = nil) if name @@gds[name.to_sym] ||= self.new(name) else self.new("Unknown #{self.object_id}") end end |
Instance Method Details
#_report ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/omf_ec/graph/graph_description.rb', line 91 def _report info "REPORT:START: #{@name}" info "REPORT:TYPE: #{@gtype}" info "REPORT:POSTFIX: #{URI.encode(@postfix)}" if @postfix @ms.each do |ctxt, a| a.each do |ms| sql = ms.is_a?(String) ? ms : ms.sql info "REPORT:MS:#{ctxt}: #{URI.encode(sql)}" end end info "REPORT:MAPPING: #{URI.encode(@mapping.to_json)}" if @axis info "REPORT:AXIS: #{URI.encode(@axis.to_json)}" end info "REPORT:CAPTION: #{URI.encode(@caption)}" if @caption info "REPORT:OPTS: #{URI.encode(@opts.to_json)}" if @opts info "REPORT:STOP" end |
#_report_meta ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/omf_ec/graph/graph_description.rb', line 111 def h = { type: @gtype, mapping: @mapping, caption: @caption } h[:postfix] = @postfix if @postfix dss = h[:dss] = {} @ms.each do |ctxt, a| a.each do |ms| dss[ctxt] = ms.sql end end if @axis h[:axis] = @axis end h[:opts] = @opts if @opts descr = h.to_json OmfEc.experiment.(@name, descr, :graph) end |
#caption(text) ⇒ Object
83 84 85 |
# File 'lib/omf_ec/graph/graph_description.rb', line 83 def (text) @caption = text end |
#mapping(mhash) ⇒ Object
Defines the mapping of columns in the measurement tuples to properties of the visualization.
67 68 69 |
# File 'lib/omf_ec/graph/graph_description.rb', line 67 def mapping(mhash) @mapping = mhash end |
#ms(ms_name, context = :default) ⇒ Object
Define the measurement stream to be visualized in the graph. The optional ‘context’ parameter defines the context in which the MS is used in the graph. This is necessary for graphs, such as ‘networks’ which need more than one MS to describe the visualization.
39 40 41 42 43 44 45 46 |
# File 'lib/omf_ec/graph/graph_description.rb', line 39 def ms(ms_name, context = :default) if (table_name = OmfEc.experiment.mp_table_names[ms_name]) (@ms[context] ||= []) << (msb = MSBuilder.new(@db[table_name.to_sym])) else warn "Measurement point '#{ms_name}' NOT defined" end msb end |
#opts(additional_opts = {}) ⇒ Object
87 88 89 |
# File 'lib/omf_ec/graph/graph_description.rb', line 87 def opts(additional_opts = {}) @opts = additional_opts end |
#postfix(text) ⇒ Object
Define text to be shown above the graph
26 27 28 |
# File 'lib/omf_ec/graph/graph_description.rb', line 26 def postfix(text) @postfix = text end |
#sql(raw_sql, context = :default) ⇒ Object
Define the measurement stream to be visualized in the graph through a raw SQL query string. The optional ‘context’ parameter defines the context in which the stream is used in the graph. This is necessary for graphs, such as ‘networks’ which need more than one MS to describe the visualization.
58 59 60 61 |
# File 'lib/omf_ec/graph/graph_description.rb', line 58 def sql(raw_sql, context = :default) @ms[context] = raw_sql raw_sql end |
#type(gtype) ⇒ Object
71 72 73 |
# File 'lib/omf_ec/graph/graph_description.rb', line 71 def type(gtype) @gtype = gtype end |
#xaxis(props) ⇒ Object
75 76 77 |
# File 'lib/omf_ec/graph/graph_description.rb', line 75 def xaxis(props) (@axis ||= {})[:x] = props end |
#yaxis(props) ⇒ Object
79 80 81 |
# File 'lib/omf_ec/graph/graph_description.rb', line 79 def yaxis(props) (@axis ||= {})[:y] = props end |