def draw
@has_left_labels = true
super
return unless @has_data
@bar_spacing ||= 0.9
@bars_width = @graph_height / @column_count.to_f
@bar_width = @bars_width * @bar_spacing / @norm_data.size
@d = @d.stroke_opacity 0.0
height = Array.new(@column_count, 0)
length = Array.new(@column_count, @graph_left)
padding = (@bars_width * (1 - @bar_spacing)) / 2
@norm_data.each_with_index do |data_row, row_index|
@d = @d.fill data_row[DATA_COLOR_INDEX]
data_row[DATA_VALUES_INDEX].each_with_index do |data_point, point_index|
temp1 = @graph_left + (@graph_width - data_point * @graph_width - height[point_index])
temp2 = @graph_left + @graph_width - height[point_index]
difference = temp2 - temp1
left_x = length[point_index] - 1
left_y = @graph_top + (@bars_width * point_index) + (@bar_width * row_index) + padding
right_x = left_x + difference
right_y = left_y + @bar_width
height[point_index] += (data_point * @graph_width)
@d = @d.rectangle(left_x, left_y, right_x, right_y)
label_center = @graph_top + (@bars_width * point_index + @bars_width / 2)
draw_label(label_center, point_index)
end
end
@d.draw(@base_image)
end