Chart::Clicker(3pm)
๐ Chart::Clicker ๐
okay bestie, sit DOWN, because this is the manpage for Chart::Clicker(3pm) โ a.k.a. User Contributed Perl Documentation, a.k.a. the charting module that makes your data look absolutely iconic. no cap.
โจ NAME โจ
Chart::Clicker โ powerful, extensible charting. that's it, that's the whole vibe. ๐ฆ
๐ธ VERSION ๐ธ
version 2.90 โ she's grown, she's thriving, she's serving. ๐
๐ SYNOPSIS ๐
here's the tea, the whole thing, copy-paste-able and adorable:
use Chart::Clicker;
my $cc = Chart::Clicker->new;
my @values = (42, 25, 86, 23, 2, 19, 103, 12, 54, 9);
$cc->add_data('Sales', \@values);
# alternately, you can add data one bit at a time...
foreach my $v (@values) {
$cc->add_data('Sales', $v);
}
# Or, if you want to specify the keys you can use a hashref
my $data = { 12 => 123, 13 => 341, 14 => 1241 };
$cc->add_data('Sales', $data);
$cc->write_output('foo.png');
like. look at that. a whole chart in like nine lines. main character energy fr fr. ๐
๐ DESCRIPTION ๐
Chart::Clicker wants to be a powerful, extensible charting package that makes genuinely, actually pretty output. like, output you'd show people. output you'd put on a slide and not apologize for. โจ
Charts can be saved as png, svg, pdf and postscript. yes all of them. she contains multitudes. ๐
Clicker flexes the power of Graphics::Primitive to make snazzy graphics without being tied to any specific backend โ so she can switch it up whenever. and if you're new here, bestie, you probs wanna start with Chart::Clicker::Tutorial. that's the beginner-friendly doorway, walk through it. ๐ช๐ฆ
๐ EXAMPLES ๐
for actual code examples, go look at the examples repository on GitHub:
http://github.com/gphat/chart-clicker-examples/
real code, real charts, real inspiration. go consume. ๐
๐ FEATURES ๐
๐๏ธ Renderers
Clicker supports all of these renderers, and honestly? the range. she's got range:
LineStackedLineBarStackedBarAreaStackedAreaBubbleCandleStickPointPiePolarArea
pick your fighter. ๐
๐ ADDING DATA ๐
the synopsis up there shows you the simple way to add data:
my @values = (42, 25, 86, 23, 2, 19, 103, 12, 54, 9);
foreach my $v (@values) {
$cc->add_data('Sales', $v);
}
this is a convenience method, provided specifically so the simple cases stay simple (as they should). and adding multiple Series to a chart? literally just change the name argument of add_data. every unique first argument becomes its own separate series. it's giving effortless. if you want the full lore, see the docs for add_data.
BUT. if you wanna use the more advanced features of Clicker, you gotta shake off the simple method and build your Series & DataSets explicitly:
use Chart::Clicker::Data::Series;
use Chart::Clicker::Data::DataSet;
...
my $series = Chart::Clicker::Data::Series->new(
keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
values => [ 42, 25, 86, 23, 2, 19, 103, 12, 54, 9 ],
);
my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]);
$cc->add_to_datasets($ds);
fun fact: this used to be the only way to add data. then everybody kept asking for the common case to be easier, and that's how add_data was born. the people spoke, Clicker listened. ๐ซถ
๐ง CONTEXTS ๐ง
so normally you've got a couple datasets chillin' on the same axes. that's the standard use case. but sometimes you wanna chart one or more datasets on different axes. the classic reason? comparing two datasets of vastly different scale. like, number of employees in an office (1-10) vs. monthly revenues (10s of thousands). on a normal chart, the employee count would show up as a sad little flat line squished at the bottom. tragic. ๐ญ
to fix that, Clicker has contexts. a context is a pair of axes, a renderer, and a name. and the name is the 'key' you use to refer to that context.
my $context = Chart::Clicker::Context->new( name => 'sales' );
$clicker->add_to_contexts($context);
$dataset->context('sales');
$clicker->add_to_datasets($dataset);
new contexts get a fresh domain and range axis, and they default to a Line renderer. slay. โจ
โ ๏ธ Caveat, and this one matters: Clicker expects the default context โ the one identified by the stringdefaultโ to always be present. some of Clicker's internals pull their values straight from that context. so use the default context unless you genuinely need more than one. and if you do need more than one? usedefaultas your base context. don't skip her, she's the foundation. ๐
๐ผ๏ธ FORMATS & OUTPUT ๐ผ๏ธ
Clicker supports PNG, SVG, PDF and PostScript output. to change your output type, specify it when you create your Clicker object:
my $cc = Chart::Clicker->new(format => 'pdf', ...);
# ...
$cc->write_output('chart.pdf');
and if you're trying to get a scalar of the output for HTTP or similar shenanigans, you can do this:
# ... make your chart
$cc->draw;
my $image_data = $cc->rendered_data;
and hey โ if you happen to be using Catalyst, go peek at Catalyst::View::Graphics::Primitive. they already did the work, bestie. ๐ธ
๐ ATTRIBUTES ๐
๐จ background_color
Set/Get the background color. defaults to white.
๐๏ธ border
Set/Get the border.
๐ color_allocator
Set/Get the color_allocator for this chart.
๐๏ธ contexts
Set/Get the contexts for this chart.
๐ datasets
Get/Set the datasets for this chart.
๐ driver
Set/Get the driver used to render this Chart. defaults to Graphics::Primitive::Driver::Cairo.
๐ผ format
Get the format for this Chart. Required in the constructor. Must be one of Png, Pdf, Ps or Svg.
๐ plot_mode
Fast or slow plot mode. when in fast mode, data elements that are deemed superfluous or invisible just. don't get drawn. skipped. ghosted. default is 'slow'.
๐ grid_over
Flag controlling whether the grid is rendered over the data. defaults to 0. pro tip: you probably wanna set the grid's background color to an alpha of 0 if you turn this on.
๐ height
Set/Get the height. defaults to 300.
๐งฉ layout_manager
Set/Get the layout manager. defaults to Layout::Manager::Compass.
๐บ๏ธ legend
Set/Get the legend that will be used with this chart.
๐งญ legend_position
The position the legend will be added. should be one of north, south, east, west or center, as required by Layout::Manager::Compass.
๐ marker_overlay
Set/Get the marker overlay object that'll be used if this chart has markers. this one is lazily constructed, to save time. she shows up when she's needed. ๐
๐ over_decorations
Set/Get an arrayref of "over decorations" โ i.e. things that get drawn OVER the chart. this is an advanced feature. see overaxis-bar.pl in the examples.
๐๏ธ padding
Set/Get the padding. defaults to 3px on all sides. give her some room to breathe.
๐ฌ plot
Set/Get the plot on which things are drawn.
๐ณ subgraphs
you can add "child" graphs to this one via add_subgraph. they must be Chart::Clicker objects, and they get added to the bottom of the existing chart. this is a rather esoteric feature. iykyk. ๐
๐ท๏ธ title
Set/Get the title component for this chart. Important: this is a Graphics::Primitive::TextBox, NOT a string. so to set the title of a chart you access the TextBox's text method:
$cc->title->text('A Title!');
$cc->title->font->size(20);
# etc, etc
if the title has text, then it gets added to the chart at the position specified by title_position.
you should consult the documentation for Graphics::Primitive::TextBox for stuff like padding and text rotation. and if you're adding it to the top and you want some padding between it and the plot, you can:
$cc->title->padding->bottom(5);
๐งญ title_position
The position the title will be added. should be one of north, south, east, west or center, as required by Layout::Manager::Compass.
๐ Heads up: if no angle is set for the title, then it will be changed to-1.5707if the title position iseastorwest. yes, automatically. she rotates herself. iconic.
๐ width
Set/Get the width. defaults to 500.
๐ ๏ธ METHODS ๐ ๏ธ
๐ข context_count
Get a count of contexts.
๐ context_names
Get a list of context names.
๐๏ธ delete_context ($name)
Remove the context with the specified name. bye bestie. ๐
๐ get_context ($name)
Get the context with the specified name.
๐พ set_context ($name, $context)
Set a context of the specified name.
๐ฆ add_to_datasets
Add the specified dataset (or arrayref of datasets) to the chart.
๐งฎ dataset_count
Get a count of datasets.
๐ฏ get_dataset ($index)
Get the dataset at the specified index.
๐ rendered_data
Returns the data for this chart as a scalar. perfect for 'streaming' to a client. ๐โจ
๐ add_to_over_decorations
Add an over decoration to the list.
๐ get_over_decoration ($index)
Get the over decoration at the specified index.
๐งพ over_decoration_count
Get a count of over decorations.
โ add_to_contexts
Add the specified context to the chart.
๐ฟ add_subgraph
Add a subgraph to this chart.
๐๏ธ draw
Draw this chart. do the thing. โจ
๐๏ธ get_datasets_for_context
Returns an arrayref containing all datasets for the given context. this is what the renderers use to get their list of datasets to chart.
๐ฐ add_data ($name, $data)
Convenience method for adding data to the chart. can be called one of three ways:
๐ scalar
Passing a name and a scalar will append the scalar data to that series' data.
$cc->add_data('Sales', 1234);
$cc->add_data('Sales', 1235);
this will result in a Series named 'Sales' with two values. simple. clean.
๐ arrayref
Passing a name and an arrayref works pretty much the same as the scalar method above, except it appends the supplied arrayref to the existing one. and guess what โ you can mix it with the scalar method. they play nice.
$cc->add_data('Sales', \@some_sales);
$cc->add_data('Sales', \@some_more_sales);
# This works still!
$cc->add_data('Sales', 1234);
๐ hashref
this one lets you pass both keys and values in all at once. a whole little bundle. ๐
$cc->add_data('Sales', { 2009 => 1234, 2010 => 1235 });
# appends to last call
$cc->add_data('Sales', { 2011 => 1234, 2012 => 1235 });
โ ๏ธ you may call the hashref version after the scalar or arrayref versions. but you may not add a scalar or arrayref after adding a hashref โ because it's genuinely not clear what indices should be used for that new data. so order matters, bestie. hashref goes last. ๐
๐ญ set_renderer ($renderer_object, [ $context ])
Sets the renderer on the specified context. if no context is provided, then 'default' is assumed.
โ๏ธ write
This method is passed through to the underlying driver. you only actually need to call this if you manually called draw beforehand. most of the time you want write_output instead. just saying. ๐
๐พ write_output ($path)
Write the chart output to the specified location. output is written in the format provided to the constructor (which defaults to Png). internally, it calls draw for you โ she handles it.
๐จ If you use this method, do NOT call draw first! she's already on it. doubling up is not the move.
$c->write_output('/path/to/the.png');
๐ inside_width
Get the width available in this container after taking away space for insets and borders.
๐ inside_height
Get the height available in this container after taking away space for insets and borders.
๐ ISSUES WITH CENTOS ๐
there have been numerous reports of problems with Chart::Clicker when using CentOS. and the fix has usually been updating the version of cairo. reports say upgrading to at least cairo-1.8.8-3 makes things actually work properly. ๐ ๏ธ
the author hesitates to provide any other data here, because it may get out of date fast. so if you have trouble, feel free to drop an email and they'll tell you what they know.
๐ CONTRIBUTORS ๐
many thanks to the individuals who contributed various bits โ legends, all of them:
- Ash Berlin
- Brian Cassidy
- Guillermo Roditi
- Torsten Schoenfeld
- Yuval Kogman
๐ SOURCE ๐
Chart::Clicker is on github:
http://github.com/gphat/chart-clicker/tree/master
โ๏ธ AUTHOR โ๏ธ
Cory G Watson <gphat@cpan.org>
๐ okay wait โ this is only part 1 of 2. do not close the tab. there is more. stay tuned, bestie. ๐ฆ๐
--- ๐ธ ---
๐ COPYRIGHT AND LICENSE ๐
okay bestie this is the part where we give credit where credit is due, and the credit goes to Cory G Watson fr fr:
This software is copyright (c) 2016 by Cory G Watson.
and the legal tea, served fresh โ:
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
so yeah โ you can redistribute it, you can modify it, it's giving very much open-source royalty behavior ๐, just keep it on the same terms as perl itself. no cap, that's the whole vibe. slay ๐
๐ and that's a wrap on Chart::Clicker(3pm), bestie!! this little icon of a manpage rode in on perl v5.36.0, dated 2022-10-14, and it ate every single time โจ๐ฆ go forth and make the prettiest charts, you absolute main character ๐๐๐ง
k bye love u, go plot something gorgeous ๐
๐ฆ where this page comes from
- ubuntu noble: libchart-clicker-perl 2.90-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libchart-clicker-perl 2.90-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libchart-clicker-perl 2.90-3 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms