Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Formatting and RMagick compatibility

  • Loading branch information...
commit 0bd3bc78ec80eb22dbe82734dafa985bbc445556 1 parent 0fc48ac
@topfunky authored
View
3  .gitignore
@@ -1,2 +1,3 @@
.DS_Store
-test/output/*
+test/output/*
+.yardoc
View
5 .rvmrc
@@ -0,0 +1,5 @@
+if [[ -n "$rvm_environments_path" && -s "$rvm_environments_path/ree-1.8.7-2010.02@gruff" ]] ; then
+ . "$rvm_environments_path/ree-1.8.7-2010.02@gruff"
+else
+ rvm --create use "ree-1.8.7-2010.02@gruff"
+fi
View
2  lib/gruff/base.rb
@@ -1085,6 +1085,7 @@ def label(value)
# handle.
def calculate_caps_height(font_size)
@d.pointsize = font_size
+ @d.font = @font
@d.get_type_metrics(@base_image, 'X').height
end
@@ -1094,6 +1095,7 @@ def calculate_caps_height(font_size)
# scaling will handle.
def calculate_width(font_size, text)
@d.pointsize = font_size
+ @d.font = font
@d.get_type_metrics(@base_image, text.to_s).width
end
View
54 lib/gruff/mini/legend.rb
@@ -1,9 +1,9 @@
module Gruff
module Mini
module Legend
-
+
attr_accessor :hide_mini_legend, :legend_position
-
+
##
# The canvas needs to be bigger so we can put the legend beneath it.
@@ -13,18 +13,18 @@ def expand_canvas_for_vertical_legend
@legend_labels = @data.collect {|item| item[Gruff::Base::DATA_LABEL_INDEX] }
legend_height = scale_fontsize(
- @data.length * calculate_line_height +
- @top_margin + @bottom_margin)
+ @data.length * calculate_line_height +
+ @top_margin + @bottom_margin)
@original_rows = @raw_rows
@original_columns = @raw_columns
case @legend_position
- when :right then
- @rows = [@rows, legend_height].max
- @columns += calculate_legend_width + @left_margin
- else
- @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
+ when :right then
+ @rows = [@rows, legend_height].max
+ @columns += calculate_legend_width + @left_margin
+ else
+ @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7
end
render_background
end
@@ -43,7 +43,7 @@ def calculate_legend_width
def draw_vertical_legend
return if @hide_mini_legend
-
+
legend_square_width = 40.0 # small square with color of this item
legend_square_margin = 10.0
@legend_left_margin = 100.0
@@ -54,17 +54,17 @@ def draw_vertical_legend
@d.pointsize = @legend_font_size
case @legend_position
- when :right then
- current_x_offset = @original_columns + @left_margin
- current_y_offset = @top_margin + legend_top_margin
- else
- current_x_offset = @legend_left_margin
- current_y_offset = @original_rows + legend_top_margin
+ when :right then
+ current_x_offset = @original_columns + @left_margin
+ current_y_offset = @top_margin + legend_top_margin
+ else
+ current_x_offset = @legend_left_margin
+ current_y_offset = @original_rows + legend_top_margin
end
debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
- @legend_labels.each_with_index do |legend_label, index|
+ @legend_labels.each_with_index do |legend_label, index|
# Draw label
@d.fill = @font_color
@@ -73,19 +73,19 @@ def draw_vertical_legend
@d.stroke = 'transparent'
@d.font_weight = Magick::NormalWeight
@d.gravity = Magick::WestGravity
- @d = @d.annotate_scaled( @base_image,
- @raw_columns, 1.0,
- current_x_offset + (legend_square_width * 1.7), current_y_offset,
- truncate_legend_label(legend_label), @scale)
+ @d = @d.annotate_scaled( @base_image,
+ @raw_columns, 1.0,
+ current_x_offset + (legend_square_width * 1.7), current_y_offset,
+ truncate_legend_label(legend_label), @scale)
# Now draw box with color of this dataset
@d = @d.stroke 'transparent'
@d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX]
- @d = @d.rectangle(current_x_offset,
- current_y_offset - legend_square_width / 2.0,
- current_x_offset + legend_square_width,
+ @d = @d.rectangle(current_x_offset,
+ current_y_offset - legend_square_width / 2.0,
+ current_x_offset + legend_square_width,
current_y_offset + legend_square_width / 2.0)
-
+
current_y_offset += calculate_line_height
end
@color_index = 0
@@ -95,7 +95,7 @@ def draw_vertical_legend
# Shorten long labels so they will fit on the canvas.
#
# Department of Hu...
-
+
def truncate_legend_label(label)
truncated_label = label.to_s
while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1)
@@ -103,7 +103,7 @@ def truncate_legend_label(label)
end
truncated_label + (truncated_label.length < label.to_s.length ? "..." : '')
end
-
+
end
end
end
View
1  test/test_line.rb
@@ -462,7 +462,6 @@ def test_jruby_error
g.legend_font_size = 12
g.marker_font_size = 16
g.hide_dots = false
- g.label_max_decimals = 1
g.write('test/output/line_jruby_error.png')
end
Please sign in to comment.
Something went wrong with that request. Please try again.