PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/DataSeriesValues.php +271 -277 3.1.03.0.10 View file →
@@ -1,10 +1,9 @@
1 1 <?php
2 -
3 2 /**
4 - * PHPExcel_Chart_DataSeriesValues
3 + * PHPExcel
5 4 *
6 - * Copyright (c) 2006 - 2015 PHPExcel
5 + * Copyright (c) 2006 - 2014 PHPExcel
7 6 *
8 7 * This library is free software; you can redistribute it and/or
9 8 * modify it under the terms of the GNU Lesser General Public
10 9 * License as published by the Free Software Foundation; either
@@ -18,316 +17,311 @@
18 17 * You should have received a copy of the GNU Lesser General Public
19 18 * License along with this library; if not, write to the Free Software
20 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 20 *
22 - * @category PHPExcel
23 - * @package PHPExcel_Chart
24 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25 - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 - * @version ##VERSION##, ##DATE##
21 + * @category PHPExcel
22 + * @package PHPExcel_Chart
23 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 + * @version ##VERSION##, ##DATE##
27 26 */
27 +
28 +
29 +/**
30 + * PHPExcel_Chart_DataSeriesValues
31 + *
32 + * @category PHPExcel
33 + * @package PHPExcel_Chart
34 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 + */
28 36 class PHPExcel_Chart_DataSeriesValues
29 37 {
30 38
31 - const DATASERIES_TYPE_STRING = 'String';
32 - const DATASERIES_TYPE_NUMBER = 'Number';
39 + const DATASERIES_TYPE_STRING = 'String';
40 + const DATASERIES_TYPE_NUMBER = 'Number';
33 41
34 - private static $dataTypeValues = array(
35 - self::DATASERIES_TYPE_STRING,
36 - self::DATASERIES_TYPE_NUMBER,
37 - );
42 + private static $_dataTypeValues = array(
43 + self::DATASERIES_TYPE_STRING,
44 + self::DATASERIES_TYPE_NUMBER,
45 + );
38 46
39 - /**
40 - * Series Data Type
41 - *
42 - * @var string
43 - */
44 - private $dataType;
47 + /**
48 + * Series Data Type
49 + *
50 + * @var string
51 + */
52 + private $_dataType = null;
45 53
46 - /**
47 - * Series Data Source
48 - *
49 - * @var string
50 - */
51 - private $dataSource;
54 + /**
55 + * Series Data Source
56 + *
57 + * @var string
58 + */
59 + private $_dataSource = null;
52 60
53 - /**
54 - * Format Code
55 - *
56 - * @var string
57 - */
58 - private $formatCode;
61 + /**
62 + * Format Code
63 + *
64 + * @var string
65 + */
66 + private $_formatCode = null;
59 67
60 - /**
61 - * Series Point Marker
62 - *
63 - * @var string
64 - */
65 - private $pointMarker;
68 + /**
69 + * Series Point Marker
70 + *
71 + * @var string
72 + */
73 + private $_marker = null;
66 74
67 - /**
68 - * Point Count (The number of datapoints in the dataseries)
69 - *
70 - * @var integer
71 - */
72 - private $pointCount = 0;
75 + /**
76 + * Point Count (The number of datapoints in the dataseries)
77 + *
78 + * @var integer
79 + */
80 + private $_pointCount = 0;
73 81
74 - /**
75 - * Data Values
76 - *
77 - * @var array of mixed
78 - */
79 - private $dataValues = array();
82 + /**
83 + * Data Values
84 + *
85 + * @var array of mixed
86 + */
87 + private $_dataValues = array();
80 88
81 - /**
82 - * Create a new PHPExcel_Chart_DataSeriesValues object
83 - */
84 - public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
85 - {
86 - $this->setDataType($dataType);
87 - $this->dataSource = $dataSource;
88 - $this->formatCode = $formatCode;
89 - $this->pointCount = $pointCount;
90 - $this->dataValues = $dataValues;
91 - $this->pointMarker = $marker;
92 - }
89 + /**
90 + * Create a new PHPExcel_Chart_DataSeriesValues object
91 + */
92 + public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
93 + {
94 + $this->setDataType($dataType);
95 + $this->_dataSource = $dataSource;
96 + $this->_formatCode = $formatCode;
97 + $this->_pointCount = $pointCount;
98 + $this->_dataValues = $dataValues;
99 + $this->_marker = $marker;
100 + }
93 101
94 - /**
95 - * Get Series Data Type
96 - *
97 - * @return string
98 - */
99 - public function getDataType()
100 - {
101 - return $this->dataType;
102 - }
102 + /**
103 + * Get Series Data Type
104 + *
105 + * @return string
106 + */
107 + public function getDataType() {
108 + return $this->_dataType;
109 + }
103 110
104 - /**
105 - * Set Series Data Type
106 - *
107 - * @param string $dataType Datatype of this data series
108 - * Typical values are:
109 - * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
110 - * Normally used for axis point values
111 - * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
112 - * Normally used for chart data values
113 - * @return PHPExcel_Chart_DataSeriesValues
114 - */
115 - public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
116 - {
117 - if (!in_array($dataType, self::$dataTypeValues)) {
118 - throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
119 - }
120 - $this->dataType = $dataType;
111 + /**
112 + * Set Series Data Type
113 + *
114 + * @param string $dataType Datatype of this data series
115 + * Typical values are:
116 + * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
117 + * Normally used for axis point values
118 + * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
119 + * Normally used for chart data values
120 + * @return PHPExcel_Chart_DataSeriesValues
121 + */
122 + public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
123 + if (!in_array($dataType, self::$_dataTypeValues)) {
124 + throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
125 + }
126 + $this->_dataType = $dataType;
121 127
122 - return $this;
123 - }
128 + return $this;
129 + }
124 130
125 - /**
126 - * Get Series Data Source (formula)
127 - *
128 - * @return string
129 - */
130 - public function getDataSource()
131 - {
132 - return $this->dataSource;
133 - }
131 + /**
132 + * Get Series Data Source (formula)
133 + *
134 + * @return string
135 + */
136 + public function getDataSource() {
137 + return $this->_dataSource;
138 + }
134 139
135 - /**
136 - * Set Series Data Source (formula)
137 - *
138 - * @param string $dataSource
139 - * @return PHPExcel_Chart_DataSeriesValues
140 - */
141 - public function setDataSource($dataSource = null, $refreshDataValues = true)
142 - {
143 - $this->dataSource = $dataSource;
140 + /**
141 + * Set Series Data Source (formula)
142 + *
143 + * @param string $dataSource
144 + * @return PHPExcel_Chart_DataSeriesValues
145 + */
146 + public function setDataSource($dataSource = null, $refreshDataValues = true) {
147 + $this->_dataSource = $dataSource;
144 148
145 - if ($refreshDataValues) {
146 - // TO DO
147 - }
149 + if ($refreshDataValues) {
150 + // TO DO
151 + }
148 152
149 - return $this;
150 - }
153 + return $this;
154 + }
151 155
152 - /**
153 - * Get Point Marker
154 - *
155 - * @return string
156 - */
157 - public function getPointMarker()
158 - {
159 - return $this->pointMarker;
160 - }
156 + /**
157 + * Get Point Marker
158 + *
159 + * @return string
160 + */
161 + public function getPointMarker() {
162 + return $this->_marker;
163 + }
161 164
162 - /**
163 - * Set Point Marker
164 - *
165 - * @param string $marker
166 - * @return PHPExcel_Chart_DataSeriesValues
167 - */
168 - public function setPointMarker($marker = null)
169 - {
170 - $this->pointMarker = $marker;
165 + /**
166 + * Set Point Marker
167 + *
168 + * @param string $marker
169 + * @return PHPExcel_Chart_DataSeriesValues
170 + */
171 + public function setPointMarker($marker = null) {
172 + $this->_marker = $marker;
171 173
172 - return $this;
173 - }
174 + return $this;
175 + }
174 176
175 - /**
176 - * Get Series Format Code
177 - *
178 - * @return string
179 - */
180 - public function getFormatCode()
181 - {
182 - return $this->formatCode;
183 - }
177 + /**
178 + * Get Series Format Code
179 + *
180 + * @return string
181 + */
182 + public function getFormatCode() {
183 + return $this->_formatCode;
184 + }
184 185
185 - /**
186 - * Set Series Format Code
187 - *
188 - * @param string $formatCode
189 - * @return PHPExcel_Chart_DataSeriesValues
190 - */
191 - public function setFormatCode($formatCode = null)
192 - {
193 - $this->formatCode = $formatCode;
186 + /**
187 + * Set Series Format Code
188 + *
189 + * @param string $formatCode
190 + * @return PHPExcel_Chart_DataSeriesValues
191 + */
192 + public function setFormatCode($formatCode = null) {
193 + $this->_formatCode = $formatCode;
194 194
195 - return $this;
196 - }
195 + return $this;
196 + }
197 197
198 - /**
199 - * Get Series Point Count
200 - *
201 - * @return integer
202 - */
203 - public function getPointCount()
204 - {
205 - return $this->pointCount;
206 - }
198 + /**
199 + * Get Series Point Count
200 + *
201 + * @return integer
202 + */
203 + public function getPointCount() {
204 + return $this->_pointCount;
205 + }
207 206
208 - /**
209 - * Identify if the Data Series is a multi-level or a simple series
210 - *
211 - * @return boolean
212 - */
213 - public function isMultiLevelSeries()
214 - {
215 - if (count($this->dataValues) > 0) {
216 - return is_array($this->dataValues[0]);
217 - }
218 - return null;
219 - }
207 + /**
208 + * Identify if the Data Series is a multi-level or a simple series
209 + *
210 + * @return boolean
211 + */
212 + public function isMultiLevelSeries() {
213 + if (count($this->_dataValues) > 0) {
214 + return is_array($this->_dataValues[0]);
215 + }
216 + return null;
217 + }
220 218
221 - /**
222 - * Return the level count of a multi-level Data Series
223 - *
224 - * @return boolean
225 - */
226 - public function multiLevelCount()
227 - {
228 - $levelCount = 0;
229 - foreach ($this->dataValues as $dataValueSet) {
230 - $levelCount = max($levelCount, count($dataValueSet));
231 - }
232 - return $levelCount;
233 - }
219 + /**
220 + * Return the level count of a multi-level Data Series
221 + *
222 + * @return boolean
223 + */
224 + public function multiLevelCount() {
225 + $levelCount = 0;
226 + foreach($this->_dataValues as $dataValueSet) {
227 + $levelCount = max($levelCount,count($dataValueSet));
228 + }
229 + return $levelCount;
230 + }
234 231
235 - /**
236 - * Get Series Data Values
237 - *
238 - * @return array of mixed
239 - */
240 - public function getDataValues()
241 - {
242 - return $this->dataValues;
243 - }
232 + /**
233 + * Get Series Data Values
234 + *
235 + * @return array of mixed
236 + */
237 + public function getDataValues() {
238 + return $this->_dataValues;
239 + }
244 240
245 - /**
246 - * Get the first Series Data value
247 - *
248 - * @return mixed
249 - */
250 - public function getDataValue()
251 - {
252 - $count = count($this->dataValues);
253 - if ($count == 0) {
254 - return null;
255 - } elseif ($count == 1) {
256 - return $this->dataValues[0];
257 - }
258 - return $this->dataValues;
259 - }
241 + /**
242 + * Get the first Series Data value
243 + *
244 + * @return mixed
245 + */
246 + public function getDataValue() {
247 + $count = count($this->_dataValues);
248 + if ($count == 0) {
249 + return null;
250 + } elseif ($count == 1) {
251 + return $this->_dataValues[0];
252 + }
253 + return $this->_dataValues;
254 + }
260 255
261 - /**
262 - * Set Series Data Values
263 - *
264 - * @param array $dataValues
265 - * @param boolean $refreshDataSource
266 - * TRUE - refresh the value of dataSource based on the values of $dataValues
267 - * FALSE - don't change the value of dataSource
268 - * @return PHPExcel_Chart_DataSeriesValues
269 - */
270 - public function setDataValues($dataValues = array(), $refreshDataSource = true)
271 - {
272 - $this->dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
273 - $this->pointCount = count($dataValues);
256 + /**
257 + * Set Series Data Values
258 + *
259 + * @param array $dataValues
260 + * @param boolean $refreshDataSource
261 + * TRUE - refresh the value of _dataSource based on the values of $dataValues
262 + * FALSE - don't change the value of _dataSource
263 + * @return PHPExcel_Chart_DataSeriesValues
264 + */
265 + public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
266 + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
267 + $this->_pointCount = count($dataValues);
274 268
275 - if ($refreshDataSource) {
276 - // TO DO
277 - }
269 + if ($refreshDataSource) {
270 + // TO DO
271 + }
278 272
279 - return $this;
280 - }
273 + return $this;
274 + }
281 275
282 - private function stripNulls($var)
283 - {
284 - return $var !== null;
285 - }
276 + private function _stripNulls($var) {
277 + return $var !== NULL;
278 + }
286 279
287 - public function refresh(PHPExcel_Worksheet $worksheet, $flatten = true)
288 - {
289 - if ($this->dataSource !== null) {
290 - $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
291 - $newDataValues = PHPExcel_Calculation::unwrapResult(
292 - $calcEngine->_calculateFormulaValue(
293 - '='.$this->dataSource,
294 - null,
295 - $worksheet->getCell('A1')
296 - )
297 - );
298 - if ($flatten) {
299 - $this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
300 - foreach ($this->dataValues as &$dataValue) {
301 - if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
302 - $dataValue = 0.0;
303 - }
304 - }
305 - unset($dataValue);
306 - } else {
307 - $cellRange = explode('!', $this->dataSource);
308 - if (count($cellRange) > 1) {
309 - list(, $cellRange) = $cellRange;
310 - }
280 + public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
281 + if ($this->_dataSource !== NULL) {
282 + $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
283 + $newDataValues = PHPExcel_Calculation::_unwrapResult(
284 + $calcEngine->_calculateFormulaValue(
285 + '='.$this->_dataSource,
286 + NULL,
287 + $worksheet->getCell('A1')
288 + )
289 + );
290 + if ($flatten) {
291 + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
292 + foreach($this->_dataValues as &$dataValue) {
293 + if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
294 + $dataValue = 0.0;
295 + }
296 + }
297 + unset($dataValue);
298 + } else {
299 + $cellRange = explode('!',$this->_dataSource);
300 + if (count($cellRange) > 1) {
301 + list(,$cellRange) = $cellRange;
302 + }
311 303
312 - $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$', '', $cellRange));
313 - if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
314 - $this->dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
315 - } else {
316 - $newArray = array_values(array_shift($newDataValues));
317 - foreach ($newArray as $i => $newDataSet) {
318 - $newArray[$i] = array($newDataSet);
319 - }
304 + $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
305 + if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
306 + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
307 + } else {
308 + $newArray = array_values(array_shift($newDataValues));
309 + foreach($newArray as $i => $newDataSet) {
310 + $newArray[$i] = array($newDataSet);
311 + }
320 312
321 - foreach ($newDataValues as $newDataSet) {
322 - $i = 0;
323 - foreach ($newDataSet as $newDataVal) {
324 - array_unshift($newArray[$i++], $newDataVal);
325 - }
326 - }
327 - $this->dataValues = $newArray;
328 - }
329 - }
330 - $this->pointCount = count($this->dataValues);
331 - }
332 - }
313 + foreach($newDataValues as $newDataSet) {
314 + $i = 0;
315 + foreach($newDataSet as $newDataVal) {
316 + array_unshift($newArray[$i++],$newDataVal);
317 + }
318 + }
319 + $this->_dataValues = $newArray;
320 + }
321 + }
322 + $this->_pointCount = count($this->_dataValues);
323 + }
324 +
325 + }
326 +
333 327 }