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