Chart::...rkflows(3)

πŸ’– Chart::...rkflows(3) β€” NAME πŸ’–

So you wanna know the different ways to create charts? Bestie, you came to the right page. This is Chart::...rkflows(3), fresh out of the User Contributed Perl Documentation collection, and it's literally all about the workflows, iykyk.


✨ OVERVIEW ✨

Okay so picture this: making a chart image is five major steps, and four of them are locked in order, no negotiating. 🫢

  1. First you load the module.
  2. Secondly you create the object.
  3. After that you may change some properties.
  4. And always, as the last step, you create the image β€” no matter if the output goes to STDOUT or into a file.

The only actual flexibility? It's in how you prefer to provide the data. And here you have three options, bestie:

  • Most commonly you add one data set at the time, which could also be understood as a row of the complete data table.
  • Second option is to build the table column by column.
  • Thirdly you can drop the complete table at once, either by reference to a data structure or a file containing the data.
Heads up though ⚠️ the last option is closed if you already gave the object data. And it is not advisable to reuse a chart object for further image creation outside of modern art projects. Like, unless your vibe is gallery-core, don't. πŸ’€

🌸 STEPS 🌸

Most steps are already explained elsewhere and the OVERVIEW just links there. The missing bits are laid out right here, so stay with me. πŸ’…

πŸŽ€ use Chart

As with any other Modul you have to:

use Chart::[Type];

Type is a placeholder for a name of a chart type, and the chart types are: Bars, Composite, Direction, ErrorBars, HorizontalBars, Lines, LinesPoints, Mountain, Pareto, Pie, Points, Split, StackedBars. To know more about them read Chart::Manual::Types. πŸ‘‘

Alternatively write this to load all chart types at once:

use Chart;

Both are not importing any symbols in your namespace, but they do load Carp and GD. Slay. ✨

πŸ¦‹ drop data

All the methods listed in the last section that create the final image take as an optional, second argument data. This data may be delivered either as a reference to an array of arrays:

my $data = [ [ 1, 4, 3 ... ], # data set 0
             [ 5, 8, 2 ... ], # data set 1
             ...
];
$graph->png( 'file.png', $data );

...or in form of a file. Then the argument has to be a file name or a file handle (old school as in "FILE" or modern as in $FH). Alternatively use the method add_datafile. Main character energy, honestly. πŸ’œ

πŸ“ data files

These are arbitrary named text files containing one or several rows of numbers, which have to be separated by spaces or tabs (\t) β€” mixing allowed, we're not judgy. 🧚

Perl style comments or empty lines will be ignored, but rows containing different amount of numbers will cause problems. Not cute, not iconic, just problems. 😭

🌈 create image

Currently we support only images in the PNG and JPEG format. The methods to create them are named straight forwardly: ->png and ->jpeg. Both take the same arguments and produce image files. 🎨

For shell scripting or web programming you need the image binary, which you get with: ->cgi_png or ->cgi_jpeg.

Some users might even want the GD object for further processing by your perl programm. In that case please use: ->scalar_png or ->scalar_jpeg.

After having created a chart for web purposes, you also might want to utilize imagemap_dump. Obsessed, fr fr. πŸ”₯


Copyright 2022 Herbert Breunung.

This program is free software; you can redistribute it and/or modify it under same terms as Perl itself.


πŸ’… AUTHOR πŸ’…

Herbert Breunung, <lichtkind@cpan.org>


Okay that's the whole page, bestie β€” no cap, every last detail accounted for. 🫢 This gem ships with perl v5.42.0, dated 2022-11-29, and it is literally Chart::...rkflows(3) from the User Contributed Perl Documentation. Periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from