def draw
super
return unless @has_data
@x_increment = (@column_count > 1) ? (@graph_width / (@column_count - 1).to_f) : @graph_width
@reference_lines.each_value do |curr_reference_line|
draw_horizontal_reference_line(curr_reference_line) if curr_reference_line.key?(:norm_value)
draw_vertical_reference_line(curr_reference_line) if curr_reference_line.key?(:index)
end
if (@show_vertical_markers)
(0..@column_count).each do |column|
x = @graph_left + @graph_width - column.to_f * @x_increment
@d = @d.fill(@marker_color)
x += 0.001 unless defined?(JRUBY_VERSION)
@d = @d.line(x, @graph_bottom, x, @graph_top)
unless @marker_shadow_color.nil?
@d = @d.fill(@marker_shadow_color)
@d = @d.line(x + 1, @graph_bottom, x + 1, @graph_top)
end
end
end
@norm_data.each do |data_row|
prev_x = prev_y = nil
@one_point = contains_one_point_only?(data_row)
data_row[DATA_VALUES_INDEX].each_with_index do |data_point, index|
x_data = data_row[DATA_VALUES_X_INDEX]
if x_data == nil
new_x = @graph_left + (@x_increment * index)
draw_label(new_x, index)
else
new_x = get_x_coord(x_data[index], @graph_width, @graph_left)
@labels.each do |label_pos, _|
draw_label(@graph_left + ((label_pos - @minimum_x_value) * @graph_width) / (@maximum_x_value - @minimum_x_value), label_pos)
end
end
unless data_point
prev_x = prev_y = nil
next
end
new_y = @graph_top + (@graph_height - data_point * @graph_height)
@d = @d.stroke data_row[DATA_COLOR_INDEX]
@d = @d.fill data_row[DATA_COLOR_INDEX]
@d = @d.stroke_opacity 1.0
@d = @d.stroke_width line_width ||
clip_value_if_greater_than(@columns / (@norm_data.first[DATA_VALUES_INDEX].size * 4), 5.0)
circle_radius = dot_radius ||
clip_value_if_greater_than(@columns / (@norm_data.first[DATA_VALUES_INDEX].size * 2.5), 5.0)
if !@hide_lines && !prev_x.nil? && !prev_y.nil?
@d = @d.line(prev_x, prev_y, new_x, new_y)
elsif @one_point
@d = @d.circle(new_x, new_y, new_x - circle_radius, new_y)
end
@d = @d.circle(new_x, new_y, new_x - circle_radius, new_y) unless @hide_dots
prev_x, prev_y = new_x, new_y
end
end
@d.draw(@base_image)
end