Browse files

* Merge branch 'staggered_labels'

* Issue #39 Add staggered labels
  • Loading branch information...
2 parents 9c73a95 + 49c056e commit 0aa9b3fdd77caa2340fed3d240dad0e6fb8e8fb2 @donv donv committed Nov 9, 2012
Showing with 83 additions and 6 deletions.
  1. +0 −1 .gitignore
  2. +44 −5 lib/gruff/base.rb
  3. BIN test/output/accum_bar.png
  4. BIN test/output/area_keynote.png
  5. BIN test/output/area_keynote_small.png
  6. BIN test/output/area_many.png
  7. BIN test/output/area_many_areas_small.png
  8. BIN test/output/area_tiny.png
  9. BIN test/output/area_wide.png
  10. BIN test/output/bar2_wrapped_legend_16_400.png
  11. BIN test/output/bar2_wrapped_legend_16_800.png
  12. BIN test/output/bar2_wrapped_legend_30_400.png
  13. BIN test/output/bar2_wrapped_legend_30_800.png
  14. BIN test/output/bar2_wrapped_legend_4_400.png
  15. BIN test/output/bar2_wrapped_legend_4_800.png
  16. BIN test/output/bar2_wrapped_legend__400.png
  17. BIN test/output/bar2_wrapped_legend__800.png
  18. BIN test/output/bar_formatted_numbers.png
  19. BIN test/output/bar_keynote.png
  20. BIN test/output/bar_keynote_small.png
  21. BIN test/output/bar_long_legend_text.png
  22. BIN test/output/bar_manual_colors.png
  23. BIN test/output/bar_nearly_zero_max_10.png
  24. BIN test/output/bar_no_legend.png
  25. BIN test/output/bar_no_line_markers.png
  26. BIN test/output/bar_no_title.png
  27. BIN test/output/bar_no_title_or_legend.png
  28. BIN test/output/bar_odeo.png
  29. BIN test/output/bar_one_value.png
  30. BIN test/output/bar_pos_neg.png
  31. BIN test/output/bar_rails_keynote.png
  32. BIN test/output/bar_set_absolute_trunc.png
  33. BIN test/output/bar_set_label_stagger_height.png
  34. BIN test/output/bar_set_legend_box_size_lg.png
  35. BIN test/output/bar_set_legend_box_size_sm.png
  36. BIN test/output/bar_set_marker.png
  37. BIN test/output/bar_set_trailing_dots_trunc.png
  38. BIN test/output/bar_spacing_full.png
  39. BIN test/output/bar_spacing_half.png
  40. BIN test/output/bar_spacing_none.png
  41. BIN test/output/bar_tall_graph.png
  42. BIN test/output/bar_tall_graph_small.png
  43. BIN test/output/bar_themed.png
  44. BIN test/output/bar_wide_graph.png
  45. BIN test/output/bar_wide_graph_small.png
  46. BIN test/output/bar_wrapped_legend_16_400.png
  47. BIN test/output/bar_wrapped_legend_16_800.png
  48. BIN test/output/bar_wrapped_legend_30_400.png
  49. BIN test/output/bar_wrapped_legend_30_800.png
  50. BIN test/output/bar_wrapped_legend_4_400.png
  51. BIN test/output/bar_wrapped_legend_4_800.png
  52. BIN test/output/bar_wrapped_legend__400.png
  53. BIN test/output/bar_wrapped_legend__800.png
  54. BIN test/output/bar_x_y_labels.png
  55. BIN test/output/bar_y_increment_1.png
  56. BIN test/output/bar_y_increment_2.0.png
  57. BIN test/output/bar_y_increment_20.png
  58. BIN test/output/bar_y_increment_5.png
  59. BIN test/output/bezier.png
  60. BIN test/output/bezier_2.png
  61. BIN test/output/bezier_3.png
  62. BIN test/output/bullet_greyscale.png
  63. BIN test/output/bullet_no_options.png
  64. BIN test/output/dot_keynote.png
  65. BIN test/output/dot_keynote_small.png
  66. BIN test/output/dot_manual_colors.png
  67. BIN test/output/dot_nearly_zero_max_10.png
  68. BIN test/output/dot_no_legend.png
  69. BIN test/output/dot_no_line_markers.png
  70. BIN test/output/dot_no_title.png
  71. BIN test/output/dot_no_title_or_legend.png
  72. BIN test/output/dot_one_value.png
  73. BIN test/output/dot_pos_neg.png
  74. BIN test/output/dot_set_legend_box_size_lg.png
  75. BIN test/output/dot_set_legend_box_size_sm.png
  76. BIN test/output/dot_set_marker.png
  77. BIN test/output/dot_tall_graph.png
  78. BIN test/output/dot_tall_graph_small.png
  79. BIN test/output/dot_themed.png
  80. BIN test/output/dot_wide_graph.png
  81. BIN test/output/dot_wide_graph_small.png
  82. BIN test/output/dot_x_y_labels.png
  83. BIN test/output/dot_y_increment_1.png
  84. BIN test/output/dot_y_increment_2.0.png
  85. BIN test/output/dot_y_increment_20.png
  86. BIN test/output/dot_y_increment_5.png
  87. BIN test/output/enhancements.png
  88. BIN test/output/line_all_neg.png
  89. BIN test/output/line_all_neg_400.png
  90. BIN test/output/line_hang_value.png
  91. BIN test/output/line_hide_dots.png
  92. BIN test/output/line_hide_lines.png
  93. BIN test/output/line_jruby_error.png
  94. BIN test/output/line_large.png
  95. BIN test/output/line_large_baseline.png
  96. BIN test/output/line_many.png
  97. BIN test/output/line_many_lines_small.png
  98. BIN test/output/line_many_numbers.png
  99. BIN test/output/line_marker_label_accuracy.png
  100. BIN test/output/line_more_sets_than_colors.png
  101. BIN test/output/line_no_data.png
  102. BIN test/output/line_no_data_msg.png
  103. BIN test/output/line_no_data_other.png
  104. BIN test/output/line_no_hide.png
  105. BIN test/output/line_no_legend.png
  106. BIN test/output/line_no_line_markers.png
  107. BIN test/output/line_no_title.png
  108. BIN test/output/line_nothing_but_the_graph.png
  109. BIN test/output/line_one_value.png
  110. BIN test/output/line_one_value_array.png
  111. BIN test/output/line_pos_neg.png
  112. BIN test/output/line_pos_neg_400.png
  113. BIN test/output/line_similar_high_end_values.png
  114. BIN test/output/line_similar_high_end_values_with_floor.png
  115. BIN test/output/line_small.png
  116. BIN test/output/line_small_small.png
  117. BIN test/output/line_small_small_zero.png
  118. BIN test/output/line_small_zero.png
  119. BIN test/output/line_some_nil_points.png
  120. BIN test/output/line_theme_37signals_.png
  121. BIN test/output/line_theme_37signals_400.png
  122. BIN test/output/line_theme_keynote_.png
  123. BIN test/output/line_theme_keynote_400.png
  124. BIN test/output/line_theme_odeo_.png
  125. BIN test/output/line_theme_odeo_400.png
  126. BIN test/output/line_theme_rails_keynote_.png
  127. BIN test/output/line_theme_rails_keynote_400.png
  128. BIN test/output/line_tiny.png
  129. BIN test/output/line_transparent.png
  130. BIN test/output/line_wide_graph.png
  131. BIN test/output/line_wide_graph_small.png
  132. BIN test/output/line_xy.png
  133. BIN test/output/line_xy_pairs.png
  134. BIN test/output/mini_bar.png
  135. BIN test/output/mini_pie.png
  136. BIN test/output/mini_pie_right_legend.png
  137. BIN test/output/mini_side_bar.png
  138. BIN test/output/mini_side_bar_multi_color.png
  139. BIN test/output/net_dots_tiny.png
  140. BIN test/output/net_large.png
  141. BIN test/output/net_many.png
  142. BIN test/output/net_many_nets_small.png
  143. BIN test/output/net_no_data.png
  144. BIN test/output/net_no_data_msg.png
  145. BIN test/output/net_no_data_other.png
  146. BIN test/output/net_no_legend.png
  147. BIN test/output/net_no_net_markers.png
  148. BIN test/output/net_no_title.png
  149. BIN test/output/net_nothing_but_the_graph.png
  150. BIN test/output/net_similar_high_end_values.png
  151. BIN test/output/net_small.png
  152. BIN test/output/net_small_small.png
  153. BIN test/output/net_small_small_zero.png
  154. BIN test/output/net_small_zero.png
  155. BIN test/output/net_wide_graph.png
  156. BIN test/output/net_wide_graph_small.png
  157. BIN test/output/pie_equal.png
  158. BIN test/output/pie_grey.png
  159. BIN test/output/pie_keynote.png
  160. BIN test/output/pie_keynote_small.png
  161. BIN test/output/pie_legend.png
  162. BIN test/output/pie_legend_small.png
  163. BIN test/output/pie_nearly_equal.png
  164. BIN test/output/pie_one_val.png
  165. BIN test/output/pie_pastel.png
  166. BIN test/output/pie_simple.png
  167. BIN test/output/pie_wide.png
  168. BIN test/output/pie_wrapped_legend_16_400.png
  169. BIN test/output/pie_wrapped_legend_16_800.png
  170. BIN test/output/pie_wrapped_legend_30_400.png
  171. BIN test/output/pie_wrapped_legend_30_800.png
  172. BIN test/output/pie_wrapped_legend_4_400.png
  173. BIN test/output/pie_wrapped_legend_4_800.png
  174. BIN test/output/pie_wrapped_legend__400.png
  175. BIN test/output/pie_wrapped_legend__800.png
  176. BIN test/output/pie_zero.png
  177. BIN test/output/scatter_all_neg.png
  178. BIN test/output/scatter_all_neg_400.png
  179. BIN test/output/scatter_basic.png
  180. BIN test/output/scatter_many.png
  181. BIN test/output/scatter_no_data.png
  182. BIN test/output/scatter_no_data_msg.png
  183. BIN test/output/scatter_no_data_other.png
  184. BIN test/output/scatter_no_hide.png
  185. BIN test/output/scatter_no_labels.png
  186. BIN test/output/scatter_no_legend.png
  187. BIN test/output/scatter_no_line_markers.png
  188. BIN test/output/scatter_no_title.png
  189. BIN test/output/scatter_nothing_but_the_graph.png
  190. BIN test/output/scatter_pos_neg.png
  191. BIN test/output/scatter_pos_neg_400.png
  192. BIN test/output/scatter_wide_graph.png
  193. BIN test/output/scatter_wide_graph_small.png
  194. BIN test/output/scene_hazy_night.png
  195. BIN test/output/scene_not_hazy_day.png
  196. BIN test/output/scene_partly_cloudy_day.png
  197. BIN test/output/scene_stormy_day.png
  198. BIN test/output/scene_stormy_night.png
  199. BIN test/output/side_bar.png
  200. BIN test/output/side_bar_data_range.png
  201. BIN test/output/side_bar_spacing_full.png
  202. BIN test/output/side_bar_spacing_half.png
  203. BIN test/output/side_bar_spacing_none.png
  204. BIN test/output/side_stacked_bar_keynote.png
  205. BIN test/output/side_stacked_bar_keynote_small.png
  206. BIN test/output/side_stacked_bar_long_label.png
  207. BIN test/output/side_stacked_bar_wide.png
  208. BIN test/output/spider_37signals.png
  209. BIN test/output/spider_equal.png
  210. BIN test/output/spider_keynote.png
  211. BIN test/output/spider_legend.png
  212. BIN test/output/spider_legend_small.png
  213. BIN test/output/spider_lots_of_data.png
  214. BIN test/output/spider_lots_of_data_normal_names.png
  215. BIN test/output/spider_nearly_equal.png
  216. BIN test/output/spider_no_axes.png
  217. BIN test/output/spider_no_background.png
  218. BIN test/output/spider_no_print.png
  219. BIN test/output/spider_overlay_1.png
  220. BIN test/output/spider_overlay_2.png
  221. BIN test/output/spider_small.png
  222. BIN test/output/spider_wide.png
  223. BIN test/output/spider_zero.png
  224. BIN test/output/stacked_area_keynote.png
  225. BIN test/output/stacked_area_keynote_small.png
  226. BIN test/output/stacked_bar_keynote.png
  227. BIN test/output/stacked_bar_keynote_small.png
  228. +39 −0 test/test_bar.rb
