class Mach5::Chart

Attributes

config[RW]
data_type[RW]
id[R]
series[RW]
size[RW]
title[RW]
type[RW]
x_axis[RW]
y_axis[RW]

Public Class Methods

new(id) click to toggle source
# File lib/mach5-tools/chart.rb, line 13
def initialize(id)
  @id = id
end

Public Instance Methods

_series(series) click to toggle source
# 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() click to toggle source
# 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