lib/squid/point.rb in squid-1.0.0.beta2 vs lib/squid/point.rb in squid-1.0.0.beta3
- old
+ new
@@ -2,20 +2,20 @@
module Squid
class Point
extend Format
- def self.for(series, minmax:, height:, labels:, stack:, format:)
+ def self.for(series, minmax:, height:, labels:, stack:, formats:)
@min = Hash.new 0
@max = Hash.new 0
min, max = minmax
offset = -> (value) { value * height.to_f / (max-min) }
- series.map do |values|
+ series.map.with_index do |values, series_i|
values.map.with_index do |value, i|
h = y_for value, index: i, stack: false, &offset if value
y = y_for value, index: i, stack: stack, &offset if value
y = y - offset.call([min, 0].min) if value
- label = format_for(value, format) if labels
+ label = format_for value, formats[series_i] if labels[series_i]
new y: y, height: h, index: i, label: label, negative: value.to_f < 0
end
end
end