21: def draw_bars
22:
23:
24:
25: spacing_factor = 0.9
26: @bar_width = @graph_width / (@column_count * @data.length).to_f
27:
28: @d = @d.stroke_opacity 0.0
29:
30:
31: conversion = Gruff::BarConversion.new()
32: conversion.graph_height = @graph_height
33: conversion.graph_top = @graph_top
34:
35:
36: if @minimum_value >= 0 then
37:
38: conversion.mode = 1
39: else
40:
41: if @maximum_value <= 0 then
42: conversion.mode = 2
43: else
44:
45: conversion.mode = 3
46: conversion.spread = @spread
47: conversion.minimum_value = @minimum_value
48: conversion.zero = -@minimum_value/@spread
49: end
50: end
51:
52:
53: @norm_data.each_with_index do |data_row, row_index|
54:
55: data_row[1].each_with_index do |data_point, point_index|
56:
57:
58: left_x = @graph_left + (@bar_width * (row_index + point_index + ((@data.length - 1) * point_index)))
59: right_x = left_x + @bar_width * spacing_factor
60:
61: conv = []
62: conversion.getLeftYRightYscaled( data_point, conv )
63:
64:
65: @d = @d.fill data_row[DATA_COLOR_INDEX]
66: @d = @d.rectangle(left_x, conv[0], right_x, conv[1])
67:
68:
69: label_center = @graph_left +
70: (@data.length * @bar_width * point_index) +
71: (@data.length * @bar_width / 2.0)
72:
73: draw_label(label_center - (@center_labels_over_point ? @bar_width / 2.0 : 0.0), point_index)
74: end
75:
76: end
77:
78:
79: draw_label(@graph_right, @column_count) if @center_labels_over_point
80:
81: @d.draw(@base_image)
82: end