48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# 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
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
|