Class: Mach5::Chart
- Inherits:
-
Object
- Object
- Mach5::Chart
- Defined in:
- lib/mach5-tools/chart.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#data_type ⇒ Object
Returns the value of attribute data_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#series ⇒ Object
Returns the value of attribute series.
-
#size ⇒ Object
Returns the value of attribute size.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#x_axis ⇒ Object
Returns the value of attribute x_axis.
-
#y_axis ⇒ Object
Returns the value of attribute y_axis.
Instance Method Summary collapse
- #_series(series) ⇒ Object
- #build ⇒ Object
-
#initialize(id) ⇒ Chart
constructor
A new instance of Chart.
Constructor Details
#initialize(id) ⇒ Chart
Returns a new instance of Chart.
13 14 15 |
# File 'lib/mach5-tools/chart.rb', line 13 def initialize(id) @id = id end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/mach5-tools/chart.rb', line 10 def config @config end |
#data_type ⇒ Object
Returns the value of attribute data_type.
4 5 6 |
# File 'lib/mach5-tools/chart.rb', line 4 def data_type @data_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/mach5-tools/chart.rb', line 11 def id @id end |
#series ⇒ Object
Returns the value of attribute series.
9 10 11 |
# File 'lib/mach5-tools/chart.rb', line 9 def series @series end |
#size ⇒ Object
Returns the value of attribute size.
5 6 7 |
# File 'lib/mach5-tools/chart.rb', line 5 def size @size end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/mach5-tools/chart.rb', line 6 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/mach5-tools/chart.rb', line 3 def type @type end |
#x_axis ⇒ Object
Returns the value of attribute x_axis.
7 8 9 |
# File 'lib/mach5-tools/chart.rb', line 7 def x_axis @x_axis end |
#y_axis ⇒ Object
Returns the value of attribute y_axis.
8 9 10 |
# File 'lib/mach5-tools/chart.rb', line 8 def y_axis @y_axis end |
Instance Method Details
#_series(series) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mach5-tools/chart.rb', line 44 def _series(series) result = [] series.each do |s| commit_id = @config.benchmarks.tagged[s[:commit_id]] unless commit_id commit_id = s[:commit_id] end serie = { "label" => "#{s[:commit_id]}.#{s[:benchmark_id]}", "file" => File.join(Dir.pwd, @config.output_folder, "#{commit_id}.#{s[:benchmark_id]}.json") } serie["label"] = s[:label] if s[:label] serie["color"] = s[:color] if s[:color] result << serie end result end |
#build ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mach5-tools/chart.rb', line 17 def build hash = { "type" => @type, "dataType" => @data_type, "size" => { "width" => size.split("x").map(&:to_i)[0], "height" => size.split("x").map(&:to_i)[1] }, "title" => { "text" => @title }, "xAxis" => { "title" => { "text" => @x_axis[:label] } }, "yAxis" => { "title" => { "text" => @y_axis } }, "series" => _series(@series) } hash["xAxis"]["categories"] = @x_axis[:categories] if @x_axis[:categories] hash end |