App-Basis-ConvertText2
view release on metacpan or search on metacpan
Sparklines are simple horizontal charts to give an indication of things, sometimes they are barcharts but we have nice smooth lines.
The only valid contents of the code-block is a single line of comma separated numbers.
The full set of optional arguments is
* title
* used as the generated images 'alt' argument
* bgcolor
* background color in hex (123456) or transparent
* line
* color or the line, in hex (abcdef)
* color
* area under the line, in hex (abcdef)
* scheme
* color scheme, only things in red blue green orange mono are valid
* size
* size of image, default 80x20, widthxheight
**Example**
## Gle / glx
This is a complex graph/chart drawing package available from http://glx.sourceforge.net/
The full set of optional arguments is
* title
* used as the generated images 'alt' argument
* size
* size of image, default 720x540, widthxheight, size is approximate
* transparent
* flag to use a transparent background
**Example**
~~~~{.gle}
set font texcmr hei 0.5 just tc
begin letz
data "saddle.z"
z = 3/2*(cos(3/5*(y-1))+5/4)/(1+(((x-4)/3)^2))
docs/README.html view on Meta::CPAN
<p>Sparklines are simple horizontal charts to give an indication of things, sometimes they are barcharts but we have nice smooth lines.</p>
<p>The only valid contents of the code-block is a single line of comma separated numbers.</p>
<p>The full set of optional arguments is</p>
<ul>
<li>title
<ul>
<li>used as the generated images âaltâ argument</li>
</ul></li>
<li>bgcolor
<ul>
<li>background color in hex (123456) or transparent</li>
</ul></li>
<li>line
<ul>
<li>color or the line, in hex (abcdef)</li>
</ul></li>
<li>color
<ul>
<li>area under the line, in hex (abcdef)</li>
</ul></li>
<li>scheme
docs/README.html view on Meta::CPAN
<p>The full set of optional arguments is</p>
<ul>
<li>title
<ul>
<li>used as the generated images âaltâ argument</li>
</ul></li>
<li>size
<ul>
<li>size of image, default 720x540, widthxheight, size is approximate</li>
</ul></li>
<li>transparent
<ul>
<li>flag to use a transparent background</li>
</ul></li>
</ul>
<p><strong>Example</strong></p>
<pre><code>~~~~{.gle}
set font texcmr hei 0.5 just tc
begin letz
data "saddle.z"
z = 3/2*(cos(3/5*(y-1))+5/4)/(1+(((x-4)/3)^2))
lib/App/Basis/ConvertText2/Plugin/Gle.pm view on Meta::CPAN
create a simple gle image
parameters
data - gle text
filename - filename to save the created image as
hashref params of
title - title to use for image alt attribute
size - size of image, widthxheight - optional, default 720x512
transparent - flag to set background transparent - optional
=cut
sub process {
my $self = shift;
my ( $tag, $content, $params, $cachedir ) = @_;
$params->{size} ||= "720x512";
my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );
# strip any ending linefeed
lib/App/Basis/ConvertText2/Plugin/Gle.pm view on Meta::CPAN
my $filename = cachefile( $cachedir, "$sig.png" );
if ( !-f $filename ) {
my $glefile = Path::Tiny->tempfile("gleXXXXXXXX");
my $res = sprintf( "size %.4f %.4f", $x / RES, $y / RES) ;
$content =~ s/size\s+(.*?)\s+(.*?)$//gsm ;
$content = "$res\n$content" ;
path($glefile)->spew_utf8($content);
my $cmd = GLE . ( $params->{transparent} ? " -transparent" : "" ) . " -output $filename $glefile";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if ($exit) {
warn "Could not run script " . GLE . " get it from http://glx.sourceforge.net/";
}
}
my $out;
if ( -f $filename ) {
# create something suitable for the HTML
$out = create_img_src( $filename, $params->{title} );
lib/App/Basis/ConvertText2/Plugin/Sparkline.pm view on Meta::CPAN
has handles => (
is => 'ro',
init_arg => undef,
default => sub {[qw{sparkline}]}
);
# -----------------------------------------------------------------------------
my %_colour_schemes = (
orange => { b => 'transparent', a => 'ffcc66', l => 'ff6000' },
blue => { b => 'transparent', a => 'ccffff', l => '3399cc' },
red => { b => 'transparent', a => 'ccaaaa', l => '990000' },
green => { b => 'transparent', a => '99ff99', l => '006600' },
mono => { b => 'ffffff', a => 'ffffff', l => '000000' }
);
# -----------------------------------------------------------------------------
=item color_schemes
return a list of the color schemes available
=cut
lib/App/Basis/ConvertText2/Plugin/Sparkline.pm view on Meta::CPAN
=item process (sparkline)
create a simple sparkline image, with some nice defaults
parameters
text - comma separated list of integers for the sparkline
filename - filename to save the created sparkline image as
hashref params of
bgcolor - background color in hex (123456) or transparent - optional
line - color or the line, in hex (abcdef) - optional
color - area under the line, in hex (abcdef) - optional
scheme - color scheme, only things in red blue green orange mono are valid - optional
size - size of image, default 80x20, widthxheight - optional
=cut
sub process {
my $self = shift;
my ( $tag, $content, $params, $cachedir ) = @_;
lib/App/Basis/ConvertText2/Plugin/Sparkline.pm view on Meta::CPAN
$scheme = lc $scheme;
if ( !$_colour_schemes{$scheme} ) {
warn "Unknown color scheme $params->{scheme}";
$scheme = ( sort keys %_colour_schemes )[0];
}
$b = $_colour_schemes{ $params->{scheme} }{b}; # background color
$a = $_colour_schemes{ $params->{scheme} }{a}; # area under line color
$l = $_colour_schemes{ $params->{scheme} }{l}; # top line color
}
else {
$b ||= 'transparent';
$a = 'cccccc';
$l = '333333';
}
my $args = { b => $b, a => $a, l => $l, s => $content, w => $w, h => $h };
my $spark = GD::Sparkline->new($args);
if ($spark) {
my $png = $spark->draw();
if ($png) {
path($filename)->spew_raw($png) ;
( run in 0.385 second using v1.01-cache-2.11-cpan-0a6323c29d9 )