1Chart::Manual::Methods(U3s)er Contributed Perl DocumentatCihoanrt::Manual::Methods(3)
2
3
4

NAME

6       Chart::Manual::Methods - user API
7

OVERVIEW

9       This are all methods for the chart user.
10

ALPHABETICALLY

12   add_datafile
13       Loads all data of a chart (one or more data sets) from a file.  (Works
14       only if no data yet added.) You have to either provide a filename or
15       filehandle (OLD_SCHOOL or $scalar).
16
17           $graph->add_dataset( 'file.tsv' );
18           $graph->add_dataset( $file_handle );
19           $graph->add_dataset( FILE_HANDLE );
20
21       An optional second argument, which defaults to 'set' can change the
22       file format if set to 'pt'. In 'set' mode every row of the file content
23       is fed to "add_dataset", in 'pt' every row get loaded like via
24       "add_pt". In other words: 'pt' transposes the data table.
25
26           $graph->add_dataset( 'file.tsv', 'pt'  );
27
28       The arbitrary named text files have to contain one or several rows of
29       numbers.  The numbers need to be separated by spaces or tabs (\t)
30       (mixing allowed).  Perl style comments or empty lines will be ignored,
31       but rows containing different amount of numbers will cause problems.
32
33   add_dataset
34       Adding a list of values as one data set. That is one row in the overall
35       data table. The first data set are usually x-axis labels (domain set).
36       Make sure all sets have the same length.
37
38           $graph->add_dataset(  1, 2, 3, ...  );
39           $graph->add_dataset( [1, 2, 3, ...] );
40
41       For instances with Points, Lines or Bars one data set is represented by
42       a set of graphic items (points, bars or line) of one color.
43
44   add_pt
45       Adds (appends) to each already existing data set one value. That is a
46       column in the overall data table. In this example it adds to set 0 the
47       value 3, to set 1 the 6 and so forth. Make sure that the list lengths
48       matches the number of already existing data sets.
49
50           $graph->add_pt(  3, 6, 9, ...  );
51           $graph->add_pt( [3, 6, 9, ...] );
52
53   cgi_jpeg
54       Creates same JPEG image as "jpeg", but outputs to STDOUT. Since no file
55       name or handle needed, only the optional data argument is acceptable.
56
57           $graph->cgi_jpeg( );
58
59           my @data = ([1, 2, 3],   # data set 0
60                       [3, 4, 5]);  # data set 1
61           $graph->cgi_jpeg( \@data );
62
63   cgi_png
64       Creates same PNG image as "png", but outputs to STDOUT. Since no file
65       name or handle needed, only the optional data argument is acceptable.
66
67           $graph->cgi_png( );
68
69           my $data = [[1, 2, 3],   # data set 0
70                       [3, 4, 5] ]; # data set 1
71           $graph->cgi_png( $data );
72
73   clear_data
74       Needs no arguments and deletes all so far added data.
75
76   get_data
77       Return all data (array of arrays) given to a graph.
78
79   imagemap_dump
80       When creating a chart for web purposes by "cgi_jpeg" or "cgi_png", you
81       maybe want the information, where the areas of interests in the image
82       are located, that should react to a users click. (HTML tag map).  These
83       areas are bounding boxes around the drawn bars or points.  You will get
84       per box the values: x1, y1, x2, y2 in one array.  These arrays are
85       again in an Array holding, all boxes from one data set.  The highest
86       level array  again holds all arrays of all data sets, beginning with
87       index 1.
88
89       This method can only be called, if the functionality is activated by
90       setting the property: imagemap to 'true'.
91
92           $graph->set( imagemap => 'true');
93           my $image_map = $graph->imagemap_dump();
94
95           say "coordinates of first bar, first data set:";
96           say for @{$image_map->[1][0]};
97
98   jpeg
99       Creates an JPEG image from given data and properties. Accepts a file
100       name or a file handle (raw or in a SCALAR). The method closes the file
101       handle.
102
103           $graph->jpeg( 'image.jpg' );
104           $graph->jpeg( $file_handle );
105           $graph->jpeg( FILE_HANDLE );
106
107           $graph->jpeg( 'image.jpg', $data );
108           $graph->jpeg( 'image.jpg', 'data_file.tsv' );
109           $graph->jpeg( 'image.jpg', $file_handle );
110           $graph->jpeg( 'image.jpg', FILE_HANDLE );
111
112       The second, optional argument is the data in form of an array of arrays
113       reference. This only works, if there is no data already given to the
114       object.  Alternatively the data can also be loaded from a file, just
115       provide the filename or filehandle (modern in SCALAR or old school).
116       Read more about the file format at "add_datafile" and note that this
117       method has another option for loading transposed data tables.
118
119   new
120       Creates a new chart object. Takes two optional arguments, which are the
121       width and height of the to be produced image in pixels.  Defaults for
122       that are 400 x 300.
123
124           my $graph = Chart::Bars->new ( );
125           my $graph = Chart::Bars->new (600, 700);
126
127       Instead of Bars, you can also use: Composite, Direction, ErrorBars,
128       HorizontalBars, Lines, LinesPoints, Mountain, Pareto, Pie, Points,
129       Split and StackedBars. To know more about them read
130       Chart::Manual::Types.
131
132   png
133       Creates an PNG image from given data and properties. Accepts a file
134       name or a file handle (raw or in a SCALAR). The method closes the file
135       handle.
136
137           $graph->png( 'image.png' );
138           $graph->png( $file_handle );
139           $graph->png( FILE_HANDLE );
140
141           $graph->png( 'image.png', $data );
142           $graph->png( 'image.png', 'data_file.tsv' );
143           $graph->png( 'image.png', $file_handle );
144           $graph->png( 'image.png', FILE_HANDLE );
145
146       The second, optional argument is the data in form of an array of arrays
147       reference. This only works, if there is no data already given to the
148       object.  Alternatively the data can also be loaded from a file, just
149       provide the filename or filehandle (modern in SCALAR or old school).
150       Read more about the file format at "add_datafile" and note that this
151       method has another option for loading transposed data tables.
152
153   scalar_jpeg
154       Creates same JPEG image as "jpeg" but returns the image binary into a
155       variable, not to STDOUT or a file.
156
157           my $image_binary = $graph->scalar_jpeg();
158           my $image_binary = $graph->scalar_jpeg( $data );
159
160   scalar_png
161       Creates same PNG image as "png" but returns the image binary into a
162       variable, not to STDOUT or a file.
163
164           my $image_binary = $graph->scalar_png();
165           my $image_binary = $graph->scalar_png( $data );
166
167   set
168       Method to change one or more chart properties in hash form.
169
170         $chart->set ( property_name => 'new value', ... );
171         $chart->set ( %properties );
172
173       Different chart types react to different properties, which are all
174       listed and explained under Chart::Manual::Properties.
175
177       Copyright 2022 Herbert Breunung.
178
179       This program is free software; you can redistribute it and/or modify it
180       under same terms as Perl itself.
181

AUTHOR

183       Herbert Breunung, <lichtkind@cpan.org>
184
185
186
187perl v5.38.0                      2023-07-20         Chart::Manual::Methods(3)
Impressum