Posted to peterc by peterc at Tue Dec 09 02:31:33 GMT 2008view raw

  1. #!/usr/bin/perl
  2. use Image::Magick::Chart::HorizontalBars;
  3. our $outfile = "blah.gif";
  4. Image::Magick::Chart::HorizontalBars -> new
  5. (
  6. antialias => 0, # 0 => No antialias; 1 => Antialias.
  7. bar_width => 8, # Pixels.
  8. bg_color => 'white',
  9. colorspace => 'RGB',
  10. depth => 8, # Bits per channel.
  11. fg_color => 'blue',
  12. font => 'Courier',
  13. frame_color => 'black',
  14. frame_option => 1, # 0 => None; 1 => Draw it.
  15. height => 0,
  16. image => '',
  17. output_file_name => $outfile,
  18. padding => [30, 30, 30, 30], # [12 noon, 3, 6, 9].
  19. pointsize => 14, # Points.
  20. tick_length => 4, # Pixels.
  21. title => 'Percent (%)',
  22. width => 0,
  23. x_axis_data => [0, 20, 40, 60, 80, 100],
  24. x_axis_labels => [0, 20, 40, 60, 80, 100],
  25. x_axis_labels_option => 1, # 0 => None; 1 => Draw them.
  26. x_axis_ticks_option => 2, # 0 => None; 1 => Below x-axis; 2 => Across frame.
  27. x_data => [15, 5, 70, 25, 45, 20, 65],
  28. x_data_option => 1,
  29. x_pixels_per_unit => 3, # Horizontal width of each data unit.
  30. y_axis_data => [1 .. 7, 8], # 7 data points, plus 1 to make image pretty.
  31. y_axis_labels => [(map{"($_)"} reverse (1 .. 7) ), ''],
  32. y_axis_labels_option => 1, # 0 => None; 1 => Draw them.
  33. y_axis_ticks_option => 1, # 0 => None; 1 => Left of y-axis; 2 => Across frame.
  34. y_pixels_per_unit => 20,
  35. ) -> draw();
  36.