ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues Class Reference
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues:

Public Member Functions

 __construct ($dataType=self::DATASERIES_TYPE_NUMBER, $dataSource=null, $formatCode=null, $pointCount=0, $dataValues=[], $marker=null, $fillColor=null)
 Create a new DataSeriesValues object. More...
 
 getDataType ()
 Get Series Data Type. More...
 
 setDataType ($dataType)
 Set Series Data Type. More...
 
 getDataSource ()
 Get Series Data Source (formula). More...
 
 setDataSource ($dataSource)
 Set Series Data Source (formula). More...
 
 getPointMarker ()
 Get Point Marker. More...
 
 setPointMarker ($marker)
 Set Point Marker. More...
 
 getFormatCode ()
 Get Series Format Code. More...
 
 setFormatCode ($formatCode)
 Set Series Format Code. More...
 
 getPointCount ()
 Get Series Point Count. More...
 
 getFillColor ()
 Get fill color. More...
 
 setFillColor ($color)
 Set fill color for series. More...
 
 getLineWidth ()
 Get line width for series. More...
 
 setLineWidth ($width)
 Set line width for the series. More...
 
 isMultiLevelSeries ()
 Identify if the Data Series is a multi-level or a simple series. More...
 
 multiLevelCount ()
 Return the level count of a multi-level Data Series. More...
 
 getDataValues ()
 Get Series Data Values. More...
 
 getDataValue ()
 Get the first Series Data value. More...
 
 setDataValues ($dataValues)
 Set Series Data Values. More...
 
 refresh (Worksheet $worksheet, $flatten=true)
 

Data Fields

const DATASERIES_TYPE_STRING = 'String'
 
const DATASERIES_TYPE_NUMBER = 'Number'
 

Private Member Functions

 validateColor ($color)
 Method for validating hex color. More...
 

Private Attributes

 $dataType
 
 $dataSource
 
 $formatCode
 
 $pointMarker
 
 $pointCount = 0
 
 $dataValues = []
 
 $fillColor
 
 $lineWidth = 12700
 

Static Private Attributes

static $dataTypeValues
 

Detailed Description

Definition at line 10 of file DataSeriesValues.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::__construct (   $dataType = self::DATASERIES_TYPE_NUMBER,
  $dataSource = null,
  $formatCode = null,
  $pointCount = 0,
  $dataValues = [],
  $marker = null,
  $fillColor = null 
)

Create a new DataSeriesValues object.

Parameters
string$dataType
string$dataSource
null | mixed$formatCode
int$pointCount
mixed$dataValues
null | mixed$marker
null|string|string[]$fillColor

Definition at line 87 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataSource, PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataType, PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataValues, PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$fillColor, PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$formatCode, PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$pointCount, and PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\setDataType().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDataSource()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getDataSource ( )

Get Series Data Source (formula).

Returns
string

Definition at line 135 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataSource.

◆ getDataType()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getDataType ( )

Get Series Data Type.

Returns
string

Definition at line 103 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataType.

◆ getDataValue()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getDataValue ( )

Get the first Series Data value.

Returns
mixed

Definition at line 328 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataValues.

329  {
330  $count = count($this->dataValues);
331  if ($count == 0) {
332  return null;
333  } elseif ($count == 1) {
334  return $this->dataValues[0];
335  }
336 
337  return $this->dataValues;
338  }

◆ getDataValues()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getDataValues ( )

Get Series Data Values.

Returns
mixed[]

Definition at line 318 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataValues.

◆ getFillColor()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getFillColor ( )

Get fill color.

Returns
string|string[] HEX color or array with HEX colors

Definition at line 217 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$fillColor.

◆ getFormatCode()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getFormatCode ( )

Get Series Format Code.

Returns
string

Definition at line 183 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$formatCode.

◆ getLineWidth()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getLineWidth ( )

Get line width for series.

Returns
int

Definition at line 264 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$lineWidth.

◆ getPointCount()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getPointCount ( )

Get Series Point Count.

Returns
int

Definition at line 207 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$pointCount.

◆ getPointMarker()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::getPointMarker ( )

Get Point Marker.

Returns
string

Definition at line 159 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$pointMarker.

◆ isMultiLevelSeries()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::isMultiLevelSeries ( )

Identify if the Data Series is a multi-level or a simple series.

Returns
null|bool

Definition at line 289 of file DataSeriesValues.php.

290  {
291  if (count($this->dataValues) > 0) {
292  return is_array(array_values($this->dataValues)[0]);
293  }
294 
295  return null;
296  }

◆ multiLevelCount()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::multiLevelCount ( )

Return the level count of a multi-level Data Series.

Returns
int

Definition at line 303 of file DataSeriesValues.php.

304  {
305  $levelCount = 0;
306  foreach ($this->dataValues as $dataValueSet) {
307  $levelCount = max($levelCount, count($dataValueSet));
308  }
309 
310  return $levelCount;
311  }

◆ refresh()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::refresh ( Worksheet  $worksheet,
  $flatten = true 
)

Definition at line 355 of file DataSeriesValues.php.