View
1 .gitignore
@@ -1,6 +1,5 @@
/.idea/
/pkg/
.DS_Store
-/test/output
.bundle
.yardoc
View
49 lib/gruff/base.rb
@@ -87,6 +87,19 @@ class Base
# Manually set increment of the horizontal marking lines
attr_accessor :y_axis_increment
+ # Height of staggering between labels (Bar graph only)
+ attr_accessor :label_stagger_height
+
+ # Truncates labels if longer than max specified
+ attr_accessor :label_max_size
+
+ # How truncated labels visually appear if they exceed label_max_size
+ # :absolute - does not show trailing dots to indicate truncation. This is
+ # the default.
+ # :trailing_dots - shows trailing dots to indicate truncation (note
+ # that label_max_size must be greater than 3).
+ attr_accessor :label_truncation_style
+
# Get or set the list of colors that will be used to draw the bars or lines.
attr_accessor :colors
@@ -233,6 +246,9 @@ def initialize_ivars
@hide_line_markers = @hide_legend = @hide_title = @hide_line_numbers = false
@center_labels_over_point = true
@has_left_labels = false
+ @label_stagger_height = 0
+ @label_max_size = 0
+ @label_truncation_style = :absolute
@additional_line_values = []
@additional_line_colors = []
@@ -521,8 +537,9 @@ def setup_graph_measurements
(@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
+ @marker_caps_height + LABEL_MARGIN
+ # FIXME: Consider chart types other than bar
+ @graph_bottom = @raw_rows - @graph_bottom_margin - x_axis_label_height - @label_stagger_height
@graph_height = @graph_bottom - @graph_top
end
@@ -761,16 +778,38 @@ def draw_label(x_offset, index)
if !@labels[index].nil? && @labels_seen[index].nil?
y_offset = @graph_bottom + LABEL_MARGIN
+ # TESTME
+ # FIXME: Consider chart types other than bar
+ # TODO: See if index.odd? is the best stragegy
+ y_offset += @label_stagger_height if index.odd?
+
+ label_text = @labels[index]
+
+ # TESTME
+ # FIXME: Consider chart types other than bar
+ if label_text.size > @label_max_size
+
+ if @label_truncation_style == :trailing_dots
+ if @label_max_size > 3
+ # 4 because '...' takes up 3 chars
+ label_text = "#{label_text[0 .. (@label_max_size - 4)]}..."
+ end
+ else # @label_truncation_style is :absolute (default)
+ label_text = label_text[0 .. (@label_max_size - 1)]
+ end
+
+ end
+
@d.fill = @font_color
@d.font = @font if @font
@d.stroke('transparent')
@d.font_weight = NormalWeight
@d.pointsize = scale_fontsize(@marker_font_size)
@d.gravity = NorthGravity
@d = @d.annotate_scaled(@base_image,
- 1.0, 1.0,
- x_offset, y_offset,
- @labels[index], @scale)
+ 1.0, 1.0,
+ x_offset, y_offset,
+ label_text, @scale)
@labels_seen[index] = 1
debug { @d.line 0.0, y_offset, @raw_columns, y_offset }
end
View
BIN test/output/accum_bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_keynote.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_keynote_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_many.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_many_areas_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_tiny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_wide.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_16_400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_16_800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_30_400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_30_800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_4_400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend_4_800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend__400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar2_wrapped_legend__800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_formatted_numbers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_keynote.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_keynote_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_long_legend_text.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_manual_colors.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_nearly_zero_max_10.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_no_legend.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_no_line_markers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_no_title.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_no_title_or_legend.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/bar_odeo.png
Diff not rendered.
View
BIN test/output/bar_one_value.png
Diff not rendered.
View
BIN test/output/bar_pos_neg.png
Diff not rendered.
View
BIN test/output/bar_rails_keynote.png
Diff not rendered.
View
BIN test/output/bar_set_absolute_trunc.png
Diff not rendered.
View
BIN test/output/bar_set_label_stagger_height.png
Diff not rendered.
View
BIN test/output/bar_set_legend_box_size_lg.png
Diff not rendered.
View
BIN test/output/bar_set_legend_box_size_sm.png
Diff not rendered.
View
BIN test/output/bar_set_marker.png
Diff not rendered.
View
BIN test/output/bar_set_trailing_dots_trunc.png
Diff not rendered.
View
BIN test/output/bar_spacing_full.png
Diff not rendered.
View
BIN test/output/bar_spacing_half.png
Diff not rendered.
View
BIN test/output/bar_spacing_none.png
Diff not rendered.
View
BIN test/output/bar_tall_graph.png
Diff not rendered.
View
BIN test/output/bar_tall_graph_small.png
Diff not rendered.
View
BIN test/output/bar_themed.png
Diff not rendered.
View
BIN test/output/bar_wide_graph.png
Diff not rendered.
View
BIN test/output/bar_wide_graph_small.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_16_400.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_16_800.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_30_400.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_30_800.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_4_400.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend_4_800.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend__400.png
Diff not rendered.
View
BIN test/output/bar_wrapped_legend__800.png
Diff not rendered.
View
BIN test/output/bar_x_y_labels.png
Diff not rendered.
View
BIN test/output/bar_y_increment_1.png
Diff not rendered.
View
BIN test/output/bar_y_increment_2.0.png
Diff not rendered.
View
BIN test/output/bar_y_increment_20.png
Diff not rendered.
View
BIN test/output/bar_y_increment_5.png
Diff not rendered.
View
BIN test/output/bezier.png
Diff not rendered.
View
BIN test/output/bezier_2.png
Diff not rendered.
View
BIN test/output/bezier_3.png
Diff not rendered.
View
BIN test/output/bullet_greyscale.png
Diff not rendered.
View
BIN test/output/bullet_no_options.png
Diff not rendered.
View
BIN test/output/dot_keynote.png
Diff not rendered.
View
BIN test/output/dot_keynote_small.png
Diff not rendered.
View
BIN test/output/dot_manual_colors.png
Diff not rendered.
View
BIN test/output/dot_nearly_zero_max_10.png
Diff not rendered.
View
BIN test/output/dot_no_legend.png
Diff not rendered.
View
BIN test/output/dot_no_line_markers.png
Diff not rendered.
View
BIN test/output/dot_no_title.png
Diff not rendered.
View
BIN test/output/dot_no_title_or_legend.png
Diff not rendered.
View
BIN test/output/dot_one_value.png
Diff not rendered.
View
BIN test/output/dot_pos_neg.png
Diff not rendered.
View
BIN test/output/dot_set_legend_box_size_lg.png
Diff not rendered.
View
BIN test/output/dot_set_legend_box_size_sm.png
Diff not rendered.
View
BIN test/output/dot_set_marker.png
Diff not rendered.
View
BIN test/output/dot_tall_graph.png
Diff not rendered.
View
BIN test/output/dot_tall_graph_small.png
Diff not rendered.
View
BIN test/output/dot_themed.png
Diff not rendered.
View
BIN test/output/dot_wide_graph.png
Diff not rendered.
View
BIN test/output/dot_wide_graph_small.png
Diff not rendered.
View
BIN test/output/dot_x_y_labels.png
Diff not rendered.
View
BIN test/output/dot_y_increment_1.png
Diff not rendered.
View
BIN test/output/dot_y_increment_2.0.png
Diff not rendered.
View
BIN test/output/dot_y_increment_20.png
Diff not rendered.
View
BIN test/output/dot_y_increment_5.png
Diff not rendered.
View
BIN test/output/enhancements.png
Diff not rendered.
View
BIN test/output/line_all_neg.png
Diff not rendered.
View
BIN test/output/line_all_neg_400.png
Diff not rendered.
View
BIN test/output/line_hang_value.png
Diff not rendered.
View
BIN test/output/line_hide_dots.png
Diff not rendered.
View
BIN test/output/line_hide_lines.png
Diff not rendered.
View
BIN test/output/line_jruby_error.png
Diff not rendered.
View
BIN test/output/line_large.png
Diff not rendered.
View
BIN test/output/line_large_baseline.png
Diff not rendered.
View
BIN test/output/line_many.png
Diff not rendered.
View
BIN test/output/line_many_lines_small.png
Diff not rendered.
View
BIN test/output/line_many_numbers.png
Diff not rendered.
View
BIN test/output/line_marker_label_accuracy.png
Diff not rendered.
View
BIN test/output/line_more_sets_than_colors.png
Diff not rendered.
View
BIN test/output/line_no_data.png
Diff not rendered.
View
BIN test/output/line_no_data_msg.png
Diff not rendered.
View
BIN test/output/line_no_data_other.png
Diff not rendered.
View
BIN test/output/line_no_hide.png
Diff not rendered.
View
BIN test/output/line_no_legend.png
Diff not rendered.
View
BIN test/output/line_no_line_markers.png
Diff not rendered.
View
BIN test/output/line_no_title.png
Diff not rendered.
View
BIN test/output/line_nothing_but_the_graph.png
Diff not rendered.
View
BIN test/output/line_one_value.png
Diff not rendered.
View
BIN test/output/line_one_value_array.png
Diff not rendered.
View
BIN test/output/line_pos_neg.png
Diff not rendered.
View
BIN test/output/line_pos_neg_400.png
Diff not rendered.
View
BIN test/output/line_similar_high_end_values.png
Diff not rendered.
View
BIN test/output/line_similar_high_end_values_with_floor.png
Diff not rendered.
View
BIN test/output/line_small.png
Diff not rendered.
View
BIN test/output/line_small_small.png
Diff not rendered.
View
BIN test/output/line_small_small_zero.png
Diff not rendered.
View
BIN test/output/line_small_zero.png
Diff not rendered.
View
BIN test/output/line_some_nil_points.png
Diff not rendered.
View
BIN test/output/line_theme_37signals_.png
Diff not rendered.
View
BIN test/output/line_theme_37signals_400.png
Diff not rendered.
View
BIN test/output/line_theme_keynote_.png
Diff not rendered.
View
BIN test/output/line_theme_keynote_400.png
Diff not rendered.
View
BIN test/output/line_theme_odeo_.png
Diff not rendered.
View
BIN test/output/line_theme_odeo_400.png
Diff not rendered.
View
BIN test/output/line_theme_rails_keynote_.png
Diff not rendered.
View
BIN test/output/line_theme_rails_keynote_400.png
Diff not rendered.
View
BIN test/output/line_tiny.png
Diff not rendered.
View
BIN test/output/line_transparent.png
Diff not rendered.
View
BIN test/output/line_wide_graph.png
Diff not rendered.
View
BIN test/output/line_wide_graph_small.png
Diff not rendered.
View
BIN test/output/line_xy.png
Diff not rendered.
View
BIN test/output/line_xy_pairs.png
Diff not rendered.
View
BIN test/output/mini_bar.png
Diff not rendered.
View
BIN test/output/mini_pie.png
Diff not rendered.
View
BIN test/output/mini_pie_right_legend.png
Diff not rendered.
View
BIN test/output/mini_side_bar.png
Diff not rendered.
View
BIN test/output/mini_side_bar_multi_color.png
Diff not rendered.
View
BIN test/output/net_dots_tiny.png
Diff not rendered.
View
BIN test/output/net_large.png
Diff not rendered.
View
BIN test/output/net_many.png
Diff not rendered.
View
BIN test/output/net_many_nets_small.png
Diff not rendered.
View
BIN test/output/net_no_data.png
Diff not rendered.
View
BIN test/output/net_no_data_msg.png
Diff not rendered.
View
BIN test/output/net_no_data_other.png
Diff not rendered.
View
BIN test/output/net_no_legend.png
Diff not rendered.
View
BIN test/output/net_no_net_markers.png
Diff not rendered.
View
BIN test/output/net_no_title.png
Diff not rendered.
View
BIN test/output/net_nothing_but_the_graph.png
Diff not rendered.
View
BIN test/output/net_similar_high_end_values.png
Diff not rendered.
View
BIN test/output/net_small.png
Diff not rendered.
View
BIN test/output/net_small_small.png
Diff not rendered.
View
BIN test/output/net_small_small_zero.png
Diff not rendered.
View
BIN test/output/net_small_zero.png
Diff not rendered.
View
BIN test/output/net_wide_graph.png
Diff not rendered.
View
BIN test/output/net_wide_graph_small.png
Diff not rendered.
View
BIN test/output/pie_equal.png
Diff not rendered.
View
BIN test/output/pie_grey.png
Diff not rendered.
View
BIN test/output/pie_keynote.png
Diff not rendered.
View
BIN test/output/pie_keynote_small.png
Diff not rendered.
View
BIN test/output/pie_legend.png
Diff not rendered.
View
BIN test/output/pie_legend_small.png
Diff not rendered.
View
BIN test/output/pie_nearly_equal.png
Diff not rendered.
View
BIN test/output/pie_one_val.png
Diff not rendered.
View
BIN test/output/pie_pastel.png
Diff not rendered.
View
BIN test/output/pie_simple.png
Diff not rendered.
View
BIN test/output/pie_wide.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_16_400.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_16_800.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_30_400.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_30_800.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_4_400.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend_4_800.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend__400.png
Diff not rendered.
View
BIN test/output/pie_wrapped_legend__800.png
Diff not rendered.
View
BIN test/output/pie_zero.png
Diff not rendered.
View
BIN test/output/scatter_all_neg.png
Diff not rendered.
View
BIN test/output/scatter_all_neg_400.png
Diff not rendered.
View
BIN test/output/scatter_basic.png
Diff not rendered.
View
BIN test/output/scatter_many.png
Diff not rendered.
View
BIN test/output/scatter_no_data.png
Diff not rendered.
View
BIN test/output/scatter_no_data_msg.png
Diff not rendered.
View
BIN test/output/scatter_no_data_other.png
Diff not rendered.
View
BIN test/output/scatter_no_hide.png
Diff not rendered.
View
BIN test/output/scatter_no_labels.png
Diff not rendered.
View
BIN test/output/scatter_no_legend.png
Diff not rendered.
View
BIN test/output/scatter_no_line_markers.png
Diff not rendered.
View
BIN test/output/scatter_no_title.png
Diff not rendered.
View
BIN test/output/scatter_nothing_but_the_graph.png
Diff not rendered.
View
BIN test/output/scatter_pos_neg.png
Diff not rendered.
View
BIN test/output/scatter_pos_neg_400.png
Diff not rendered.
View
BIN test/output/scatter_wide_graph.png
Diff not rendered.
View
BIN test/output/scatter_wide_graph_small.png
Diff not rendered.
View
BIN test/output/scene_hazy_night.png
Diff not rendered.
View
BIN test/output/scene_not_hazy_day.png
Diff not rendered.
View
BIN test/output/scene_partly_cloudy_day.png
Diff not rendered.
View
BIN test/output/scene_stormy_day.png
Diff not rendered.
View
BIN test/output/scene_stormy_night.png
Diff not rendered.
View
BIN test/output/side_bar.png
Diff not rendered.
View
BIN test/output/side_bar_data_range.png
Diff not rendered.
View
BIN test/output/side_bar_spacing_full.png
Diff not rendered.
View
BIN test/output/side_bar_spacing_half.png
Diff not rendered.
View
BIN test/output/side_bar_spacing_none.png
Diff not rendered.
View
BIN test/output/side_stacked_bar_keynote.png
Diff not rendered.
View
BIN test/output/side_stacked_bar_keynote_small.png
Diff not rendered.
View
BIN test/output/side_stacked_bar_long_label.png
Diff not rendered.
View
BIN test/output/side_stacked_bar_wide.png
Diff not rendered.
View
BIN test/output/spider_37signals.png
Diff not rendered.
View
BIN test/output/spider_equal.png
Diff not rendered.
View
BIN test/output/spider_keynote.png
Diff not rendered.
View
BIN test/output/spider_legend.png
Diff not rendered.
View
BIN test/output/spider_legend_small.png
Diff not rendered.
View
BIN test/output/spider_lots_of_data.png
Diff not rendered.
View
BIN test/output/spider_lots_of_data_normal_names.png
Diff not rendered.
View
BIN test/output/spider_nearly_equal.png
Diff not rendered.
View
BIN test/output/spider_no_axes.png
Diff not rendered.
View
BIN test/output/spider_no_background.png
Diff not rendered.
View
BIN test/output/spider_no_print.png
Diff not rendered.
View
BIN test/output/spider_overlay_1.png
Diff not rendered.
View
BIN test/output/spider_overlay_2.png
Diff not rendered.
View
BIN test/output/spider_small.png
Diff not rendered.
View
BIN test/output/spider_wide.png
Diff not rendered.
View
BIN test/output/spider_zero.png
Diff not rendered.
View
BIN test/output/stacked_area_keynote.png
Diff not rendered.
View
BIN test/output/stacked_area_keynote_small.png
Diff not rendered.
View
BIN test/output/stacked_bar_keynote.png
Diff not rendered.
View
BIN test/output/stacked_bar_keynote_small.png
Diff not rendered.
View
39 test/test_bar.rb
@@ -300,6 +300,29 @@ def test_bar_spacing
g.write("test/output/bar_spacing_none.png")
end
+ def test_set_label_stagger_height
+ g = setup_long_labelled_graph
+ g.title = "Staggered labels"
+ g.label_stagger_height = 30
+ g.write("test/output/bar_set_label_stagger_height.png")
+ end
+
+ def test_set_label_max_size_and_label_truncation_style
+ # Absolute trunc
+ g = setup_long_labelled_graph
+ g.title = "Absolute truncation (13 chars)"
+ g.label_max_size = 13
+ g.label_truncation_style = :absolute
+ g.write("test/output/bar_set_absolute_trunc.png")
+
+ # Trailing Dots trunc
+ g = setup_long_labelled_graph
+ g.title = "Trailing dots truncation (6 chars inc dots)"
+ g.label_max_size = 6
+ g.label_truncation_style = :trailing_dots
+ g.write("test/output/bar_set_trailing_dots_trunc.png")
+ end
+
protected
def setup_basic_graph(size=800)
@@ -317,5 +340,21 @@ def setup_basic_graph(size=800)
g
end
+ def setup_long_labelled_graph(size=500)
+
+ g = Gruff::Bar.new(size)
+ g.title = 'A Graph for All Seasons'
+ g.labels = {
+ 0 => 'January was a cold one',
+ 1 => 'February is little better',
+ 2 => 'March will bring me hares',
+ 3 => 'April and I\'m a fool'
+ }
+
+ @datasets.each do |data|
+ g.data(data[0], data[1])
+ end
+ g
+ end
end

0 comments on commit 0aa9b3f

Please sign in to comment.