Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Chart;
4
 
5
class TrendLine extends Properties
6
{
7
    const TRENDLINE_EXPONENTIAL = 'exp';
8
    const TRENDLINE_LINEAR = 'linear';
9
    const TRENDLINE_LOGARITHMIC = 'log';
10
    const TRENDLINE_POLYNOMIAL = 'poly'; // + 'order'
11
    const TRENDLINE_POWER = 'power';
12
    const TRENDLINE_MOVING_AVG = 'movingAvg'; // + 'period'
13
    const TRENDLINE_TYPES = [
14
        self::TRENDLINE_EXPONENTIAL,
15
        self::TRENDLINE_LINEAR,
16
        self::TRENDLINE_LOGARITHMIC,
17
        self::TRENDLINE_POLYNOMIAL,
18
        self::TRENDLINE_POWER,
19
        self::TRENDLINE_MOVING_AVG,
20
    ];
21
 
22
    private string $trendLineType = 'linear'; // TRENDLINE_LINEAR
23
 
24
    private int $order = 2;
25
 
26
    private int $period = 3;
27
 
28
    private bool $dispRSqr = false;
29
 
30
    private bool $dispEq = false;
31
 
32
    private string $name = '';
33
 
34
    private float $backward = 0.0;
35
 
36
    private float $forward = 0.0;
37
 
38
    private float $intercept = 0.0;
39
 
40
    /**
41
     * Create a new TrendLine object.
42
     */
43
    public function __construct(
44
        string $trendLineType = '',
45
        ?int $order = null,
46
        ?int $period = null,
47
        bool $dispRSqr = false,
48
        bool $dispEq = false,
49
        ?float $backward = null,
50
        ?float $forward = null,
51
        ?float $intercept = null,
52
        ?string $name = null
53
    ) {
54
        parent::__construct();
55
        $this->setTrendLineProperties(
56
            $trendLineType,
57
            $order,
58
            $period,
59
            $dispRSqr,
60
            $dispEq,
61
            $backward,
62
            $forward,
63
            $intercept,
64
            $name
65
        );
66
    }
67
 
68
    public function getTrendLineType(): string
69
    {
70
        return $this->trendLineType;
71
    }
72
 
73
    public function setTrendLineType(string $trendLineType): self
74
    {
75
        $this->trendLineType = $trendLineType;
76
 
77
        return $this;
78
    }
79
 
80
    public function getOrder(): int
81
    {
82
        return $this->order;
83
    }
84
 
85
    public function setOrder(int $order): self
86
    {
87
        $this->order = $order;
88
 
89
        return $this;
90
    }
91
 
92
    public function getPeriod(): int
93
    {
94
        return $this->period;
95
    }
96
 
97
    public function setPeriod(int $period): self
98
    {
99
        $this->period = $period;
100
 
101
        return $this;
102
    }
103
 
104
    public function getDispRSqr(): bool
105
    {
106
        return $this->dispRSqr;
107
    }
108
 
109
    public function setDispRSqr(bool $dispRSqr): self
110
    {
111
        $this->dispRSqr = $dispRSqr;
112
 
113
        return $this;
114
    }
115
 
116
    public function getDispEq(): bool
117
    {
118
        return $this->dispEq;
119
    }
120
 
121
    public function setDispEq(bool $dispEq): self
122
    {
123
        $this->dispEq = $dispEq;
124
 
125
        return $this;
126
    }
127
 
128
    public function getName(): string
129
    {
130
        return $this->name;
131
    }
132
 
133
    public function setName(string $name): self
134
    {
135
        $this->name = $name;
136
 
137
        return $this;
138
    }
139
 
140
    public function getBackward(): float
141
    {
142
        return $this->backward;
143
    }
144
 
145
    public function setBackward(float $backward): self
146
    {
147
        $this->backward = $backward;
148
 
149
        return $this;
150
    }
151
 
152
    public function getForward(): float
153
    {
154
        return $this->forward;
155
    }
156
 
157
    public function setForward(float $forward): self
158
    {
159
        $this->forward = $forward;
160
 
161
        return $this;
162
    }
163
 
164
    public function getIntercept(): float
165
    {
166
        return $this->intercept;
167
    }
168
 
169
    public function setIntercept(float $intercept): self
170
    {
171
        $this->intercept = $intercept;
172
 
173
        return $this;
174
    }
175
 
176
    public function setTrendLineProperties(
177
        ?string $trendLineType = null,
178
        ?int $order = 0,
179
        ?int $period = 0,
180
        ?bool $dispRSqr = false,
181
        ?bool $dispEq = false,
182
        ?float $backward = null,
183
        ?float $forward = null,
184
        ?float $intercept = null,
185
        ?string $name = null
186
    ): self {
187
        if (!empty($trendLineType)) {
188
            $this->setTrendLineType($trendLineType);
189
        }
190
        if ($order !== null) {
191
            $this->setOrder($order);
192
        }
193
        if ($period !== null) {
194
            $this->setPeriod($period);
195
        }
196
        if ($dispRSqr !== null) {
197
            $this->setDispRSqr($dispRSqr);
198
        }
199
        if ($dispEq !== null) {
200
            $this->setDispEq($dispEq);
201
        }
202
        if ($backward !== null) {
203
            $this->setBackward($backward);
204
        }
205
        if ($forward !== null) {
206
            $this->setForward($forward);
207
        }
208
        if ($intercept !== null) {
209
            $this->setIntercept($intercept);
210
        }
211
        if ($name !== null) {
212
            $this->setName($name);
213
        }
214
 
215
        return $this;
216
    }
217
}