References $i, PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\extractSheetTitle(), PhpOffice\PhpSpreadsheet\Calculation\Functions\flattenArray(), PhpOffice\PhpSpreadsheet\Calculation\Calculation\getInstance(), PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\getParent(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\rangeDimension(), and PhpOffice\PhpSpreadsheet\Calculation\Calculation\unwrapResult().

355  : void
356  {
357  if ($this->dataSource !== null) {
358  $calcEngine = Calculation::getInstance($worksheet->getParent());
359  $newDataValues = Calculation::unwrapResult(
360  $calcEngine->_calculateFormulaValue(
361  '=' . $this->dataSource,
362  null,
363  $worksheet->getCell('A1')
364  )
365  );
366  if ($flatten) {
367  $this->dataValues = Functions::flattenArray($newDataValues);
368  foreach ($this->dataValues as &$dataValue) {
369  if (is_string($dataValue) && !empty($dataValue) && $dataValue[0] == '#') {
370  $dataValue = 0.0;
371  }
372  }
373  unset($dataValue);
374  } else {
375  [$worksheet, $cellRange] = Worksheet::extractSheetTitle($this->dataSource, true);
376  $dimensions = Coordinate::rangeDimension(str_replace('$', '', $cellRange));
377  if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
378  $this->dataValues = Functions::flattenArray($newDataValues);
379  } else {
380  $newArray = array_values(array_shift($newDataValues));
381  foreach ($newArray as $i => $newDataSet) {
382  $newArray[$i] = [$newDataSet];
383  }
384 
385  foreach ($newDataValues as $newDataSet) {
386  $i = 0;
387  foreach ($newDataSet as $newDataVal) {
388  array_unshift($newArray[$i++], $newDataVal);
389  }
390  }
391  $this->dataValues = $newArray;
392  }
393  }
394  $this->pointCount = count($this->dataValues);
395  }
396  }
static extractSheetTitle($pRange, $returnRange=false)
Extract worksheet title from range.
Definition: Worksheet.php:2719
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:583
static unwrapResult($value)
Remove quotes used as a wrapper to identify string values.
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
$i
Definition: disco.tpl.php:19
static rangeDimension($pRange)
Calculate range dimension.
Definition: Coordinate.php:222
+ Here is the call graph for this function:

◆ setDataSource()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setDataSource (   $dataSource)

Set Series Data Source (formula).

Parameters
string$dataSource
Returns
$this

Definition at line 147 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataSource.

148  {
149  $this->dataSource = $dataSource;
150 
151  return $this;
152  }

◆ setDataType()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setDataType (   $dataType)

Set Series Data Type.

Parameters
string$dataTypeDatatype of this data series Typical values are: DataSeriesValues::DATASERIES_TYPE_STRING Normally used for axis point values DataSeriesValues::DATASERIES_TYPE_NUMBER Normally used for chart data values
Returns
$this

Definition at line 120 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataType.

Referenced by PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\__construct().

121  {
122  if (!in_array($dataType, self::$dataTypeValues)) {
123  throw new Exception('Invalid datatype for chart data series values');
124  }
125  $this->dataType = $dataType;
126 
127  return $this;
128  }
+ Here is the caller graph for this function:

◆ setDataValues()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setDataValues (   $dataValues)

Set Series Data Values.

Parameters
array$dataValues
Returns
$this

Definition at line 347 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$dataValues, and PhpOffice\PhpSpreadsheet\Calculation\Functions\flattenArray().

348  {
349  $this->dataValues = Functions::flattenArray($dataValues);
350  $this->pointCount = count($dataValues);
351 
352  return $this;
353  }
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:583
+ Here is the call graph for this function:

◆ setFillColor()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setFillColor (   $color)

Set fill color for series.

Parameters
string|string[]$color HEX color or array with HEX colors
Returns
DataSeriesValues

Definition at line 229 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\validateColor().

230  {
231  if (is_array($color)) {
232  foreach ($color as $colorValue) {
233  $this->validateColor($colorValue);
234  }
235  } else {
236  $this->validateColor($color);
237  }
238  $this->fillColor = $color;
239 
240  return $this;
241  }
validateColor($color)
Method for validating hex color.
+ Here is the call graph for this function:

◆ setFormatCode()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setFormatCode (   $formatCode)

Set Series Format Code.

Parameters
string$formatCode
Returns
$this

Definition at line 195 of file DataSeriesValues.php.

References PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\$formatCode.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart\chartDataSeriesValueSet().

196  {
197  $this->formatCode = $formatCode;
198 
199  return $this;
200  }
+ Here is the caller graph for this function:

◆ setLineWidth()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setLineWidth (   $width)

Set line width for the series.

Parameters
int$width
Returns
$this

Definition at line 276 of file DataSeriesValues.php.

277  {
278  $minWidth = 12700;
279  $this->lineWidth = max($minWidth, $width);
280 
281  return $this;
282  }

◆ setPointMarker()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::setPointMarker (   $marker)

Set Point Marker.

Parameters
string$marker
Returns
$this

Definition at line 171 of file DataSeriesValues.php.

172  {
173  $this->pointMarker = $marker;
174 
175  return $this;
176  }

◆ validateColor()

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::validateColor (   $color)
private

Method for validating hex color.

Parameters
string$colorvalue for color
Returns
bool true if validation was successful

Definition at line 250 of file DataSeriesValues.php.

Referenced by PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues\setFillColor().

251  {
252  if (!preg_match('/^[a-f0-9]{6}$/i', $color)) {
253  throw new Exception(sprintf('Invalid hex color for chart series (color: "%s")', $color));
254  }
255 
256  return true;
257  }
+ Here is the caller graph for this function:

Field Documentation

◆ $dataSource

◆ $dataType

◆ $dataTypeValues

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::$dataTypeValues
staticprivate
Initial value:
= [
self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER,
]

Definition at line 15 of file DataSeriesValues.php.

◆ $dataValues

◆ $fillColor

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::$fillColor
private

◆ $formatCode

◆ $lineWidth

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::$lineWidth = 12700
private

◆ $pointCount

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::$pointCount = 0
private

◆ $pointMarker

PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::$pointMarker
private

◆ DATASERIES_TYPE_NUMBER

const PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER = 'Number'

Definition at line 13 of file DataSeriesValues.php.

◆ DATASERIES_TYPE_STRING

const PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_STRING = 'String'

Definition at line 12 of file DataSeriesValues.php.


The documentation for this class was generated from the following file: