Chart-Graph
view release on metacpan or search on metacpan
Graph/Xrt2d.pm view on Meta::CPAN
}
if ($key eq "footer") {
if(defined($value)) {
$footer = $value;
}
}
if ($key eq "misc labels") {
if(defined($value)) {
$misc_labels = $value;
}
}
if ($key eq "set labels") {
if(defined($value)) {
$set_labels = $value;
}
}
if ($key eq "point labels") {
if(defined($value)) {
$point_labels = $value;
}
}
if ($key eq "invert") {
if(defined($value) and $value) {
$xrt_options .= " -xrm '*xrtInvertOrientation: True'";
}
}
if ($key eq "x time") {
if(defined($value) and $value) {
$xrt_options .= " -xrm '*xrtXAnnotationMethod: ANNOTIMELABELS'";
$x_timestamps = 1;
}
}
if ($key eq "style") {
if(defined($value)) {
if ($value eq "stackedbar") {
$xrt_options .= " -xrm '*xrtType: TYPESTACKINGBAR'";
} elsif ($value eq "bar") {
$xrt_options .= " -xrm '*xrtType: TYPEBAR'";
} elsif ($value eq "pie") {
$xrt_options .= " -xrm '*xrtType: TYPEPIE'";
} elsif ($value eq "area") {
$xrt_options .= " -xrm '*xrtType: TYPEAREA'";
} elsif ($value eq "stackedarea") {
$xrt_options .= " -xrm '*xrtLegendReversed: True'";
$xrt_options .= " -xrm '*xrtType: TYPEAREA'" .
" -xrm '*xrtIsStacked: True'";
} else {
carp "No graph type defined, defaulting to bar";
$xrt_options .= " -xrm '*xrtType: TYPEBAR'";
}
}
}
}
# Only reverse legend if NOT inverting bars.
if (not $global_opts{"invert"} and $global_opts{"style"} eq "stackedbar") {
$xrt_options .= " -xrm '*xrtLegendReversed: True'";
}
# get the number of columns and number of rows
$x_cnt = @{$point_labels};
$y_cnt = @{$set_labels};
# because xrt allows multiline headers
# get the length of the header array
# each line of the header is one index
# in the array
$hdr_cnt = $#{$header} + 1;
$ftr_cnt = $#{$footer} + 1;
$label_cnt = $#{$misc_labels} + 1;
my @colors;
my @all_data;
foreach $data_set_ref (@data_sets) {
if (ref($data_set_ref) ne "ARRAY") {
carp "Data set must be an array";
_cleanup_tmpdir();
return 0;
}
my ($user_data_opts_ref, $data_ref) = @$data_set_ref;
my (%data_opts);
## check first arg for hash
if (ref($user_data_opts_ref) ne "HASH") {
carp "Data options must be a hash.";
_cleanup_tmpdir();
return 0;
}
push @all_data, $data_ref;
# call to combine user options with default options
%data_opts = _mesh_opts($user_data_opts_ref, \%def_xrt_data_opts);
# write data options to command file
while (my ($key, $value) = each %data_opts) {
if ($key eq "color") {
if (defined $value) {
push @colors, $value;
}
}
}
}
if (@colors) {
my $resource_string;
foreach my $color (@colors) {
$resource_string .=
"(LpatSolid FpatSolid \"$color\" 1 PointNone \"$color\" 7)";
}
$xrt_options .= " -xrm '*xrtDataStyles: ($resource_string)'";
}
##
## print command file using this format (for bar graphs)
( run in 0.796 second using v1.01-cache-2.11-cpan-39bf76dae61 )