def setup_graph_measurements
@marker_caps_height = @hide_line_markers ? 0 :
calculate_caps_height(@marker_font_size)
@title_caps_height = @hide_title ? 0 :
calculate_caps_height(@title_font_size)
@legend_caps_height = @hide_legend ? 0 :
calculate_caps_height(@legend_font_size)
if @hide_line_markers
(@graph_left,
@graph_right_margin,
@graph_bottom_margin) = [@left_margin, @right_margin, @bottom_margin]
else
longest_left_label_width = 0
if @has_left_labels
longest_left_label_width = calculate_width(@marker_font_size,
labels.values.inject('') { |value, memo| (value.to_s.length > memo.to_s.length) ? value : memo }) * 1.25
else
longest_left_label_width = calculate_width(@marker_font_size,
label(@maximum_value.to_f))
end
line_number_width = @hide_line_numbers && !@has_left_labels ?
0.0 :
(longest_left_label_width + LABEL_MARGIN * 2)
@graph_left = @left_margin +
line_number_width +
(@y_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN * 2)
last_label = @labels.keys.sort.last.to_i
extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
calculate_width(@marker_font_size, @labels[last_label]) / 2.0 :
0
@graph_right_margin = @right_margin + extra_room_for_long_label
@graph_bottom_margin = @bottom_margin +
@marker_caps_height + LABEL_MARGIN
end
@graph_right = @raw_columns - @graph_right_margin
@graph_width = @raw_columns - @graph_left - @graph_right_margin
@graph_top = @top_margin +
(@hide_title ? title_margin : @title_caps_height + title_margin ) +
(@hide_legend ? legend_margin : @legend_caps_height + legend_margin)
x_axis_label_height = @x_axis_label.nil? ? 0.0 :
@marker_caps_height + LABEL_MARGIN
@graph_bottom = @raw_rows - @graph_bottom_margin - x_axis_label_height
@graph_height = @graph_bottom - @graph_top
end