our
$VERSION
=
'0.01'
;
sub
report_occurrence_percentage {
my
(
$field
,
$occhash
) =
@_
;
my
$occ
=
$occhash
->{
$field
};
my
(
@labels
,
@values
);
for
(
sort
{
$occ
->{
$b
} <=>
$occ
->{
$a
} }
keys
%$occ
) {
push
@labels
,
$_
;
push
@values
,
$occ
->{
$_
};
}
my
$graph
= GD::Graph::pie->new(640,480);
my
$img
=
$graph
->plot([\
@labels
,\
@values
]);
my
$filename
= md5_hex(
$occ
);
$self
->save(
$img
,
$filename
,
$graph
->export_format);
}
sub
report_field_group_occurrence_percentage {
print
STDERR
"XXX: Fixme. I don't now how to draw group occurrence into graphs\n"
;
}
sub
save {
my
(
$obj
,
$file
,
$format
) =
@_
;
open
(IMG,
">${file}.${format}"
) or
die
$!;
binmode
IMG;
print
IMG
$obj
->
$format
();
close
IMG;
print
STDERR
"${file}.${format} saved\n"
;
}