lib/gruff/mini/legend.rb
##
# Shorten long labels so they will fit on the canvas.
#
#   Department of Hu...
Shorten long labels so they will fit on the canvas.
Department of Hu
Shorten long labels so they will fit on the canvas . Department of Hu
def truncate_legend_label(label)
        truncated_label = label.to_s
        font = @legend_font.dup
        font.size = scale_fontsize(font.size)
        max_width = @columns - @legend_left_margin - @right_margin
        while calculate_width(font, truncated_label) > max_width && truncated_label.length > 1
          truncated_label = truncated_label[0..truncated_label.length - 2]
        end
        truncated_label + (truncated_label.length < label.to_s.length ? '...' : '')
      end
def truncate_legend_label ( label ) truncated_label = label . to_s font = @legend_font . dup font . size = scale_fontsize ( font . size ) max_width = @columns - @legend_left_margin - @right_margin while calculate_width ( font , truncated_label ) > max_width && truncated_label . length > 1 truncated_label = truncated_label [ 0 .. truncated_label . length - 2 ] end truncated_label + ( truncated_label . length < label . to_s . length ? '...' : '' ) end
Shorten long labels so they will fit on the canvas.
Shorten long labels so they will fit on the canvas .
label
<not_specific>