App-Widget-ChartDirector
view release on metacpan or search on metacpan
lib/App/Widget/ChartDirector.pm view on Meta::CPAN
$height += (($margin + $textsize) * $number_legend_rows) + (4 * $margin);
} while ($height > (2 * $spec->{height})); # Max. graph height should not be greater than twice of chosen graph height
if ($#{$spec->{y_labels}} <= 0) {
$height = $spec->{height};
}
}
my $graph_height_increment = 0;
my $fontsize = 10;
if ($spec->{x_label_pos}) {
if ($#$x > 30 && $total_x_length > $width/8 && $x->[0] !~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
for (my $i = 30; $i <= $#$x; $i++ ) {
$fontsize = $fontsize - 0.1;
$fontsize = 1 if ($fontsize < 1);
}
$fontsize += ceil(($width - $spec->{width})/$#$x) - 1 if ($#$x > 50);
}
$self->{fontsize} = $fontsize;
if ($total_x_length > $width/8 && $x->[0] !~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) {
$graph_height_increment = 1/2 * $x_values[-1] * floor ($fontsize);
$height += $graph_height_increment;
}
}
my $c = new XYChart($width, $height);
my $graph_adjusted_height = $height - $spec->{height}-$graph_height_increment;
my ($top_margin_adjusted,$bottom_margin_adjusted);
if ($legend_pos eq "top" ) {
lib/App/Widget/ChartDirector.pm view on Meta::CPAN
foreach my $xlabel (@$x) {
if ($xlabel =~ /^-/) {
$xlabel = '\\' . $xlabel;
}
}
$chart->xAxis()->setLabels($x);
if ($spec->{x_label_pos}) {
$chart->xAxis()->setLabels($x)->setFontAngle(45) if ( $self->{total_x_length} > $self->{width}/8 );
$chart->xAxis()->setLabels($x)->setFontSize($self->{fontsize}, 0) if ($#$x > 30);
}
}
}
}
if ($spec->{graphtype} ne "pie" && $spec->{graphtype} ne "meter") {
my $x_titlecolor = $self->get_theme_value("x_titlecolor", "0xfffcf0");
$chart->xAxis()->setTitle($x_title, "arial.ttf", 10, hex($x_titlecolor)) if ($x_title);
}
}
lib/App/Widget/ChartDirector.pm view on Meta::CPAN
#Set 0 - 60 as green (66FF66) zone
$c->addZone(0, $y_yellow, 0, $radius, 0x66ff66);
#Set 60 - 80 as yellow (FFFF33) zone
$c->addZone($y_yellow, $y_red, 0, $radius, 0xffff33);
#Set 80 - 100 as red (FF6666) zone
$c->addZone($y_red, $y_max, 0, $radius, 0xff6666);
#Add a text label centered at (100, 60) with 12 pts Arial Bold font
if ($spec->{y_title}) {
$c->addText($center_x, $center_y-int($radius * 0.35), $spec->{y_title},
"arialbd.ttf", 11, $perlchartdir::TextColor, $perlchartdir::Center);
}
my $x_title = "";
$x_title = $spec->{x_title} if ($spec->{x_title});
if ($x) {
$x_title .= ": " if ($x_title);
$x_title .= $x->[0];
lib/App/Widget/ChartDirector.pm view on Meta::CPAN
#Create a XYChart object of size 500 x 270 pixels, with a pale blue (0xe0e0ff)
#background, a light blue (0xccccff) border, and 1 pixel 3D border effect.
my $c = new XYChart(600, 350, 0xe0e0ff, 0xccccff, 1); #800
#Set the plotarea at (50, 50) and of size 420 x 180 pixels, using white
#(0xffffff) as the plot area background color. Turn on both horizontal and
#vertical grid lines with light grey color (0xc0c0c0)
$c->setPlotArea(50, 50, 320, 260, 0xffffff)->setGridColor(0xc0c0c0, 0xc0c0c0); #720
#Add a legend box at (55, 25) (top of the chart) with horizontal layout. Use 10
#pts Arial Bold Italic font. Set the background and border color to Transparent.
$c->addLegend(55, 20, 0, "arialbi.ttf", 10)->setBackground($perlchartdir::Transparent);
#Add a title to the chart using 14 points Times Bold Itatic font, using blue
#(0x9999ff) as the background color
$c->addTitle("Rate History", "arialbi.ttf", 12)->setBackground(0x9999ff);
#Set the y axis label format to display a percentage sign
#$c->yAxis()->setLabelFormat("{value}%");
my $labels = $spec->{labels} || [ "Unknown" ];
my $default_colors =
[ 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff00,
0x111199, 0x119911, 0x991111, 0x119999, 0x991199, 0x999911,
( run in 1.916 second using v1.01-cache-2.11-cpan-ceb78f64989 )