1Chart::Manual::WorkflowUss(e3r)Contributed Perl DocumentCahtairotn::Manual::Workflows(3)
2
3
4
6 Chart::Manual::Workflows - different ways to create charts
7
9 Four of the five major steps in creating a chart image are fixed in
10 their order. First you have to load the module, secondly create create
11 the object. After that you
12 may change some properties. And always as a last step you create the
13 image, no matter if the output goes to STDOUT or into a file.
14
15 The only flexibility lies in how you prefer to provide the data. And
16 here you have three options. Most commonly you add one data set at the
17 time, which could be also understood as a row of the complete data
18 table. Second option is to build the table column by column. Thirdly
19 you can drop the complete table at once, either by reference to a data
20 structure or a file containing the data. The last option is closed if
21 you already given the object data. It is not advisable to reuse a
22 chart object for further image creation outside of modern art projects.
23
25 Most steps are already explained elsewhere and the OVERVIEW just links
26 there. The missing bits are layed out here.
27
28 use Chart
29 As with any other Modul you have to:
30
31 use Chart::[Type];
32
33 Type being a placeholder for a name of a chart type, which are: Bars,
34 Composite, Direction, ErrorBars, HorizontalBars, Lines, LinesPoints,
35 Mountain, Pareto, Pie, Points, Split, StackedBars. To know more about
36 them read Chart::Manual::Types.
37
38 Alternatively write to load all chart types at ones with
39
40 use Chart;
41
42 Both are not importing any symbols in your name space but load Carp and
43 GD.
44
45 drop data
46 All the methods listed in the last section, that create the final
47 image, take as an optional, second argument data. This data may be
48 delivered either as a reference to an array of arrays:
49
50 my $data = [ [ 1, 4, 3 ... ], # data set 0
51 [ 5, 8, 2 ... ], # data set 1
52 ...
53 ];
54 $graph->png( 'file.png', $data );
55
56 or in form of a file. Then the argument has to be a file name or a file
57 handle (old school as in "FILE" or modern as in $FH). Alternatively
58 use the method add_datafile.
59
60 data files
61 Are arbitrary named text files containing one or several rows of
62 numbers, which have to be separated by spaces or tabs (\t) (mixing
63 allowed). Perl style comments or empty lines will be ignored, but rows
64 containing different amount of numbers will cause problems.
65
66 create image
67 Currently we support only images in the PNG and JPEG format. The
68 methods to create them are named straight forwardly: ->png and ->jpeg.
69 Both take the same arguments and produce image files. For shell
70 scripting or web programming you need the image binary, which you get
71 with: ->cgi_png or ->cgi_jpeg. Some users might even want the GD object
72 for further processing by your perl programm. In that case please use:
73 ->scalar_png or ->scalar_jpeg.
74
75 After having created a chart for web purposes, you also might want to
76 utilize imagemap_dump.
77
79 Copyright 2022 Herbert Breunung.
80
81 This program is free software; you can redistribute it and/or modify it
82 under same terms as Perl itself.
83
85 Herbert Breunung, <lichtkind@cpan.org>
86
87
88
89perl v5.36.0 2022-08-01 Chart::Manual::Workflows(3)