class SparklineShield
Public Class Methods
new(shield_name, chart_type, data, options, output_path)
click to toggle source
# File src/systems/sparkline_shield.rb, line 6 def initialize(shield_name, chart_type, data, options, output_path) @shield_name = shield_name @chart_type = chart_type.to_sym @data = data @options = options @output_path = output_path @shield_list = [:bar,:pie] end
Public Instance Methods
bar()
click to toggle source
# File src/systems/sparkline_shield.rb, line 20 def bar Sparklines.plot_to_file(@output_path + "/#{@shield_name}.gif", @data, bar_default_options.merge(@options)) end
bar_default_options()
click to toggle source
# File src/systems/sparkline_shield.rb, line 25 def bar_default_options { :type => 'bar', :below_color => 'blue', :above_color => 'orange', :upper => 0, :step => 6, :height => 30, } end
generate()
click to toggle source
# File src/systems/sparkline_shield.rb, line 15 def generate raise ArgumentError, "Chart type: #{@chart_type} not supported - please use one of: #{@shield_list}" unless @shield_list.include?(@chart_type) send @chart_type end
pie()
click to toggle source
# File src/systems/sparkline_shield.rb, line 36 def pie Sparklines.plot_to_file(@output_path + "/#{@shield_name}.gif", @data, pie_default_options.merge(@options)) end
pie_default_options()
click to toggle source
# File src/systems/sparkline_shield.rb, line 42 def pie_default_options { :type => 'pie', :share_color => '#3BB314', :remain_color => '#C8EDFA', :diameter => 30 } end