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
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
6
 
7
class PlotArea
8
{
9
    /**
10
     * No fill in plot area (show Excel gridlines through chart).
11
     */
12
    private bool $noFill = false;
13
 
14
    /**
15
     * PlotArea Gradient Stop list.
16
     * Each entry is a 2-element array.
17
     *     First is position in %.
18
     *     Second is ChartColor.
19
     *
20
     * @var array[]
21
     */
22
    private array $gradientFillStops = [];
23
 
24
    /**
25
     * PlotArea Gradient Angle.
26
     */
27
    private ?float $gradientFillAngle = null;
28
 
29
    /**
30
     * PlotArea Layout.
31
     */
32
    private ?Layout $layout;
33
 
34
    /**
35
     * Plot Series.
36
     *
37
     * @var DataSeries[]
38
     */
39
    private array $plotSeries;
40
 
41
    /**
42
     * Create a new PlotArea.
43
     *
44
     * @param DataSeries[] $plotSeries
45
     */
46
    public function __construct(?Layout $layout = null, array $plotSeries = [])
47
    {
48
        $this->layout = $layout;
49
        $this->plotSeries = $plotSeries;
50
    }
51
 
52
    public function getLayout(): ?Layout
53
    {
54
        return $this->layout;
55
    }
56
 
57
    /**
58
     * Get Number of Plot Groups.
59
     */
60
    public function getPlotGroupCount(): int
61
    {
62
        return count($this->plotSeries);
63
    }
64
 
65
    /**
66
     * Get Number of Plot Series.
67
     */
68
    public function getPlotSeriesCount(): int|float
69
    {
70
        $seriesCount = 0;
71
        foreach ($this->plotSeries as $plot) {
72
            $seriesCount += $plot->getPlotSeriesCount();
73
        }
74
 
75
        return $seriesCount;
76
    }
77
 
78
    /**
79
     * Get Plot Series.
80
     *
81
     * @return DataSeries[]
82
     */
83
    public function getPlotGroup(): array
84
    {
85
        return $this->plotSeries;
86
    }
87
 
88
    /**
89
     * Get Plot Series by Index.
90
     */
91
    public function getPlotGroupByIndex(int $index): DataSeries
92
    {
93
        return $this->plotSeries[$index];
94
    }
95
 
96
    /**
97
     * Set Plot Series.
98
     *
99
     * @param DataSeries[] $plotSeries
100
     *
101
     * @return $this
102
     */
103
    public function setPlotSeries(array $plotSeries): static
104
    {
105
        $this->plotSeries = $plotSeries;
106
 
107
        return $this;
108
    }
109
 
110
    public function refresh(Worksheet $worksheet): void
111
    {
112
        foreach ($this->plotSeries as $plotSeries) {
113
            $plotSeries->refresh($worksheet);
114
        }
115
    }
116
 
117
    public function setNoFill(bool $noFill): self
118
    {
119
        $this->noFill = $noFill;
120
 
121
        return $this;
122
    }
123
 
124
    public function getNoFill(): bool
125
    {
126
        return $this->noFill;
127
    }
128
 
129
    public function setGradientFillProperties(array $gradientFillStops, ?float $gradientFillAngle): self
130
    {
131
        $this->gradientFillStops = $gradientFillStops;
132
        $this->gradientFillAngle = $gradientFillAngle;
133
 
134
        return $this;
135
    }
136
 
137
    /**
138
     * Get gradientFillAngle.
139
     */
140
    public function getGradientFillAngle(): ?float
141
    {
142
        return $this->gradientFillAngle;
143
    }
144
 
145
    /**
146
     * Get gradientFillStops.
147
     */
148
    public function getGradientFillStops(): array
149
    {
150
        return $this->gradientFillStops;
151
    }
152
 
153
    private ?int $gapWidth = null;
154
 
155
    private bool $useUpBars = false;
156
 
157
    private bool $useDownBars = false;
158
 
159
    public function getGapWidth(): ?int
160
    {
161
        return $this->gapWidth;
162
    }
163
 
164
    public function setGapWidth(?int $gapWidth): self
165
    {
166
        $this->gapWidth = $gapWidth;
167
 
168
        return $this;
169
    }
170
 
171
    public function getUseUpBars(): bool
172
    {
173
        return $this->useUpBars;
174
    }
175
 
176
    public function setUseUpBars(bool $useUpBars): self
177
    {
178
        $this->useUpBars = $useUpBars;
179
 
180
        return $this;
181
    }
182
 
183
    public function getUseDownBars(): bool
184
    {
185
        return $this->useDownBars;
186
    }
187
 
188
    public function setUseDownBars(bool $useDownBars): self
189
    {
190
        $this->useDownBars = $useDownBars;
191
 
192
        return $this;
193
    }
194
 
195
    /**
196
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
197
     */
198
    public function __clone()
199
    {
200
        $this->layout = ($this->layout === null) ? null : clone $this->layout;
201
        $plotSeries = $this->plotSeries;
202
        $this->plotSeries = [];
203
        foreach ($plotSeries as $series) {
204
            $this->plotSeries[] = clone $series;
205
        }
206
    }
207
}