view release on metacpan or search on metacpan
Changelog.ini view on Meta::CPAN
[Module]
Name=Image::Magick::Chart
Changelog.Creator=Module::Metadata::Changes V 2.11
Changelog.Parser=Config::IniFiles V 2.88
[V 1.07]
Date=2017-01-08T08:36:00
Comments= <<EOT
- Replace /usr/bin/perl with /usr/bin/env perl.
- Replace common::sense with use strict and use warnings, to get uninit var warnings.
- Adopt new repo structure. See
http://savage.net.au/Ron/html/My.Workflow.for.Building.Distros.html.
Changelog.ini view on Meta::CPAN
[V 1.04]
Date=2009-11-13T13:20:00
Comments= <<EOT
- Run dos2unix
- Rename Changes.txt to CHANGES
EOT
[V 1.03]
Date=2008-12-12T18:15:00
Comments= <<EOT
- Image::Magick's Draw() method has an option, 'fill'. When I first wrote this module,
fill's value defaulted to 'none', and now it defaults to something else. The effect is
that when drawing a frame, the whole image is now filled in with black. Hence the patch
to Image::Magick::Chart's draw_frame() method.
I am tempted to rant and rave about the endless butchering of Image::Magick by its author,
but that would not achieve anything... And anyway, it's an extremely useful module
EOT
[V 1.02]
Date=2005-07-17T17:52:00
Comments= <<EOT
- Add an option, y_axis_labels_x, which allows the user to specify the x-axis value
(abscissa) at which to start writing y-axis labels. From the POD:
The value, if not undef, determines the x-axis value (abscissa) at which y-axis labels are written.
The special value undef means this module calculates an abscissa at which to start writing
Revision history for Perl extension Image::Magick::Chart.
1.07 2017-01-08T08:36:00
- Replace /usr/bin/perl with /usr/bin/env perl.
- Replace common::sense with use strict and use warnings, to get uninit var warnings.
- Adopt new repo structure. See
http://savage.net.au/Ron/html/My.Workflow.for.Building.Distros.html.
1.06 2010-02-21T12:55:21
- Remove text 'All rights reserved' (for Debian licensing).
- Remove POD heads 'Required Modules' and 'Changes'.
1.05 2010-02-10T14:02:08
- MANIFEST.SKIP updated to exclude MYMETA.yml. Add MYMETA.yml.
1.04 2009-11-13T13:20:00
- Run dos2unix
- Rename Changes.txt to CHANGES
1.03 2008-12-12T18:15:00
- Image::Magick's Draw() method has an option, 'fill'. When I first wrote this module,
fill's value defaulted to 'none', and now it defaults to something else. The effect is
that when drawing a frame, the whole image is now filled in with black. Hence the patch
to Image::Magick::Chart's draw_frame() method.
I am tempted to rant and rave about the endless butchering of Image::Magick by its author,
but that would not achieve anything... And anyway, it's an extremely useful module
1.02 2005-07-17T17:52:00
- Add an option, y_axis_labels_x, which allows the user to specify the x-axis value
(abscissa) at which to start writing y-axis labels. From the POD:
The value, if not undef, determines the x-axis value (abscissa) at which y-axis labels are written.
The special value undef means this module calculates an abscissa at which to start writing
y-axis labels. The default behaviour is identical to the previous version 1.01.
This calculation will only produce a pretty-looking column of y-axis labels when all labels are
the same width in pixels. See C<sub draw_y_axis_labels()> for the calculation.
{
"abstract" : "Use Image::Magick to create charts",
"author" : [
"Ron Savage (ron@savage.net.au)"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.22, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"Image::Magick" : "0",
"Moo" : "2.003",
"Types::Standard" : "1.000005",
"parent" : "0",
"perl" : "5.006002",
"strict" : "0",
"warnings" : "0"
}
},
"test" : {
"requires" : {
---
abstract: 'Use Image::Magick to create charts'
author:
- 'Ron Savage (ron@savage.net.au)'
build_requires:
ExtUtils::MakeMaker: '0'
Test::More: '1.001002'
Test::Pod: '1.51'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.22, CPAN::Meta::Converter version 2.150005'
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Image-Magick-Chart
no_index:
directory:
- t
- inc
requires:
Carp: '0'
Image::Magick: '0'
Moo: '2.003'
Types::Standard: '1.000005'
parent: '0'
perl: '5.006002'
strict: '0'
warnings: '0'
resources:
bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Image-Magick-Chart
license: http://dev.perl.org/licenses/
repository: https://github.com/ronsavage/Image-Magick-Chart.git
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
my(%params) =
(
($] ge '5.005') ?
(
'AUTHOR' => 'Ron Savage (ron@savage.net.au)',
'ABSTRACT' => 'Use Image::Magick to create charts',
) : (),
clean =>
{
FILES => 'blib/* Makefile MANIFEST Image-Magick-Chart-*'
},
dist =>
{
COMPRESS => 'gzip',
SUFFIX => 'gz'
},
DISTNAME => 'Image-Magick-Chart',
NAME => 'Image::Magick::Chart',
PL_FILES => {},
PREREQ_PM =>
{
'Carp' => 0,
'Image::Magick' => undef,
'Moo' => 2.003000,
'parent' => 0,
'perl' => 5.006002,
'strict' => 0,
'Types::Standard' => 1.000005,
'warnings' => 0,
},
TEST_REQUIRES =>
{
'Test::More' => 1.001002,
README file for Image::Magick::Chart.
See also: Changes.txt.
Warning: WinZip 8.1 and 9.0 both contain an 'accidental' bug which stops
them recognizing POSIX-style directory structures in valid tar files.
You are better off using a reliable tool such as InfoZip:
ftp://ftp.info-zip.org/pub/infozip/
1 Installing from a Unix-like distro
------------------------------------
examples/test-chart.pl view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Image::Magick::Chart::HorizontalBars;
# -----------------------
Image::Magick::Chart::HorizontalBars -> new
(
antialias => 0, # 0 => No antialias; 1 => Antialias.
bar_width => 8, # Pixels.
bg_color => 'white',
colorspace => 'RGB',
depth => 8, # Bits per channel.
fg_color => 'blue',
font => 'Courier',
frame_color => 'black',
frame_option => 1, # 0 => None; 1 => Draw it.
examples/test-chart.pl view on Meta::CPAN
x_data => [15, 5, 70, 25, 45, 20, 65],
x_data_option => 1,
x_pixels_per_unit => 3, # Horizontal width of each data unit.
y_axis_data => [1 .. 7, 8], # 7 data points, plus 1 to make result pretty.
y_axis_labels => [(map{"($_)"} reverse (1 .. 7) ), ''],
y_axis_labels_option => 1, # 0 => None; 1 => Draw them.
y_axis_ticks_option => 1, # 0 => None; 1 => Left of y-axis; 2 => Across frame.
y_pixels_per_unit => 20,
) -> draw();
Image::Magick::Chart::HorizontalBars -> new
(
antialias => 0, # 0 => No antialias; 1 => Antialias.
bar_width => 8, # Pixels.
bg_color => 'white',
colorspace => 'RGB',
depth => 8, # Bits per channel.
fg_color => 'blue',
font => 'Courier',
frame_color => 'black',
frame_option => 1, # 0 => None; 1 => Draw it.
lib/Image/Magick/Chart.pm view on Meta::CPAN
package Image::Magick::Chart;
use strict;
use warnings;
use Carp;
use Image::Magick;
use Moo;
require 5.006002;
our $VERSION = '1.07';
use Types::Standard qw/Any ArrayRef Bool Int Str/;
has antialias =>
lib/Image/Magick/Chart.pm view on Meta::CPAN
my($self) = @_;
if ($self -> image)
{
($self -> width, $self -> height) = $self -> image -> Get('width', 'height');
}
else
{
$self -> width(${$self -> padding}[3] + 1 + ($self -> x_pixels_per_unit * ${$self -> x_axis_data}[$#{$self -> x_axis_data}]) + ${$self -> padding}[1]);
$self -> height(${$self -> padding}[2] + 1 + ($self -> y_pixels_per_unit * ${$self -> y_axis_data}[$#{$self -> y_axis_data}]) + ${$self -> padding}[0]);
$self -> image(Image::Magick -> new(size => "$self -> width x $self -> height") );
$self -> image -> Set(antialias => $self -> antialias) && Carp::croak("Can't set antialias: $self -> antialias");
$self -> image -> Set(colorspace => $self -> colorspace) && Carp::croak("Can't set colorspace: $self -> colorspace");
$self -> image -> Set(depth => $self -> depth) && Carp::croak("Can't set depth: $self -> depth");
$self -> image -> Read('xc:' . $self -> bg_color) && Carp::croak("Can't set bg_color color: $self -> bg_color");
}
} # End of BUILD.
# -----------------------------------------------
lib/Image/Magick/Chart.pm view on Meta::CPAN
} # End of write.
# -----------------------------------------------
1;
__END__
=head1 NAME
Image::Magick::Chart - Use Image::Magick to create charts
=head1 Synopsis
#!/usr/bin/env perl
use Image::Magick::Chart::HorizontalBars;
Image::Magick::Chart::HorizontalBars -> new
(
antialias => 0, # 0 => No antialias; 1 => Antialias.
bar_width => 8, # Pixels.
bg_color => 'white',
colorspace => 'RGB',
depth => 8, # Bits per channel.
fg_color => 'blue',
font => 'Courier',
frame_color => 'black',
frame_option => 1, # 0 => None; 1 => Draw it.
lib/Image/Magick/Chart.pm view on Meta::CPAN
y_axis_ticks_option => 1, # 0 => None; 1 => Left of y-axis; 2 => Across frame.
y_pixels_per_unit => 20,
) -> draw();
This code is part of examples/test-chart.pl.
Note: You do not need to specify all the options above, of course, but only those you
wish to differ from the defaults. I've included all options in examples/test-chart.pl
just to save you the effort of having to type them in.
See Image::Magick's documentation page www/perl.html for the list of values supported by
each Image::Magick option.
=head1 Description
C<Image::Magick::Chart> is a pure Perl module.
This module uses C<Image::Magick> as the base of a set of modules which create simple images
of various types. Only C<Image::Magick::Chart::HorizontalBars> is available at this time.
See examples/image-*.png for sample output, and examples/test-chart.pl for the program
which created those samples.
You control the size of the image by specifying the data values for X and Y, and also by
specifying the scaling factors in the X and Y directions in terms of pixels per unit of data.
Eg: In the above code, the x-axis data ranges up to 100 (sic), and the x-axis scaling factor
is 3 pixels/unit, so the part of the image occupied by the data will be 3 * 100 + 1 pixels wide.
The 1 is for the y-axis.
lib/Image/Magick/Chart.pm view on Meta::CPAN
This module is available both as a Unix-style distro (*.tgz) and an
ActiveState-style distro (*.ppd). The latter is shipped in a *.zip file.
See http://savage.net.au/Perl-modules.html for details.
See http://savage.net.au/Perl-modules/html/installing-a-module.html for
help on unpacking and installing each type of distro.
=head1 Constructor and initialization
new(...) returns an C<Image::Magick::Chart> object.
This is the class contructor.
Usage: Image::Magick::Chart -> new().
Note: Actually, you do not normally do this.
Instead, you call: Image::Magick::Chart::HorizontalBars -> new(...) -> draw().
This method takes a set of parameters. Only the output_file_name parameter is mandatory.
For each parameter you wish to use, call new as new(param_1 => value_1, ...).
Parameters:
=over 4
=item o antialias
The value, 0 or 1, is passed to Image::Magick, if this module creates the image.
See the 'image' option if you wish to use a pre-existing object of type Image::Magick.
Using a value of 1 will make your output file slightly larger.
The default value is 0.
This parameter is optional.
=item o bar_width
This is the thickness of the bars, in pixels.
The default value is 8 pixels.
This parameter is optional.
=item o bg_color
This is the background color of the image, if this module creates the image.
See the 'image' option if you wish to use a pre-existing object of type Image::Magick.
The default value is 'white'.
This parameter is optional.
=item o colorspace
The value, 'RGB' etc, is passed to Image::Magick, if this module creates the image.
See the 'image' option if you wish to use a pre-existing object of type Image::Magick.
This parameter is optional.
=item o depth
This is the number of bits per color channel.
The default value is 8.
This parameter is optional.
=item o fg_color
This is the color of the horizontal bars, when using C<Image::Magick::Chart::HorizontalBars>.
The default value is 'black'.
This parameter is optional.
=item o font
This is the font used for:
=over 4
lib/Image/Magick/Chart.pm view on Meta::CPAN
The default value is 1.
This parameter is optional.
=item o height
This is the calculated height of the image, taking into account the area occupied by
the data (the framed area), and the padding on the 4 sides of the frame.
If you use a pre-existing object of type Image::Magick, this module will get the
values for width and height from that image.
This parameter is optional.
=item o image
This is the object of type Image::Magick used to manage the image.
This module creates this object by default, but you can pass in to the constructor
a pre-existing object of type Image::Magick, and this module will use your object.
If you use you own object, I assume you have set these parameters for your image:
=over 4
=item o antialias
=item o bg_color
=item o colorspace
lib/Image/Magick/Chart.pm view on Meta::CPAN
The default value is '' (the empty string).
This parameter is optional.
=item o width
This is the calculated width of the image, taking into account the area occupied by
the data (the framed area), and the padding on the 4 sides of the frame.
If you use a pre-existing object of type Image::Magick, this module will get the
values for width and height from that image.
This parameter is optional.
=item o x_axis_data
This is an array ref of X values (abscissas) where you want the x-axis labels and x-axis tick marks
to be drawn.
The values in this array ref are multiplied by the value of the x_pixels_per_unit parameter,
lib/Image/Magick/Chart.pm view on Meta::CPAN
the area occupied by the data (the framed area) a bit higher.
This parameter is optional.
=back
=head1 Methods
=head2 draw_frame()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_horizontal_bars()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_title()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_x_axis_labels()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_x_axis_ticks()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_y_axis_labels()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 draw_y_axis_ticks()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head2 new(...)
Returns a object of type C<Image::Magick::Chart>.
See above, in the section called 'Constructor and initialization' for details.
=head2 write()
Called by method C<draw()> in C<Image::Magick::Chart::HorizontalBars>.
These is no need to call this method yourself.
=head1 Machine-Readable Change Log
The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
=head1 Version Numbers
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
lib/Image/Magick/Chart.pm view on Meta::CPAN
L<https://github.com/ronsavage/Image-Magick-Chart>
=head1 Support
Email the author, or log a bug on RT:
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Image-Magick-Chart>.
=head1 Author
C<Image::Magick::Chart> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2005.
L<Homepage|http://savage.net.au/>
=head1 Copyright
Australian copyright (c) 2005, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Perl License, a copy of which is available at:
http://dev.perl.org/licenses/
lib/Image/Magick/Chart/HorizontalBars.pm view on Meta::CPAN
package Image::Magick::Chart::HorizontalBars;
use parent Image::Magick::Chart;
use strict;
use warnings;
use Carp;
use Image::Magick::Chart;
our $VERSION = '1.07';
# -----------------------------------------------
sub draw
{
my($self) = @_;
$self -> draw_frame() if ($self -> frame_option);
lib/Image/Magick/Chart/HorizontalBars.pm view on Meta::CPAN
} # End of draw.
# -----------------------------------------------
1;
__END__
=head1 NAME
C<Image::Magick::Chart::HorizontalBars> - Use Image::Magick to create charts.
=head1 Synopsis
#!/usr/bin/env perl
use Image::Magick::Chart::HorizontalBars;
Image::Magick::Chart::HorizontalBars -> new
(
antialias => 0, # 0 => No antialias; 1 => Antialias.
bar_width => 8, # Pixels.
bg_color => 'white',
colorspace => 'RGB',
depth => 8, # Bits per channel.
fg_color => 'blue',
font => 'Courier',
frame_color => 'black',
frame_option => 1, # 0 => None; 1 => Draw it.
lib/Image/Magick/Chart/HorizontalBars.pm view on Meta::CPAN
) -> draw();
This code is part of examples/test-chart.pl.
Note: You do not need to specify all the options above, of course, but only those you
wish to differ from the defaults. I have included all options in examples/test-chart.pl
just to save you the effort of having to type them in.
=head1 Description
C<Image::Magick::Chart::HorizontalBars> is a pure Perl module.
This module uses Image::Magick to create simple charts (images consisting of horizontal bars)
with optional axes, axis labels, etc.
See examples/image-*.png for sample output, and examples/test-chart.pl for the program
which created those samples.
See the docs for C<Image::Magick::Chart> for details.
=head1 Distributions
This module is available both as a Unix-style distro (*.tgz) and an
ActiveState-style distro (*.ppd). The latter is shipped in a *.zip file.
See http://savage.net.au/Perl-modules.html for details.
See http://savage.net.au/Perl-modules/html/installing-a-module.html for
help on unpacking and installing each type of distro.
=head1 Constructor and initialization
new(...) returns a C<Image::Magick::Chart::HorizontalBars> object.
This is the class contructor.
Usage: Image::Magick::Chart::HorizontalBars -> new().
This method takes a set of parameters.
For each parameter you wish to use, call new as new(param_1 => value_1, ...).
Any parameter which is supported by the parent class, Image::Magick::Chart, can be used
in the call the C<new()> in this class. So, see the docs for Image::Magick::Chart.
=head1 Methods
=head2 draw()
Output the chart.
=head2 new(...)
Returns a object of type C<Image::Magick::Chart::HorizontalBars>.
See above, in the section called 'Constructor and initialization' for details.
=head1 Machine-Readable Change Log
The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
=head1 Version Numbers
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
lib/Image/Magick/Chart/HorizontalBars.pm view on Meta::CPAN
L<https://github.com/ronsavage/Image-Magick-Chart>
=head1 Support
Email the author, or log a bug on RT:
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Image-Magick-Chart>.
=head1 Author
C<Image::Magick::Chart::HorizontalBars> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2005.
L<Homepage|http://savage.net.au/>
=head1 Copyright
Australian copyright (c) 2005, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Perl License, a copy of which is available at:
http://dev.perl.org/licenses/
use strict;
use warnings;
use Test::More;
use Image::Magick::Chart;
# ------------------------
my($charter) = Image::Magick::Chart -> new
(
x_axis_data => [0, 20, 40, 60, 80, 100],
x_axis_labels => [0, 20, 40, 60, 80, 100],
x_data => [15, 5, 70, 25, 45, 20, 65],
y_axis_data => [1 .. 7, 8], # 7 data points, plus 1 to make result pretty.
y_axis_labels => [(map{"($_)"} reverse (1 .. 7) ), ''],
);
ok(defined $charter);
ok($charter -> isa('Image::Magick::Chart') );
ok($charter -> image -> isa('Image::Magick') );
ok($charter -> bg_color eq 'white');
ok($charter -> y_pixels_per_unit == 20);
done_testing();