gruff 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (540) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.travis.yml +6 -0
  4. data/Gemfile +2 -8
  5. data/History.txt +76 -0
  6. data/MIT-LICENSE +3 -2
  7. data/README.md +96 -6
  8. data/RELEASE.md +92 -0
  9. data/Rakefile +203 -23
  10. data/gruff.gemspec +13 -10
  11. data/lib/gruff.rb +8 -7
  12. data/lib/gruff/accumulator_bar.rb +4 -13
  13. data/lib/gruff/area.rb +6 -13
  14. data/lib/gruff/bar.rb +24 -3
  15. data/lib/gruff/bar_conversion.rb +31 -31
  16. data/lib/gruff/base.rb +310 -267
  17. data/lib/gruff/bezier.rb +46 -0
  18. data/lib/gruff/bullet.rb +3 -1
  19. data/lib/gruff/dot.rb +56 -44
  20. data/lib/gruff/line.rb +83 -69
  21. data/lib/gruff/net.rb +7 -9
  22. data/lib/gruff/pie.rb +2 -4
  23. data/lib/gruff/scatter.rb +25 -29
  24. data/lib/gruff/side_bar.rb +54 -37
  25. data/lib/gruff/side_stacked_bar.rb +25 -5
  26. data/lib/gruff/spider.rb +22 -21
  27. data/lib/gruff/themes.rb +102 -0
  28. data/lib/gruff/version.rb +1 -1
  29. data/test/gruff_test_case.rb +68 -38
  30. data/test/image_compare.rb +58 -0
  31. data/test/output/accum_bar.png +0 -0
  32. data/test/output/area_keynote.png +0 -0
  33. data/test/output/area_keynote_small.png +0 -0
  34. data/test/output/area_many.png +0 -0
  35. data/test/output/area_many_areas_small.png +0 -0
  36. data/test/output/area_tiny.png +0 -0
  37. data/test/output/area_wide.png +0 -0
  38. data/test/output/bar2_wrapped_legend_16_400.png +0 -0
  39. data/test/output/bar2_wrapped_legend_16_800.png +0 -0
  40. data/test/output/bar2_wrapped_legend_30_400.png +0 -0
  41. data/test/output/bar2_wrapped_legend_30_800.png +0 -0
  42. data/test/output/bar2_wrapped_legend_4_400.png +0 -0
  43. data/test/output/bar2_wrapped_legend_4_800.png +0 -0
  44. data/test/output/bar2_wrapped_legend__400.png +0 -0
  45. data/test/output/bar2_wrapped_legend__800.png +0 -0
  46. data/test/output/bar_background_gradient_bottom_top.png +0 -0
  47. data/test/output/bar_background_gradient_left_right.png +0 -0
  48. data/test/output/bar_background_gradient_right_left.png +0 -0
  49. data/test/output/bar_background_gradient_top_bottom.png +0 -0
  50. data/test/output/bar_background_gradient_topleft_bottomright.png +0 -0
  51. data/test/output/bar_background_gradient_topright_bottomleft.png +0 -0
  52. data/test/output/bar_formatted_numbers.png +0 -0
  53. data/test/output/bar_keynote.png +0 -0
  54. data/test/output/bar_keynote_small.png +0 -0
  55. data/test/output/bar_long_legend_text.png +0 -0
  56. data/test/output/bar_manual_colors.png +0 -0
  57. data/test/output/bar_marker_shadow.png +0 -0
  58. data/test/output/bar_nearly_zero_max_10.png +0 -0
  59. data/test/output/bar_no_legend.png +0 -0
  60. data/test/output/bar_no_line_markers.png +0 -0
  61. data/test/output/bar_no_title.png +0 -0
  62. data/test/output/bar_no_title_or_legend.png +0 -0
  63. data/test/output/bar_odeo.png +0 -0
  64. data/test/output/bar_one_value.png +0 -0
  65. data/test/output/bar_pos_neg.png +0 -0
  66. data/test/output/bar_rails_keynote.png +0 -0
  67. data/test/output/bar_set_absolute_trunc.png +0 -0
  68. data/test/output/bar_set_label_stagger_height.png +0 -0
  69. data/test/output/bar_set_legend_box_size_lg.png +0 -0
  70. data/test/output/bar_set_legend_box_size_sm.png +0 -0
  71. data/test/output/bar_set_marker.png +0 -0
  72. data/test/output/bar_set_trailing_dots_trunc.png +0 -0
  73. data/test/output/bar_spacing_full.png +0 -0
  74. data/test/output/bar_spacing_half.png +0 -0
  75. data/test/output/bar_spacing_none.png +0 -0
  76. data/test/output/bar_tall_graph.png +0 -0
  77. data/test/output/bar_tall_graph_small.png +0 -0
  78. data/test/output/bar_themed.png +0 -0
  79. data/test/output/bar_title_margin.png +0 -0
  80. data/test/output/bar_value_labels.png +0 -0
  81. data/test/output/bar_wide_graph.png +0 -0
  82. data/test/output/bar_wide_graph_small.png +0 -0
  83. data/test/output/bar_wrapped_legend_16_400.png +0 -0
  84. data/test/output/bar_wrapped_legend_16_800.png +0 -0
  85. data/test/output/bar_wrapped_legend_30_400.png +0 -0
  86. data/test/output/bar_wrapped_legend_30_800.png +0 -0
  87. data/test/output/bar_wrapped_legend_4_400.png +0 -0
  88. data/test/output/bar_wrapped_legend_4_800.png +0 -0
  89. data/test/output/bar_wrapped_legend__400.png +0 -0
  90. data/test/output/bar_wrapped_legend__800.png +0 -0
  91. data/test/output/bar_x_y_labels.png +0 -0
  92. data/test/output/bar_y_increment_1.png +0 -0
  93. data/test/output/bar_y_increment_2.0.png +0 -0
  94. data/test/output/bar_y_increment_20.png +0 -0
  95. data/test/output/bar_y_increment_5.png +0 -0
  96. data/test/output/bar_zero_marker_count.png +0 -0
  97. data/test/output/bar_zero_spacing.png +0 -0
  98. data/test/output/bezier.png +0 -0
  99. data/test/output/bezier_2.png +0 -0
  100. data/test/output/bezier_3.png +0 -0
  101. data/test/output/bullet_greyscale.png +0 -0
  102. data/test/output/bullet_no_options.png +0 -0
  103. data/test/output/dot.png +0 -0
  104. data/test/output/dot_manual_colors.png +0 -0
  105. data/test/output/dot_nearly_zero_max_10.png +0 -0
  106. data/test/output/dot_no_legend.png +0 -0
  107. data/test/output/dot_no_line_markers.png +0 -0
  108. data/test/output/dot_no_title.png +0 -0
  109. data/test/output/dot_no_title_or_legend.png +0 -0
  110. data/test/output/dot_one_value.png +0 -0
  111. data/test/output/dot_pos_neg.png +0 -0
  112. data/test/output/dot_set_legend_box_size_lg.png +0 -0
  113. data/test/output/dot_set_legend_box_size_sm.png +0 -0
  114. data/test/output/dot_set_marker.png +0 -0
  115. data/test/output/dot_small.png +0 -0
  116. data/test/output/dot_tall_graph.png +0 -0
  117. data/test/output/dot_tall_graph_small.png +0 -0
  118. data/test/output/dot_themed.png +0 -0
  119. data/test/output/dot_wide_graph.png +0 -0
  120. data/test/output/dot_wide_graph_small.png +0 -0
  121. data/test/output/dot_x_y_labels.png +0 -0
  122. data/test/output/dot_y_increment_1.png +0 -0
  123. data/test/output/dot_y_increment_2.0.png +0 -0
  124. data/test/output/dot_y_increment_20.png +0 -0
  125. data/test/output/dot_y_increment_5.png +0 -0
  126. data/test/output/enhancements-1.png +0 -0
  127. data/test/output/enhancements.png +0 -0
  128. data/test/output/line_all_neg.png +0 -0
  129. data/test/output/line_all_neg_400.png +0 -0
  130. data/test/output/line_all_neg_no_max.png +0 -0
  131. data/test/output/line_baseline.png +0 -0
  132. data/test/output/line_hang_value.png +0 -0
  133. data/test/output/line_hide_dots.png +0 -0
  134. data/test/output/line_hide_lines.png +0 -0
  135. data/test/output/line_jruby_error.png +0 -0
  136. data/test/output/line_large.png +0 -0
  137. data/test/output/line_large_baseline.png +0 -0
  138. data/test/output/line_legend_at_bottom.png +0 -0
  139. data/test/output/line_many.png +0 -0
  140. data/test/output/line_many_lines_small.png +0 -0
  141. data/test/output/line_many_numbers.png +0 -0
  142. data/test/output/line_marker_label_accuracy.png +0 -0
  143. data/test/output/line_more_sets_than_colors.png +0 -0
  144. data/test/output/line_no_data.png +0 -0
  145. data/test/output/line_no_data_msg.png +0 -0
  146. data/test/output/line_no_data_other.png +0 -0
  147. data/test/output/line_no_hide.png +0 -0
  148. data/test/output/line_no_legend.png +0 -0
  149. data/test/output/line_no_line_markers.png +0 -0
  150. data/test/output/line_no_title.png +0 -0
  151. data/test/output/line_nothing_but_the_graph.png +0 -0
  152. data/test/output/line_one_value.png +0 -0
  153. data/test/output/line_one_value_array.png +0 -0
  154. data/test/output/line_pos_neg.png +0 -0
  155. data/test/output/line_pos_neg_400.png +0 -0
  156. data/test/output/line_similar_high_end_values.png +0 -0
  157. data/test/output/line_similar_high_end_values_with_floor.png +0 -0
  158. data/test/output/line_small_small_zero.png +0 -0
  159. data/test/output/line_small_values.png +0 -0
  160. data/test/output/line_small_values_small.png +0 -0
  161. data/test/output/line_small_zero.png +0 -0
  162. data/test/output/line_some_nil_points.png +0 -0
  163. data/test/output/line_theme_37signals_.png +0 -0
  164. data/test/output/line_theme_37signals_400.png +0 -0
  165. data/test/output/line_theme_keynote_.png +0 -0
  166. data/test/output/line_theme_keynote_400.png +0 -0
  167. data/test/output/line_theme_odeo_.png +0 -0
  168. data/test/output/line_theme_odeo_400.png +0 -0
  169. data/test/output/line_theme_rails_keynote_.png +0 -0
  170. data/test/output/line_theme_rails_keynote_400.png +0 -0
  171. data/test/output/line_tiny.png +0 -0
  172. data/test/output/line_transparent.png +0 -0
  173. data/test/output/line_very_small.png +0 -0
  174. data/test/output/line_wide_graph.png +0 -0
  175. data/test/output/line_wide_graph_small.png +0 -0
  176. data/test/output/line_xy.png +0 -0
  177. data/test/output/line_xy_pairs.png +0 -0
  178. data/test/output/line_y_axis_increment.png +0 -0
  179. data/test/output/mini_bar.png +0 -0
  180. data/test/output/mini_pie.png +0 -0
  181. data/test/output/mini_pie_right_legend.png +0 -0
  182. data/test/output/mini_side_bar.png +0 -0
  183. data/test/output/mini_side_bar_multi_color.png +0 -0
  184. data/test/output/net_dots_tiny.png +0 -0
  185. data/test/output/net_large.png +0 -0
  186. data/test/output/net_many.png +0 -0
  187. data/test/output/net_many_nets_small.png +0 -0
  188. data/test/output/net_no_data.png +0 -0
  189. data/test/output/net_no_data_msg.png +0 -0
  190. data/test/output/net_no_data_other.png +0 -0
  191. data/test/output/net_no_legend.png +0 -0
  192. data/test/output/net_no_net_markers.png +0 -0
  193. data/test/output/net_no_title.png +0 -0
  194. data/test/output/net_nothing_but_the_graph.png +0 -0
  195. data/test/output/net_similar_high_end_values.png +0 -0
  196. data/test/output/net_small.png +0 -0
  197. data/test/output/net_small_small.png +0 -0
  198. data/test/output/net_small_small_zero.png +0 -0
  199. data/test/output/net_small_zero.png +0 -0
  200. data/test/output/net_wide_graph.png +0 -0
  201. data/test/output/net_wide_graph_small.png +0 -0
  202. data/test/output/pie_equal.png +0 -0
  203. data/test/output/pie_grey.png +0 -0
  204. data/test/output/pie_keynote.png +0 -0
  205. data/test/output/pie_keynote_small.png +0 -0
  206. data/test/output/pie_legend.png +0 -0
  207. data/test/output/pie_legend_small.png +0 -0
  208. data/test/output/pie_nearly_equal.png +0 -0
  209. data/test/output/pie_one_val.png +0 -0
  210. data/test/output/pie_pastel.png +0 -0
  211. data/test/output/pie_simple.png +0 -0
  212. data/test/output/pie_wide.png +0 -0
  213. data/test/output/pie_wrapped_legend_16_400.png +0 -0
  214. data/test/output/pie_wrapped_legend_16_800.png +0 -0
  215. data/test/output/pie_wrapped_legend_30_400.png +0 -0
  216. data/test/output/pie_wrapped_legend_30_800.png +0 -0
  217. data/test/output/pie_wrapped_legend_4_400.png +0 -0
  218. data/test/output/pie_wrapped_legend_4_800.png +0 -0
  219. data/test/output/pie_wrapped_legend__400.png +0 -0
  220. data/test/output/pie_wrapped_legend__800.png +0 -0
  221. data/test/output/pie_zero.png +0 -0
  222. data/test/output/scatter_all_neg.png +0 -0
  223. data/test/output/scatter_all_neg_400.png +0 -0
  224. data/test/output/scatter_basic.png +0 -0
  225. data/test/output/scatter_many.png +0 -0
  226. data/test/output/scatter_no_data.png +0 -0
  227. data/test/output/scatter_no_data_msg.png +0 -0
  228. data/test/output/scatter_no_data_other.png +0 -0
  229. data/test/output/scatter_no_hide.png +0 -0
  230. data/test/output/scatter_no_labels.png +0 -0
  231. data/test/output/scatter_no_legend.png +0 -0
  232. data/test/output/scatter_no_line_markers.png +0 -0
  233. data/test/output/scatter_no_title.png +0 -0
  234. data/test/output/scatter_nothing_but_the_graph.png +0 -0
  235. data/test/output/scatter_pos_neg.png +0 -0
  236. data/test/output/scatter_pos_neg_400.png +0 -0
  237. data/test/output/scatter_wide_graph.png +0 -0
  238. data/test/output/scatter_wide_graph_small.png +0 -0
  239. data/test/output/scene_hazy_night.png +0 -0
  240. data/test/output/scene_not_hazy_day.png +0 -0
  241. data/test/output/scene_partly_cloudy_day.png +0 -0
  242. data/test/output/scene_stormy_day.png +0 -0
  243. data/test/output/scene_stormy_night.png +0 -0
  244. data/test/output/side_bar.png +0 -0
  245. data/test/output/side_bar_data_range.png +0 -0
  246. data/test/output/side_bar_labels.png +0 -0
  247. data/test/output/side_bar_spacing_full.png +0 -0
  248. data/test/output/side_bar_spacing_half.png +0 -0
  249. data/test/output/side_bar_spacing_none.png +0 -0
  250. data/test/output/side_stacked_bar_keynote.png +0 -0
  251. data/test/output/side_stacked_bar_keynote_small.png +0 -0
  252. data/test/output/side_stacked_bar_labels.png +0 -0
  253. data/test/output/side_stacked_bar_long_label.png +0 -0
  254. data/test/output/side_stacked_bar_wide.png +0 -0
  255. data/test/output/spider_37signals.png +0 -0
  256. data/test/output/spider_equal.png +0 -0
  257. data/test/output/spider_keynote.png +0 -0
  258. data/test/output/spider_legend.png +0 -0
  259. data/test/output/spider_legend_small.png +0 -0
  260. data/test/output/spider_lots_of_data.png +0 -0
  261. data/test/output/spider_lots_of_data_normal_names.png +0 -0
  262. data/test/output/spider_nearly_equal.png +0 -0
  263. data/test/output/spider_no_axes.png +0 -0
  264. data/test/output/spider_no_background.png +0 -0
  265. data/test/output/spider_no_print.png +0 -0
  266. data/test/output/spider_overlay_1.png +0 -0
  267. data/test/output/spider_overlay_2.png +0 -0
  268. data/test/output/spider_rotation.png +0 -0
  269. data/test/output/spider_small.png +0 -0
  270. data/test/output/spider_wide.png +0 -0
  271. data/test/output/spider_zero.png +0 -0
  272. data/test/output/stacked_area_keynote.png +0 -0
  273. data/test/output/stacked_area_keynote_small.png +0 -0
  274. data/test/output/stacked_bar_keynote.png +0 -0
  275. data/test/output/stacked_bar_keynote_small.png +0 -0
  276. data/test/output_java/accum_bar.png +0 -0
  277. data/test/output_java/area_keynote.png +0 -0
  278. data/test/output_java/area_keynote_small.png +0 -0
  279. data/test/output_java/area_many.png +0 -0
  280. data/test/output_java/area_many_areas_small.png +0 -0
  281. data/test/output_java/area_tiny.png +0 -0
  282. data/test/output_java/area_wide.png +0 -0
  283. data/test/output_java/bar2_wrapped_legend_16_400.png +0 -0
  284. data/test/output_java/bar2_wrapped_legend_16_800.png +0 -0
  285. data/test/output_java/bar2_wrapped_legend_30_400.png +0 -0
  286. data/test/output_java/bar2_wrapped_legend_30_800.png +0 -0
  287. data/test/output_java/bar2_wrapped_legend_4_400.png +0 -0
  288. data/test/output_java/bar2_wrapped_legend_4_800.png +0 -0
  289. data/test/output_java/bar2_wrapped_legend__400.png +0 -0
  290. data/test/output_java/bar2_wrapped_legend__800.png +0 -0
  291. data/test/output_java/bar_background_gradient_bottom_top.png +0 -0
  292. data/test/output_java/bar_background_gradient_left_right.png +0 -0
  293. data/test/output_java/bar_background_gradient_right_left.png +0 -0
  294. data/test/output_java/bar_background_gradient_top_bottom.png +0 -0
  295. data/test/output_java/bar_background_gradient_topleft_bottomright.png +0 -0
  296. data/test/output_java/bar_background_gradient_topright_bottomleft.png +0 -0
  297. data/test/output_java/bar_formatted_numbers.png +0 -0
  298. data/test/output_java/bar_keynote.png +0 -0
  299. data/test/output_java/bar_keynote_small.png +0 -0
  300. data/test/output_java/bar_long_legend_text.png +0 -0
  301. data/test/output_java/bar_manual_colors.png +0 -0
  302. data/test/output_java/bar_marker_shadow.png +0 -0
  303. data/test/output_java/bar_nearly_zero_max_10.png +0 -0
  304. data/test/output_java/bar_no_legend.png +0 -0
  305. data/test/output_java/bar_no_line_markers.png +0 -0
  306. data/test/output_java/bar_no_title.png +0 -0
  307. data/test/output_java/bar_no_title_or_legend.png +0 -0
  308. data/test/output_java/bar_odeo.png +0 -0
  309. data/test/output_java/bar_one_value.png +0 -0
  310. data/test/output_java/bar_pos_neg.png +0 -0
  311. data/test/output_java/bar_rails_keynote.png +0 -0
  312. data/test/output_java/bar_set_absolute_trunc.png +0 -0
  313. data/test/output_java/bar_set_label_stagger_height.png +0 -0
  314. data/test/output_java/bar_set_legend_box_size_lg.png +0 -0
  315. data/test/output_java/bar_set_legend_box_size_sm.png +0 -0
  316. data/test/output_java/bar_set_marker.png +0 -0
  317. data/test/output_java/bar_set_trailing_dots_trunc.png +0 -0
  318. data/test/output_java/bar_spacing_full.png +0 -0
  319. data/test/output_java/bar_spacing_half.png +0 -0
  320. data/test/output_java/bar_spacing_none.png +0 -0
  321. data/test/output_java/bar_tall_graph.png +0 -0
  322. data/test/output_java/bar_tall_graph_small.png +0 -0
  323. data/test/output_java/bar_themed.png +0 -0
  324. data/test/output_java/bar_title_margin.png +0 -0
  325. data/test/output_java/bar_value_labels.png +0 -0
  326. data/test/output_java/bar_wide_graph.png +0 -0
  327. data/test/output_java/bar_wide_graph_small.png +0 -0
  328. data/test/output_java/bar_wrapped_legend_16_400.png +0 -0
  329. data/test/output_java/bar_wrapped_legend_16_800.png +0 -0
  330. data/test/output_java/bar_wrapped_legend_30_400.png +0 -0
  331. data/test/output_java/bar_wrapped_legend_30_800.png +0 -0
  332. data/test/output_java/bar_wrapped_legend_4_400.png +0 -0
  333. data/test/output_java/bar_wrapped_legend_4_800.png +0 -0
  334. data/test/output_java/bar_wrapped_legend__400.png +0 -0
  335. data/test/output_java/bar_wrapped_legend__800.png +0 -0
  336. data/test/output_java/bar_x_y_labels.png +0 -0
  337. data/test/output_java/bar_y_increment_1.png +0 -0
  338. data/test/output_java/bar_y_increment_2.0.png +0 -0
  339. data/test/output_java/bar_y_increment_20.png +0 -0
  340. data/test/output_java/bar_y_increment_5.png +0 -0
  341. data/test/output_java/bar_zero_marker_count.png +0 -0
  342. data/test/output_java/bar_zero_spacing.png +0 -0
  343. data/test/output_java/bezier.png +0 -0
  344. data/test/output_java/bezier_2.png +0 -0
  345. data/test/output_java/bezier_3.png +0 -0
  346. data/test/output_java/bullet_greyscale.png +0 -0
  347. data/test/output_java/bullet_no_options.png +0 -0
  348. data/test/output_java/dot.png +0 -0
  349. data/test/output_java/dot_manual_colors.png +0 -0
  350. data/test/output_java/dot_nearly_zero_max_10.png +0 -0
  351. data/test/output_java/dot_no_legend.png +0 -0
  352. data/test/output_java/dot_no_line_markers.png +0 -0
  353. data/test/output_java/dot_no_title.png +0 -0
  354. data/test/output_java/dot_no_title_or_legend.png +0 -0
  355. data/test/output_java/dot_one_value.png +0 -0
  356. data/test/output_java/dot_pos_neg.png +0 -0
  357. data/test/output_java/dot_set_legend_box_size_lg.png +0 -0
  358. data/test/output_java/dot_set_legend_box_size_sm.png +0 -0
  359. data/test/output_java/dot_set_marker.png +0 -0
  360. data/test/output_java/dot_small.png +0 -0
  361. data/test/output_java/dot_tall_graph.png +0 -0
  362. data/test/output_java/dot_tall_graph_small.png +0 -0
  363. data/test/output_java/dot_themed.png +0 -0
  364. data/test/output_java/dot_wide_graph.png +0 -0
  365. data/test/output_java/dot_wide_graph_small.png +0 -0
  366. data/test/output_java/dot_x_y_labels.png +0 -0
  367. data/test/output_java/dot_y_increment_1.png +0 -0
  368. data/test/output_java/dot_y_increment_2.0.png +0 -0
  369. data/test/output_java/dot_y_increment_20.png +0 -0
  370. data/test/output_java/dot_y_increment_5.png +0 -0
  371. data/test/output_java/enhancements-1.png +0 -0
  372. data/test/output_java/enhancements.png +0 -0
  373. data/test/output_java/line_all_neg.png +0 -0
  374. data/test/output_java/line_all_neg_400.png +0 -0
  375. data/test/output_java/line_all_neg_no_max.png +0 -0
  376. data/test/output_java/line_baseline.png +0 -0
  377. data/test/output_java/line_hang_value.png +0 -0
  378. data/test/output_java/line_hide_dots.png +0 -0
  379. data/test/output_java/line_hide_lines.png +0 -0
  380. data/test/output_java/line_jruby_error.png +0 -0
  381. data/test/output_java/line_large.png +0 -0
  382. data/test/output_java/line_large_baseline.png +0 -0
  383. data/test/output_java/line_legend_at_bottom.png +0 -0
  384. data/test/output_java/line_many.png +0 -0
  385. data/test/output_java/line_many_lines_small.png +0 -0
  386. data/test/output_java/line_many_numbers.png +0 -0
  387. data/test/output_java/line_marker_label_accuracy.png +0 -0
  388. data/test/output_java/line_more_sets_than_colors.png +0 -0
  389. data/test/output_java/line_no_data.png +0 -0
  390. data/test/output_java/line_no_data_msg.png +0 -0
  391. data/test/output_java/line_no_data_other.png +0 -0
  392. data/test/output_java/line_no_hide.png +0 -0
  393. data/test/output_java/line_no_legend.png +0 -0
  394. data/test/output_java/line_no_line_markers.png +0 -0
  395. data/test/output_java/line_no_title.png +0 -0
  396. data/test/output_java/line_nothing_but_the_graph.png +0 -0
  397. data/test/output_java/line_one_value.png +0 -0
  398. data/test/output_java/line_one_value_array.png +0 -0
  399. data/test/output_java/line_pos_neg.png +0 -0
  400. data/test/output_java/line_pos_neg_400.png +0 -0
  401. data/test/output_java/line_similar_high_end_values.png +0 -0
  402. data/test/output_java/line_similar_high_end_values_with_floor.png +0 -0
  403. data/test/output_java/line_small_small_zero.png +0 -0
  404. data/test/output_java/line_small_values.png +0 -0
  405. data/test/output_java/line_small_values_small.png +0 -0
  406. data/test/output_java/line_small_zero.png +0 -0
  407. data/test/output_java/line_some_nil_points.png +0 -0
  408. data/test/output_java/line_theme_37signals_.png +0 -0
  409. data/test/output_java/line_theme_37signals_400.png +0 -0
  410. data/test/output_java/line_theme_keynote_.png +0 -0
  411. data/test/output_java/line_theme_keynote_400.png +0 -0
  412. data/test/output_java/line_theme_odeo_.png +0 -0
  413. data/test/output_java/line_theme_odeo_400.png +0 -0
  414. data/test/output_java/line_theme_rails_keynote_.png +0 -0
  415. data/test/output_java/line_theme_rails_keynote_400.png +0 -0
  416. data/test/output_java/line_tiny.png +0 -0
  417. data/test/output_java/line_transparent.png +0 -0
  418. data/test/output_java/line_very_small.png +0 -0
  419. data/test/output_java/line_wide_graph.png +0 -0
  420. data/test/output_java/line_wide_graph_small.png +0 -0
  421. data/test/output_java/line_xy.png +0 -0
  422. data/test/output_java/line_xy_pairs.png +0 -0
  423. data/test/output_java/line_y_axis_increment.png +0 -0
  424. data/test/output_java/mini_bar.png +0 -0
  425. data/test/output_java/mini_pie.png +0 -0
  426. data/test/output_java/mini_pie_right_legend.png +0 -0
  427. data/test/output_java/mini_side_bar.png +0 -0
  428. data/test/output_java/mini_side_bar_multi_color.png +0 -0
  429. data/test/output_java/net_dots_tiny.png +0 -0
  430. data/test/output_java/net_large.png +0 -0
  431. data/test/output_java/net_many.png +0 -0
  432. data/test/output_java/net_many_nets_small.png +0 -0
  433. data/test/output_java/net_no_data.png +0 -0
  434. data/test/output_java/net_no_data_msg.png +0 -0
  435. data/test/output_java/net_no_data_other.png +0 -0
  436. data/test/output_java/net_no_legend.png +0 -0
  437. data/test/output_java/net_no_net_markers.png +0 -0
  438. data/test/output_java/net_no_title.png +0 -0
  439. data/test/output_java/net_nothing_but_the_graph.png +0 -0
  440. data/test/output_java/net_similar_high_end_values.png +0 -0
  441. data/test/output_java/net_small.png +0 -0
  442. data/test/output_java/net_small_small.png +0 -0
  443. data/test/output_java/net_small_small_zero.png +0 -0
  444. data/test/output_java/net_small_zero.png +0 -0
  445. data/test/output_java/net_wide_graph.png +0 -0
  446. data/test/output_java/net_wide_graph_small.png +0 -0
  447. data/test/output_java/pie_equal.png +0 -0
  448. data/test/output_java/pie_grey.png +0 -0
  449. data/test/output_java/pie_keynote.png +0 -0
  450. data/test/output_java/pie_keynote_small.png +0 -0
  451. data/test/output_java/pie_legend.png +0 -0
  452. data/test/output_java/pie_legend_small.png +0 -0
  453. data/test/output_java/pie_nearly_equal.png +0 -0
  454. data/test/output_java/pie_one_val.png +0 -0
  455. data/test/output_java/pie_pastel.png +0 -0
  456. data/test/output_java/pie_simple.png +0 -0
  457. data/test/output_java/pie_wide.png +0 -0
  458. data/test/output_java/pie_wrapped_legend_16_400.png +0 -0
  459. data/test/output_java/pie_wrapped_legend_16_800.png +0 -0
  460. data/test/output_java/pie_wrapped_legend_30_400.png +0 -0
  461. data/test/output_java/pie_wrapped_legend_30_800.png +0 -0
  462. data/test/output_java/pie_wrapped_legend_4_400.png +0 -0
  463. data/test/output_java/pie_wrapped_legend_4_800.png +0 -0
  464. data/test/output_java/pie_wrapped_legend__400.png +0 -0
  465. data/test/output_java/pie_wrapped_legend__800.png +0 -0
  466. data/test/output_java/pie_zero.png +0 -0
  467. data/test/output_java/scatter_all_neg.png +0 -0
  468. data/test/output_java/scatter_all_neg_400.png +0 -0
  469. data/test/output_java/scatter_basic.png +0 -0
  470. data/test/output_java/scatter_many.png +0 -0
  471. data/test/output_java/scatter_no_data.png +0 -0
  472. data/test/output_java/scatter_no_data_msg.png +0 -0
  473. data/test/output_java/scatter_no_data_other.png +0 -0
  474. data/test/output_java/scatter_no_hide.png +0 -0
  475. data/test/output_java/scatter_no_labels.png +0 -0
  476. data/test/output_java/scatter_no_legend.png +0 -0
  477. data/test/output_java/scatter_no_line_markers.png +0 -0
  478. data/test/output_java/scatter_no_title.png +0 -0
  479. data/test/output_java/scatter_nothing_but_the_graph.png +0 -0
  480. data/test/output_java/scatter_pos_neg.png +0 -0
  481. data/test/output_java/scatter_pos_neg_400.png +0 -0
  482. data/test/output_java/scatter_wide_graph.png +0 -0
  483. data/test/output_java/scatter_wide_graph_small.png +0 -0
  484. data/test/output_java/scene_hazy_night.png +0 -0
  485. data/test/output_java/scene_not_hazy_day.png +0 -0
  486. data/test/output_java/scene_partly_cloudy_day.png +0 -0
  487. data/test/output_java/scene_stormy_day.png +0 -0
  488. data/test/output_java/scene_stormy_night.png +0 -0
  489. data/test/output_java/side_bar.png +0 -0
  490. data/test/output_java/side_bar_data_range.png +0 -0
  491. data/test/output_java/side_bar_labels.png +0 -0
  492. data/test/output_java/side_bar_spacing_full.png +0 -0
  493. data/test/output_java/side_bar_spacing_half.png +0 -0
  494. data/test/output_java/side_bar_spacing_none.png +0 -0
  495. data/test/output_java/side_stacked_bar_keynote.png +0 -0
  496. data/test/output_java/side_stacked_bar_keynote_small.png +0 -0
  497. data/test/output_java/side_stacked_bar_labels.png +0 -0
  498. data/test/output_java/side_stacked_bar_long_label.png +0 -0
  499. data/test/output_java/side_stacked_bar_wide.png +0 -0
  500. data/test/output_java/spider_37signals.png +0 -0
  501. data/test/output_java/spider_equal.png +0 -0
  502. data/test/output_java/spider_keynote.png +0 -0
  503. data/test/output_java/spider_legend.png +0 -0
  504. data/test/output_java/spider_legend_small.png +0 -0
  505. data/test/output_java/spider_lots_of_data.png +0 -0
  506. data/test/output_java/spider_lots_of_data_normal_names.png +0 -0
  507. data/test/output_java/spider_nearly_equal.png +0 -0
  508. data/test/output_java/spider_no_axes.png +0 -0
  509. data/test/output_java/spider_no_background.png +0 -0
  510. data/test/output_java/spider_no_print.png +0 -0
  511. data/test/output_java/spider_overlay_1.png +0 -0
  512. data/test/output_java/spider_overlay_2.png +0 -0
  513. data/test/output_java/spider_rotation.png +0 -0
  514. data/test/output_java/spider_small.png +0 -0
  515. data/test/output_java/spider_wide.png +0 -0
  516. data/test/output_java/spider_zero.png +0 -0
  517. data/test/output_java/stacked_area_keynote.png +0 -0
  518. data/test/output_java/stacked_area_keynote_small.png +0 -0
  519. data/test/output_java/stacked_bar_keynote.png +0 -0
  520. data/test/output_java/stacked_bar_keynote_small.png +0 -0
  521. data/test/test_accumulator_bar.rb +7 -6
  522. data/test/test_area.rb +2 -2
  523. data/test/test_bar.rb +296 -112
  524. data/test/test_bezier.rb +33 -0
  525. data/test/test_bullet.rb +26 -26
  526. data/test/test_dot.rb +44 -54
  527. data/test/test_legend.rb +29 -29
  528. data/test/test_line.rb +250 -218
  529. data/test/test_net.rb +2 -1
  530. data/test/test_pie.rb +2 -2
  531. data/test/test_scatter.rb +85 -85
  532. data/test/test_side_bar.rb +13 -0
  533. data/test/test_sidestacked_bar.rb +16 -0
  534. data/test/test_spider.rb +11 -1
  535. data/test/test_stacked_area.rb +5 -5
  536. metadata +1041 -49
  537. data/.rvmrc +0 -5
  538. data/Gemfile.lock +0 -20
  539. data/LICENSE.txt +0 -22
  540. data/README.txt +0 -43
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + "/gruff_test_case"
2
+
3
+ class TestBezier < GruffTestCase
4
+
5
+ def setup
6
+ @data_args = [75, 100, {
7
+ :target => 80,
8
+ :low => 50,
9
+ :high => 90
10
+ }]
11
+ end
12
+
13
+ def test_bezier
14
+ g = Gruff::Bezier.new
15
+ g.title = "Bezier?"
16
+ g.data 'Series 1', [0, 100]
17
+ g.write("test/output/bezier.png")
18
+ end
19
+
20
+ def test_bezier_2
21
+ g = Gruff::Bezier.new
22
+ g.data 'Series 2', [0, 127, 150]
23
+ g.write("test/output/bezier_2.png")
24
+ end
25
+
26
+ def test_bezier_3
27
+ g = Gruff::Bezier.new
28
+ g.data 'Series 3', [100,300,200,250]
29
+ g.minimum_value = 0
30
+ g.write("test/output/bezier_3.png")
31
+ end
32
+
33
+ end
data/test/test_bullet.rb CHANGED
@@ -1,26 +1,26 @@
1
- # require File.dirname(__FILE__) + "/gruff_test_case"
2
- #
3
- # class TestGruffBullet < GruffTestCase
4
- #
5
- # def setup
6
- # @data_args = [75, 100, {
7
- # :target => 80,
8
- # :low => 50,
9
- # :high => 90
10
- # }]
11
- # end
12
- #
13
- # def test_bullet_graph
14
- # g = Gruff::Bullet.new
15
- # g.title = "Monthly Revenue"
16
- # g.data *@data_args
17
- # g.write("test/output/bullet_greyscale.png")
18
- # end
19
- #
20
- # def test_no_options
21
- # g = Gruff::Bullet.new
22
- # g.data 127, 150
23
- # g.write("test/output/bullet_no_options.png")
24
- # end
25
- #
26
- # end
1
+ require File.dirname(__FILE__) + "/gruff_test_case"
2
+
3
+ class TestGruffBullet < GruffTestCase
4
+
5
+ def setup
6
+ @data_args = [75, 100, {
7
+ :target => 80,
8
+ :low => 50,
9
+ :high => 90
10
+ }]
11
+ end
12
+
13
+ def test_bullet_graph
14
+ g = Gruff::Bullet.new
15
+ g.title = "Monthly Revenue"
16
+ g.data *@data_args
17
+ g.write("test/output/bullet_greyscale.png")
18
+ end
19
+
20
+ def test_no_options
21
+ g = Gruff::Bullet.new
22
+ g.data *@data_args
23
+ g.write("test/output/bullet_no_options.png")
24
+ end
25
+
26
+ end
data/test/test_dot.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/gruff_test_case"
3
+ require File.dirname(__FILE__) + '/gruff_test_case'
4
4
 
5
5
  class TestGruffDot < GruffTestCase
6
6
 
@@ -19,13 +19,13 @@ class TestGruffDot < GruffTestCase
19
19
 
20
20
  def test_dot_graph
21
21
  g = setup_basic_graph
22
- g.title = "Dot Graph Test"
23
- g.write("test/output/dot_keynote.png")
22
+ g.title = 'Dot Graph Test'
23
+ g.write('test/output/dot.png')
24
24
  end
25
25
 
26
26
  def test_dot_graph_set_colors
27
27
  g = Gruff::Dot.new
28
- g.title = "Dot Graph With Manual Colors"
28
+ g.title = 'Dot Graph With Manual Colors'
29
29
  g.labels = {
30
30
  0 => '5/6',
31
31
  1 => '5/15',
@@ -38,23 +38,13 @@ class TestGruffDot < GruffTestCase
38
38
 
39
39
  g.minimum_value = 0
40
40
 
41
- g.write("test/output/dot_manual_colors.png")
41
+ g.write('test/output/dot_manual_colors.png')
42
42
  end
43
43
 
44
44
  def test_dot_graph_small
45
- g = Gruff::Dot.new(400)
46
- g.title = "Visual Multi-Line Dot Graph Test"
47
- g.labels = {
48
- 0 => '5/6',
49
- 1 => '5/15',
50
- 2 => '5/24',
51
- 3 => '5/30',
52
- }
53
- @datasets.each do |data|
54
- g.data(data[0], data[1])
55
- end
56
-
57
- g.write("test/output/dot_keynote_small.png")
45
+ g = setup_basic_graph(400)
46
+ g.title = 'Visual Multi-Line Dot Graph Test'
47
+ g.write('test/output/dot_small.png')
58
48
  end
59
49
 
60
50
  # Somewhat worthless test. Should an error be thrown?
@@ -68,98 +58,98 @@ class TestGruffDot < GruffTestCase
68
58
 
69
59
  def test_no_line_markers
70
60
  g = setup_basic_graph(400)
71
- g.title = "No Line Markers"
61
+ g.title = 'No Line Markers'
72
62
  g.hide_line_markers = true
73
- g.write("test/output/dot_no_line_markers.png")
63
+ g.write('test/output/dot_no_line_markers.png')
74
64
  end
75
65
 
76
66
  def test_no_legend
77
67
  g = setup_basic_graph(400)
78
- g.title = "No Legend"
68
+ g.title = 'No Legend'
79
69
  g.hide_legend = true
80
- g.write("test/output/dot_no_legend.png")
70
+ g.write('test/output/dot_no_legend.png')
81
71
  end
82
72
 
83
73
  def test_no_title
84
74
  g = setup_basic_graph(400)
85
- g.title = "No Title"
75
+ g.title = 'No Title'
86
76
  g.hide_title = true
87
- g.write("test/output/dot_no_title.png")
77
+ g.write('test/output/dot_no_title.png')
88
78
  end
89
79
 
90
80
  def test_no_title_or_legend
91
81
  g = setup_basic_graph(400)
92
- g.title = "No Title or Legend"
82
+ g.title = 'No Title or Legend'
93
83
  g.hide_legend = true
94
84
  g.hide_title = true
95
- g.write("test/output/dot_no_title_or_legend.png")
85
+ g.write('test/output/dot_no_title_or_legend.png')
96
86
  end
97
87
 
98
88
  def test_set_marker_count
99
89
  g = setup_basic_graph(400)
100
- g.title = "Set marker"
90
+ g.title = 'Set marker'
101
91
  g.marker_count = 10
102
- g.write("test/output/dot_set_marker.png")
92
+ g.write('test/output/dot_set_marker.png')
103
93
  end
104
94
 
105
95
  def test_set_legend_box_size
106
96
  g = setup_basic_graph(400)
107
- g.title = "Set Small Legend Box Size"
97
+ g.title = 'Set Small Legend Box Size'
108
98
  g.legend_box_size = 10.0
109
- g.write("test/output/dot_set_legend_box_size_sm.png")
99
+ g.write('test/output/dot_set_legend_box_size_sm.png')
110
100
 
111
101
  g = setup_basic_graph(400)
112
- g.title = "Set Large Legend Box Size"
102
+ g.title = 'Set Large Legend Box Size'
113
103
  g.legend_box_size = 50.0
114
- g.write("test/output/dot_set_legend_box_size_lg.png")
104
+ g.write('test/output/dot_set_legend_box_size_lg.png')
115
105
  end
116
106
 
117
107
  def test_x_y_labels
118
108
  g = setup_basic_graph(400)
119
- g.title = "X Y Labels"
109
+ g.title = 'X Y Labels'
120
110
  g.x_axis_label = 'Score (%)'
121
- g.y_axis_label = "Students"
122
- g.write("test/output/dot_x_y_labels.png")
111
+ g.y_axis_label = 'Students'
112
+ g.write('test/output/dot_x_y_labels.png')
123
113
  end
124
114
 
125
115
  def test_wide_graph
126
116
  g = setup_basic_graph('800x400')
127
- g.title = "Wide Graph"
128
- g.write("test/output/dot_wide_graph.png")
117
+ g.title = 'Wide Graph'
118
+ g.write('test/output/dot_wide_graph.png')
129
119
 
130
120
  g = setup_basic_graph('400x200')
131
- g.title = "Wide Graph Small"
132
- g.write("test/output/dot_wide_graph_small.png")
121
+ g.title = 'Wide Graph Small'
122
+ g.write('test/output/dot_wide_graph_small.png')
133
123
  end
134
124
 
135
125
 
136
126
  def test_tall_graph
137
127
  g = setup_basic_graph('400x600')
138
- g.title = "Tall Graph"
139
- g.write("test/output/dot_tall_graph.png")
128
+ g.title = 'Tall Graph'
129
+ g.write('test/output/dot_tall_graph.png')
140
130
 
141
131
  g = setup_basic_graph('200x400')
142
- g.title = "Tall Graph Small"
143
- g.write("test/output/dot_tall_graph_small.png")
132
+ g.title = 'Tall Graph Small'
133
+ g.write('test/output/dot_tall_graph_small.png')
144
134
  end
145
135
 
146
136
 
147
137
  def test_one_value
148
138
  g = Gruff::Dot.new
149
- g.title = "One Value Graph Test"
139
+ g.title = 'One Value Graph Test'
150
140
  g.labels = {
151
141
  0 => '1',
152
142
  1 => '2'
153
143
  }
154
144
  g.data('one', [1,1])
155
145
 
156
- g.write("test/output/dot_one_value.png")
146
+ g.write('test/output/dot_one_value.png')
157
147
  end
158
148
 
159
149
 
160
150
  def test_negative
161
151
  g = Gruff::Dot.new
162
- g.title = "Pos/Neg Dot Graph Test"
152
+ g.title = 'Pos/Neg Dot Graph Test'
163
153
  g.labels = {
164
154
  0 => '5/6',
165
155
  1 => '5/15',
@@ -169,13 +159,13 @@ class TestGruffDot < GruffTestCase
169
159
  g.data(:apples, [-1, 0, 4, -4])
170
160
  g.data(:peaches, [10, 8, 6, 3])
171
161
 
172
- g.write("test/output/dot_pos_neg.png")
162
+ g.write('test/output/dot_pos_neg.png')
173
163
  end
174
164
 
175
165
 
176
166
  def test_nearly_zero
177
167
  g = Gruff::Dot.new
178
- g.title = "Nearly Zero Graph"
168
+ g.title = 'Nearly Zero Graph'
179
169
  g.labels = {
180
170
  0 => '5/6',
181
171
  1 => '5/15',
@@ -186,7 +176,7 @@ class TestGruffDot < GruffTestCase
186
176
  g.data(:peaches, [4, 3, 2, 1])
187
177
  g.minimum_value = 0
188
178
  g.maximum_value = 10
189
- g.write("test/output/dot_nearly_zero_max_10.png")
179
+ g.write('test/output/dot_nearly_zero_max_10.png')
190
180
  end
191
181
 
192
182
  def test_y_axis_increment
@@ -214,7 +204,7 @@ class TestGruffDot < GruffTestCase
214
204
 
215
205
  def test_custom_theme
216
206
  g = Gruff::Dot.new
217
- g.title = "Custom Theme"
207
+ g.title = 'Custom Theme'
218
208
  g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
219
209
  g.title_font_size = 60
220
210
  g.legend_font_size = 32
@@ -223,7 +213,7 @@ class TestGruffDot < GruffTestCase
223
213
  :colors => %w(#efd250 #666699 #e5573f #9595e2),
224
214
  :marker_color => 'white',
225
215
  :font_color => 'blue',
226
- :background_image => "assets/pc306715.jpg"
216
+ :background_image => 'assets/pc306715.jpg'
227
217
  }
228
218
  g.labels = {
229
219
  0 => '5/6',
@@ -236,13 +226,13 @@ class TestGruffDot < GruffTestCase
236
226
  g.data(:portland, [3, 1, 7, 3])
237
227
  g.data(:victoria, [4, 3, 5, 7])
238
228
  g.minimum_value = 0
239
- g.write("test/output/dot_themed.png")
229
+ g.write('test/output/dot_themed.png')
240
230
  end
241
231
 
242
232
  def test_july_enhancements
243
233
  g = Gruff::Dot.new(600)
244
234
  g.hide_legend = true
245
- g.title = "Full speed ahead"
235
+ g.title = 'Full speed ahead'
246
236
  g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
247
237
  g.data(:apples, (0..9).map { rand(20)/10.0 })
248
238
  g.y_axis_increment = 1.0
@@ -256,7 +246,7 @@ protected
256
246
 
257
247
  def setup_basic_graph(size=800)
258
248
  g = Gruff::Dot.new(size)
259
- g.title = "My Dot Graph"
249
+ g.title = 'My Dot Graph'
260
250
  g.labels = {
261
251
  0 => '5/6',
262
252
  1 => '5/15',
data/test/test_legend.rb CHANGED
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + "/gruff_test_case"
1
+ require File.dirname(__FILE__) + '/gruff_test_case'
2
2
 
3
3
  class TestGruffLegend < GruffTestCase
4
4
 
5
5
  def setup
6
6
  @datasets = [
7
- [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
8
- [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
9
- [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
10
- [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
11
- [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
12
- ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
13
- ["Vincent", [5, 10, 13, 11, 6, 16, 22, 32]],
14
- ["Jake", [5, 10, 13, 11, 6, 16, 22, 32]],
15
- ["Stephen", [5, 10, 13, 11, 6, 16, 22, 32]],
16
- ]
7
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
8
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
9
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
10
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
11
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
12
+ [:Arthur, [5, 10, 13, 11, 6, 16, 22, 32]],
13
+ [:Vincent, [5, 10, 13, 11, 6, 16, 22, 32]],
14
+ [:Jake, [5, 10, 13, 11, 6, 16, 22, 32]],
15
+ [:Stephen, [5, 10, 13, 11, 6, 16, 22, 32]],
16
+ ]
17
17
 
18
18
  @sample_labels = {
19
- 0 => '5/6',
20
- 1 => '5/15',
21
- 2 => '5/24',
22
- 3 => '5/30',
23
- 4 => '6/4',
24
- 5 => '6/12',
25
- 6 => '6/21',
26
- 7 => '6/28',
27
- }
19
+ 0 => '5/6',
20
+ 1 => '5/15',
21
+ 2 => '5/24',
22
+ 3 => '5/30',
23
+ 4 => '6/4',
24
+ 5 => '6/12',
25
+ 6 => '6/21',
26
+ 7 => '6/28',
27
+ }
28
28
  end
29
29
 
30
30
  def full_suite_for(name, type)
@@ -34,13 +34,13 @@ class TestGruffLegend < GruffTestCase
34
34
  g.title = "Wrapped Legend Bar Test #{font_size}pts #{width}px"
35
35
  g.labels = @sample_labels
36
36
  0xEFD250.step(0xFF0000, 60) do |num|
37
- g.colors << "#%x" % num
37
+ g.colors << '#%x' % num
38
38
  end
39
-
39
+
40
40
  @datasets.each do |data|
41
41
  g.data(data[0], data[1])
42
42
  end
43
-
43
+
44
44
  g.legend_font_size = font_size unless font_size.nil?
45
45
  g.write("test/output/#{name}_wrapped_legend_#{font_size}_#{width}.png")
46
46
  end
@@ -50,19 +50,19 @@ class TestGruffLegend < GruffTestCase
50
50
  def test_bar_legend_wrap
51
51
  full_suite_for(:bar, Gruff::Bar)
52
52
  end
53
-
53
+
54
54
  def test_pie_legend_wrap
55
55
  full_suite_for(:pie, Gruff::Pie)
56
56
  end
57
-
57
+
58
58
  def test_more_than_two_lines_of_legends
59
59
  @datasets = @datasets + [[:Julie2, [22, 29, 35, 38, 36, 40, 46, 57]],
60
60
  [:Jane2, [95, 95, 95, 90, 85, 80, 88, 100]],
61
61
  [:Philip2, [90, 34, 23, 12, 78, 89, 98, 88]],
62
- ["Arthur2", [5, 10, 13, 11, 6, 16, 22, 32]],
63
- ["Vincent2", [5, 10, 13, 11, 6, 16, 22, 32]],
64
- ["Jake2", [5, 10, 13, 11, 6, 16, 22, 32]],
65
- ["Stephen2", [5, 10, 13, 11, 6, 16, 22, 32]]]
62
+ [:Arthur2, [5, 10, 13, 11, 6, 16, 22, 32]],
63
+ [:Vincent2, [5, 10, 13, 11, 6, 16, 22, 32]],
64
+ [:Jake2, [5, 10, 13, 11, 6, 16, 22, 32]],
65
+ [:Stephen2, [5, 10, 13, 11, 6, 16, 22, 32]]]
66
66
  full_suite_for(:bar2, Gruff::Bar)
67
67
  end
68
68
  end
data/test/test_line.rb CHANGED
@@ -1,30 +1,37 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/gruff_test_case"
3
+ require File.dirname(__FILE__) + '/gruff_test_case'
4
4
 
5
5
  class TestGruffLine < GruffTestCase
6
-
7
- # TODO Delete old output files once when starting tests
8
-
9
6
  def test_should_render_with_transparent_theme
10
7
  g = Gruff::Line.new(400)
11
- g.title = "Transparent Background"
8
+ g.title = 'Transparent Background'
12
9
  g.theme = {
13
- :colors => ['black', 'grey'],
14
- :marker_color => 'grey',
15
- :font_color => 'black',
16
- :background_colors => 'transparent'
10
+ :colors => %w(black grey),
11
+ :marker_color => 'grey',
12
+ :font_color => 'black',
13
+ :background_colors => 'transparent'
17
14
  }
18
15
 
19
16
  g.labels = {
20
- 0 => '5/6',
21
- 1 => '5/15',
22
- 2 => '5/24',
23
- 3 => '5/30',
17
+ 0 => '5/6',
18
+ 1 => '5/15',
19
+ 2 => '5/24',
20
+ 3 => '5/30',
24
21
  }
25
22
  g.data(:apples, [-1, 0, 4, -4])
26
23
  g.data(:peaches, [10, 8, 6, 3])
27
- g.write("test/output/line_transparent.png")
24
+ g.write('test/output/line_transparent.png')
25
+ end
26
+
27
+ def test_very_small
28
+ g = Gruff::Line.new(200)
29
+ g.title = 'Very Small Line Chart 200px'
30
+ g.labels = @labels
31
+ @datasets.each do |data|
32
+ g.data(data[0], data[1])
33
+ end
34
+ g.write('test/output/line_very_small.png')
28
35
  end
29
36
 
30
37
  def test_line_graph_with_themes
@@ -34,35 +41,35 @@ class TestGruffLine < GruffTestCase
34
41
 
35
42
  def test_one_value
36
43
  g = Gruff::Line.new
37
- g.title = "One Value"
44
+ g.title = 'One Value'
38
45
  g.labels = {
39
- 0 => '1',
40
- 1 => '2'
46
+ 0 => '1',
47
+ 1 => '2'
41
48
  }
42
49
  g.data('one', 1)
43
50
 
44
- g.write("test/output/line_one_value.png")
51
+ g.write('test/output/line_one_value.png')
45
52
  end
46
53
 
47
54
  def test_one_value_array
48
55
  g = Gruff::Line.new
49
- g.title = "One Value in an Array"
56
+ g.title = 'One Value in an Array'
50
57
  g.labels = {
51
- 0 => '1',
52
- 1 => '2'
58
+ 0 => '1',
59
+ 1 => '2'
53
60
  }
54
61
  g.data('one', [1])
55
62
 
56
- g.write("test/output/line_one_value_array.png")
63
+ g.write('test/output/line_one_value_array.png')
57
64
  end
58
65
 
59
66
 
60
67
  def test_should_not_hang_with_0_0_100
61
68
  g = Gruff::Line.new(320)
62
- g.title = "Hang Value Graph Test"
63
- g.data('test', [0,0,100])
69
+ g.title = 'Hang Value Graph Test'
70
+ g.data('test', [0, 0, 100])
64
71
 
65
- g.write("test/output/line_hang_value.png")
72
+ g.write('test/output/line_hang_value.png')
66
73
  end
67
74
 
68
75
  # TODO
@@ -79,57 +86,57 @@ class TestGruffLine < GruffTestCase
79
86
 
80
87
  def test_line_small_values
81
88
  @datasets = [
82
- [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
83
- [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
84
- ]
89
+ [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
90
+ [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
91
+ ]
85
92
 
86
93
  g = Gruff::Line.new
87
- g.title = "Small Values Line Graph Test"
94
+ g.title = 'Small Values Line Graph Test'
88
95
  @datasets.each do |data|
89
96
  g.data(data[0], data[1])
90
97
  end
91
- g.write("test/output/line_small.png")
98
+ g.write('test/output/line_small_values.png')
92
99
 
93
100
  g = Gruff::Line.new(400)
94
- g.title = "Small Values Line Graph Test 400px"
101
+ g.title = 'Small Values Line Graph Test 400px'
95
102
  @datasets.each do |data|
96
103
  g.data(data[0], data[1])
97
104
  end
98
- g.write("test/output/line_small_small.png")
105
+ g.write('test/output/line_small_values_small.png')
99
106
  end
100
107
 
101
108
  def test_line_starts_with_zero
102
109
  @datasets = [
103
- [:first0, [0, 5, 10, 8, 18]],
104
- [:normal, [1, 2, 3, 4, 5]]
105
- ]
110
+ [:first0, [0, 5, 10, 8, 18]],
111
+ [:normal, [1, 2, 3, 4, 5]]
112
+ ]
106
113
 
107
114
  g = Gruff::Line.new
108
- g.title = "Small Values Line Graph Test"
115
+ g.title = 'Small Values Line Graph Test'
109
116
  @datasets.each do |data|
110
117
  g.data(data[0], data[1])
111
118
  end
112
- g.write("test/output/line_small_zero.png")
119
+ g.write('test/output/line_small_zero.png')
113
120
 
114
121
  g = Gruff::Line.new(400)
115
- g.title = "Small Values Line Graph Test 400px"
122
+ g.title = 'Small Values Line Graph Test 400px'
116
123
  @datasets.each do |data|
117
124
  g.data(data[0], data[1])
118
125
  end
119
- g.write("test/output/line_small_small_zero.png")
126
+ g.write('test/output/line_small_small_zero.png')
120
127
  end
121
128
 
122
129
 
123
130
  def test_line_large_values
124
131
  @datasets = [
125
- [:large, [100_005, 35_000, 28_000, 27_000]],
126
- [:large2, [35_000, 28_000, 27_000, 100_005]],
127
- [:large3, [28_000, 27_000, 100_005, 35_000]],
128
- [:large4, [1_238, 39_092, 27_938, 48_876]]
129
- ]
132
+ [:large, [100_005, 35_000, 28_000, 27_000]],
133
+ [:large2, [35_000, 28_000, 27_000, 100_005]],
134
+ [:large3, [28_000, 27_000, 100_005, 35_000]],
135
+ [:large4, [1_238, 39_092, 27_938, 48_876]]
136
+ ]
130
137
 
131
138
  g = Gruff::Line.new
132
- g.title = "Very Large Values Line Graph Test"
139
+ g.title = 'Very Large Values Line Graph Test'
133
140
  g.baseline_value = 50_000
134
141
  g.baseline_color = 'green'
135
142
  g.dot_radius = 15
@@ -138,7 +145,7 @@ class TestGruffLine < GruffTestCase
138
145
  g.data(data[0], data[1])
139
146
  end
140
147
 
141
- g.write("test/output/line_large.png")
148
+ g.write('test/output/line_large.png')
142
149
  end
143
150
 
144
151
  # def test_long_title
@@ -152,15 +159,15 @@ class TestGruffLine < GruffTestCase
152
159
 
153
160
  def test_request_too_many_colors
154
161
  g = Gruff::Line.new
155
- g.title = "More Sets Than in Color Array"
162
+ g.title = 'More Sets Than in Color Array'
156
163
  # g.theme = {} # Sets theme with only black and white
157
164
  @datasets.each do |data|
158
165
  g.data(data[0], data[1])
159
166
  end
160
167
  @datasets.each do |data|
161
- g.data("#{data[0]}-B", data[1].map {|d| d + 20})
168
+ g.data("#{data[0]}-B", data[1].map { |d| d + 20 })
162
169
  end
163
- g.write("test/output/line_more_sets_than_colors.png")
170
+ g.write('test/output/line_more_sets_than_colors.png')
164
171
  end
165
172
 
166
173
  #
@@ -170,116 +177,116 @@ class TestGruffLine < GruffTestCase
170
177
 
171
178
  def test_many_datapoints
172
179
  g = Gruff::Line.new
173
- g.title = "Many Multi-Line Graph Test"
180
+ g.title = 'Many Multi-Line Graph Test'
174
181
  g.labels = {
175
- 0 => 'June',
176
- 10 => 'July',
177
- 30 => 'August',
178
- 50 => 'September',
182
+ 0 => 'June',
183
+ 10 => 'July',
184
+ 30 => 'August',
185
+ 50 => 'September',
179
186
  }
180
- g.data('many points', (0..50).collect {|i| rand(100) })
181
- g.x_axis_label = "Months"
187
+ g.data('many points', (0..50).collect { |i| rand(100) })
188
+ g.x_axis_label = 'Months'
182
189
 
183
190
  # Default theme
184
- g.write("test/output/line_many.png")
191
+ g.write('test/output/line_many.png')
185
192
  end
186
193
 
187
194
 
188
195
  def test_similar_high_end_values
189
- @dataset = %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f}
196
+ @dataset = %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect { |i| i.to_f }
190
197
 
191
198
  g = Gruff::Line.new
192
- g.title = "Similar High End Values Test"
193
- g.data('similar points', @dataset )
194
- g.write("test/output/line_similar_high_end_values.png")
199
+ g.title = 'Similar High End Values Test'
200
+ g.data('similar points', @dataset)
201
+ g.write('test/output/line_similar_high_end_values.png')
195
202
 
196
203
  g = Gruff::Line.new
197
- g.title = "Similar High End Values With Floor"
198
- g.data('similar points', @dataset )
204
+ g.title = 'Similar High End Values With Floor'
205
+ g.data('similar points', @dataset)
199
206
  g.minimum_value = 0
200
- g.y_axis_label = "Barometric Pressure"
201
- g.write("test/output/line_similar_high_end_values_with_floor.png")
207
+ g.y_axis_label = 'Barometric Pressure'
208
+ g.write('test/output/line_similar_high_end_values_with_floor.png')
202
209
  end
203
210
 
204
211
  def test_many_lines_graph_small
205
212
  g = Gruff::Line.new(400)
206
- g.title = "Many Values Line Test 400px"
213
+ g.title = 'Many Values Line Test 400px'
207
214
  g.labels = {
208
- 0 => '5/6',
209
- 10 => '5/15',
210
- 20 => '5/24',
211
- 30 => '5/30',
212
- 40 => '6/4',
213
- 50 => '6/16'
215
+ 0 => '5/6',
216
+ 10 => '5/15',
217
+ 20 => '5/24',
218
+ 30 => '5/30',
219
+ 40 => '6/4',
220
+ 50 => '6/16'
214
221
  }
215
222
  %w{jimmy jane philip arthur julie bert}.each do |student_name|
216
223
  g.data(student_name, (0..50).collect { |i| rand 100 })
217
224
  end
218
225
 
219
226
  # Default theme
220
- g.write("test/output/line_many_lines_small.png")
227
+ g.write('test/output/line_many_lines_small.png')
221
228
  end
222
229
 
223
230
  def test_graph_tiny
224
231
  g = Gruff::Line.new(300)
225
- g.title = "Tiny Test 300px"
232
+ g.title = 'Tiny Test 300px'
226
233
  g.labels = {
227
- 0 => '5/6',
228
- 10 => '5/15',
229
- 20 => '5/24',
230
- 30 => '5/30',
231
- 40 => '6/4',
232
- 50 => '6/16'
234
+ 0 => '5/6',
235
+ 10 => '5/15',
236
+ 20 => '5/24',
237
+ 30 => '5/30',
238
+ 40 => '6/4',
239
+ 50 => '6/16'
233
240
  }
234
241
  %w{jimmy jane philip arthur julie bert}.each do |student_name|
235
242
  g.data(student_name, (0..50).collect { |i| rand 100 })
236
243
  end
237
244
 
238
245
  # Default theme
239
- g.write("test/output/line_tiny.png")
246
+ g.write('test/output/line_tiny.png')
240
247
  end
241
248
 
242
249
  def test_no_data
243
250
  g = Gruff::Line.new(400)
244
- g.title = "No Data"
251
+ g.title = 'No Data'
245
252
  # Default theme
246
- g.write("test/output/line_no_data.png")
253
+ g.write('test/output/line_no_data.png')
247
254
 
248
255
  g = Gruff::Line.new(400)
249
- g.title = "No Data Title"
256
+ g.title = 'No Data Title'
250
257
  g.no_data_message = 'There is no data'
251
- g.write("test/output/line_no_data_msg.png")
258
+ g.write('test/output/line_no_data_msg.png')
252
259
  end
253
260
 
254
261
 
255
262
  def test_all_zeros
256
263
  g = Gruff::Line.new(400)
257
- g.title = "All Zeros"
264
+ g.title = 'All Zeros'
258
265
 
259
- g.data(:gus, [0,0,0,0])
266
+ g.data(:gus, [0, 0, 0, 0])
260
267
 
261
268
  # Default theme
262
- g.write("test/output/line_no_data_other.png")
269
+ g.write('test/output/line_no_data_other.png')
263
270
  end
264
271
 
265
272
 
266
273
  def test_some_nil_points
267
274
  g = Gruff::Line.new
268
- g.title = "Some Nil Points"
275
+ g.title = 'Some Nil Points'
269
276
 
270
277
  @datasets = [
271
- [:data1, [1, 2, 3, nil, 3, 5, 6]],
272
- [:data2, [5, nil, nil, nil, nil, nil, 5]],
273
- [:data3, [4, nil, 2, 1, 0]],
274
- [:data4, [nil, nil, 3, 1, 2]]
275
- ]
278
+ [:data1, [1, 2, 3, nil, 3, 5, 6]],
279
+ [:data2, [5, nil, nil, 5, nil, nil, 5]],
280
+ [:data3, [4, nil, 2, 1, 0]],
281
+ [:data4, [nil, nil, 3, 1, 2]]
282
+ ]
276
283
 
277
284
  @datasets.each do |data|
278
285
  g.data(*data)
279
286
  end
280
287
 
281
288
  # Default theme
282
- g.write("test/output/line_some_nil_points.png")
289
+ g.write('test/output/line_some_nil_points.png')
283
290
  end
284
291
 
285
292
  def test_no_title
@@ -289,150 +296,162 @@ class TestGruffLine < GruffTestCase
289
296
  g.data(data[0], data[1])
290
297
  end
291
298
 
292
- g.write("test/output/line_no_title.png")
299
+ g.write('test/output/line_no_title.png')
293
300
  end
294
301
 
295
302
  def test_no_line_markers
296
303
  g = setup_basic_graph(400)
297
- g.title = "No Line Markers"
304
+ g.title = 'No Line Markers'
298
305
  g.hide_line_markers = true
299
- g.write("test/output/line_no_line_markers.png")
306
+ g.write('test/output/line_no_line_markers.png')
300
307
  end
301
308
 
302
309
  def test_no_legend
303
310
  g = setup_basic_graph(400)
304
- g.title = "No Legend"
311
+ g.title = 'No Legend'
305
312
  g.hide_legend = true
306
- g.write("test/output/line_no_legend.png")
313
+ g.write('test/output/line_no_legend.png')
307
314
  end
308
315
 
309
316
  def test_nothing_but_the_graph
310
317
  g = setup_basic_graph(400)
311
- g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
318
+ g.title = 'THIS TITLE SHOULD NOT DISPLAY!!!'
312
319
  g.hide_line_markers = true
313
320
  g.hide_legend = true
314
321
  g.hide_title = true
315
- g.write("test/output/line_nothing_but_the_graph.png")
322
+ g.write('test/output/line_nothing_but_the_graph.png')
323
+ end
324
+
325
+ def test_legend_below_the_chart
326
+ g = setup_basic_graph(400)
327
+ g.title = 'Legend below the chart'
328
+ g.legend_at_bottom = true
329
+ g.write('test/output/line_legend_at_bottom.png')
316
330
  end
317
331
 
318
332
  def test_baseline_larger_than_data
319
333
  g = setup_basic_graph(400)
320
- g.title = "Baseline Larger Than Data"
334
+ g.title = 'Baseline Larger Than Data'
321
335
  g.baseline_value = 150
322
- g.write("test/output/line_large_baseline.png")
336
+ g.write('test/output/line_large_baseline.png')
323
337
  end
324
338
 
325
-
326
339
  def test_hide_dots
327
340
  g = setup_basic_graph(400)
328
- g.title = "Hide Dots"
341
+ g.title = 'Hide Dots'
329
342
  g.hide_dots = true
330
- g.write("test/output/line_hide_dots.png")
343
+ g.write('test/output/line_hide_dots.png')
331
344
  end
332
345
 
333
346
  def test_hide_lines
334
347
  g = setup_basic_graph(400)
335
- g.title = "Hide Lines"
348
+ g.title = 'Hide Lines'
336
349
  g.hide_lines = true
337
- g.write("test/output/line_hide_lines.png")
350
+ g.write('test/output/line_hide_lines.png')
338
351
  end
339
352
 
340
353
  def test_wide_graph
341
354
  g = setup_basic_graph('800x400')
342
- g.title = "Wide Graph"
343
- g.write("test/output/line_wide_graph.png")
355
+ g.title = 'Wide Graph'
356
+ g.write('test/output/line_wide_graph.png')
344
357
 
345
358
  g = setup_basic_graph('400x200')
346
- g.title = "Wide Graph Small"
347
- g.write("test/output/line_wide_graph_small.png")
359
+ g.title = 'Wide Graph Small'
360
+ g.write('test/output/line_wide_graph_small.png')
348
361
  end
349
362
 
350
363
  def test_negative
351
364
  g = setup_pos_neg(800)
352
- g.write("test/output/line_pos_neg.png")
365
+ g.write('test/output/line_pos_neg.png')
353
366
 
354
367
  g = setup_pos_neg(400)
355
368
  g.title = 'Pos/Neg Line Test Small'
356
- g.write("test/output/line_pos_neg_400.png")
369
+ g.write('test/output/line_pos_neg_400.png')
357
370
  end
358
371
 
359
372
  def test_all_negative
360
373
  g = setup_all_neg(800)
361
- g.write("test/output/line_all_neg.png")
374
+ g.maximum_value = 0
375
+ g.write('test/output/line_all_neg.png')
376
+ end
362
377
 
378
+ def test_all_negative_no_max_value
379
+ g = setup_all_neg(800)
380
+ g.write('test/output/line_all_neg_no_max.png')
381
+ end
382
+
383
+ def test_all_negative_400
363
384
  g = setup_all_neg(400)
385
+ g.maximum_value = 0
364
386
  g.title = 'All Neg Line Test Small'
365
- g.write("test/output/line_all_neg_400.png")
387
+ g.write('test/output/line_all_neg_400.png')
366
388
  end
367
389
 
368
390
  def test_many_numbers
369
391
  g = Gruff::Line.new('400x170')
370
- g.title = "Line Test, Many Numbers"
392
+ g.title = 'Line Test, Many Numbers'
371
393
 
372
394
  data = [
373
- { :date => '01',
374
- :wpm => 0,
375
- :errors => 0,
376
- :accuracy => 0 },
377
- { :date => '02',
378
- :wpm => 10,
379
- :errors => 2,
380
- :accuracy => 80 },
381
- { :date => '03',
382
- :wpm => 15,
383
- :errors => 0,
384
- :accuracy => 100 },
385
- { :date => '04',
386
- :wpm => 16,
387
- :errors => 2,
388
- :accuracy => 87 },
389
- { :date => '05',
390
- :wpm => nil,
391
- :errors => nil,
392
- :accuracy => nil },
393
- { :date => '06',
394
- :wpm => 18,
395
- :errors => 1,
396
- :accuracy => 94 },
397
- { :date => '07'},
398
- { :date => '08' },
399
- { :date => '09',
395
+ {:date => '01',
396
+ :wpm => 0,
397
+ :errors => 0,
398
+ :accuracy => 0},
399
+ {:date => '02',
400
+ :wpm => 10,
401
+ :errors => 2,
402
+ :accuracy => 80},
403
+ {:date => '03',
404
+ :wpm => 15,
405
+ :errors => 0,
406
+ :accuracy => 100},
407
+ {:date => '04',
408
+ :wpm => 16,
409
+ :errors => 2,
410
+ :accuracy => 87},
411
+ {:date => '05'},
412
+ {:date => '06',
413
+ :wpm => 18,
414
+ :errors => 1,
415
+ :accuracy => 94},
416
+ {:date => '07'},
417
+ {:date => '08'},
418
+ {:date => '09',
400
419
  :wpm => 21,
401
420
  :errors => 1,
402
- :accuracy => 95 },
403
- { :date => '10'},
404
- { :date => '11'},
405
- { :date => '12'},
406
- { :date => '13'},
407
- { :date => '14'},
408
- { :date => '15'},
409
- { :date => '16'},
410
- { :date => '17'},
411
- { :date => '18'},
412
- { :date => '19',
421
+ :accuracy => 95},
422
+ {:date => '10'},
423
+ {:date => '11'},
424
+ {:date => '12'},
425
+ {:date => '13'},
426
+ {:date => '14'},
427
+ {:date => '15'},
428
+ {:date => '16'},
429
+ {:date => '17'},
430
+ {:date => '18'},
431
+ {:date => '19',
413
432
  :wpm => 28,
414
433
  :errors => 5,
415
- :accuracy => 82 },
416
- { :date => '20'},
417
- { :date => '21'},
418
- { :date => '22'},
419
- { :date => '23'},
420
- { :date => '24'},
421
- { :date => '25'},
422
- { :date => '26'},
423
- { :date => '27',
434
+ :accuracy => 82},
435
+ {:date => '20'},
436
+ {:date => '21'},
437
+ {:date => '22'},
438
+ {:date => '23'},
439
+ {:date => '24'},
440
+ {:date => '25'},
441
+ {:date => '26'},
442
+ {:date => '27',
424
443
  :wpm => 37,
425
444
  :errors => 3,
426
- :accuracy => 92 },
445
+ :accuracy => 92},
427
446
  ]
428
447
 
429
448
  [:wpm, :errors, :accuracy].each do |field|
430
- g.data(field.to_s, data.collect {|d| d[field] })
449
+ g.dataxy(field, data.each_with_index.map { |d, i| [i + 1, d[field]] if d[field] }.compact)
431
450
  end
432
451
 
433
452
  labels = Hash.new
434
453
  data.each_with_index do |d, i|
435
- labels[i] = d[:date]
454
+ labels[i + 1] = d[:date] if d.size > 1
436
455
  end
437
456
  g.labels = labels
438
457
 
@@ -441,7 +460,7 @@ class TestGruffLine < GruffTestCase
441
460
 
442
461
  def test_no_hide_line_no_labels
443
462
  g = Gruff::Line.new
444
- g.title = "No Hide Line No Labels"
463
+ g.title = 'No Hide Line No Labels'
445
464
  @datasets.each do |data|
446
465
  g.data(data[0], data[1])
447
466
  end
@@ -451,32 +470,32 @@ class TestGruffLine < GruffTestCase
451
470
 
452
471
  def test_xy_data
453
472
  g = Gruff::Line.new
454
- g.title = "X/Y Dataset"
455
- g.dataxy("Apples", [1,3,4,5,6,10], [1, 2, 3, 4, 4, 3])
456
- g.dataxy("Bapples", [1,3,4,5,7,9], [1, 1, 2, 2, 3, 3])
457
- g.data("Capples", [1, 1, 2, 2, 3, 3])
458
- g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
459
- g.write('test/output/data_xy.png')
473
+ g.title = 'X/Y Dataset'
474
+ g.dataxy('Apples', [1, 3, 4, 5, 6, 10], [1, 2, 3, 4, 4, 3])
475
+ g.dataxy('Bapples', [1, 3, 4, 5, 7, 9], [1, 1, 2, 2, 3, 3])
476
+ g.data('Capples', [1, 1, 2, 2, 3, 3])
477
+ g.labels = {0 => '2003', 2 => '2004', 4 => '2005', 6 => '2006', 8 => '2007', 10 => '2008'}
478
+ g.write('test/output/line_xy.png')
460
479
  end
461
480
 
462
481
  def test_xy_data_pairs
463
482
  g = Gruff::Line.new
464
- g.title = "X/Y Dataset"
465
- g.dataxy("Apples", [[1,1], [3,2],[4,3],[5,4],[6,4],[10,3]])
466
- g.dataxy("Bapples", [[1,1],[3,1],[4,2],[5,2],[7,3],[9,3]])
467
- g.data("Capples", [1, 1, 2, 2, 3, 3])
468
- g.dataxy("Dapples", [[1,1],[2,3],[5,8],[13,21]])
469
- g.dataxy("Eapples", [[1,1],[2,3],[5,8],[13,21],[13,8],[5,3],[2,1],[1,1]])
470
- g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
471
- g.write('test/output/data_xy_pairs.png')
483
+ g.title = 'X/Y Dataset Pairs'
484
+ g.dataxy('Apples', [[1, 1], [3, 2], [4, 3], [5, 4], [6, 4], [10, 3]])
485
+ g.dataxy('Bapples', [[1, 1], [3, 1], [4, 2], [5, 2], [7, 3], [9, 3]])
486
+ g.data('Capples', [1, 1, 2, 2, 3, 3])
487
+ g.dataxy('Dapples', [[1, 1], [2, 3], [5, 8], [13, 21]])
488
+ g.dataxy('Eapples', [[1, 1], [2, 3], [5, 8], [13, 21], [13, 8], [5, 3], [2, 1], [1, 1]])
489
+ g.labels = {0 => '2003', 2 => '2004', 4 => '2005', 6 => '2006', 8 => '2007', 10 => '2008', 12 => '2009'}
490
+ g.write('test/output/line_xy_pairs.png')
472
491
  end
473
492
 
474
493
  def test_jruby_error
475
494
  g = Gruff::Line.new
476
495
  g.theme = {
477
- :colors => ['#7F0099', '#2F85ED', '#2FED09','#EC962F'],
478
- :marker_color => '#aaa',
479
- :background_colors => ['#E8E8E8','#B9FD6C']
496
+ :colors => %w(#7F0099 #2F85ED #2FED09 #EC962F),
497
+ :marker_color => '#aaa',
498
+ :background_colors => %w(#E8E8E8 #B9FD6C)
480
499
  }
481
500
  g.hide_title = true
482
501
 
@@ -489,36 +508,49 @@ class TestGruffLine < GruffTestCase
489
508
 
490
509
  def test_marker_label_accuracy
491
510
  g = Gruff::Line.new
492
- g.title = "Marker label accuracy"
511
+ g.title = 'Marker label accuracy'
493
512
  g.labels = {
494
- 0 => '1',
495
- 1 => '2',
496
- 2 => '3',
497
- 3 => '4',
498
- 4 => '5'
513
+ 0 => '1',
514
+ 1 => '2',
515
+ 2 => '3',
516
+ 3 => '4',
517
+ 4 => '5'
499
518
  }
500
- g.data('first', [0.5, 0.51, 0.52, 0.53, 0.54])
519
+ g.data('first', [0.5, 0.51, 0.52, 0.53, 0.54])
501
520
  g.data('second', [0.6, 0.61, 0.62, 0.63, 0.64])
502
- g.data('third', [0.7, 0.71, 0.72, 0.73, 0.74])
521
+ g.data('third', [0.7, 0.71, 0.72, 0.73, 0.74])
503
522
 
504
- g.write("test/output/line_marker_label_accuracy.png")
523
+ g.write('test/output/line_marker_label_accuracy.png')
505
524
  end
506
525
 
526
+ def test_y_axis_increment
527
+ g = Gruff::Line.new
528
+ g.title = 'y axis increment'
529
+
530
+ g.data('data', [1, 2, 3])
507
531
 
508
- private
532
+ g.y_axis_increment = 1
509
533
 
510
- def bmi(params={})
511
- g = basic_graph()
534
+ g.write('test/output/line_y_axis_increment.png')
535
+ end
512
536
 
513
- g.y_axis_label = 'BMI'
537
+ def test_baseline
538
+ g = Gruff::Line.new
539
+ g.title = 'Line Chart with Baseline = 5'
514
540
 
515
- bmis = [24.3, 23.9, 23.7, 23.7, 23.6, 23.9, 23.6, 23.7, 23.4, 23.4, 23.4, 22.9]
541
+ g.data('Apples', [3, 2, 3, 4, 4, 3])
542
+ g.data('Oranges', [4, 8, 7, 9, 8, 9])
543
+ g.data('Watermelon', [2, 3, 4, 5, 6, 8])
544
+ g.data('Peaches', [9, 9, 10, 8, 7, 9])
516
545
 
517
- g.data( 'BMI', bmis )
518
- g.hide_legend = true
519
- return g
546
+ g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
547
+ g.baseline_value = 5
548
+
549
+ g.write('line_baseline.png')
520
550
  end
521
551
 
552
+ private
553
+
522
554
  # TODO Reset data after each theme
523
555
  def line_graph_with_themes(size=nil)
524
556
  g = Gruff::Line.new(size)
@@ -535,7 +567,7 @@ private
535
567
  g.title = "Multi-Line Graph Test #{size}"
536
568
  g.labels = @labels
537
569
  g.baseline_value = 90
538
- g.theme_37signals
570
+ g.theme = Gruff::Themes::THIRTYSEVEN_SIGNALS
539
571
  @datasets.each do |data|
540
572
  g.data(data[0], data[1])
541
573
  end
@@ -545,7 +577,7 @@ private
545
577
  g.title = "Multi-Line Graph Test #{size}"
546
578
  g.labels = @labels
547
579
  g.baseline_value = 90
548
- g.theme_rails_keynote
580
+ g.theme = Gruff::Themes::RAILS_KEYNOTE
549
581
  @datasets.each do |data|
550
582
  g.data(data[0], data[1])
551
583
  end
@@ -555,7 +587,7 @@ private
555
587
  g.title = "Multi-Line Graph Test #{size}"
556
588
  g.labels = @labels
557
589
  g.baseline_value = 90
558
- g.theme_odeo
590
+ g.theme = Gruff::Themes::ODEO
559
591
  @datasets.each do |data|
560
592
  g.data(data[0], data[1])
561
593
  end
@@ -564,31 +596,31 @@ private
564
596
 
565
597
  def setup_pos_neg(size=800)
566
598
  g = Gruff::Line.new(size)
567
- g.title = "Pos/Neg Line Graph Test"
599
+ g.title = 'Pos/Neg Line Graph Test'
568
600
  g.labels = {
569
- 0 => '5/6',
570
- 1 => '5/15',
571
- 2 => '5/24',
572
- 3 => '5/30',
601
+ 0 => '5/6',
602
+ 1 => '5/15',
603
+ 2 => '5/24',
604
+ 3 => '5/30',
573
605
  }
574
606
  g.data(:apples, [-1, 0, 4, -4])
575
607
  g.data(:peaches, [10, 8, 6, 3])
576
- return g
608
+ g
577
609
  end
578
610
 
579
611
 
580
612
  def setup_all_neg(size=800)
581
613
  g = Gruff::Line.new(size)
582
- g.title = "All Neg Line Graph Test"
614
+ g.title = 'All Neg Line Graph Test'
583
615
  g.labels = {
584
- 0 => '5/6',
585
- 1 => '5/15',
586
- 2 => '5/24',
587
- 3 => '5/30',
616
+ 0 => '5/6',
617
+ 1 => '5/15',
618
+ 2 => '5/24',
619
+ 3 => '5/30',
588
620
  }
589
621
  g.data(:apples, [-1, -5, -20, -4])
590
622
  g.data(:peaches, [-10, -8, -6, -3])
591
623
  g
592
624
  end
593
-
625
+
594
626
  end