.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Chart::Manual::Methods 3pm" .TH Chart::Manual::Methods 3pm "2022-12-10" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Chart::Manual::Methods \- user API .SH "OVERVIEW" .IX Header "OVERVIEW" This are all methods for the chart user. .SH "ALPHABETICALLY" .IX Header "ALPHABETICALLY" .SS "add_datafile" .IX Subsection "add_datafile" Loads all data of a chart (one or more data sets) from a file. (Works only if no data yet added.) You have to either provide a filename or filehandle (\s-1OLD_SCHOOL\s0 or \f(CW$scalar\fR). .PP .Vb 3 \& $graph\->add_dataset( \*(Aqfile.tsv\*(Aq ); \& $graph\->add_dataset( $file_handle ); \& $graph\->add_dataset( FILE_HANDLE ); .Ve .PP An optional second argument, which defaults to \f(CW\*(Aqset\*(Aq\fR can change the file format if set to \f(CW\*(Aqpt\*(Aq\fR. In \f(CW\*(Aqset\*(Aq\fR mode every row of the file content is fed to \*(L"add_dataset\*(R", in \f(CW\*(Aqpt\*(Aq\fR every row get loaded like via \*(L"add_pt\*(R". In other words: \f(CW\*(Aqpt\*(Aq\fR transposes the data table. .PP .Vb 1 \& $graph\->add_dataset( \*(Aqfile.tsv\*(Aq, \*(Aqpt\*(Aq ); .Ve .PP The arbitrary named text files have to contain one or several rows of numbers. The numbers need to be separated by spaces or tabs (\et) (mixing allowed). Perl style comments or empty lines will be ignored, but rows containing different amount of numbers will cause problems. .SS "add_dataset" .IX Subsection "add_dataset" Adding a list of values as one data set. That is one row in the overall data table. The first data set are usually x\-axis labels (domain set). Make sure all sets have the same length. .PP .Vb 2 \& $graph\->add_dataset( 1, 2, 3, ... ); \& $graph\->add_dataset( [1, 2, 3, ...] ); .Ve .PP For instances with Points, Lines or Bars one data set is represented by a set of graphic items (points, bars or line) of one color. .SS "add_pt" .IX Subsection "add_pt" Adds (appends) to each already existing data set one value. That is a column in the overall data table. In this example it adds to set 0 the value 3, to set 1 the 6 and so forth. Make sure that the list lengths matches the number of already existing data sets. .PP .Vb 2 \& $graph\->add_pt( 3, 6, 9, ... ); \& $graph\->add_pt( [3, 6, 9, ...] ); .Ve .SS "cgi_jpeg" .IX Subsection "cgi_jpeg" Creates same \s-1JPEG\s0 image as \*(L"jpeg\*(R", but outputs to \s-1STDOUT.\s0 Since no file name or handle needed, only the optional data argument is acceptable. .PP .Vb 1 \& $graph\->cgi_jpeg( ); \& \& my @data = ([1, 2, 3], # data set 0 \& [3, 4, 5]); # data set 1 \& $graph\->cgi_jpeg( \e@data ); .Ve .SS "cgi_png" .IX Subsection "cgi_png" Creates same \s-1PNG\s0 image as \*(L"png\*(R", but outputs to \s-1STDOUT.\s0 Since no file name or handle needed, only the optional data argument is acceptable. .PP .Vb 1 \& $graph\->cgi_png( ); \& \& my $data = [[1, 2, 3], # data set 0 \& [3, 4, 5] ]; # data set 1 \& $graph\->cgi_png( $data ); .Ve .SS "clear_data" .IX Subsection "clear_data" Needs no arguments and deletes all so far added data. .SS "get_data" .IX Subsection "get_data" Return all data (array of arrays) given to a graph. .SS "imagemap_dump" .IX Subsection "imagemap_dump" When creating a chart for web purposes by \*(L"cgi_jpeg\*(R" or \*(L"cgi_png\*(R", you maybe want the information, where the areas of interests in the image are located, that should react to a users click. (\s-1HTML\s0 tag map). These areas are bounding boxes around the drawn bars or points. You will get per box the values: x1, y1, x2, y2 in one array. These arrays are again in an Array holding, all boxes from one data set. The highest level array again holds all arrays of all data sets, beginning with index \f(CW1\fR. .PP This method can only be called, if the functionality is activated by setting the property: imagemap to \f(CW\*(Aqtrue\*(Aq\fR. .PP .Vb 2 \& $graph\->set( imagemap => \*(Aqtrue\*(Aq); \& my $image_map = $graph\->imagemap_dump(); \& \& say "coordinates of first bar, first data set:"; \& say for @{$image_map\->[1][0]}; .Ve .SS "jpeg" .IX Subsection "jpeg" Creates an \s-1JPEG\s0 image from given data and properties. Accepts a file name or a file handle (raw or in a \s-1SCALAR\s0). The method closes the file handle. .PP .Vb 3 \& $graph\->jpeg( \*(Aqimage.jpg\*(Aq ); \& $graph\->jpeg( $file_handle ); \& $graph\->jpeg( FILE_HANDLE ); \& \& $graph\->jpeg( \*(Aqimage.jpg\*(Aq, $data ); \& $graph\->jpeg( \*(Aqimage.jpg\*(Aq, \*(Aqdata_file.tsv\*(Aq ); \& $graph\->jpeg( \*(Aqimage.jpg\*(Aq, $file_handle ); \& $graph\->jpeg( \*(Aqimage.jpg\*(Aq, FILE_HANDLE ); .Ve .PP The second, optional argument is the data in form of an array of arrays reference. This only works, if there is no data already given to the object. Alternatively the data can also be loaded from a file, just provide the filename or filehandle (modern in \s-1SCALAR\s0 or old school). Read more about the file format at \*(L"add_datafile\*(R" and note that this method has another option for loading transposed data tables. .SS "new" .IX Subsection "new" Creates a new chart object. Takes two optional arguments, which are the width and height of the to be produced image in pixels. Defaults for that are 400 x 300. .PP .Vb 2 \& my $graph = Chart::Bars\->new ( ); \& my $graph = Chart::Bars\->new (600, 700); .Ve .PP Instead of Bars, you can also use: Composite, Direction, ErrorBars, HorizontalBars, Lines, LinesPoints, Mountain, Pareto, Pie, Points, Split and StackedBars. To know more about them read Chart::Manual::Types. .SS "png" .IX Subsection "png" Creates an \s-1PNG\s0 image from given data and properties. Accepts a file name or a file handle (raw or in a \s-1SCALAR\s0). The method closes the file handle. .PP .Vb 3 \& $graph\->png( \*(Aqimage.png\*(Aq ); \& $graph\->png( $file_handle ); \& $graph\->png( FILE_HANDLE ); \& \& $graph\->png( \*(Aqimage.png\*(Aq, $data ); \& $graph\->png( \*(Aqimage.png\*(Aq, \*(Aqdata_file.tsv\*(Aq ); \& $graph\->png( \*(Aqimage.png\*(Aq, $file_handle ); \& $graph\->png( \*(Aqimage.png\*(Aq, FILE_HANDLE ); .Ve .PP The second, optional argument is the data in form of an array of arrays reference. This only works, if there is no data already given to the object. Alternatively the data can also be loaded from a file, just provide the filename or filehandle (modern in \s-1SCALAR\s0 or old school). Read more about the file format at \*(L"add_datafile\*(R" and note that this method has another option for loading transposed data tables. .SS "scalar_jpeg" .IX Subsection "scalar_jpeg" Creates same \s-1JPEG\s0 image as \*(L"jpeg\*(R" but returns the image binary into a variable, not to \s-1STDOUT\s0 or a file. .PP .Vb 2 \& my $image_binary = $graph\->scalar_jpeg(); \& my $image_binary = $graph\->scalar_jpeg( $data ); .Ve .SS "scalar_png" .IX Subsection "scalar_png" Creates same \s-1PNG\s0 image as \*(L"png\*(R" but returns the image binary into a variable, not to \s-1STDOUT\s0 or a file. .PP .Vb 2 \& my $image_binary = $graph\->scalar_png(); \& my $image_binary = $graph\->scalar_png( $data ); .Ve .SS "set" .IX Subsection "set" Method to change one or more chart properties in hash form. .PP .Vb 2 \& $chart\->set ( property_name => \*(Aqnew value\*(Aq, ... ); \& $chart\->set ( %properties ); .Ve .PP Different chart types react to different properties, which are all listed and explained under Chart::Manual::Properties. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2022 Herbert Breunung. .PP This program is free software; you can redistribute it and/or modify it under same terms as Perl itself. .SH "AUTHOR" .IX Header "AUTHOR" Herbert Breunung,