class Charty::Plotters::SimpleNormalizer
TODO: This should be replaced with red-colors's Normalize feature
Attributes
vmax[RW]
vmin[RW]
Public Class Methods
new(vmin=nil, vmax=nil)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 41 def initialize(vmin=nil, vmax=nil) @vmin = vmin @vmax = vmax end
Public Instance Methods
call(value, clip=nil)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 48 def call(value, clip=nil) scalar_p = false vector_p = false case value when Charty::Vector vector_p = true value = value.to_a when Array # do nothing else scalar_p = true value = [value] end @vmin = value.min if vmin.nil? @vmax = value.max if vmax.nil? result = value.map {|x| (x - vmin) / (vmax - vmin).to_f } case when scalar_p result[0] when vector_p Charty::Vector.new(result, index: value.index) else result end end