class Minichart::Leds

Base class for led charts

Public Class Methods

leds_defaults() click to toggle source
# File lib/minichart/leds/leds.rb, line 5
def leds_defaults
  @meter_defaults ||= {
    positive_color: '#6f6',
    negative_color: '#f66',
    neutral_color: '#eee',
    min_opacity: 1,
    padding: 2,
  }
end

Protected Instance Methods

max() click to toggle source

Returns the absolute highest or loest value. Used to define the availble range of values

# File lib/minichart/leds/leds.rb, line 26
def max
  @max ||= [data.compact.max, data.compact.min.abs].max.to_f
end
opacity(value) click to toggle source

Returns opacith level for a given value

# File lib/minichart/leds/leds.rb, line 19
def opacity(value)
  return 1 if !value or value == 0
  value.abs * ((1 - options[:min_opacity]) / max) + options[:min_opacity]
end