Image-BoxModel
view release on metacpan or search on metacpan
0.15 Mit Jul 29 2009
- ::Chart has point and line charts, bug fixes
0.14 Son Jul 26 2009
- debug, ::Chart has points
0.13 Fre Aug 1 2008
- Chart: many bugs fixed, does bars and points now
0.12 Son Jun 1 2008
- Chart: improved, has legend; IM-image-size bug fixed
0.11 Mit Apr 30 2008
- color support for GD, pod improved
0.10 Die Apr 15 2008
- add ChartBars (naked), add Chart (incomplete)
0.09 Fre Apr 11 2008
- remove .svn from tar.gz
examples/20_chart_bars.pl view on Meta::CPAN
);
# print subtitle
$image -> Annotate (
text => 'version of Image::BoxModel::Chart',
textsize => 15,
box_position => "bottom",
font => './FreeSans.ttf'
);
# draw the legend
$image -> Legend(
font => './FreeSans.ttf',
textsize => 15,
name => 'legend',
values_annotations => ['Marc','Joss','Joe','Kim','Frederic','X','y',"other\nfriends"],
border => 1,
padding_top => 0,
position => 'right', #left | right only at the moment. bug.
);
# define some arrays
my @a = [7,7,7];
my @val_ann = ['0.01', '0.04', '0.09', '0.10', '0.11', "(future)\nstable\nrelease"];
lib/Image/BoxModel/Chart.pm view on Meta::CPAN
);
}
}
}
=head3 Legend
$image -> Legend(
#mandatory:
font => (path to font file),
name => (name of box in which the legend lives)
values_annotations => (name of your datasets)
#optional (dafaults preset):
textsize => [number],
rotate => [number],
colors => (color names of datasets), #nice: 'colors => DefaultColors()' sets default colors
position => ['right'|'left],
orientation => 'vertical', #horizontal is unimplemented so far
resize => (name of box to be resized),
background => (color),
lib/Image/BoxModel/Chart.pm view on Meta::CPAN
orientation => $p{orientation},
values_ref => $p{values_ref},
textsize => $p{textsize},
rotate => $p{rotate},
font => $p{font},
no_box => 1
);
#~ print "Width: $w, height: $h\n";
#idea: have a big box into which the smaller boxes for legend etc go.
$image -> Box (
name => "$p{name}",
width => $p{padding_left} + $p{border} + $p{spacing_left} + $square_size + $p{spacing_left} + $w + $p{spacing_right} + $p{border} + $p{padding_right}+6,
height => $p{padding_top} + $p{border} + $p{spacing_top} + $h + $p{spacing_bottom} + $p{border} + $p{padding_bottom}+4,
position => $p{position},
resize => $p{resize},
);
#~ print "Top: $image->{$p{name}}{top}, bottom: $image->{$p{name}}{bottom}\n";
lib/Image/BoxModel/Chart.pm view on Meta::CPAN
height => $p{"spacing_$_"} + $p{border},
name => "$p{name}_spacing_$_",
position=> "$_",
);
}
$image -> ArrayBox ( #reserve space for the text
resize => $p{name},
name => "$p{name}_text",
background => $p{background},
position => 'right', # Text is *always" right of little squares, wherever the legend is put.
orientation => $p{orientation},
values_ref => $p{values_ref},
textsize => $p{textsize},
rotate => $p{rotate},
font => $p{font},
);
$image -> Box( #some spacing between text & squares
resize => $p{name},
name => "$p{name}_spacing_text_squares",
lib/Image/BoxModel/Chart.pm view on Meta::CPAN
$image -> Box( #box for squares
resize => $p{name},
name => "$p{name}_squares",
width => $square_size,
height => $square_size,
position => $p{position},
);
$image -> DrawRectangle( #a rectangle as border of the legend
top => $image ->{"$p{name}_spacing_top"}{top},
bottom => $image->{"$p{name}_spacing_top"}{top}+ $p{border} * 2 + $h+ $p{spacing_top} + $p{spacing_bottom}, # Calculate space needed.
left => $image->{"$p{name}_spacing_left"}{left},
right => $image->{"$p{name}_spacing_right"}{right},
fill_color => $p{background},
border_color=> $p{border_color},
border_thickness => $p{border}
)if ($p{border});
#~ print $image->{"$p{name}_spacing_top"}{top}, "\t", $p{border} * 2 ,"\t", $h, "\t", $p{spacing_top} ,"\t", $p{spacing_bottom},"\n";
lib/Image/BoxModel/Chart.pm view on Meta::CPAN
foreach (0.. scalar(@{$p{values_ref}})-1){
#~ #print @{$p{colors}}[$_], "\t", @{$p{values_ref}}[$_], "\n";
my ($width, $height) = $image -> GetTextSize(
text => @{$p{values_ref}}[$_],
textsize => $p{textsize},
rotate => $p{rotate},
font => $p{font}
);
#there will be a distinction between vertically and horizontally drawn legends as soon as this is implemented
my $e = $image -> Annotate(
resize =>"$p{name}_text",
text => @{$p{values_ref}}[$_],
textsize => $p{textsize},
rotate => $p{rotate},
align => 'left',
text_position=> 'west',
font => $p{font},
( run in 1.295 second using v1.01-cache-2.11-cpan-49f99fa48dc )