Add options --pointtype and --pointsize (tsplot only for now)

This commit is contained in:
Peter J. Holzer 2020-02-20 11:44:34 +01:00
parent 11c13599c8
commit aa026a4eaf
2 changed files with 48 additions and 0 deletions

View File

@ -309,6 +309,42 @@ sub colors {
} }
=head2 pointtype($pointtype)
Get or set the point type. This sets the point type for all the
timeseries. There probably should be a way to set the point type for
each timeseries, like for the colors.
=cut
sub pointtype {
my ($self, $pointtype) = @_;
if (defined $pointtype) {
$self->{pointtype} = $pointtype;
}
return $self->{pointtype};
}
=head2 pointsize($pointsize)
Get or set the point size. This sets the point size for all the
timeseries. I think that's what we usually want. Different point sizes
for different timeseries are probably not a good idea.
=cut
sub pointsize {
my ($self, $pointsize) = @_;
if (defined $pointsize) {
$self->{pointsize} = $pointsize;
}
return $self->{pointsize};
}
=head2 dstcorr $time [, $period] =head2 dstcorr $time [, $period]
corrects for time shifts caused by DST switches by aligning the corrects for time shifts caused by DST switches by aligning the
@ -433,6 +469,12 @@ sub plot {
if (my $color = $self->{colors}[$i]) { if (my $color = $self->{colors}[$i]) {
print $ctlfh " linecolor rgbcolor '$color'"; print $ctlfh " linecolor rgbcolor '$color'";
} }
if (defined $self->{pointtype}) {
print $ctlfh " pointtype $self->{pointtype}";
}
if (defined $self->{pointsize}) {
print $ctlfh " pointsize $self->{pointsize}";
}
} }
print $ctlfh "\n"; print $ctlfh "\n";

6
tsplot
View File

@ -58,11 +58,15 @@ my @yrange;
my $keeptempfiles; my $keeptempfiles;
my $finalresolution; my $finalresolution;
my $legend_position = 'top right'; my $legend_position = 'top right';
my $pointtype;
my $pointsize;
GetOptions('output_format|output-format=s' => \$output_format, GetOptions('output_format|output-format=s' => \$output_format,
'log_y|log-y' => \$log_y, 'log_y|log-y' => \$log_y,
'time_t' => \$time_t, 'time_t' => \$time_t,
'style=s' => \$style, 'style=s' => \$style,
'pointtype=s' => \$pointtype,
'pointsize=s' => \$pointsize,
'tsv' => \$tsv, 'tsv' => \$tsv,
'stacked' => \$stacked, 'stacked' => \$stacked,
'yrange=s{2}' => \@yrange, 'yrange=s{2}' => \@yrange,
@ -100,6 +104,8 @@ $ts->style($style);
$ts->stacked($stacked); $ts->stacked($stacked);
$ts->yrange(@yrange); $ts->yrange(@yrange);
$ts->finalresolution($finalresolution) if $finalresolution; $ts->finalresolution($finalresolution) if $finalresolution;
$ts->pointtype($pointtype) if $pointtype;
$ts->pointsize($pointsize) if $pointsize;
my $g = $ts->plot(); my $g = $ts->plot();
print $g print $g