# File lib/scruffy/layers/sparkline_bar.rb, line 23 def generate_coordinates(options = {}) @bar_width = (width / points.size) * 0.9 options[:point_distance] = (width - (width / points.size)) / (points.size - 1).to_f #TODO iteration by index on points. Needs to change coords = (0...points.size).map do |idx| x_coord = (options[:point_distance] * idx) + (width / points.size * 0.5) relative_percent = ((points[idx] == min_value) ? 0 : ((points[idx] - min_value) / (max_value - min_value).to_f)) y_coord = (height - (height * relative_percent)) [x_coord, y_coord] end coords end