| 1 | # ----------------------------------------------------------------------------- | ||||||||||
| 2 | |||||||||||
| 3 | =encoding utf8 | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Quiq::Gnuplot::Plot - Gnuplot-Plot | ||||||||||
| 8 | |||||||||||
| 9 | =head1 BASE CLASS | ||||||||||
| 10 | |||||||||||
| 11 | L<Quiq::Hash> | ||||||||||
| 12 | |||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||
| 14 | |||||||||||
| 15 | Ein Objekt der Klasse repräsentiert einen Plot. | ||||||||||
| 16 | |||||||||||
| 17 | =cut | ||||||||||
| 18 | |||||||||||
| 19 | # ----------------------------------------------------------------------------- | ||||||||||
| 20 | |||||||||||
| 21 | package Quiq::Gnuplot::Plot; | ||||||||||
| 22 | 2 | ▶ | use base qw/Quiq::Hash/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 2 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 2 | our $VERSION = '1.240'; | |||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | use Quiq::Gnuplot::Graph; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 2 | ▶ | use Quiq::Gnuplot::Arrow; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 2 | ▶ | use Quiq::Gnuplot::Label; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | # ----------------------------------------------------------------------------- | ||||||||||
| 35 | |||||||||||
| 36 | =head1 METHODS | ||||||||||
| 37 | |||||||||||
| 38 | =head2 Konstruktor | ||||||||||
| 39 | |||||||||||
| 40 | =head3 new() - Instantiiere Plot-Objekt | ||||||||||
| 41 | |||||||||||
| 42 | =head4 Synopsis | ||||||||||
| 43 | |||||||||||
| 44 | $plt = Quiq::Gnuplot::Plot->new; | ||||||||||
| 45 | |||||||||||
| 46 | =cut | ||||||||||
| 47 | |||||||||||
| 48 | # ----------------------------------------------------------------------------- | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | 0 | my $class = shift; | |||||||||
| 52 | # @_: @keyVal | ||||||||||
| 53 | |||||||||||
| 54 | 0 | my $self = $class->SUPER::new( | |||||||||
| 55 | terminal => undef, | ||||||||||
| 56 | output => undef, | ||||||||||
| 57 | timeSeries => 0, | ||||||||||
| 58 | formatX => undef, | ||||||||||
| 59 | ytics => undef, | ||||||||||
| 60 | yMin => undef, | ||||||||||
| 61 | yMax => undef, | ||||||||||
| 62 | title => undef, | ||||||||||
| 63 | titleFont => 'giant', | ||||||||||
| 64 | xlabel => undef, | ||||||||||
| 65 | ylabel => undef, | ||||||||||
| 66 | width => undef, | ||||||||||
| 67 | height => undef, | ||||||||||
| 68 | graphs => [], | ||||||||||
| 69 | arrows => [], | ||||||||||
| 70 | labels => [], | ||||||||||
| 71 | mxTics => 1, | ||||||||||
| 72 | myTics => 1, | ||||||||||
| 73 | legendPosition => 'left top', | ||||||||||
| 74 | xMin => undef, | ||||||||||
| 75 | xMax => undef, | ||||||||||
| 76 | ); | ||||||||||
| 77 | 0 | $self->set(@_); | |||||||||
| 78 | |||||||||||
| 79 | 0 | return $self; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | # ----------------------------------------------------------------------------- | ||||||||||
| 83 | |||||||||||
| 84 | =head2 Objektmethoden | ||||||||||
| 85 | |||||||||||
| 86 | =head3 title() - Setze/liefere Plot-Titel | ||||||||||
| 87 | |||||||||||
| 88 | =head4 Synopsis | ||||||||||
| 89 | |||||||||||
| 90 | $title = $plt->title; | ||||||||||
| 91 | $title = $plt->title($title); | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | |||||||||||
| 95 | # ----------------------------------------------------------------------------- | ||||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | sub title { | ||||||||
|
Subroutine
title: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 98 | 0 | my $self = shift; | |||||||||
| 99 | # @_: $title | ||||||||||
| 100 | |||||||||||
| 101 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 0 | $self->{'title'} = shift; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | 0 | return $self->{'title'}; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | # ----------------------------------------------------------------------------- | ||||||||||
| 109 | |||||||||||
| 110 | =head3 addGraph() - Füge Graph zum Plot-Objekt hinzu | ||||||||||
| 111 | |||||||||||
| 112 | =head4 Synopsis | ||||||||||
| 113 | |||||||||||
| 114 | $plt->addGraph($gph); | ||||||||||
| 115 | $plt->addGraph(@keyVal); | ||||||||||
| 116 | |||||||||||
| 117 | =head4 Alias | ||||||||||
| 118 | |||||||||||
| 119 | add() | ||||||||||
| 120 | |||||||||||
| 121 | =head4 Description | ||||||||||
| 122 | |||||||||||
| 123 | Füge Graph $gph oder einen Graph mit der Attributen @keyVal | ||||||||||
| 124 | zum Plot hinzu. In letzterem Fall instantiiert die Methode | ||||||||||
| 125 | das Quiq::Gnuplot::Graph-Objekt. | ||||||||||
| 126 | |||||||||||
| 127 | =cut | ||||||||||
| 128 | |||||||||||
| 129 | # ----------------------------------------------------------------------------- | ||||||||||
| 130 | |||||||||||
| 131 | 0 | ▶ | sub addGraph { | ||||||||
|
Subroutine
addGraph: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 132 | 0 | my $self = shift; | |||||||||
| 133 | # @_: $gph -oder- @keyVal | ||||||||||
| 134 | |||||||||||
| 135 | 0 | my $gph; | |||||||||
| 136 | 0 | ▶ | if (@_ == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 137 | 0 | $gph = shift; | |||||||||
| 138 | } | ||||||||||
| 139 | else { | ||||||||||
| 140 | 0 | $gph = Quiq::Gnuplot::Graph->new(@_); | |||||||||
| 141 | } | ||||||||||
| 142 | 0 | push @{$self->{'graphs'}},$gph; | |||||||||
| 143 | |||||||||||
| 144 | 0 | return; | |||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | { | ||||||||||
| 148 | 2 | ▶ | no warnings 'once'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 149 | 2 | *add = \&addGraph; | |||||||||
| 150 | } | ||||||||||
| 151 | |||||||||||
| 152 | # ----------------------------------------------------------------------------- | ||||||||||
| 153 | |||||||||||
| 154 | =head3 addArrow() - Füge Arrow zum Plot-Objekt hinzu | ||||||||||
| 155 | |||||||||||
| 156 | =head4 Synopsis | ||||||||||
| 157 | |||||||||||
| 158 | $plt->addArrow($arw); | ||||||||||
| 159 | $plt->addArrow(@keyVal); | ||||||||||
| 160 | |||||||||||
| 161 | =head4 Description | ||||||||||
| 162 | |||||||||||
| 163 | Füge Arrow $arw oder einen Arrow mit der Attributen @keyVal | ||||||||||
| 164 | zum Plot hinzu. In letzterem Fall instantiiert die Methode | ||||||||||
| 165 | selbst das Quiq::Gnuplot::Arrow-Objekt. | ||||||||||
| 166 | |||||||||||
| 167 | =cut | ||||||||||
| 168 | |||||||||||
| 169 | # ----------------------------------------------------------------------------- | ||||||||||
| 170 | |||||||||||
| 171 | 0 | ▶ | sub addArrow { | ||||||||
|
Subroutine
addArrow: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 172 | 0 | my $self = shift; | |||||||||
| 173 | # @_: $arw -oder- @keyVal | ||||||||||
| 174 | |||||||||||
| 175 | 0 | my $arw; | |||||||||
| 176 | 0 | ▶ | if (@_ == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 0 | $arw = shift; | |||||||||
| 178 | } | ||||||||||
| 179 | else { | ||||||||||
| 180 | 0 | $arw = Quiq::Gnuplot::Arrow->new(@_); | |||||||||
| 181 | } | ||||||||||
| 182 | 0 | push @{$self->{'arrows'}},$arw; | |||||||||
| 183 | |||||||||||
| 184 | 0 | return; | |||||||||
| 185 | } | ||||||||||
| 186 | |||||||||||
| 187 | # ----------------------------------------------------------------------------- | ||||||||||
| 188 | |||||||||||
| 189 | =head3 addLabel() - Füge Label zum Plot-Objekt hinzu | ||||||||||
| 190 | |||||||||||
| 191 | =head4 Synopsis | ||||||||||
| 192 | |||||||||||
| 193 | $plt->addLabel($lab); | ||||||||||
| 194 | $plt->addLabel(@keyVal); | ||||||||||
| 195 | |||||||||||
| 196 | =head4 Description | ||||||||||
| 197 | |||||||||||
| 198 | Füge Label $lab oder ein Label mit den Attributen @keyVal | ||||||||||
| 199 | zum Plot hinzu. In letzterem Fall instantiiert die Methode | ||||||||||
| 200 | selbst das Quiq::Gnuplot::Label-Objekt. | ||||||||||
| 201 | |||||||||||
| 202 | =cut | ||||||||||
| 203 | |||||||||||
| 204 | # ----------------------------------------------------------------------------- | ||||||||||
| 205 | |||||||||||
| 206 | 0 | ▶ | sub addLabel { | ||||||||
|
Subroutine
addLabel: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 207 | 0 | my $self = shift; | |||||||||
| 208 | # @_: $lab -oder- @keyVal | ||||||||||
| 209 | |||||||||||
| 210 | 0 | my $lab; | |||||||||
| 211 | 0 | ▶ | if (@_ == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 212 | 0 | $lab = shift; | |||||||||
| 213 | } | ||||||||||
| 214 | else { | ||||||||||
| 215 | 0 | $lab = Quiq::Gnuplot::Label->new(@_); | |||||||||
| 216 | } | ||||||||||
| 217 | 0 | push @{$self->{'labels'}},$lab; | |||||||||
| 218 | |||||||||||
| 219 | 0 | return; | |||||||||
| 220 | } | ||||||||||
| 221 | |||||||||||
| 222 | # ----------------------------------------------------------------------------- | ||||||||||
| 223 | |||||||||||
| 224 | =head3 graphsWithData() - Liefere Graphen mit Daten | ||||||||||
| 225 | |||||||||||
| 226 | =head4 Synopsis | ||||||||||
| 227 | |||||||||||
| 228 | @gph | $gphA = $plt->graphsWithData; | ||||||||||
| 229 | |||||||||||
| 230 | =cut | ||||||||||
| 231 | |||||||||||
| 232 | # ----------------------------------------------------------------------------- | ||||||||||
| 233 | |||||||||||
| 234 | 0 | ▶ | sub graphsWithData { | ||||||||
|
Subroutine
graphsWithData: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 235 | 0 | my $self = shift; | |||||||||
| 236 | |||||||||||
| 237 | 0 | my @arr; | |||||||||
| 238 | 0 | my $gphA = $self->{'graphs'}; | |||||||||
| 239 | 0 | for my $gph (@$gphA) { | |||||||||
| 240 | 0 | ▶ | if ($gph->hasData) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 241 | 0 | push @arr,$gph; | |||||||||
| 242 | } | ||||||||||
| 243 | } | ||||||||||
| 244 | |||||||||||
| 245 | 0 | ▶ | return wantarray? @arr: \@arr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 246 | } | ||||||||||
| 247 | |||||||||||
| 248 | # ----------------------------------------------------------------------------- | ||||||||||
| 249 | |||||||||||
| 250 | =head1 VERSION | ||||||||||
| 251 | |||||||||||
| 252 | 1.240 | ||||||||||
| 253 | |||||||||||
| 254 | =head1 AUTHOR | ||||||||||
| 255 | |||||||||||
| 256 | Frank Seitz, L<http://fseitz.de/> | ||||||||||
| 257 | |||||||||||
| 258 | =head1 COPYRIGHT | ||||||||||
| 259 | |||||||||||
| 260 | Copyright (C) 2026 Frank Seitz | ||||||||||
| 261 | |||||||||||
| 262 | =head1 LICENSE | ||||||||||
| 263 | |||||||||||
| 264 | This code is free software; you can redistribute it and/or modify | ||||||||||
| 265 | it under the same terms as Perl itself. | ||||||||||
| 266 | |||||||||||
| 267 | =cut | ||||||||||
| 268 | |||||||||||
| 269 | # ----------------------------------------------------------------------------- | ||||||||||
| 270 | |||||||||||
| 271 | 2 | 1; | |||||||||
| 272 | |||||||||||
| 273 | # eof | ||||||||||