Option --colors.
This commit is contained in:
parent
06b3d02fd9
commit
8f8955978d
|
@ -33,7 +33,7 @@ use HTTP::Date qw(parse_date);
|
||||||
use Time::Local qw(timegm_nocheck);
|
use Time::Local qw(timegm_nocheck);
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
our $VERSION = do { my @r=(q$Revision: 1.23 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
our $VERSION = do { my @r=(q$Revision: 1.24 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
|
||||||
|
|
||||||
our $debug;
|
our $debug;
|
||||||
|
|
||||||
|
@ -292,6 +292,21 @@ sub yrange {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=head2 colors(@colors)
|
||||||
|
|
||||||
|
Get or set the color palette.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub colors {
|
||||||
|
my ($self, @colors) = @_;
|
||||||
|
|
||||||
|
if (@colors) {
|
||||||
|
$self->{colors} = [@colors];
|
||||||
|
}
|
||||||
|
return @colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
=head2 dstcorr $time [, $period]
|
=head2 dstcorr $time [, $period]
|
||||||
|
|
||||||
|
@ -399,16 +414,20 @@ sub plot {
|
||||||
my $comma = 0;
|
my $comma = 0;
|
||||||
my $col = 2;
|
my $col = 2;
|
||||||
|
|
||||||
for my $i (@{$self->{legend}}) {
|
for my $i (0 .. $#{$self->{legend}}) {
|
||||||
if ($comma) {
|
if ($comma) {
|
||||||
print $ctlfh ", ";
|
print $ctlfh ", ";
|
||||||
} else {
|
} else {
|
||||||
$comma = 1;
|
$comma = 1;
|
||||||
}
|
}
|
||||||
|
my $legend = $self->{legend}[$i];
|
||||||
if ($self->{style} eq 'filledcurves') {
|
if ($self->{style} eq 'filledcurves') {
|
||||||
print $ctlfh "'$datafn' using 1:(\$", $col++, "):(0) title '$i'";
|
print $ctlfh "'$datafn' using 1:(\$", $col++, "):(0) title '$legend'";
|
||||||
} else {
|
} else {
|
||||||
print $ctlfh "'$datafn' using 1:(\$", $col++, ") title '$i'";
|
print $ctlfh "'$datafn' using 1:(\$", $col++, ") title '$legend'";
|
||||||
|
}
|
||||||
|
if (my $color = $self->{colors}[$i]) {
|
||||||
|
print $ctlfh " linecolor rgbcolor '$color'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
tsplotv
11
tsplotv
|
@ -43,12 +43,13 @@ use Pod::Usage;
|
||||||
|
|
||||||
my $help;
|
my $help;
|
||||||
my $legend_position = 'top right';
|
my $legend_position = 'top right';
|
||||||
my $output_format ='png';
|
my $output_format = 'png';
|
||||||
my $stacked = 0;
|
my $stacked = 0;
|
||||||
my $style = "lines";
|
my $style = "lines";
|
||||||
my $log_y =0;
|
my $log_y = 0;
|
||||||
my $finalresolution;
|
my $finalresolution;
|
||||||
my $time_t =0;
|
my $time_t = 0;
|
||||||
|
my $colors;
|
||||||
|
|
||||||
GetOptions('help|?' => \$help,
|
GetOptions('help|?' => \$help,
|
||||||
'legend_position|legend-position=s' => \$legend_position,
|
'legend_position|legend-position=s' => \$legend_position,
|
||||||
|
@ -58,6 +59,7 @@ GetOptions('help|?' => \$help,
|
||||||
'log_y|log-y' => \$log_y,
|
'log_y|log-y' => \$log_y,
|
||||||
'finalresolution' => \$finalresolution,
|
'finalresolution' => \$finalresolution,
|
||||||
'time_t' => \$time_t,
|
'time_t' => \$time_t,
|
||||||
|
'colors=s' => \$colors,
|
||||||
) or pod2usage(2);
|
) or pod2usage(2);
|
||||||
pod2usage(1) if $help;
|
pod2usage(1) if $help;
|
||||||
|
|
||||||
|
@ -82,6 +84,9 @@ $ts->stacked($stacked);
|
||||||
$ts->style($style);
|
$ts->style($style);
|
||||||
$ts->log_y($log_y);
|
$ts->log_y($log_y);
|
||||||
$ts->finalresolution($finalresolution) if $finalresolution;
|
$ts->finalresolution($finalresolution) if $finalresolution;
|
||||||
|
if ($colors) {
|
||||||
|
$ts->colors(split(/,/, $colors));
|
||||||
|
}
|
||||||
|
|
||||||
for my $timestamp (sort keys %data) {
|
for my $timestamp (sort keys %data) {
|
||||||
my %d = %{$data{$timestamp}};
|
my %d = %{$data{$timestamp}};
|
||||||
|
|
Loading…
Reference in New Issue