HTML::TagCloud::Centred - Biggest tags in the centre
use HTML::TagCloud::Centred; my $cloud = HTML::TagCloud::Centred->new( # size_min_pc => 50, # size_max_pc => 200, # scale_code => sub { ... }, # html_esc_code => sub { ... }, # clr_max => '#FF0000', # clr_min => '#550000', ); $cloud->add( 'FirstWord', 'http://www.google.co.uk' ); foreach my $w ( ('Biggest')x7, ('Medium')x5, ('Small')x5, ('Smallest')x10 ){ $cloud->add( $w ); } open my $OUT, '>cloud.html'; # print $OUT $cloud->css; # print $OUT $cloud->html; print $OUT $cloud->html_and_css; close $OUT; warn 'Tags: ',Dumper $cloud->tags; exit;
This modules produces a tag cloud with the heaviest words in the centre, and the lightest on the outside, to make it appear a bit like the clouds seen in the sky.
Words are accepted through add in a sorted order - that is, add the heaviest word first, the lightest last. When the html or css_and_html methods are called, the words are added to a grid in a simple spiral: this may change to produce a prettier cloud, but it works well enough as it is.
html
css_and_html
Otherwise, it is API-compatible with HTML::TagCloud, though that module is not required. For further details of this modules methods, please see HTML::TagCloud.
Output is HTML and/or CSS. The HTML contains a div of class tagcloud, that contains one or more div of class row. Each row contains a elements for each linked word. If words were supplied without links, they are contained in span elements.
div
tagcloud
row
a
span
Colouring and font-sizing is contained in the a and span style attributes. The base size can of course be set in your CSS, since all sizing is by percentage relevant to the parent container. The CSS supplied is minimal, just to centre the rows.
style
Takes the following optional parameters:
The maximum font size of the output, as a CSS percentage value. Default is 120.
The minimum font size of the output, as a CSS percentgage value. Default is half of size_max_pc.
size_max_pc
Code reference to calculate the scaling of items in the cloud. Defaults to something reasonable, but could be used to implement logarithmic or exponential scaling. The routine gets called as an instance method. Note that the words added to create the cloud are stored as a list in words.
words
Code referene to escape HTML in the output (text within the cloud and in a element title attributes). Default is to require CGI::Util, and call CGI::Util::escape. The sole argument is the word to escape.
title
CGI::Util
CGI::Util::escape
You can supply these as arguments for Color::Spectrum, if you have it installed. See Color::Spectrum. By defaul these values are not set.
HTML::TagCloud.
Copyright (C) Lee Goddard, 2010-2011. All Rights Reserved.
This distribution is made available under the same terms as Perl.
To install HTML::TagCloud::Centred::Base, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::TagCloud::Centred::Base
CPAN shell
perl -MCPAN -e shell install HTML::TagCloud::Centred::Base
For more information on module installation, please visit the detailed CPAN module installation guide.