commitall
This commit is contained in:
298
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php
vendored
Normal file
298
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Wiktor Trzonkowski
|
||||
* Date: 6/17/14
|
||||
* Time: 12:11 PM.
|
||||
*/
|
||||
class Axis extends Properties
|
||||
{
|
||||
const AXIS_TYPE_CATEGORY = 'catAx';
|
||||
const AXIS_TYPE_DATE = 'dateAx';
|
||||
const AXIS_TYPE_VALUE = 'valAx';
|
||||
|
||||
const TIME_UNIT_DAYS = 'days';
|
||||
const TIME_UNIT_MONTHS = 'months';
|
||||
const TIME_UNIT_YEARS = 'years';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->fillColor = new ChartColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart Major Gridlines as.
|
||||
*
|
||||
* @var ?GridLines
|
||||
*/
|
||||
private $majorGridlines;
|
||||
|
||||
/**
|
||||
* Chart Minor Gridlines as.
|
||||
*
|
||||
* @var ?GridLines
|
||||
*/
|
||||
private $minorGridlines;
|
||||
|
||||
/**
|
||||
* Axis Number.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $axisNumber = [
|
||||
'format' => self::FORMAT_CODE_GENERAL,
|
||||
'source_linked' => 1,
|
||||
'numeric' => null,
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $axisType = '';
|
||||
|
||||
/**
|
||||
* Axis Options.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $axisOptions = [
|
||||
'minimum' => null,
|
||||
'maximum' => null,
|
||||
'major_unit' => null,
|
||||
'minor_unit' => null,
|
||||
'orientation' => self::ORIENTATION_NORMAL,
|
||||
'minor_tick_mark' => self::TICK_MARK_NONE,
|
||||
'major_tick_mark' => self::TICK_MARK_NONE,
|
||||
'axis_labels' => self::AXIS_LABELS_NEXT_TO,
|
||||
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO,
|
||||
'horizontal_crosses_value' => null,
|
||||
'textRotation' => null,
|
||||
'hidden' => null,
|
||||
'majorTimeUnit' => self::TIME_UNIT_YEARS,
|
||||
'minorTimeUnit' => self::TIME_UNIT_MONTHS,
|
||||
'baseTimeUnit' => self::TIME_UNIT_DAYS,
|
||||
];
|
||||
|
||||
/**
|
||||
* Fill Properties.
|
||||
*
|
||||
* @var ChartColor
|
||||
*/
|
||||
private $fillColor;
|
||||
|
||||
private const NUMERIC_FORMAT = [
|
||||
Properties::FORMAT_CODE_NUMBER,
|
||||
Properties::FORMAT_CODE_DATE,
|
||||
Properties::FORMAT_CODE_DATE_ISO8601,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Series Data Type.
|
||||
*
|
||||
* @param mixed $format_code
|
||||
*/
|
||||
public function setAxisNumberProperties($format_code, ?bool $numeric = null, int $sourceLinked = 0): void
|
||||
{
|
||||
$format = (string) $format_code;
|
||||
$this->axisNumber['format'] = $format;
|
||||
$this->axisNumber['source_linked'] = $sourceLinked;
|
||||
if (is_bool($numeric)) {
|
||||
$this->axisNumber['numeric'] = $numeric;
|
||||
} elseif (in_array($format, self::NUMERIC_FORMAT, true)) {
|
||||
$this->axisNumber['numeric'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis Number Format Data Type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAxisNumberFormat()
|
||||
{
|
||||
return $this->axisNumber['format'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis Number Source Linked.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAxisNumberSourceLinked()
|
||||
{
|
||||
return (string) $this->axisNumber['source_linked'];
|
||||
}
|
||||
|
||||
public function getAxisIsNumericFormat(): bool
|
||||
{
|
||||
return $this->axisType === self::AXIS_TYPE_DATE || (bool) $this->axisNumber['numeric'];
|
||||
}
|
||||
|
||||
public function setAxisOption(string $key, ?string $value): void
|
||||
{
|
||||
if ($value !== null && $value !== '') {
|
||||
$this->axisOptions[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Axis Options Properties.
|
||||
*/
|
||||
public function setAxisOptionsProperties(
|
||||
string $axisLabels,
|
||||
?string $horizontalCrossesValue = null,
|
||||
?string $horizontalCrosses = null,
|
||||
?string $axisOrientation = null,
|
||||
?string $majorTmt = null,
|
||||
?string $minorTmt = null,
|
||||
?string $minimum = null,
|
||||
?string $maximum = null,
|
||||
?string $majorUnit = null,
|
||||
?string $minorUnit = null,
|
||||
?string $textRotation = null,
|
||||
?string $hidden = null,
|
||||
?string $baseTimeUnit = null,
|
||||
?string $majorTimeUnit = null,
|
||||
?string $minorTimeUnit = null
|
||||
): void {
|
||||
$this->axisOptions['axis_labels'] = $axisLabels;
|
||||
$this->setAxisOption('horizontal_crosses_value', $horizontalCrossesValue);
|
||||
$this->setAxisOption('horizontal_crosses', $horizontalCrosses);
|
||||
$this->setAxisOption('orientation', $axisOrientation);
|
||||
$this->setAxisOption('major_tick_mark', $majorTmt);
|
||||
$this->setAxisOption('minor_tick_mark', $minorTmt);
|
||||
$this->setAxisOption('minimum', $minimum);
|
||||
$this->setAxisOption('maximum', $maximum);
|
||||
$this->setAxisOption('major_unit', $majorUnit);
|
||||
$this->setAxisOption('minor_unit', $minorUnit);
|
||||
$this->setAxisOption('textRotation', $textRotation);
|
||||
$this->setAxisOption('hidden', $hidden);
|
||||
$this->setAxisOption('baseTimeUnit', $baseTimeUnit);
|
||||
$this->setAxisOption('majorTimeUnit', $majorTimeUnit);
|
||||
$this->setAxisOption('minorTimeUnit', $minorTimeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis Options Property.
|
||||
*
|
||||
* @param string $property
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getAxisOptionsProperty($property)
|
||||
{
|
||||
return $this->axisOptions[$property];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Axis Orientation Property.
|
||||
*
|
||||
* @param string $orientation
|
||||
*/
|
||||
public function setAxisOrientation($orientation): void
|
||||
{
|
||||
$this->axisOptions['orientation'] = (string) $orientation;
|
||||
}
|
||||
|
||||
public function getAxisType(): string
|
||||
{
|
||||
return $this->axisType;
|
||||
}
|
||||
|
||||
public function setAxisType(string $type): self
|
||||
{
|
||||
if ($type === self::AXIS_TYPE_CATEGORY || $type === self::AXIS_TYPE_VALUE || $type === self::AXIS_TYPE_DATE) {
|
||||
$this->axisType = $type;
|
||||
} else {
|
||||
$this->axisType = '';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Property.
|
||||
*
|
||||
* @param ?string $color
|
||||
* @param ?int $alpha
|
||||
* @param ?string $AlphaType
|
||||
*/
|
||||
public function setFillParameters($color, $alpha = null, $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void
|
||||
{
|
||||
$this->fillColor->setColorProperties($color, $alpha, $AlphaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Property.
|
||||
*
|
||||
* @param string $property
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillProperty($property)
|
||||
{
|
||||
return (string) $this->fillColor->getColorProperty($property);
|
||||
}
|
||||
|
||||
public function getFillColorObject(): ChartColor
|
||||
{
|
||||
return $this->fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Color Property.
|
||||
*
|
||||
* @deprecated 1.24.0
|
||||
* Use the getLineColor property in the Properties class instead
|
||||
* @see Properties::getLineColorProperty()
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return null|int|string
|
||||
*/
|
||||
public function getLineProperty($propertyName)
|
||||
{
|
||||
return $this->getLineColorProperty($propertyName);
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $crossBetween = ''; // 'between' or 'midCat' might be better
|
||||
|
||||
public function setCrossBetween(string $crossBetween): self
|
||||
{
|
||||
$this->crossBetween = $crossBetween;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCrossBetween(): string
|
||||
{
|
||||
return $this->crossBetween;
|
||||
}
|
||||
|
||||
public function getMajorGridlines(): ?GridLines
|
||||
{
|
||||
return $this->majorGridlines;
|
||||
}
|
||||
|
||||
public function getMinorGridlines(): ?GridLines
|
||||
{
|
||||
return $this->minorGridlines;
|
||||
}
|
||||
|
||||
public function setMajorGridlines(?GridLines $gridlines): self
|
||||
{
|
||||
$this->majorGridlines = $gridlines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMinorGridlines(?GridLines $gridlines): self
|
||||
{
|
||||
$this->minorGridlines = $gridlines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
789
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php
vendored
Normal file
789
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php
vendored
Normal file
@ -0,0 +1,789 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class Chart
|
||||
{
|
||||
/**
|
||||
* Chart Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name = '';
|
||||
|
||||
/**
|
||||
* Worksheet.
|
||||
*
|
||||
* @var ?Worksheet
|
||||
*/
|
||||
private $worksheet;
|
||||
|
||||
/**
|
||||
* Chart Title.
|
||||
*
|
||||
* @var ?Title
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Chart Legend.
|
||||
*
|
||||
* @var ?Legend
|
||||
*/
|
||||
private $legend;
|
||||
|
||||
/**
|
||||
* X-Axis Label.
|
||||
*
|
||||
* @var ?Title
|
||||
*/
|
||||
private $xAxisLabel;
|
||||
|
||||
/**
|
||||
* Y-Axis Label.
|
||||
*
|
||||
* @var ?Title
|
||||
*/
|
||||
private $yAxisLabel;
|
||||
|
||||
/**
|
||||
* Chart Plot Area.
|
||||
*
|
||||
* @var ?PlotArea
|
||||
*/
|
||||
private $plotArea;
|
||||
|
||||
/**
|
||||
* Plot Visible Only.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $plotVisibleOnly = true;
|
||||
|
||||
/**
|
||||
* Display Blanks as.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $displayBlanksAs = DataSeries::EMPTY_AS_GAP;
|
||||
|
||||
/**
|
||||
* Chart Asix Y as.
|
||||
*
|
||||
* @var Axis
|
||||
*/
|
||||
private $yAxis;
|
||||
|
||||
/**
|
||||
* Chart Asix X as.
|
||||
*
|
||||
* @var Axis
|
||||
*/
|
||||
private $xAxis;
|
||||
|
||||
/**
|
||||
* Top-Left Cell Position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $topLeftCellRef = 'A1';
|
||||
|
||||
/**
|
||||
* Top-Left X-Offset.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $topLeftXOffset = 0;
|
||||
|
||||
/**
|
||||
* Top-Left Y-Offset.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $topLeftYOffset = 0;
|
||||
|
||||
/**
|
||||
* Bottom-Right Cell Position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $bottomRightCellRef = '';
|
||||
|
||||
/**
|
||||
* Bottom-Right X-Offset.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $bottomRightXOffset = 10;
|
||||
|
||||
/**
|
||||
* Bottom-Right Y-Offset.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $bottomRightYOffset = 10;
|
||||
|
||||
/** @var ?int */
|
||||
private $rotX;
|
||||
|
||||
/** @var ?int */
|
||||
private $rotY;
|
||||
|
||||
/** @var ?int */
|
||||
private $rAngAx;
|
||||
|
||||
/** @var ?int */
|
||||
private $perspective;
|
||||
|
||||
/** @var bool */
|
||||
private $oneCellAnchor = false;
|
||||
|
||||
/** @var bool */
|
||||
private $autoTitleDeleted = false;
|
||||
|
||||
/** @var bool */
|
||||
private $noFill = false;
|
||||
|
||||
/** @var bool */
|
||||
private $roundedCorners = false;
|
||||
|
||||
/**
|
||||
* Create a new Chart.
|
||||
* majorGridlines and minorGridlines are deprecated, moved to Axis.
|
||||
*
|
||||
* @param mixed $name
|
||||
* @param mixed $plotVisibleOnly
|
||||
* @param string $displayBlanksAs
|
||||
*/
|
||||
public function __construct($name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->title = $title;
|
||||
$this->legend = $legend;
|
||||
$this->xAxisLabel = $xAxisLabel;
|
||||
$this->yAxisLabel = $yAxisLabel;
|
||||
$this->plotArea = $plotArea;
|
||||
$this->plotVisibleOnly = $plotVisibleOnly;
|
||||
$this->displayBlanksAs = $displayBlanksAs;
|
||||
$this->xAxis = $xAxis ?? new Axis();
|
||||
$this->yAxis = $yAxis ?? new Axis();
|
||||
if ($majorGridlines !== null) {
|
||||
$this->yAxis->setMajorGridlines($majorGridlines);
|
||||
}
|
||||
if ($minorGridlines !== null) {
|
||||
$this->yAxis->setMinorGridlines($minorGridlines);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Worksheet.
|
||||
*/
|
||||
public function getWorksheet(): ?Worksheet
|
||||
{
|
||||
return $this->worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Worksheet.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWorksheet(?Worksheet $worksheet = null)
|
||||
{
|
||||
$this->worksheet = $worksheet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?Title
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle(Title $title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLegend(): ?Legend
|
||||
{
|
||||
return $this->legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Legend.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLegend(Legend $legend)
|
||||
{
|
||||
$this->legend = $legend;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getXAxisLabel(): ?Title
|
||||
{
|
||||
return $this->xAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Axis Label.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setXAxisLabel(Title $label)
|
||||
{
|
||||
$this->xAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getYAxisLabel(): ?Title
|
||||
{
|
||||
return $this->yAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Axis Label.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setYAxisLabel(Title $label)
|
||||
{
|
||||
$this->yAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlotArea(): ?PlotArea
|
||||
{
|
||||
return $this->plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Area.
|
||||
*/
|
||||
public function setPlotArea(PlotArea $plotArea): self
|
||||
{
|
||||
$this->plotArea = $plotArea;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Visible Only.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getPlotVisibleOnly()
|
||||
{
|
||||
return $this->plotVisibleOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Visible Only.
|
||||
*
|
||||
* @param bool $plotVisibleOnly
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotVisibleOnly($plotVisibleOnly)
|
||||
{
|
||||
$this->plotVisibleOnly = $plotVisibleOnly;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Blanks as.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayBlanksAs()
|
||||
{
|
||||
return $this->displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Blanks as.
|
||||
*
|
||||
* @param string $displayBlanksAs
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDisplayBlanksAs($displayBlanksAs)
|
||||
{
|
||||
$this->displayBlanksAs = $displayBlanksAs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChartAxisY(): Axis
|
||||
{
|
||||
return $this->yAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set yAxis.
|
||||
*/
|
||||
public function setChartAxisY(?Axis $axis): self
|
||||
{
|
||||
$this->yAxis = $axis ?? new Axis();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChartAxisX(): Axis
|
||||
{
|
||||
return $this->xAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set xAxis.
|
||||
*/
|
||||
public function setChartAxisX(?Axis $axis): self
|
||||
{
|
||||
$this->xAxis = $axis ?? new Axis();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Major Gridlines.
|
||||
*
|
||||
* @deprecated 1.24.0 Use Axis->getMajorGridlines()
|
||||
* @see Axis::getMajorGridlines()
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getMajorGridlines(): ?GridLines
|
||||
{
|
||||
return $this->yAxis->getMajorGridLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Minor Gridlines.
|
||||
*
|
||||
* @deprecated 1.24.0 Use Axis->getMinorGridlines()
|
||||
* @see Axis::getMinorGridlines()
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getMinorGridlines(): ?GridLines
|
||||
{
|
||||
return $this->yAxis->getMinorGridLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Top Left position for the chart.
|
||||
*
|
||||
* @param string $cellAddress
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopLeftPosition($cellAddress, $xOffset = null, $yOffset = null)
|
||||
{
|
||||
$this->topLeftCellRef = $cellAddress;
|
||||
if ($xOffset !== null) {
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
}
|
||||
if ($yOffset !== null) {
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top left position of the chart.
|
||||
*
|
||||
* Returns ['cell' => string cell address, 'xOffset' => int, 'yOffset' => int].
|
||||
*
|
||||
* @return array{cell: string, xOffset: int, yOffset: int} an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getTopLeftPosition(): array
|
||||
{
|
||||
return [
|
||||
'cell' => $this->topLeftCellRef,
|
||||
'xOffset' => $this->topLeftXOffset,
|
||||
'yOffset' => $this->topLeftYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the top left of the chart is fixed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeftCell()
|
||||
{
|
||||
return $this->topLeftCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Top Left cell position for the chart.
|
||||
*
|
||||
* @param string $cellAddress
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopLeftCell($cellAddress)
|
||||
{
|
||||
$this->topLeftCellRef = $cellAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset position within the Top Left cell for the chart.
|
||||
*
|
||||
* @param ?int $xOffset
|
||||
* @param ?int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopLeftOffset($xOffset, $yOffset)
|
||||
{
|
||||
if ($xOffset !== null) {
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
}
|
||||
|
||||
if ($yOffset !== null) {
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset position within the Top Left cell for the chart.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getTopLeftOffset()
|
||||
{
|
||||
return [
|
||||
'X' => $this->topLeftXOffset,
|
||||
'Y' => $this->topLeftYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $xOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopLeftXOffset($xOffset)
|
||||
{
|
||||
$this->topLeftXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftXOffset(): int
|
||||
{
|
||||
return $this->topLeftXOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopLeftYOffset($yOffset)
|
||||
{
|
||||
$this->topLeftYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftYOffset(): int
|
||||
{
|
||||
return $this->topLeftYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bottom Right position of the chart.
|
||||
*
|
||||
* @param string $cellAddress
|
||||
* @param int $xOffset
|
||||
* @param int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBottomRightPosition($cellAddress = '', $xOffset = null, $yOffset = null)
|
||||
{
|
||||
$this->bottomRightCellRef = $cellAddress;
|
||||
if ($xOffset !== null) {
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
}
|
||||
if ($yOffset !== null) {
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom right position of the chart.
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getBottomRightPosition()
|
||||
{
|
||||
return [
|
||||
'cell' => $this->bottomRightCellRef,
|
||||
'xOffset' => $this->bottomRightXOffset,
|
||||
'yOffset' => $this->bottomRightYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bottom Right cell for the chart.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBottomRightCell(string $cellAddress = '')
|
||||
{
|
||||
$this->bottomRightCellRef = $cellAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the bottom right of the chart is fixed.
|
||||
*/
|
||||
public function getBottomRightCell(): string
|
||||
{
|
||||
return $this->bottomRightCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset position within the Bottom Right cell for the chart.
|
||||
*
|
||||
* @param ?int $xOffset
|
||||
* @param ?int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBottomRightOffset($xOffset, $yOffset)
|
||||
{
|
||||
if ($xOffset !== null) {
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
}
|
||||
|
||||
if ($yOffset !== null) {
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset position within the Bottom Right cell for the chart.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getBottomRightOffset()
|
||||
{
|
||||
return [
|
||||
'X' => $this->bottomRightXOffset,
|
||||
'Y' => $this->bottomRightYOffset,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $xOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBottomRightXOffset($xOffset)
|
||||
{
|
||||
$this->bottomRightXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightXOffset(): int
|
||||
{
|
||||
return $this->bottomRightXOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $yOffset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBottomRightYOffset($yOffset)
|
||||
{
|
||||
$this->bottomRightYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightYOffset(): int
|
||||
{
|
||||
return $this->bottomRightYOffset;
|
||||
}
|
||||
|
||||
public function refresh(): void
|
||||
{
|
||||
if ($this->worksheet !== null && $this->plotArea !== null) {
|
||||
$this->plotArea->refresh($this->worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the chart to given file (or stream).
|
||||
*
|
||||
* @param string $outputDestination Name of the file render to
|
||||
*
|
||||
* @return bool true on success
|
||||
*/
|
||||
public function render($outputDestination = null)
|
||||
{
|
||||
if ($outputDestination == 'php://output') {
|
||||
$outputDestination = null;
|
||||
}
|
||||
|
||||
$libraryName = Settings::getChartRenderer();
|
||||
if ($libraryName === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure that data series values are up-to-date before we render
|
||||
$this->refresh();
|
||||
|
||||
$renderer = new $libraryName($this);
|
||||
|
||||
return $renderer->render($outputDestination); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
public function getRotX(): ?int
|
||||
{
|
||||
return $this->rotX;
|
||||
}
|
||||
|
||||
public function setRotX(?int $rotX): self
|
||||
{
|
||||
$this->rotX = $rotX;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRotY(): ?int
|
||||
{
|
||||
return $this->rotY;
|
||||
}
|
||||
|
||||
public function setRotY(?int $rotY): self
|
||||
{
|
||||
$this->rotY = $rotY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRAngAx(): ?int
|
||||
{
|
||||
return $this->rAngAx;
|
||||
}
|
||||
|
||||
public function setRAngAx(?int $rAngAx): self
|
||||
{
|
||||
$this->rAngAx = $rAngAx;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPerspective(): ?int
|
||||
{
|
||||
return $this->perspective;
|
||||
}
|
||||
|
||||
public function setPerspective(?int $perspective): self
|
||||
{
|
||||
$this->perspective = $perspective;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOneCellAnchor(): bool
|
||||
{
|
||||
return $this->oneCellAnchor;
|
||||
}
|
||||
|
||||
public function setOneCellAnchor(bool $oneCellAnchor): self
|
||||
{
|
||||
$this->oneCellAnchor = $oneCellAnchor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAutoTitleDeleted(): bool
|
||||
{
|
||||
return $this->autoTitleDeleted;
|
||||
}
|
||||
|
||||
public function setAutoTitleDeleted(bool $autoTitleDeleted): self
|
||||
{
|
||||
$this->autoTitleDeleted = $autoTitleDeleted;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNoFill(): bool
|
||||
{
|
||||
return $this->noFill;
|
||||
}
|
||||
|
||||
public function setNoFill(bool $noFill): self
|
||||
{
|
||||
$this->noFill = $noFill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoundedCorners(): bool
|
||||
{
|
||||
return $this->roundedCorners;
|
||||
}
|
||||
|
||||
public function setRoundedCorners(?bool $roundedCorners): self
|
||||
{
|
||||
if ($roundedCorners !== null) {
|
||||
$this->roundedCorners = $roundedCorners;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
177
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/ChartColor.php
vendored
Normal file
177
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/ChartColor.php
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
class ChartColor
|
||||
{
|
||||
const EXCEL_COLOR_TYPE_STANDARD = 'prstClr';
|
||||
const EXCEL_COLOR_TYPE_SCHEME = 'schemeClr';
|
||||
const EXCEL_COLOR_TYPE_RGB = 'srgbClr';
|
||||
/** @deprecated 1.24 use EXCEL_COLOR_TYPE_RGB instead */
|
||||
const EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
|
||||
const EXCEL_COLOR_TYPES = [
|
||||
self::EXCEL_COLOR_TYPE_ARGB,
|
||||
self::EXCEL_COLOR_TYPE_SCHEME,
|
||||
self::EXCEL_COLOR_TYPE_STANDARD,
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $value = '';
|
||||
|
||||
/** @var string */
|
||||
private $type = '';
|
||||
|
||||
/** @var ?int */
|
||||
private $alpha;
|
||||
|
||||
/** @var ?int */
|
||||
private $brightness;
|
||||
|
||||
/**
|
||||
* @param string|string[] $value
|
||||
*/
|
||||
public function __construct($value = '', ?int $alpha = null, ?string $type = null, ?int $brightness = null)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$this->setColorPropertiesArray($value);
|
||||
} else {
|
||||
$this->setColorProperties($value, $alpha, $type, $brightness);
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue(string $value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAlpha(): ?int
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function setAlpha(?int $alpha): self
|
||||
{
|
||||
$this->alpha = $alpha;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBrightness(): ?int
|
||||
{
|
||||
return $this->brightness;
|
||||
}
|
||||
|
||||
public function setBrightness(?int $brightness): self
|
||||
{
|
||||
$this->brightness = $brightness;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|float|int|string $alpha
|
||||
* @param null|float|int|string $brightness
|
||||
*/
|
||||
public function setColorProperties(?string $color, $alpha = null, ?string $type = null, $brightness = null): self
|
||||
{
|
||||
if (empty($type) && !empty($color)) {
|
||||
if (substr($color, 0, 1) === '*') {
|
||||
$type = 'schemeClr';
|
||||
$color = substr($color, 1);
|
||||
} elseif (substr($color, 0, 1) === '/') {
|
||||
$type = 'prstClr';
|
||||
$color = substr($color, 1);
|
||||
} elseif (preg_match('/^[0-9A-Fa-f]{6}$/', $color) === 1) {
|
||||
$type = 'srgbClr';
|
||||
}
|
||||
}
|
||||
if ($color !== null) {
|
||||
$this->setValue("$color");
|
||||
}
|
||||
if ($type !== null) {
|
||||
$this->setType($type);
|
||||
}
|
||||
if ($alpha === null) {
|
||||
$this->setAlpha(null);
|
||||
} elseif (is_numeric($alpha)) {
|
||||
$this->setAlpha((int) $alpha);
|
||||
}
|
||||
if ($brightness === null) {
|
||||
$this->setBrightness(null);
|
||||
} elseif (is_numeric($brightness)) {
|
||||
$this->setBrightness((int) $brightness);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setColorPropertiesArray(array $color): self
|
||||
{
|
||||
return $this->setColorProperties(
|
||||
$color['value'] ?? '',
|
||||
$color['alpha'] ?? null,
|
||||
$color['type'] ?? null,
|
||||
$color['brightness'] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
public function isUsable(): bool
|
||||
{
|
||||
return $this->type !== '' && $this->value !== '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color Property.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return null|int|string
|
||||
*/
|
||||
public function getColorProperty($propertyName)
|
||||
{
|
||||
$retVal = null;
|
||||
if ($propertyName === 'value') {
|
||||
$retVal = $this->value;
|
||||
} elseif ($propertyName === 'type') {
|
||||
$retVal = $this->type;
|
||||
} elseif ($propertyName === 'alpha') {
|
||||
$retVal = $this->alpha;
|
||||
} elseif ($propertyName === 'brightness') {
|
||||
$retVal = $this->brightness;
|
||||
}
|
||||
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
public static function alphaToXml(int $alpha): string
|
||||
{
|
||||
return (string) (100 - $alpha) . '000';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float|int|string $alpha
|
||||
*/
|
||||
public static function alphaFromXml($alpha): int
|
||||
{
|
||||
return 100 - ((int) $alpha / 1000);
|
||||
}
|
||||
}
|
419
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php
vendored
Normal file
419
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php
vendored
Normal file
@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class DataSeries
|
||||
{
|
||||
const TYPE_BARCHART = 'barChart';
|
||||
const TYPE_BARCHART_3D = 'bar3DChart';
|
||||
const TYPE_LINECHART = 'lineChart';
|
||||
const TYPE_LINECHART_3D = 'line3DChart';
|
||||
const TYPE_AREACHART = 'areaChart';
|
||||
const TYPE_AREACHART_3D = 'area3DChart';
|
||||
const TYPE_PIECHART = 'pieChart';
|
||||
const TYPE_PIECHART_3D = 'pie3DChart';
|
||||
const TYPE_DOUGHNUTCHART = 'doughnutChart';
|
||||
const TYPE_DONUTCHART = self::TYPE_DOUGHNUTCHART; // Synonym
|
||||
const TYPE_SCATTERCHART = 'scatterChart';
|
||||
const TYPE_SURFACECHART = 'surfaceChart';
|
||||
const TYPE_SURFACECHART_3D = 'surface3DChart';
|
||||
const TYPE_RADARCHART = 'radarChart';
|
||||
const TYPE_BUBBLECHART = 'bubbleChart';
|
||||
const TYPE_STOCKCHART = 'stockChart';
|
||||
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
|
||||
|
||||
const GROUPING_CLUSTERED = 'clustered';
|
||||
const GROUPING_STACKED = 'stacked';
|
||||
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
||||
const GROUPING_STANDARD = 'standard';
|
||||
|
||||
const DIRECTION_BAR = 'bar';
|
||||
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
||||
const DIRECTION_COL = 'col';
|
||||
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
||||
const DIRECTION_VERTICAL = self::DIRECTION_COL;
|
||||
|
||||
const STYLE_LINEMARKER = 'lineMarker';
|
||||
const STYLE_SMOOTHMARKER = 'smoothMarker';
|
||||
const STYLE_MARKER = 'marker';
|
||||
const STYLE_FILLED = 'filled';
|
||||
|
||||
const EMPTY_AS_GAP = 'gap';
|
||||
const EMPTY_AS_ZERO = 'zero';
|
||||
const EMPTY_AS_SPAN = 'span';
|
||||
|
||||
/**
|
||||
* Series Plot Type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $plotType;
|
||||
|
||||
/**
|
||||
* Plot Grouping Type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $plotGrouping;
|
||||
|
||||
/**
|
||||
* Plot Direction.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $plotDirection;
|
||||
|
||||
/**
|
||||
* Plot Style.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
private $plotStyle;
|
||||
|
||||
/**
|
||||
* Order of plots in Series.
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
private $plotOrder = [];
|
||||
|
||||
/**
|
||||
* Plot Label.
|
||||
*
|
||||
* @var DataSeriesValues[]
|
||||
*/
|
||||
private $plotLabel = [];
|
||||
|
||||
/**
|
||||
* Plot Category.
|
||||
*
|
||||
* @var DataSeriesValues[]
|
||||
*/
|
||||
private $plotCategory = [];
|
||||
|
||||
/**
|
||||
* Smooth Line. Must be specified for both DataSeries and DataSeriesValues.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $smoothLine;
|
||||
|
||||
/**
|
||||
* Plot Values.
|
||||
*
|
||||
* @var DataSeriesValues[]
|
||||
*/
|
||||
private $plotValues = [];
|
||||
|
||||
/**
|
||||
* Plot Bubble Sizes.
|
||||
*
|
||||
* @var DataSeriesValues[]
|
||||
*/
|
||||
private $plotBubbleSizes = [];
|
||||
|
||||
/**
|
||||
* Create a new DataSeries.
|
||||
*
|
||||
* @param null|mixed $plotType
|
||||
* @param null|mixed $plotGrouping
|
||||
* @param int[] $plotOrder
|
||||
* @param DataSeriesValues[] $plotLabel
|
||||
* @param DataSeriesValues[] $plotCategory
|
||||
* @param DataSeriesValues[] $plotValues
|
||||
* @param null|string $plotDirection
|
||||
* @param bool $smoothLine
|
||||
* @param null|string $plotStyle
|
||||
*/
|
||||
public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null)
|
||||
{
|
||||
$this->plotType = $plotType;
|
||||
$this->plotGrouping = $plotGrouping;
|
||||
$this->plotOrder = $plotOrder;
|
||||
$keys = array_keys($plotValues);
|
||||
$this->plotValues = $plotValues;
|
||||
if (!isset($plotLabel[$keys[0]])) {
|
||||
$plotLabel[$keys[0]] = new DataSeriesValues();
|
||||
}
|
||||
$this->plotLabel = $plotLabel;
|
||||
|
||||
if (!isset($plotCategory[$keys[0]])) {
|
||||
$plotCategory[$keys[0]] = new DataSeriesValues();
|
||||
}
|
||||
$this->plotCategory = $plotCategory;
|
||||
|
||||
$this->smoothLine = $smoothLine;
|
||||
$this->plotStyle = $plotStyle;
|
||||
|
||||
if ($plotDirection === null) {
|
||||
$plotDirection = self::DIRECTION_COL;
|
||||
}
|
||||
$this->plotDirection = $plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotType()
|
||||
{
|
||||
return $this->plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Type.
|
||||
*
|
||||
* @param string $plotType
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotType($plotType)
|
||||
{
|
||||
$this->plotType = $plotType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Grouping Type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotGrouping()
|
||||
{
|
||||
return $this->plotGrouping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Grouping Type.
|
||||
*
|
||||
* @param string $groupingType
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotGrouping($groupingType)
|
||||
{
|
||||
$this->plotGrouping = $groupingType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Direction.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotDirection()
|
||||
{
|
||||
return $this->plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Direction.
|
||||
*
|
||||
* @param string $plotDirection
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotDirection($plotDirection)
|
||||
{
|
||||
$this->plotDirection = $plotDirection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Order.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getPlotOrder()
|
||||
{
|
||||
return $this->plotOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Labels.
|
||||
*
|
||||
* @return DataSeriesValues[]
|
||||
*/
|
||||
public function getPlotLabels()
|
||||
{
|
||||
return $this->plotLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Label by Index.
|
||||
*
|
||||
* @param mixed $index
|
||||
*
|
||||
* @return DataSeriesValues|false
|
||||
*/
|
||||
public function getPlotLabelByIndex($index)
|
||||
{
|
||||
$keys = array_keys($this->plotLabel);
|
||||
if (in_array($index, $keys)) {
|
||||
return $this->plotLabel[$index];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Categories.
|
||||
*
|
||||
* @return DataSeriesValues[]
|
||||
*/
|
||||
public function getPlotCategories()
|
||||
{
|
||||
return $this->plotCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Category by Index.
|
||||
*
|
||||
* @param mixed $index
|
||||
*
|
||||
* @return DataSeriesValues|false
|
||||
*/
|
||||
public function getPlotCategoryByIndex($index)
|
||||
{
|
||||
$keys = array_keys($this->plotCategory);
|
||||
if (in_array($index, $keys)) {
|
||||
return $this->plotCategory[$index];
|
||||
} elseif (isset($keys[$index])) {
|
||||
return $this->plotCategory[$keys[$index]];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Style.
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getPlotStyle()
|
||||
{
|
||||
return $this->plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Style.
|
||||
*
|
||||
* @param null|string $plotStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotStyle($plotStyle)
|
||||
{
|
||||
$this->plotStyle = $plotStyle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values.
|
||||
*
|
||||
* @return DataSeriesValues[]
|
||||
*/
|
||||
public function getPlotValues()
|
||||
{
|
||||
return $this->plotValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values by Index.
|
||||
*
|
||||
* @param mixed $index
|
||||
*
|
||||
* @return DataSeriesValues|false
|
||||
*/
|
||||
public function getPlotValuesByIndex($index)
|
||||
{
|
||||
$keys = array_keys($this->plotValues);
|
||||
if (in_array($index, $keys)) {
|
||||
return $this->plotValues[$index];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Bubble Sizes.
|
||||
*
|
||||
* @return DataSeriesValues[]
|
||||
*/
|
||||
public function getPlotBubbleSizes(): array
|
||||
{
|
||||
return $this->plotBubbleSizes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Bubble Sizes.
|
||||
*
|
||||
* @param DataSeriesValues[] $plotBubbleSizes
|
||||
*/
|
||||
public function setPlotBubbleSizes(array $plotBubbleSizes): self
|
||||
{
|
||||
$this->plotBubbleSizes = $plotBubbleSizes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPlotSeriesCount()
|
||||
{
|
||||
return count($this->plotValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Smooth Line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getSmoothLine()
|
||||
{
|
||||
return $this->smoothLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Smooth Line.
|
||||
*
|
||||
* @param bool $smoothLine
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSmoothLine($smoothLine)
|
||||
{
|
||||
$this->smoothLine = $smoothLine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function refresh(Worksheet $worksheet): void
|
||||
{
|
||||
foreach ($this->plotValues as $plotValues) {
|
||||
if ($plotValues !== null) {
|
||||
$plotValues->refresh($worksheet, true);
|
||||
}
|
||||
}
|
||||
foreach ($this->plotLabel as $plotValues) {
|
||||
if ($plotValues !== null) {
|
||||
$plotValues->refresh($worksheet, true);
|
||||
}
|
||||
}
|
||||
foreach ($this->plotCategory as $plotValues) {
|
||||
if ($plotValues !== null) {
|
||||
$plotValues->refresh($worksheet, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
595
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php
vendored
Normal file
595
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php
vendored
Normal file
@ -0,0 +1,595 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class DataSeriesValues extends Properties
|
||||
{
|
||||
const DATASERIES_TYPE_STRING = 'String';
|
||||
const DATASERIES_TYPE_NUMBER = 'Number';
|
||||
|
||||
private const DATA_TYPE_VALUES = [
|
||||
self::DATASERIES_TYPE_STRING,
|
||||
self::DATASERIES_TYPE_NUMBER,
|
||||
];
|
||||
|
||||
/**
|
||||
* Series Data Type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $dataType;
|
||||
|
||||
/**
|
||||
* Series Data Source.
|
||||
*
|
||||
* @var ?string
|
||||
*/
|
||||
private $dataSource;
|
||||
|
||||
/**
|
||||
* Format Code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $formatCode;
|
||||
|
||||
/**
|
||||
* Series Point Marker.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $pointMarker;
|
||||
|
||||
/** @var ChartColor */
|
||||
private $markerFillColor;
|
||||
|
||||
/** @var ChartColor */
|
||||
private $markerBorderColor;
|
||||
|
||||
/**
|
||||
* Series Point Size.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pointSize = 3;
|
||||
|
||||
/**
|
||||
* Point Count (The number of datapoints in the dataseries).
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pointCount = 0;
|
||||
|
||||
/**
|
||||
* Data Values.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $dataValues = [];
|
||||
|
||||
/**
|
||||
* Fill color (can be array with colors if dataseries have custom colors).
|
||||
*
|
||||
* @var null|ChartColor|ChartColor[]
|
||||
*/
|
||||
private $fillColor;
|
||||
|
||||
/** @var bool */
|
||||
private $scatterLines = true;
|
||||
|
||||
/** @var bool */
|
||||
private $bubble3D = false;
|
||||
|
||||
/** @var ?Layout */
|
||||
private $labelLayout;
|
||||
|
||||
/** @var TrendLine[] */
|
||||
private $trendLines = [];
|
||||
|
||||
/**
|
||||
* Create a new DataSeriesValues object.
|
||||
*
|
||||
* @param string $dataType
|
||||
* @param string $dataSource
|
||||
* @param null|mixed $formatCode
|
||||
* @param int $pointCount
|
||||
* @param mixed $dataValues
|
||||
* @param null|mixed $marker
|
||||
* @param null|ChartColor|ChartColor[]|string|string[] $fillColor
|
||||
* @param string $pointSize
|
||||
*/
|
||||
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $fillColor = null, $pointSize = '3')
|
||||
{
|
||||
parent::__construct();
|
||||
$this->markerFillColor = new ChartColor();
|
||||
$this->markerBorderColor = new ChartColor();
|
||||
$this->setDataType($dataType);
|
||||
$this->dataSource = $dataSource;
|
||||
$this->formatCode = $formatCode;
|
||||
$this->pointCount = $pointCount;
|
||||
$this->dataValues = $dataValues;
|
||||
$this->pointMarker = $marker;
|
||||
if ($fillColor !== null) {
|
||||
$this->setFillColor($fillColor);
|
||||
}
|
||||
if (is_numeric($pointSize)) {
|
||||
$this->pointSize = (int) $pointSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataType()
|
||||
{
|
||||
return $this->dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Type.
|
||||
*
|
||||
* @param string $dataType Datatype 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
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataType($dataType)
|
||||
{
|
||||
if (!in_array($dataType, self::DATA_TYPE_VALUES)) {
|
||||
throw new Exception('Invalid datatype for chart data series values');
|
||||
}
|
||||
$this->dataType = $dataType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Source (formula).
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getDataSource()
|
||||
{
|
||||
return $this->dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Source (formula).
|
||||
*
|
||||
* @param ?string $dataSource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataSource($dataSource)
|
||||
{
|
||||
$this->dataSource = $dataSource;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Point Marker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPointMarker()
|
||||
{
|
||||
return $this->pointMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Point Marker.
|
||||
*
|
||||
* @param string $marker
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPointMarker($marker)
|
||||
{
|
||||
$this->pointMarker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMarkerFillColor(): ChartColor
|
||||
{
|
||||
return $this->markerFillColor;
|
||||
}
|
||||
|
||||
public function getMarkerBorderColor(): ChartColor
|
||||
{
|
||||
return $this->markerBorderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Point Size.
|
||||
*/
|
||||
public function getPointSize(): int
|
||||
{
|
||||
return $this->pointSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Point Size.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPointSize(int $size = 3)
|
||||
{
|
||||
$this->pointSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Format Code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode()
|
||||
{
|
||||
return $this->formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Format Code.
|
||||
*
|
||||
* @param string $formatCode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFormatCode($formatCode)
|
||||
{
|
||||
$this->formatCode = $formatCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Point Count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPointCount()
|
||||
{
|
||||
return $this->pointCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill color object.
|
||||
*
|
||||
* @return null|ChartColor|ChartColor[]
|
||||
*/
|
||||
public function getFillColorObject()
|
||||
{
|
||||
return $this->fillColor;
|
||||
}
|
||||
|
||||
private function stringToChartColor(string $fillString): ChartColor
|
||||
{
|
||||
$value = $type = '';
|
||||
if (substr($fillString, 0, 1) === '*') {
|
||||
$type = 'schemeClr';
|
||||
$value = substr($fillString, 1);
|
||||
} elseif (substr($fillString, 0, 1) === '/') {
|
||||
$type = 'prstClr';
|
||||
$value = substr($fillString, 1);
|
||||
} elseif ($fillString !== '') {
|
||||
$type = 'srgbClr';
|
||||
$value = $fillString;
|
||||
$this->validateColor($value);
|
||||
}
|
||||
|
||||
return new ChartColor($value, null, $type);
|
||||
}
|
||||
|
||||
private function chartColorToString(ChartColor $chartColor): string
|
||||
{
|
||||
$type = (string) $chartColor->getColorProperty('type');
|
||||
$value = (string) $chartColor->getColorProperty('value');
|
||||
if ($type === '' || $value === '') {
|
||||
return '';
|
||||
}
|
||||
if ($type === 'schemeClr') {
|
||||
return "*$value";
|
||||
}
|
||||
if ($type === 'prstClr') {
|
||||
return "/$value";
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill color.
|
||||
*
|
||||
* @return string|string[] HEX color or array with HEX colors
|
||||
*/
|
||||
public function getFillColor()
|
||||
{
|
||||
if ($this->fillColor === null) {
|
||||
return '';
|
||||
}
|
||||
if (is_array($this->fillColor)) {
|
||||
$array = [];
|
||||
foreach ($this->fillColor as $chartColor) {
|
||||
$array[] = $this->chartColorToString($chartColor);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
return $this->chartColorToString($this->fillColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fill color for series.
|
||||
*
|
||||
* @param ChartColor|ChartColor[]|string|string[] $color HEX color or array with HEX colors
|
||||
*
|
||||
* @return DataSeriesValues
|
||||
*/
|
||||
public function setFillColor($color)
|
||||
{
|
||||
if (is_array($color)) {
|
||||
$this->fillColor = [];
|
||||
foreach ($color as $fillString) {
|
||||
if ($fillString instanceof ChartColor) {
|
||||
$this->fillColor[] = $fillString;
|
||||
} else {
|
||||
$this->fillColor[] = $this->stringToChartColor($fillString);
|
||||
}
|
||||
}
|
||||
} elseif ($color instanceof ChartColor) {
|
||||
$this->fillColor = $color;
|
||||
} else {
|
||||
$this->fillColor = $this->stringToChartColor($color);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for validating hex color.
|
||||
*
|
||||
* @param string $color value for color
|
||||
*
|
||||
* @return bool true if validation was successful
|
||||
*/
|
||||
private function validateColor($color)
|
||||
{
|
||||
if (!preg_match('/^[a-f0-9]{6}$/i', $color)) {
|
||||
throw new Exception(sprintf('Invalid hex color for chart series (color: "%s")', $color));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line width for series.
|
||||
*
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getLineWidth()
|
||||
{
|
||||
return $this->lineStyleProperties['width'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line width for the series.
|
||||
*
|
||||
* @param null|float|int $width
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLineWidth($width)
|
||||
{
|
||||
$this->lineStyleProperties['width'] = $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series.
|
||||
*
|
||||
* @return null|bool
|
||||
*/
|
||||
public function isMultiLevelSeries()
|
||||
{
|
||||
if (!empty($this->dataValues)) {
|
||||
return is_array(array_values($this->dataValues)[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level count of a multi-level Data Series.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function multiLevelCount()
|
||||
{
|
||||
$levelCount = 0;
|
||||
foreach ($this->dataValues as $dataValueSet) {
|
||||
$levelCount = max($levelCount, count($dataValueSet));
|
||||
}
|
||||
|
||||
return $levelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Values.
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getDataValues()
|
||||
{
|
||||
return $this->dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first Series Data value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDataValue()
|
||||
{
|
||||
$count = count($this->dataValues);
|
||||
if ($count == 0) {
|
||||
return null;
|
||||
} elseif ($count == 1) {
|
||||
return $this->dataValues[0];
|
||||
}
|
||||
|
||||
return $this->dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Values.
|
||||
*
|
||||
* @param array $dataValues
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataValues($dataValues)
|
||||
{
|
||||
$this->dataValues = Functions::flattenArray($dataValues);
|
||||
$this->pointCount = count($dataValues);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function refresh(Worksheet $worksheet, bool $flatten = true): void
|
||||
{
|
||||
if ($this->dataSource !== null) {
|
||||
$calcEngine = Calculation::getInstance($worksheet->getParent());
|
||||
$newDataValues = Calculation::unwrapResult(
|
||||
$calcEngine->_calculateFormulaValue(
|
||||
'=' . $this->dataSource,
|
||||
null,
|
||||
$worksheet->getCell('A1')
|
||||
)
|
||||
);
|
||||
if ($flatten) {
|
||||
$this->dataValues = Functions::flattenArray($newDataValues);
|
||||
foreach ($this->dataValues as &$dataValue) {
|
||||
if (is_string($dataValue) && !empty($dataValue) && $dataValue[0] == '#') {
|
||||
$dataValue = 0.0;
|
||||
}
|
||||
}
|
||||
unset($dataValue);
|
||||
} else {
|
||||
[$worksheet, $cellRange] = Worksheet::extractSheetTitle($this->dataSource, true);
|
||||
$dimensions = Coordinate::rangeDimension(str_replace('$', '', $cellRange));
|
||||
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
|
||||
$this->dataValues = Functions::flattenArray($newDataValues);
|
||||
} else {
|
||||
$newArray = array_values(array_shift(/** @scrutinizer ignore-type */ $newDataValues));
|
||||
foreach ($newArray as $i => $newDataSet) {
|
||||
$newArray[$i] = [$newDataSet];
|
||||
}
|
||||
|
||||
foreach ($newDataValues as $newDataSet) {
|
||||
$i = 0;
|
||||
foreach ($newDataSet as $newDataVal) {
|
||||
array_unshift($newArray[$i++], $newDataVal);
|
||||
}
|
||||
}
|
||||
$this->dataValues = $newArray;
|
||||
}
|
||||
}
|
||||
$this->pointCount = count($this->dataValues);
|
||||
}
|
||||
}
|
||||
|
||||
public function getScatterLines(): bool
|
||||
{
|
||||
return $this->scatterLines;
|
||||
}
|
||||
|
||||
public function setScatterLines(bool $scatterLines): self
|
||||
{
|
||||
$this->scatterLines = $scatterLines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBubble3D(): bool
|
||||
{
|
||||
return $this->bubble3D;
|
||||
}
|
||||
|
||||
public function setBubble3D(bool $bubble3D): self
|
||||
{
|
||||
$this->bubble3D = $bubble3D;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smooth Line. Must be specified for both DataSeries and DataSeriesValues.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $smoothLine;
|
||||
|
||||
/**
|
||||
* Get Smooth Line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getSmoothLine()
|
||||
{
|
||||
return $this->smoothLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Smooth Line.
|
||||
*
|
||||
* @param bool $smoothLine
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSmoothLine($smoothLine)
|
||||
{
|
||||
$this->smoothLine = $smoothLine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabelLayout(): ?Layout
|
||||
{
|
||||
return $this->labelLayout;
|
||||
}
|
||||
|
||||
public function setLabelLayout(?Layout $labelLayout): self
|
||||
{
|
||||
$this->labelLayout = $labelLayout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTrendLines(array $trendLines): self
|
||||
{
|
||||
$this->trendLines = $trendLines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTrendLines(): array
|
||||
{
|
||||
return $this->trendLines;
|
||||
}
|
||||
}
|
9
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php
vendored
Normal file
9
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
|
||||
|
||||
class Exception extends PhpSpreadsheetException
|
||||
{
|
||||
}
|
13
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php
vendored
Normal file
13
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Wiktor Trzonkowski
|
||||
* Date: 7/2/14
|
||||
* Time: 2:36 PM.
|
||||
*/
|
||||
class GridLines extends Properties
|
||||
{
|
||||
}
|
543
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php
vendored
Normal file
543
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php
vendored
Normal file
@ -0,0 +1,543 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
class Layout
|
||||
{
|
||||
/**
|
||||
* layoutTarget.
|
||||
*
|
||||
* @var ?string
|
||||
*/
|
||||
private $layoutTarget;
|
||||
|
||||
/**
|
||||
* X Mode.
|
||||
*
|
||||
* @var ?string
|
||||
*/
|
||||
private $xMode;
|
||||
|
||||
/**
|
||||
* Y Mode.
|
||||
*
|
||||
* @var ?string
|
||||
*/
|
||||
private $yMode;
|
||||
|
||||
/**
|
||||
* X-Position.
|
||||
*
|
||||
* @var ?float
|
||||
*/
|
||||
private $xPos;
|
||||
|
||||
/**
|
||||
* Y-Position.
|
||||
*
|
||||
* @var ?float
|
||||
*/
|
||||
private $yPos;
|
||||
|
||||
/**
|
||||
* width.
|
||||
*
|
||||
* @var ?float
|
||||
*/
|
||||
private $width;
|
||||
|
||||
/**
|
||||
* height.
|
||||
*
|
||||
* @var ?float
|
||||
*/
|
||||
private $height;
|
||||
|
||||
/**
|
||||
* Position - t=top.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $dLblPos = '';
|
||||
|
||||
/** @var string */
|
||||
private $numFmtCode = '';
|
||||
|
||||
/** @var bool */
|
||||
private $numFmtLinked = false;
|
||||
|
||||
/**
|
||||
* show legend key
|
||||
* Specifies that legend keys should be shown in data labels.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showLegendKey;
|
||||
|
||||
/**
|
||||
* show value
|
||||
* Specifies that the value should be shown in a data label.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showVal;
|
||||
|
||||
/**
|
||||
* show category name
|
||||
* Specifies that the category name should be shown in the data label.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showCatName;
|
||||
|
||||
/**
|
||||
* show data series name
|
||||
* Specifies that the series name should be shown in the data label.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showSerName;
|
||||
|
||||
/**
|
||||
* show percentage
|
||||
* Specifies that the percentage should be shown in the data label.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showPercent;
|
||||
|
||||
/**
|
||||
* show bubble size.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showBubbleSize;
|
||||
|
||||
/**
|
||||
* show leader lines
|
||||
* Specifies that leader lines should be shown for the data label.
|
||||
*
|
||||
* @var ?bool
|
||||
*/
|
||||
private $showLeaderLines;
|
||||
|
||||
/** @var ?ChartColor */
|
||||
private $labelFillColor;
|
||||
|
||||
/** @var ?ChartColor */
|
||||
private $labelBorderColor;
|
||||
|
||||
/** @var ?ChartColor */
|
||||
private $labelFontColor;
|
||||
|
||||
/**
|
||||
* Create a new Layout.
|
||||
*/
|
||||
public function __construct(array $layout = [])
|
||||
{
|
||||
if (isset($layout['layoutTarget'])) {
|
||||
$this->layoutTarget = $layout['layoutTarget'];
|
||||
}
|
||||
if (isset($layout['xMode'])) {
|
||||
$this->xMode = $layout['xMode'];
|
||||
}
|
||||
if (isset($layout['yMode'])) {
|
||||
$this->yMode = $layout['yMode'];
|
||||
}
|
||||
if (isset($layout['x'])) {
|
||||
$this->xPos = (float) $layout['x'];
|
||||
}
|
||||
if (isset($layout['y'])) {
|
||||
$this->yPos = (float) $layout['y'];
|
||||
}
|
||||
if (isset($layout['w'])) {
|
||||
$this->width = (float) $layout['w'];
|
||||
}
|
||||
if (isset($layout['h'])) {
|
||||
$this->height = (float) $layout['h'];
|
||||
}
|
||||
if (isset($layout['dLblPos'])) {
|
||||
$this->dLblPos = (string) $layout['dLblPos'];
|
||||
}
|
||||
if (isset($layout['numFmtCode'])) {
|
||||
$this->numFmtCode = (string) $layout['numFmtCode'];
|
||||
}
|
||||
$this->initBoolean($layout, 'showLegendKey');
|
||||
$this->initBoolean($layout, 'showVal');
|
||||
$this->initBoolean($layout, 'showCatName');
|
||||
$this->initBoolean($layout, 'showSerName');
|
||||
$this->initBoolean($layout, 'showPercent');
|
||||
$this->initBoolean($layout, 'showBubbleSize');
|
||||
$this->initBoolean($layout, 'showLeaderLines');
|
||||
$this->initBoolean($layout, 'numFmtLinked');
|
||||
$this->initColor($layout, 'labelFillColor');
|
||||
$this->initColor($layout, 'labelBorderColor');
|
||||
$this->initColor($layout, 'labelFontColor');
|
||||
}
|
||||
|
||||
private function initBoolean(array $layout, string $name): void
|
||||
{
|
||||
if (isset($layout[$name])) {
|
||||
$this->$name = (bool) $layout[$name];
|
||||
}
|
||||
}
|
||||
|
||||
private function initColor(array $layout, string $name): void
|
||||
{
|
||||
if (isset($layout[$name]) && $layout[$name] instanceof ChartColor) {
|
||||
$this->$name = $layout[$name];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout Target.
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getLayoutTarget()
|
||||
{
|
||||
return $this->layoutTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Layout Target.
|
||||
*
|
||||
* @param ?string $target
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLayoutTarget($target)
|
||||
{
|
||||
$this->layoutTarget = $target;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Mode.
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getXMode()
|
||||
{
|
||||
return $this->xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Mode.
|
||||
*
|
||||
* @param ?string $mode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setXMode($mode)
|
||||
{
|
||||
$this->xMode = (string) $mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Mode.
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getYMode()
|
||||
{
|
||||
return $this->yMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Mode.
|
||||
*
|
||||
* @param ?string $mode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setYMode($mode)
|
||||
{
|
||||
$this->yMode = (string) $mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Position.
|
||||
*
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getXPosition()
|
||||
{
|
||||
return $this->xPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Position.
|
||||
*
|
||||
* @param ?float $position
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setXPosition($position)
|
||||
{
|
||||
$this->xPos = (float) $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Position.
|
||||
*
|
||||
* @return null|float
|
||||
*/
|
||||
public function getYPosition()
|
||||
{
|
||||
return $this->yPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Position.
|
||||
*
|
||||
* @param ?float $position
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setYPosition($position)
|
||||
{
|
||||
$this->yPos = (float) $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width.
|
||||
*
|
||||
* @return ?float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width.
|
||||
*
|
||||
* @param ?float $width
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($width)
|
||||
{
|
||||
$this->width = $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height.
|
||||
*
|
||||
* @return null|float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height.
|
||||
*
|
||||
* @param ?float $height
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($height)
|
||||
{
|
||||
$this->height = $height;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowLegendKey(): ?bool
|
||||
{
|
||||
return $this->showLegendKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show legend key
|
||||
* Specifies that legend keys should be shown in data labels.
|
||||
*/
|
||||
public function setShowLegendKey(?bool $showLegendKey): self
|
||||
{
|
||||
$this->showLegendKey = $showLegendKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowVal(): ?bool
|
||||
{
|
||||
return $this->showVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show val
|
||||
* Specifies that the value should be shown in data labels.
|
||||
*/
|
||||
public function setShowVal(?bool $showDataLabelValues): self
|
||||
{
|
||||
$this->showVal = $showDataLabelValues;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowCatName(): ?bool
|
||||
{
|
||||
return $this->showCatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show cat name
|
||||
* Specifies that the category name should be shown in data labels.
|
||||
*/
|
||||
public function setShowCatName(?bool $showCategoryName): self
|
||||
{
|
||||
$this->showCatName = $showCategoryName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowSerName(): ?bool
|
||||
{
|
||||
return $this->showSerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show data series name.
|
||||
* Specifies that the series name should be shown in data labels.
|
||||
*/
|
||||
public function setShowSerName(?bool $showSeriesName): self
|
||||
{
|
||||
$this->showSerName = $showSeriesName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowPercent(): ?bool
|
||||
{
|
||||
return $this->showPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show percentage.
|
||||
* Specifies that the percentage should be shown in data labels.
|
||||
*/
|
||||
public function setShowPercent(?bool $showPercentage): self
|
||||
{
|
||||
$this->showPercent = $showPercentage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowBubbleSize(): ?bool
|
||||
{
|
||||
return $this->showBubbleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show bubble size.
|
||||
* Specifies that the bubble size should be shown in data labels.
|
||||
*/
|
||||
public function setShowBubbleSize(?bool $showBubbleSize): self
|
||||
{
|
||||
$this->showBubbleSize = $showBubbleSize;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowLeaderLines(): ?bool
|
||||
{
|
||||
return $this->showLeaderLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show leader lines.
|
||||
* Specifies that leader lines should be shown in data labels.
|
||||
*/
|
||||
public function setShowLeaderLines(?bool $showLeaderLines): self
|
||||
{
|
||||
$this->showLeaderLines = $showLeaderLines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabelFillColor(): ?ChartColor
|
||||
{
|
||||
return $this->labelFillColor;
|
||||
}
|
||||
|
||||
public function setLabelFillColor(?ChartColor $chartColor): self
|
||||
{
|
||||
$this->labelFillColor = $chartColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabelBorderColor(): ?ChartColor
|
||||
{
|
||||
return $this->labelBorderColor;
|
||||
}
|
||||
|
||||
public function setLabelBorderColor(?ChartColor $chartColor): self
|
||||
{
|
||||
$this->labelBorderColor = $chartColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabelFontColor(): ?ChartColor
|
||||
{
|
||||
return $this->labelFontColor;
|
||||
}
|
||||
|
||||
public function setLabelFontColor(?ChartColor $chartColor): self
|
||||
{
|
||||
$this->labelFontColor = $chartColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDLblPos(): string
|
||||
{
|
||||
return $this->dLblPos;
|
||||
}
|
||||
|
||||
public function setDLblPos(string $dLblPos): self
|
||||
{
|
||||
$this->dLblPos = $dLblPos;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNumFmtCode(): string
|
||||
{
|
||||
return $this->numFmtCode;
|
||||
}
|
||||
|
||||
public function setNumFmtCode(string $numFmtCode): self
|
||||
{
|
||||
$this->numFmtCode = $numFmtCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNumFmtLinked(): bool
|
||||
{
|
||||
return $this->numFmtLinked;
|
||||
}
|
||||
|
||||
public function setNumFmtLinked(bool $numFmtLinked): self
|
||||
{
|
||||
$this->numFmtLinked = $numFmtLinked;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
150
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php
vendored
Normal file
150
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
class Legend
|
||||
{
|
||||
/** Legend positions */
|
||||
const XL_LEGEND_POSITION_BOTTOM = -4107; // Below the chart.
|
||||
const XL_LEGEND_POSITION_CORNER = 2; // In the upper right-hand corner of the chart border.
|
||||
const XL_LEGEND_POSITION_CUSTOM = -4161; // A custom position.
|
||||
const XL_LEGEND_POSITION_LEFT = -4131; // Left of the chart.
|
||||
const XL_LEGEND_POSITION_RIGHT = -4152; // Right of the chart.
|
||||
const XL_LEGEND_POSITION_TOP = -4160; // Above the chart.
|
||||
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
const POSITION_XLREF = [
|
||||
self::XL_LEGEND_POSITION_BOTTOM => self::POSITION_BOTTOM,
|
||||
self::XL_LEGEND_POSITION_CORNER => self::POSITION_TOPRIGHT,
|
||||
self::XL_LEGEND_POSITION_CUSTOM => '??',
|
||||
self::XL_LEGEND_POSITION_LEFT => self::POSITION_LEFT,
|
||||
self::XL_LEGEND_POSITION_RIGHT => self::POSITION_RIGHT,
|
||||
self::XL_LEGEND_POSITION_TOP => self::POSITION_TOP,
|
||||
];
|
||||
|
||||
/**
|
||||
* Legend position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* Allow overlay of other elements?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $overlay = true;
|
||||
|
||||
/**
|
||||
* Legend Layout.
|
||||
*
|
||||
* @var ?Layout
|
||||
*/
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* Create a new Legend.
|
||||
*
|
||||
* @param string $position
|
||||
* @param bool $overlay
|
||||
*/
|
||||
public function __construct($position = self::POSITION_RIGHT, ?Layout $layout = null, $overlay = false)
|
||||
{
|
||||
$this->setPosition($position);
|
||||
$this->layout = $layout;
|
||||
$this->setOverlay($overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an excel string value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position using an excel string value.
|
||||
*
|
||||
* @param string $position see self::POSITION_*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setPosition($position)
|
||||
{
|
||||
if (!in_array($position, self::POSITION_XLREF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->position = $position;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an Excel internal numeric value.
|
||||
*
|
||||
* @return false|int
|
||||
*/
|
||||
public function getPositionXL()
|
||||
{
|
||||
// Scrutinizer thinks the following could return string. It is wrong.
|
||||
return array_search($this->position, self::POSITION_XLREF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legend position using an Excel internal numeric value.
|
||||
*
|
||||
* @param int $positionXL see self::XL_LEGEND_POSITION_*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setPositionXL($positionXL)
|
||||
{
|
||||
if (!isset(self::POSITION_XLREF[$positionXL])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->position = self::POSITION_XLREF[$positionXL];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allow overlay of other elements?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getOverlay()
|
||||
{
|
||||
return $this->overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allow overlay of other elements?
|
||||
*
|
||||
* @param bool $overlay
|
||||
*/
|
||||
public function setOverlay($overlay): void
|
||||
{
|
||||
$this->overlay = $overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout.
|
||||
*
|
||||
* @return ?Layout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
}
|
166
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php
vendored
Normal file
166
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class PlotArea
|
||||
{
|
||||
/**
|
||||
* No fill in plot area (show Excel gridlines through chart).
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $noFill = false;
|
||||
|
||||
/**
|
||||
* PlotArea Gradient Stop list.
|
||||
* Each entry is a 2-element array.
|
||||
* First is position in %.
|
||||
* Second is ChartColor.
|
||||
*
|
||||
* @var array[]
|
||||
*/
|
||||
private $gradientFillStops = [];
|
||||
|
||||
/**
|
||||
* PlotArea Gradient Angle.
|
||||
*
|
||||
* @var ?float
|
||||
*/
|
||||
private $gradientFillAngle;
|
||||
|
||||
/**
|
||||
* PlotArea Layout.
|
||||
*
|
||||
* @var ?Layout
|
||||
*/
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* Plot Series.
|
||||
*
|
||||
* @var DataSeries[]
|
||||
*/
|
||||
private $plotSeries = [];
|
||||
|
||||
/**
|
||||
* Create a new PlotArea.
|
||||
*
|
||||
* @param DataSeries[] $plotSeries
|
||||
*/
|
||||
public function __construct(?Layout $layout = null, array $plotSeries = [])
|
||||
{
|
||||
$this->layout = $layout;
|
||||
$this->plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
public function getLayout(): ?Layout
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Groups.
|
||||
*/
|
||||
public function getPlotGroupCount(): int
|
||||
{
|
||||
return count($this->plotSeries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPlotSeriesCount()
|
||||
{
|
||||
$seriesCount = 0;
|
||||
foreach ($this->plotSeries as $plot) {
|
||||
$seriesCount += $plot->getPlotSeriesCount();
|
||||
}
|
||||
|
||||
return $seriesCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series.
|
||||
*
|
||||
* @return DataSeries[]
|
||||
*/
|
||||
public function getPlotGroup()
|
||||
{
|
||||
return $this->plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series by Index.
|
||||
*
|
||||
* @param mixed $index
|
||||
*
|
||||
* @return DataSeries
|
||||
*/
|
||||
public function getPlotGroupByIndex($index)
|
||||
{
|
||||
return $this->plotSeries[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Series.
|
||||
*
|
||||
* @param DataSeries[] $plotSeries
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlotSeries(array $plotSeries)
|
||||
{
|
||||
$this->plotSeries = $plotSeries;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function refresh(Worksheet $worksheet): void
|
||||
{
|
||||
foreach ($this->plotSeries as $plotSeries) {
|
||||
$plotSeries->refresh($worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
public function setNoFill(bool $noFill): self
|
||||
{
|
||||
$this->noFill = $noFill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNoFill(): bool
|
||||
{
|
||||
return $this->noFill;
|
||||
}
|
||||
|
||||
public function setGradientFillProperties(array $gradientFillStops, ?float $gradientFillAngle): self
|
||||
{
|
||||
$this->gradientFillStops = $gradientFillStops;
|
||||
$this->gradientFillAngle = $gradientFillAngle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gradientFillAngle.
|
||||
*/
|
||||
public function getGradientFillAngle(): ?float
|
||||
{
|
||||
return $this->gradientFillAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gradientFillStops.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGradientFillStops()
|
||||
{
|
||||
return $this->gradientFillStops;
|
||||
}
|
||||
}
|
985
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php
vendored
Normal file
985
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php
vendored
Normal file
@ -0,0 +1,985 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: nhw2h8s
|
||||
* Date: 7/2/14
|
||||
* Time: 5:45 PM.
|
||||
*/
|
||||
abstract class Properties
|
||||
{
|
||||
/** @deprecated 1.24 use constant from ChartColor instead */
|
||||
const EXCEL_COLOR_TYPE_STANDARD = ChartColor::EXCEL_COLOR_TYPE_STANDARD;
|
||||
/** @deprecated 1.24 use constant from ChartColor instead */
|
||||
const EXCEL_COLOR_TYPE_SCHEME = ChartColor::EXCEL_COLOR_TYPE_SCHEME;
|
||||
/** @deprecated 1.24 use constant from ChartColor instead */
|
||||
const EXCEL_COLOR_TYPE_ARGB = ChartColor::EXCEL_COLOR_TYPE_ARGB;
|
||||
|
||||
const
|
||||
AXIS_LABELS_LOW = 'low';
|
||||
const AXIS_LABELS_HIGH = 'high';
|
||||
const AXIS_LABELS_NEXT_TO = 'nextTo';
|
||||
const AXIS_LABELS_NONE = 'none';
|
||||
|
||||
const
|
||||
TICK_MARK_NONE = 'none';
|
||||
const TICK_MARK_INSIDE = 'in';
|
||||
const TICK_MARK_OUTSIDE = 'out';
|
||||
const TICK_MARK_CROSS = 'cross';
|
||||
|
||||
const
|
||||
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero';
|
||||
const HORIZONTAL_CROSSES_MAXIMUM = 'max';
|
||||
|
||||
const
|
||||
FORMAT_CODE_GENERAL = 'General';
|
||||
const FORMAT_CODE_NUMBER = '#,##0.00';
|
||||
const FORMAT_CODE_CURRENCY = '$#,##0.00';
|
||||
const FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)';
|
||||
const FORMAT_CODE_DATE = 'm/d/yyyy';
|
||||
const FORMAT_CODE_DATE_ISO8601 = 'yyyy-mm-dd';
|
||||
const FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM';
|
||||
const FORMAT_CODE_PERCENTAGE = '0.00%';
|
||||
const FORMAT_CODE_FRACTION = '# ?/?';
|
||||
const FORMAT_CODE_SCIENTIFIC = '0.00E+00';
|
||||
const FORMAT_CODE_TEXT = '@';
|
||||
const FORMAT_CODE_SPECIAL = '00000';
|
||||
|
||||
const
|
||||
ORIENTATION_NORMAL = 'minMax';
|
||||
const ORIENTATION_REVERSED = 'maxMin';
|
||||
|
||||
const
|
||||
LINE_STYLE_COMPOUND_SIMPLE = 'sng';
|
||||
const LINE_STYLE_COMPOUND_DOUBLE = 'dbl';
|
||||
const LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin';
|
||||
const LINE_STYLE_COMPOUND_THINTHICK = 'thinThick';
|
||||
const LINE_STYLE_COMPOUND_TRIPLE = 'tri';
|
||||
const LINE_STYLE_DASH_SOLID = 'solid';
|
||||
const LINE_STYLE_DASH_ROUND_DOT = 'sysDot';
|
||||
const LINE_STYLE_DASH_SQUARE_DOT = 'sysDash';
|
||||
/** @deprecated 1.24 use LINE_STYLE_DASH_SQUARE_DOT instead */
|
||||
const LINE_STYLE_DASH_SQUERE_DOT = 'sysDash';
|
||||
const LINE_STYPE_DASH_DASH = 'dash';
|
||||
const LINE_STYLE_DASH_DASH_DOT = 'dashDot';
|
||||
const LINE_STYLE_DASH_LONG_DASH = 'lgDash';
|
||||
const LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot';
|
||||
const LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot';
|
||||
const LINE_STYLE_CAP_SQUARE = 'sq';
|
||||
const LINE_STYLE_CAP_ROUND = 'rnd';
|
||||
const LINE_STYLE_CAP_FLAT = 'flat';
|
||||
const LINE_STYLE_JOIN_ROUND = 'round';
|
||||
const LINE_STYLE_JOIN_MITER = 'miter';
|
||||
const LINE_STYLE_JOIN_BEVEL = 'bevel';
|
||||
const LINE_STYLE_ARROW_TYPE_NOARROW = null;
|
||||
const LINE_STYLE_ARROW_TYPE_ARROW = 'triangle';
|
||||
const LINE_STYLE_ARROW_TYPE_OPEN = 'arrow';
|
||||
const LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth';
|
||||
const LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond';
|
||||
const LINE_STYLE_ARROW_TYPE_OVAL = 'oval';
|
||||
const LINE_STYLE_ARROW_SIZE_1 = 1;
|
||||
const LINE_STYLE_ARROW_SIZE_2 = 2;
|
||||
const LINE_STYLE_ARROW_SIZE_3 = 3;
|
||||
const LINE_STYLE_ARROW_SIZE_4 = 4;
|
||||
const LINE_STYLE_ARROW_SIZE_5 = 5;
|
||||
const LINE_STYLE_ARROW_SIZE_6 = 6;
|
||||
const LINE_STYLE_ARROW_SIZE_7 = 7;
|
||||
const LINE_STYLE_ARROW_SIZE_8 = 8;
|
||||
const LINE_STYLE_ARROW_SIZE_9 = 9;
|
||||
|
||||
const
|
||||
SHADOW_PRESETS_NOSHADOW = null;
|
||||
const SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1;
|
||||
const SHADOW_PRESETS_OUTER_BOTTOM = 2;
|
||||
const SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3;
|
||||
const SHADOW_PRESETS_OUTER_RIGHT = 4;
|
||||
const SHADOW_PRESETS_OUTER_CENTER = 5;
|
||||
const SHADOW_PRESETS_OUTER_LEFT = 6;
|
||||
const SHADOW_PRESETS_OUTER_TOP_RIGHT = 7;
|
||||
const SHADOW_PRESETS_OUTER_TOP = 8;
|
||||
const SHADOW_PRESETS_OUTER_TOP_LEFT = 9;
|
||||
const SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10;
|
||||
const SHADOW_PRESETS_INNER_BOTTOM = 11;
|
||||
const SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12;
|
||||
const SHADOW_PRESETS_INNER_RIGHT = 13;
|
||||
const SHADOW_PRESETS_INNER_CENTER = 14;
|
||||
const SHADOW_PRESETS_INNER_LEFT = 15;
|
||||
const SHADOW_PRESETS_INNER_TOP_RIGHT = 16;
|
||||
const SHADOW_PRESETS_INNER_TOP = 17;
|
||||
const SHADOW_PRESETS_INNER_TOP_LEFT = 18;
|
||||
const SHADOW_PRESETS_PERSPECTIVE_BELOW = 19;
|
||||
const SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20;
|
||||
const SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21;
|
||||
const SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22;
|
||||
const SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
|
||||
|
||||
const POINTS_WIDTH_MULTIPLIER = 12700;
|
||||
const ANGLE_MULTIPLIER = 60000; // direction and size-kx size-ky
|
||||
const PERCENTAGE_MULTIPLIER = 100000; // size sx and sy
|
||||
|
||||
/** @var bool */
|
||||
protected $objectState = false; // used only for minor gridlines
|
||||
|
||||
/** @var ?float */
|
||||
protected $glowSize;
|
||||
|
||||
/** @var ChartColor */
|
||||
protected $glowColor;
|
||||
|
||||
/** @var array */
|
||||
protected $softEdges = [
|
||||
'size' => null,
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
protected $shadowProperties = self::PRESETS_OPTIONS[0];
|
||||
|
||||
/** @var ChartColor */
|
||||
protected $shadowColor;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->lineColor = new ChartColor();
|
||||
$this->glowColor = new ChartColor();
|
||||
$this->shadowColor = new ChartColor();
|
||||
$this->shadowColor->setType(ChartColor::EXCEL_COLOR_TYPE_STANDARD);
|
||||
$this->shadowColor->setValue('black');
|
||||
$this->shadowColor->setAlpha(40);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Object State.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getObjectState()
|
||||
{
|
||||
return $this->objectState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Object State to True.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function activateObject()
|
||||
{
|
||||
$this->objectState = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function pointsToXml(float $width): string
|
||||
{
|
||||
return (string) (int) ($width * self::POINTS_WIDTH_MULTIPLIER);
|
||||
}
|
||||
|
||||
public static function xmlToPoints(string $width): float
|
||||
{
|
||||
return ((float) $width) / self::POINTS_WIDTH_MULTIPLIER;
|
||||
}
|
||||
|
||||
public static function angleToXml(float $angle): string
|
||||
{
|
||||
return (string) (int) ($angle * self::ANGLE_MULTIPLIER);
|
||||
}
|
||||
|
||||
public static function xmlToAngle(string $angle): float
|
||||
{
|
||||
return ((float) $angle) / self::ANGLE_MULTIPLIER;
|
||||
}
|
||||
|
||||
public static function tenthOfPercentToXml(float $value): string
|
||||
{
|
||||
return (string) (int) ($value * self::PERCENTAGE_MULTIPLIER);
|
||||
}
|
||||
|
||||
public static function xmlToTenthOfPercent(string $value): float
|
||||
{
|
||||
return ((float) $value) / self::PERCENTAGE_MULTIPLIER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|float|int|string $alpha
|
||||
*/
|
||||
protected function setColorProperties(?string $color, $alpha, ?string $colorType): array
|
||||
{
|
||||
return [
|
||||
'type' => $colorType,
|
||||
'value' => $color,
|
||||
'alpha' => ($alpha === null) ? null : (int) $alpha,
|
||||
];
|
||||
}
|
||||
|
||||
protected const PRESETS_OPTIONS = [
|
||||
//NONE
|
||||
0 => [
|
||||
'presets' => self::SHADOW_PRESETS_NOSHADOW,
|
||||
'effect' => null,
|
||||
//'color' => [
|
||||
// 'type' => ChartColor::EXCEL_COLOR_TYPE_STANDARD,
|
||||
// 'value' => 'black',
|
||||
// 'alpha' => 40,
|
||||
//],
|
||||
'size' => [
|
||||
'sx' => null,
|
||||
'sy' => null,
|
||||
'kx' => null,
|
||||
'ky' => null,
|
||||
],
|
||||
'blur' => null,
|
||||
'direction' => null,
|
||||
'distance' => null,
|
||||
'algn' => null,
|
||||
'rotWithShape' => null,
|
||||
],
|
||||
//OUTER
|
||||
1 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 2700000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 'tl',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
2 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 5400000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 't',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
3 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 8100000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 'tr',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
4 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'algn' => 'l',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
5 => [
|
||||
'effect' => 'outerShdw',
|
||||
'size' => [
|
||||
'sx' => 102000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'sy' => 102000 / self::PERCENTAGE_MULTIPLIER,
|
||||
],
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'algn' => 'ctr',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
6 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 10800000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 'r',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
7 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 18900000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
8 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 16200000 / self::ANGLE_MULTIPLIER,
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
9 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 38100 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 13500000 / self::ANGLE_MULTIPLIER,
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
//INNER
|
||||
10 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 2700000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
11 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 5400000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
12 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 8100000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
13 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
],
|
||||
14 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 114300 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
],
|
||||
15 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 10800000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
16 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 18900000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
17 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 16200000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
18 => [
|
||||
'effect' => 'innerShdw',
|
||||
'blur' => 63500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 50800 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 13500000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
//perspective
|
||||
19 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 152400 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 317500 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'size' => [
|
||||
'sx' => 90000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'sy' => -19000 / self::PERCENTAGE_MULTIPLIER,
|
||||
],
|
||||
'direction' => 5400000 / self::ANGLE_MULTIPLIER,
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
20 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 76200 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 18900000 / self::ANGLE_MULTIPLIER,
|
||||
'size' => [
|
||||
'sy' => 23000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'kx' => -1200000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
21 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 76200 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 13500000 / self::ANGLE_MULTIPLIER,
|
||||
'size' => [
|
||||
'sy' => 23000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'kx' => 1200000 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
22 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 76200 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 12700 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 2700000 / self::ANGLE_MULTIPLIER,
|
||||
'size' => [
|
||||
'sy' => -23000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'kx' => -800400 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
'algn' => 'bl',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
23 => [
|
||||
'effect' => 'outerShdw',
|
||||
'blur' => 76200 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'distance' => 12700 / self::POINTS_WIDTH_MULTIPLIER,
|
||||
'direction' => 8100000 / self::ANGLE_MULTIPLIER,
|
||||
'size' => [
|
||||
'sy' => -23000 / self::PERCENTAGE_MULTIPLIER,
|
||||
'kx' => 800400 / self::ANGLE_MULTIPLIER,
|
||||
],
|
||||
'algn' => 'br',
|
||||
'rotWithShape' => '0',
|
||||
],
|
||||
];
|
||||
|
||||
protected function getShadowPresetsMap(int $presetsOption): array
|
||||
{
|
||||
return self::PRESETS_OPTIONS[$presetsOption] ?? self::PRESETS_OPTIONS[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of array element.
|
||||
*
|
||||
* @param mixed $properties
|
||||
* @param mixed $elements
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getArrayElementsValue($properties, $elements)
|
||||
{
|
||||
$reference = &$properties;
|
||||
if (!is_array($elements)) {
|
||||
return $reference[$elements];
|
||||
}
|
||||
|
||||
foreach ($elements as $keys) {
|
||||
$reference = &$reference[$keys];
|
||||
}
|
||||
|
||||
return $reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Glow Properties.
|
||||
*
|
||||
* @param float $size
|
||||
* @param ?string $colorValue
|
||||
* @param ?int $colorAlpha
|
||||
* @param ?string $colorType
|
||||
*/
|
||||
public function setGlowProperties($size, $colorValue = null, $colorAlpha = null, $colorType = null): void
|
||||
{
|
||||
$this
|
||||
->activateObject()
|
||||
->setGlowSize($size);
|
||||
$this->glowColor->setColorPropertiesArray(
|
||||
[
|
||||
'value' => $colorValue,
|
||||
'type' => $colorType,
|
||||
'alpha' => $colorAlpha,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Glow Property.
|
||||
*
|
||||
* @param array|string $property
|
||||
*
|
||||
* @return null|array|float|int|string
|
||||
*/
|
||||
public function getGlowProperty($property)
|
||||
{
|
||||
$retVal = null;
|
||||
if ($property === 'size') {
|
||||
$retVal = $this->glowSize;
|
||||
} elseif ($property === 'color') {
|
||||
$retVal = [
|
||||
'value' => $this->glowColor->getColorProperty('value'),
|
||||
'type' => $this->glowColor->getColorProperty('type'),
|
||||
'alpha' => $this->glowColor->getColorProperty('alpha'),
|
||||
];
|
||||
} elseif (is_array($property) && count($property) >= 2 && $property[0] === 'color') {
|
||||
$retVal = $this->glowColor->getColorProperty($property[1]);
|
||||
}
|
||||
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Glow Color Property.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return null|int|string
|
||||
*/
|
||||
public function getGlowColor($propertyName)
|
||||
{
|
||||
return $this->glowColor->getColorProperty($propertyName);
|
||||
}
|
||||
|
||||
public function getGlowColorObject(): ChartColor
|
||||
{
|
||||
return $this->glowColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Glow Size.
|
||||
*
|
||||
* @return ?float
|
||||
*/
|
||||
public function getGlowSize()
|
||||
{
|
||||
return $this->glowSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Glow Size.
|
||||
*
|
||||
* @param ?float $size
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setGlowSize($size)
|
||||
{
|
||||
$this->glowSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Soft Edges Size.
|
||||
*
|
||||
* @param ?float $size
|
||||
*/
|
||||
public function setSoftEdges($size): void
|
||||
{
|
||||
if ($size !== null) {
|
||||
$this->activateObject();
|
||||
$this->softEdges['size'] = $size;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Soft Edges Size.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSoftEdgesSize()
|
||||
{
|
||||
return $this->softEdges['size'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setShadowProperty(string $propertyName, $value): self
|
||||
{
|
||||
$this->activateObject();
|
||||
if ($propertyName === 'color' && is_array($value)) {
|
||||
$this->shadowColor->setColorPropertiesArray($value);
|
||||
} else {
|
||||
$this->shadowProperties[$propertyName] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow Properties.
|
||||
*
|
||||
* @param int $presets
|
||||
* @param string $colorValue
|
||||
* @param string $colorType
|
||||
* @param null|float|int|string $colorAlpha
|
||||
* @param null|float $blur
|
||||
* @param null|int $angle
|
||||
* @param null|float $distance
|
||||
*/
|
||||
public function setShadowProperties($presets, $colorValue = null, $colorType = null, $colorAlpha = null, $blur = null, $angle = null, $distance = null): void
|
||||
{
|
||||
$this->activateObject()->setShadowPresetsProperties((int) $presets);
|
||||
if ($presets === 0) {
|
||||
$this->shadowColor->setType(ChartColor::EXCEL_COLOR_TYPE_STANDARD);
|
||||
$this->shadowColor->setValue('black');
|
||||
$this->shadowColor->setAlpha(40);
|
||||
}
|
||||
if ($colorValue !== null) {
|
||||
$this->shadowColor->setValue($colorValue);
|
||||
}
|
||||
if ($colorType !== null) {
|
||||
$this->shadowColor->setType($colorType);
|
||||
}
|
||||
if (is_numeric($colorAlpha)) {
|
||||
$this->shadowColor->setAlpha((int) $colorAlpha);
|
||||
}
|
||||
$this
|
||||
->setShadowBlur($blur)
|
||||
->setShadowAngle($angle)
|
||||
->setShadowDistance($distance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow Presets Properties.
|
||||
*
|
||||
* @param int $presets
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setShadowPresetsProperties($presets)
|
||||
{
|
||||
$this->shadowProperties['presets'] = $presets;
|
||||
$this->setShadowPropertiesMapValues($this->getShadowPresetsMap($presets));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected const SHADOW_ARRAY_KEYS = ['size', 'color'];
|
||||
|
||||
/**
|
||||
* Set Shadow Properties Values.
|
||||
*
|
||||
* @param mixed $reference
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setShadowPropertiesMapValues(array $propertiesMap, &$reference = null)
|
||||
{
|
||||
$base_reference = $reference;
|
||||
foreach ($propertiesMap as $property_key => $property_val) {
|
||||
if (is_array($property_val)) {
|
||||
if (in_array($property_key, self::SHADOW_ARRAY_KEYS, true)) {
|
||||
$reference = &$this->shadowProperties[$property_key];
|
||||
$this->setShadowPropertiesMapValues($property_val, $reference);
|
||||
}
|
||||
} else {
|
||||
if ($base_reference === null) {
|
||||
$this->shadowProperties[$property_key] = $property_val;
|
||||
} else {
|
||||
$reference[$property_key] = $property_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow Blur.
|
||||
*
|
||||
* @param ?float $blur
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setShadowBlur($blur)
|
||||
{
|
||||
if ($blur !== null) {
|
||||
$this->shadowProperties['blur'] = $blur;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow Angle.
|
||||
*
|
||||
* @param null|float|int|string $angle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setShadowAngle($angle)
|
||||
{
|
||||
if (is_numeric($angle)) {
|
||||
$this->shadowProperties['direction'] = $angle;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow Distance.
|
||||
*
|
||||
* @param ?float $distance
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setShadowDistance($distance)
|
||||
{
|
||||
if ($distance !== null) {
|
||||
$this->shadowProperties['distance'] = $distance;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShadowColorObject(): ChartColor
|
||||
{
|
||||
return $this->shadowColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow Property.
|
||||
*
|
||||
* @param string|string[] $elements
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function getShadowProperty($elements)
|
||||
{
|
||||
if ($elements === 'color') {
|
||||
return [
|
||||
'value' => $this->shadowColor->getValue(),
|
||||
'type' => $this->shadowColor->getType(),
|
||||
'alpha' => $this->shadowColor->getAlpha(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->getArrayElementsValue($this->shadowProperties, $elements);
|
||||
}
|
||||
|
||||
public function getShadowArray(): array
|
||||
{
|
||||
$array = $this->shadowProperties;
|
||||
if ($this->getShadowColorObject()->isUsable()) {
|
||||
$array['color'] = $this->getShadowProperty('color');
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/** @var ChartColor */
|
||||
protected $lineColor;
|
||||
|
||||
/** @var array */
|
||||
protected $lineStyleProperties = [
|
||||
'width' => null, //'9525',
|
||||
'compound' => '', //self::LINE_STYLE_COMPOUND_SIMPLE,
|
||||
'dash' => '', //self::LINE_STYLE_DASH_SOLID,
|
||||
'cap' => '', //self::LINE_STYLE_CAP_FLAT,
|
||||
'join' => '', //self::LINE_STYLE_JOIN_BEVEL,
|
||||
'arrow' => [
|
||||
'head' => [
|
||||
'type' => '', //self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => '', //self::LINE_STYLE_ARROW_SIZE_5,
|
||||
'w' => '',
|
||||
'len' => '',
|
||||
],
|
||||
'end' => [
|
||||
'type' => '', //self::LINE_STYLE_ARROW_TYPE_NOARROW,
|
||||
'size' => '', //self::LINE_STYLE_ARROW_SIZE_8,
|
||||
'w' => '',
|
||||
'len' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function copyLineStyles(self $otherProperties): void
|
||||
{
|
||||
$this->lineStyleProperties = $otherProperties->lineStyleProperties;
|
||||
$this->lineColor = $otherProperties->lineColor;
|
||||
$this->glowSize = $otherProperties->glowSize;
|
||||
$this->glowColor = $otherProperties->glowColor;
|
||||
$this->softEdges = $otherProperties->softEdges;
|
||||
$this->shadowProperties = $otherProperties->shadowProperties;
|
||||
}
|
||||
|
||||
public function getLineColor(): ChartColor
|
||||
{
|
||||
return $this->lineColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Line Color Properties.
|
||||
*
|
||||
* @param string $value
|
||||
* @param ?int $alpha
|
||||
* @param ?string $colorType
|
||||
*/
|
||||
public function setLineColorProperties($value, $alpha = null, $colorType = null): void
|
||||
{
|
||||
$this->activateObject();
|
||||
$this->lineColor->setColorPropertiesArray(
|
||||
$this->setColorProperties(
|
||||
$value,
|
||||
$alpha,
|
||||
$colorType
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Color Property.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return null|int|string
|
||||
*/
|
||||
public function getLineColorProperty($propertyName)
|
||||
{
|
||||
return $this->lineColor->getColorProperty($propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Line Style Properties.
|
||||
*
|
||||
* @param null|float|int|string $lineWidth
|
||||
* @param string $compoundType
|
||||
* @param string $dashType
|
||||
* @param string $capType
|
||||
* @param string $joinType
|
||||
* @param string $headArrowType
|
||||
* @param string $headArrowSize
|
||||
* @param string $endArrowType
|
||||
* @param string $endArrowSize
|
||||
* @param string $headArrowWidth
|
||||
* @param string $headArrowLength
|
||||
* @param string $endArrowWidth
|
||||
* @param string $endArrowLength
|
||||
*/
|
||||
public function setLineStyleProperties($lineWidth = null, $compoundType = '', $dashType = '', $capType = '', $joinType = '', $headArrowType = '', $headArrowSize = '', $endArrowType = '', $endArrowSize = '', $headArrowWidth = '', $headArrowLength = '', $endArrowWidth = '', $endArrowLength = ''): void
|
||||
{
|
||||
$this->activateObject();
|
||||
if (is_numeric($lineWidth)) {
|
||||
$this->lineStyleProperties['width'] = $lineWidth;
|
||||
}
|
||||
if ($compoundType !== '') {
|
||||
$this->lineStyleProperties['compound'] = $compoundType;
|
||||
}
|
||||
if ($dashType !== '') {
|
||||
$this->lineStyleProperties['dash'] = $dashType;
|
||||
}
|
||||
if ($capType !== '') {
|
||||
$this->lineStyleProperties['cap'] = $capType;
|
||||
}
|
||||
if ($joinType !== '') {
|
||||
$this->lineStyleProperties['join'] = $joinType;
|
||||
}
|
||||
if ($headArrowType !== '') {
|
||||
$this->lineStyleProperties['arrow']['head']['type'] = $headArrowType;
|
||||
}
|
||||
if (array_key_exists($headArrowSize, self::ARROW_SIZES)) {
|
||||
$this->lineStyleProperties['arrow']['head']['size'] = $headArrowSize;
|
||||
$this->lineStyleProperties['arrow']['head']['w'] = self::ARROW_SIZES[$headArrowSize]['w'];
|
||||
$this->lineStyleProperties['arrow']['head']['len'] = self::ARROW_SIZES[$headArrowSize]['len'];
|
||||
}
|
||||
if ($endArrowType !== '') {
|
||||
$this->lineStyleProperties['arrow']['end']['type'] = $endArrowType;
|
||||
}
|
||||
if (array_key_exists($endArrowSize, self::ARROW_SIZES)) {
|
||||
$this->lineStyleProperties['arrow']['end']['size'] = $endArrowSize;
|
||||
$this->lineStyleProperties['arrow']['end']['w'] = self::ARROW_SIZES[$endArrowSize]['w'];
|
||||
$this->lineStyleProperties['arrow']['end']['len'] = self::ARROW_SIZES[$endArrowSize]['len'];
|
||||
}
|
||||
if ($headArrowWidth !== '') {
|
||||
$this->lineStyleProperties['arrow']['head']['w'] = $headArrowWidth;
|
||||
}
|
||||
if ($headArrowLength !== '') {
|
||||
$this->lineStyleProperties['arrow']['head']['len'] = $headArrowLength;
|
||||
}
|
||||
if ($endArrowWidth !== '') {
|
||||
$this->lineStyleProperties['arrow']['end']['w'] = $endArrowWidth;
|
||||
}
|
||||
if ($endArrowLength !== '') {
|
||||
$this->lineStyleProperties['arrow']['end']['len'] = $endArrowLength;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLineStyleArray(): array
|
||||
{
|
||||
return $this->lineStyleProperties;
|
||||
}
|
||||
|
||||
public function setLineStyleArray(array $lineStyleProperties = []): self
|
||||
{
|
||||
$this->activateObject();
|
||||
$this->lineStyleProperties['width'] = $lineStyleProperties['width'] ?? null;
|
||||
$this->lineStyleProperties['compound'] = $lineStyleProperties['compound'] ?? '';
|
||||
$this->lineStyleProperties['dash'] = $lineStyleProperties['dash'] ?? '';
|
||||
$this->lineStyleProperties['cap'] = $lineStyleProperties['cap'] ?? '';
|
||||
$this->lineStyleProperties['join'] = $lineStyleProperties['join'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['head']['type'] = $lineStyleProperties['arrow']['head']['type'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['head']['size'] = $lineStyleProperties['arrow']['head']['size'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['head']['w'] = $lineStyleProperties['arrow']['head']['w'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['head']['len'] = $lineStyleProperties['arrow']['head']['len'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['end']['type'] = $lineStyleProperties['arrow']['end']['type'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['end']['size'] = $lineStyleProperties['arrow']['end']['size'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['end']['w'] = $lineStyleProperties['arrow']['end']['w'] ?? '';
|
||||
$this->lineStyleProperties['arrow']['end']['len'] = $lineStyleProperties['arrow']['end']['len'] ?? '';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setLineStyleProperty(string $propertyName, $value): self
|
||||
{
|
||||
$this->activateObject();
|
||||
$this->lineStyleProperties[$propertyName] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Style Property.
|
||||
*
|
||||
* @param array|string $elements
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineStyleProperty($elements)
|
||||
{
|
||||
return $this->getArrayElementsValue($this->lineStyleProperties, $elements);
|
||||
}
|
||||
|
||||
protected const ARROW_SIZES = [
|
||||
1 => ['w' => 'sm', 'len' => 'sm'],
|
||||
2 => ['w' => 'sm', 'len' => 'med'],
|
||||
3 => ['w' => 'sm', 'len' => 'lg'],
|
||||
4 => ['w' => 'med', 'len' => 'sm'],
|
||||
5 => ['w' => 'med', 'len' => 'med'],
|
||||
6 => ['w' => 'med', 'len' => 'lg'],
|
||||
7 => ['w' => 'lg', 'len' => 'sm'],
|
||||
8 => ['w' => 'lg', 'len' => 'med'],
|
||||
9 => ['w' => 'lg', 'len' => 'lg'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Line Style Arrow Size.
|
||||
*
|
||||
* @param int $arraySelector
|
||||
* @param string $arrayKaySelector
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getLineStyleArrowSize($arraySelector, $arrayKaySelector)
|
||||
{
|
||||
return self::ARROW_SIZES[$arraySelector][$arrayKaySelector] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Style Arrow Parameters.
|
||||
*
|
||||
* @param string $arrowSelector
|
||||
* @param string $propertySelector
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineStyleArrowParameters($arrowSelector, $propertySelector)
|
||||
{
|
||||
return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrowSelector]['size'], $propertySelector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Style Arrow Width.
|
||||
*
|
||||
* @param string $arrow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineStyleArrowWidth($arrow)
|
||||
{
|
||||
return $this->getLineStyleProperty(['arrow', $arrow, 'w']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Line Style Arrow Excel Length.
|
||||
*
|
||||
* @param string $arrow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineStyleArrowLength($arrow)
|
||||
{
|
||||
return $this->getLineStyleProperty(['arrow', $arrow, 'len']);
|
||||
}
|
||||
}
|
22
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php
vendored
Normal file
22
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Chart;
|
||||
|
||||
interface IRenderer
|
||||
{
|
||||
/**
|
||||
* IRenderer constructor.
|
||||
*/
|
||||
public function __construct(Chart $chart);
|
||||
|
||||
/**
|
||||
* Render the chart to given file (or stream).
|
||||
*
|
||||
* @param string $filename Name of the file render to
|
||||
*
|
||||
* @return bool true on success
|
||||
*/
|
||||
public function render($filename);
|
||||
}
|
40
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
vendored
Normal file
40
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
|
||||
|
||||
/**
|
||||
* Jpgraph is not oficially maintained in Composer, so the version there
|
||||
* could be out of date. For that reason, all unit test requiring Jpgraph
|
||||
* are skipped. So, do not measure code coverage for this class till that
|
||||
* is fixed.
|
||||
*
|
||||
* This implementation uses abandoned package
|
||||
* https://packagist.org/packages/jpgraph/jpgraph
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class JpGraph extends JpGraphRendererBase
|
||||
{
|
||||
protected static function init(): void
|
||||
{
|
||||
static $loaded = false;
|
||||
if ($loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
// JpGraph is no longer included with distribution, but user may install it.
|
||||
// So Scrutinizer's complaint that it can't find it is reasonable, but unfixable.
|
||||
\JpGraph\JpGraph::load();
|
||||
\JpGraph\JpGraph::module('bar');
|
||||
\JpGraph\JpGraph::module('contour');
|
||||
\JpGraph\JpGraph::module('line');
|
||||
\JpGraph\JpGraph::module('pie');
|
||||
\JpGraph\JpGraph::module('pie3d');
|
||||
\JpGraph\JpGraph::module('radar');
|
||||
\JpGraph\JpGraph::module('regstat');
|
||||
\JpGraph\JpGraph::module('scatter');
|
||||
\JpGraph\JpGraph::module('stock');
|
||||
|
||||
$loaded = true;
|
||||
}
|
||||
}
|
852
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php
vendored
Normal file
852
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php
vendored
Normal file
@ -0,0 +1,852 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
|
||||
|
||||
use AccBarPlot;
|
||||
use AccLinePlot;
|
||||
use BarPlot;
|
||||
use ContourPlot;
|
||||
use Graph;
|
||||
use GroupBarPlot;
|
||||
use LinePlot;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Chart;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PieGraph;
|
||||
use PiePlot;
|
||||
use PiePlot3D;
|
||||
use PiePlotC;
|
||||
use RadarGraph;
|
||||
use RadarPlot;
|
||||
use ScatterPlot;
|
||||
use Spline;
|
||||
use StockPlot;
|
||||
|
||||
/**
|
||||
* Base class for different Jpgraph implementations as charts renderer.
|
||||
*/
|
||||
abstract class JpGraphRendererBase implements IRenderer
|
||||
{
|
||||
private static $width = 640;
|
||||
|
||||
private static $height = 480;
|
||||
|
||||
private static $colourSet = [
|
||||
'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1',
|
||||
'darkmagenta', 'coral', 'dodgerblue3', 'eggplant',
|
||||
'mediumblue', 'magenta', 'sandybrown', 'cyan',
|
||||
'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen',
|
||||
'goldenrod2',
|
||||
];
|
||||
|
||||
private static $markSet;
|
||||
|
||||
private $chart;
|
||||
|
||||
private $graph;
|
||||
|
||||
private static $plotColour = 0;
|
||||
|
||||
private static $plotMark = 0;
|
||||
|
||||
/**
|
||||
* Create a new jpgraph.
|
||||
*/
|
||||
public function __construct(Chart $chart)
|
||||
{
|
||||
static::init();
|
||||
$this->graph = null;
|
||||
$this->chart = $chart;
|
||||
|
||||
self::$markSet = [
|
||||
'diamond' => MARK_DIAMOND,
|
||||
'square' => MARK_SQUARE,
|
||||
'triangle' => MARK_UTRIANGLE,
|
||||
'x' => MARK_X,
|
||||
'star' => MARK_STAR,
|
||||
'dot' => MARK_FILLEDCIRCLE,
|
||||
'dash' => MARK_DTRIANGLE,
|
||||
'circle' => MARK_CIRCLE,
|
||||
'plus' => MARK_CROSS,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overriden in descendants to do real JpGraph library initialization.
|
||||
*/
|
||||
abstract protected static function init(): void;
|
||||
|
||||
private function formatPointMarker($seriesPlot, $markerID)
|
||||
{
|
||||
$plotMarkKeys = array_keys(self::$markSet);
|
||||
if ($markerID === null) {
|
||||
// Use default plot marker (next marker in the series)
|
||||
self::$plotMark %= count(self::$markSet);
|
||||
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
|
||||
} elseif ($markerID !== 'none') {
|
||||
// Use specified plot marker (if it exists)
|
||||
if (isset(self::$markSet[$markerID])) {
|
||||
$seriesPlot->mark->SetType(self::$markSet[$markerID]);
|
||||
} else {
|
||||
// If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
|
||||
self::$plotMark %= count(self::$markSet);
|
||||
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
|
||||
}
|
||||
} else {
|
||||
// Hide plot marker
|
||||
$seriesPlot->mark->Hide();
|
||||
}
|
||||
$seriesPlot->mark->SetColor(self::$colourSet[self::$plotColour]);
|
||||
$seriesPlot->mark->SetFillColor(self::$colourSet[self::$plotColour]);
|
||||
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||
|
||||
return $seriesPlot;
|
||||
}
|
||||
|
||||
private function formatDataSetLabels($groupID, $datasetLabels, $rotation = '')
|
||||
{
|
||||
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode() ?? '';
|
||||
// Retrieve any label formatting code
|
||||
$datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
|
||||
|
||||
$testCurrentIndex = 0;
|
||||
foreach ($datasetLabels as $i => $datasetLabel) {
|
||||
if (is_array($datasetLabel)) {
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels[$i] = implode(' ', $datasetLabel);
|
||||
} else {
|
||||
$datasetLabel = array_reverse($datasetLabel);
|
||||
$datasetLabels[$i] = implode("\n", $datasetLabel);
|
||||
}
|
||||
} else {
|
||||
// Format labels according to any formatting code
|
||||
if ($datasetLabelFormatCode !== null) {
|
||||
$datasetLabels[$i] = NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode);
|
||||
}
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
return $datasetLabels;
|
||||
}
|
||||
|
||||
private function percentageSumCalculation($groupID, $seriesCount)
|
||||
{
|
||||
$sumValues = [];
|
||||
// Adjust our values to a percentage value across all series in the group
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
if ($i == 0) {
|
||||
$sumValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
} else {
|
||||
$nextValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
foreach ($nextValues as $k => $value) {
|
||||
if (isset($sumValues[$k])) {
|
||||
$sumValues[$k] += $value;
|
||||
} else {
|
||||
$sumValues[$k] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sumValues;
|
||||
}
|
||||
|
||||
private function percentageAdjustValues($dataValues, $sumValues)
|
||||
{
|
||||
foreach ($dataValues as $k => $dataValue) {
|
||||
$dataValues[$k] = $dataValue / $sumValues[$k] * 100;
|
||||
}
|
||||
|
||||
return $dataValues;
|
||||
}
|
||||
|
||||
private function getCaption($captionElement)
|
||||
{
|
||||
// Read any caption
|
||||
$caption = ($captionElement !== null) ? $captionElement->getCaption() : null;
|
||||
// Test if we have a title caption to display
|
||||
if ($caption !== null) {
|
||||
// If we do, it could be a plain string or an array
|
||||
if (is_array($caption)) {
|
||||
// Implode an array to a plain string
|
||||
$caption = implode('', $caption);
|
||||
}
|
||||
}
|
||||
|
||||
return $caption;
|
||||
}
|
||||
|
||||
private function renderTitle(): void
|
||||
{
|
||||
$title = $this->getCaption($this->chart->getTitle());
|
||||
if ($title !== null) {
|
||||
$this->graph->title->Set($title);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderLegend(): void
|
||||
{
|
||||
$legend = $this->chart->getLegend();
|
||||
if ($legend !== null) {
|
||||
$legendPosition = $legend->getPosition();
|
||||
switch ($legendPosition) {
|
||||
case 'r':
|
||||
$this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right
|
||||
$this->graph->legend->SetColumns(1);
|
||||
|
||||
break;
|
||||
case 'l':
|
||||
$this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left
|
||||
$this->graph->legend->SetColumns(1);
|
||||
|
||||
break;
|
||||
case 't':
|
||||
$this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top
|
||||
|
||||
break;
|
||||
case 'b':
|
||||
$this->graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); // bottom
|
||||
|
||||
break;
|
||||
default:
|
||||
$this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right
|
||||
$this->graph->legend->SetColumns(1);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->graph->legend->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private function renderCartesianPlotArea($type = 'textlin'): void
|
||||
{
|
||||
$this->graph = new Graph(self::$width, self::$height);
|
||||
$this->graph->SetScale($type);
|
||||
|
||||
$this->renderTitle();
|
||||
|
||||
// Rotate for bar rather than column chart
|
||||
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
|
||||
$reverse = $rotation == 'bar';
|
||||
|
||||
$xAxisLabel = $this->chart->getXAxisLabel();
|
||||
if ($xAxisLabel !== null) {
|
||||
$title = $this->getCaption($xAxisLabel);
|
||||
if ($title !== null) {
|
||||
$this->graph->xaxis->SetTitle($title, 'center');
|
||||
$this->graph->xaxis->title->SetMargin(35);
|
||||
if ($reverse) {
|
||||
$this->graph->xaxis->title->SetAngle(90);
|
||||
$this->graph->xaxis->title->SetMargin(90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$yAxisLabel = $this->chart->getYAxisLabel();
|
||||
if ($yAxisLabel !== null) {
|
||||
$title = $this->getCaption($yAxisLabel);
|
||||
if ($title !== null) {
|
||||
$this->graph->yaxis->SetTitle($title, 'center');
|
||||
if ($reverse) {
|
||||
$this->graph->yaxis->title->SetAngle(0);
|
||||
$this->graph->yaxis->title->SetMargin(-55);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function renderPiePlotArea(): void
|
||||
{
|
||||
$this->graph = new PieGraph(self::$width, self::$height);
|
||||
|
||||
$this->renderTitle();
|
||||
}
|
||||
|
||||
private function renderRadarPlotArea(): void
|
||||
{
|
||||
$this->graph = new RadarGraph(self::$width, self::$height);
|
||||
$this->graph->SetScale('lin');
|
||||
|
||||
$this->renderTitle();
|
||||
}
|
||||
|
||||
private function renderPlotLine($groupID, $filled = false, $combination = false): void
|
||||
{
|
||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$index = array_keys($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder())[0];
|
||||
$labelCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($index)->getPointCount();
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels);
|
||||
$this->graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = [];
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||
} else {
|
||||
$sumValues = [];
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$index = array_keys($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder())[$i];
|
||||
$dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($index)->getDataValues();
|
||||
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($index)->getPointMarker();
|
||||
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->percentageAdjustValues($dataValues, $sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach ($dataValues as $k => $dataValue) {
|
||||
while ($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
$seriesPlot = new LinePlot($dataValues);
|
||||
if ($combination) {
|
||||
$seriesPlot->SetBarCenter();
|
||||
}
|
||||
|
||||
if ($filled) {
|
||||
$seriesPlot->SetFilled(true);
|
||||
$seriesPlot->SetColor('black');
|
||||
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]);
|
||||
} else {
|
||||
// Set the appropriate plot marker
|
||||
$this->formatPointMarker($seriesPlot, $marker);
|
||||
}
|
||||
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$seriesPlots[] = $seriesPlot;
|
||||
}
|
||||
|
||||
if ($grouping == 'standard') {
|
||||
$groupPlot = $seriesPlots;
|
||||
} else {
|
||||
$groupPlot = new AccLinePlot($seriesPlots);
|
||||
}
|
||||
$this->graph->Add($groupPlot);
|
||||
}
|
||||
|
||||
private function renderPlotBar($groupID, $dimensions = '2d'): void
|
||||
{
|
||||
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
||||
// Rotate for bar rather than column chart
|
||||
if (($groupID == 0) && ($rotation == 'bar')) {
|
||||
$this->graph->Set90AndMargin();
|
||||
}
|
||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$index = array_keys($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder())[0];
|
||||
$labelCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($index)->getPointCount();
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $rotation);
|
||||
// Rotate for bar rather than column chart
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels = array_reverse($datasetLabels);
|
||||
$this->graph->yaxis->SetPos('max');
|
||||
$this->graph->yaxis->SetLabelAlign('center', 'top');
|
||||
$this->graph->yaxis->SetLabelSide(SIDE_RIGHT);
|
||||
}
|
||||
$this->graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = [];
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||
} else {
|
||||
$sumValues = [];
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($j = 0; $j < $seriesCount; ++$j) {
|
||||
$index = array_keys($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder())[$j];
|
||||
$dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($index)->getDataValues();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->percentageAdjustValues($dataValues, $sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach ($dataValues as $k => $dataValue) {
|
||||
while ($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
// Reverse the $dataValues order for bar rather than column chart
|
||||
if ($rotation == 'bar') {
|
||||
$dataValues = array_reverse($dataValues);
|
||||
}
|
||||
$seriesPlot = new BarPlot($dataValues);
|
||||
$seriesPlot->SetColor('black');
|
||||
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]);
|
||||
if ($dimensions == '3d') {
|
||||
$seriesPlot->SetShadow();
|
||||
}
|
||||
if (!$this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
|
||||
$dataLabel = '';
|
||||
} else {
|
||||
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
|
||||
}
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$seriesPlots[] = $seriesPlot;
|
||||
}
|
||||
// Reverse the plot order for bar rather than column chart
|
||||
if (($rotation == 'bar') && ($grouping != 'percentStacked')) {
|
||||
$seriesPlots = array_reverse($seriesPlots);
|
||||
}
|
||||
|
||||
if ($grouping == 'clustered') {
|
||||
$groupPlot = new GroupBarPlot($seriesPlots);
|
||||
} elseif ($grouping == 'standard') {
|
||||
$groupPlot = new GroupBarPlot($seriesPlots);
|
||||
} else {
|
||||
$groupPlot = new AccBarPlot($seriesPlots);
|
||||
if ($dimensions == '3d') {
|
||||
$groupPlot->SetShadow();
|
||||
}
|
||||
}
|
||||
|
||||
$this->graph->Add($groupPlot);
|
||||
}
|
||||
|
||||
private function renderPlotScatter($groupID, $bubble): void
|
||||
{
|
||||
$scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
foreach ($dataValuesY as $k => $dataValueY) {
|
||||
$dataValuesY[$k] = $k;
|
||||
}
|
||||
|
||||
$seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
|
||||
if ($scatterStyle == 'lineMarker') {
|
||||
$seriesPlot->SetLinkPoints();
|
||||
$seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]);
|
||||
} elseif ($scatterStyle == 'smoothMarker') {
|
||||
$spline = new Spline($dataValuesY, $dataValuesX);
|
||||
[$splineDataY, $splineDataX] = $spline->Get(count($dataValuesX) * self::$width / 20);
|
||||
$lplot = new LinePlot($splineDataX, $splineDataY);
|
||||
$lplot->SetColor(self::$colourSet[self::$plotColour]);
|
||||
|
||||
$this->graph->Add($lplot);
|
||||
}
|
||||
|
||||
if ($bubble) {
|
||||
$this->formatPointMarker($seriesPlot, 'dot');
|
||||
$seriesPlot->mark->SetColor('black');
|
||||
$seriesPlot->mark->SetSize($bubbleSize);
|
||||
} else {
|
||||
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
$this->formatPointMarker($seriesPlot, $marker);
|
||||
}
|
||||
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderPlotRadar($groupID): void
|
||||
{
|
||||
$radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
|
||||
$dataValues = [];
|
||||
foreach ($dataValuesY as $k => $dataValueY) {
|
||||
$dataValues[$k] = implode(' ', array_reverse($dataValueY));
|
||||
}
|
||||
$tmp = array_shift($dataValues);
|
||||
$dataValues[] = $tmp;
|
||||
$tmp = array_shift($dataValuesX);
|
||||
$dataValuesX[] = $tmp;
|
||||
|
||||
$this->graph->SetTitles(array_reverse($dataValues));
|
||||
|
||||
$seriesPlot = new RadarPlot(array_reverse($dataValuesX));
|
||||
|
||||
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||
if ($radarStyle == 'filled') {
|
||||
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour]);
|
||||
}
|
||||
$this->formatPointMarker($seriesPlot, $marker);
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderPlotContour($groupID): void
|
||||
{
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
|
||||
$dataValues = [];
|
||||
// Loop through each data series in turn
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
$dataValues[$i] = $dataValuesX;
|
||||
}
|
||||
$seriesPlot = new ContourPlot($dataValues);
|
||||
|
||||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
|
||||
private function renderPlotStock($groupID): void
|
||||
{
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
||||
|
||||
$dataValues = [];
|
||||
// Loop through each data series in turn and build the plot arrays
|
||||
foreach ($plotOrder as $i => $v) {
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v);
|
||||
if ($dataValuesX === false) {
|
||||
continue;
|
||||
}
|
||||
$dataValuesX = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
|
||||
foreach ($dataValuesX as $j => $dataValueX) {
|
||||
$dataValues[$plotOrder[$i]][$j] = $dataValueX;
|
||||
}
|
||||
}
|
||||
if (empty($dataValues)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dataValuesPlot = [];
|
||||
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
||||
$jMax = count($dataValues[0]);
|
||||
for ($j = 0; $j < $jMax; ++$j) {
|
||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesPlot[] = $dataValues[$i][$j] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the x-axis labels
|
||||
$labelCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount();
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels);
|
||||
$this->graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
$seriesPlot = new StockPlot($dataValuesPlot);
|
||||
$seriesPlot->SetWidth(20);
|
||||
|
||||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
|
||||
private function renderAreaChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotLine($i, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderLineChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotLine($i, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderBarChart($groupCount, $dimensions = '2d'): void
|
||||
{
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotBar($i, $dimensions);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderScatterChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea('linlin');
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotScatter($i, false);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderBubbleChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea('linlin');
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotScatter($i, true);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false): void
|
||||
{
|
||||
$this->renderPiePlotArea();
|
||||
|
||||
$iLimit = ($multiplePlots) ? $groupCount : 1;
|
||||
for ($groupID = 0; $groupID < $iLimit; ++$groupID) {
|
||||
$exploded = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
$datasetLabels = [];
|
||||
if ($groupID == 0) {
|
||||
$labelCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount();
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels);
|
||||
}
|
||||
}
|
||||
|
||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
// For pie charts, we only display the first series: doughnut charts generally display all series
|
||||
$jLimit = ($multiplePlots) ? $seriesCount : 1;
|
||||
// Loop through each data series in turn
|
||||
for ($j = 0; $j < $jLimit; ++$j) {
|
||||
$dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach ($dataValues as $k => $dataValue) {
|
||||
while ($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
if ($dimensions == '3d') {
|
||||
$seriesPlot = new PiePlot3D($dataValues);
|
||||
} else {
|
||||
if ($doughnut) {
|
||||
$seriesPlot = new PiePlotC($dataValues);
|
||||
} else {
|
||||
$seriesPlot = new PiePlot($dataValues);
|
||||
}
|
||||
}
|
||||
|
||||
if ($multiplePlots) {
|
||||
$seriesPlot->SetSize(($jLimit - $j) / ($jLimit * 4));
|
||||
}
|
||||
|
||||
if ($doughnut && method_exists($seriesPlot, 'SetMidColor')) {
|
||||
$seriesPlot->SetMidColor('white');
|
||||
}
|
||||
|
||||
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||
if (count($datasetLabels) > 0) {
|
||||
$seriesPlot->SetLabels(array_fill(0, count($datasetLabels), ''));
|
||||
}
|
||||
if ($dimensions != '3d') {
|
||||
$seriesPlot->SetGuideLines(false);
|
||||
}
|
||||
if ($j == 0) {
|
||||
if ($exploded) {
|
||||
$seriesPlot->ExplodeAll();
|
||||
}
|
||||
$seriesPlot->SetLegends($datasetLabels);
|
||||
}
|
||||
|
||||
$this->graph->Add($seriesPlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function renderRadarChart($groupCount): void
|
||||
{
|
||||
$this->renderRadarPlotArea();
|
||||
|
||||
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
||||
$this->renderPlotRadar($groupID);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderStockChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea('intint');
|
||||
|
||||
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
||||
$this->renderPlotStock($groupID);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderContourChart($groupCount): void
|
||||
{
|
||||
$this->renderCartesianPlotArea('intint');
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->renderPlotContour($i);
|
||||
}
|
||||
}
|
||||
|
||||
private function renderCombinationChart($groupCount, $outputDestination)
|
||||
{
|
||||
$this->renderCartesianPlotArea();
|
||||
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$dimensions = null;
|
||||
$chartType = $this->chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
switch ($chartType) {
|
||||
case 'area3DChart':
|
||||
case 'areaChart':
|
||||
$this->renderPlotLine($i, true, true);
|
||||
|
||||
break;
|
||||
case 'bar3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'barChart':
|
||||
$this->renderPlotBar($i, $dimensions);
|
||||
|
||||
break;
|
||||
case 'line3DChart':
|
||||
case 'lineChart':
|
||||
$this->renderPlotLine($i, false, true);
|
||||
|
||||
break;
|
||||
case 'scatterChart':
|
||||
$this->renderPlotScatter($i, false);
|
||||
|
||||
break;
|
||||
case 'bubbleChart':
|
||||
$this->renderPlotScatter($i, true);
|
||||
|
||||
break;
|
||||
default:
|
||||
$this->graph = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->renderLegend();
|
||||
|
||||
$this->graph->Stroke($outputDestination);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function render($outputDestination)
|
||||
{
|
||||
self::$plotColour = 0;
|
||||
|
||||
$groupCount = $this->chart->getPlotArea()->getPlotGroupCount();
|
||||
|
||||
$dimensions = null;
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
} else {
|
||||
$chartTypes = [];
|
||||
for ($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $this->chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$chartTypes = array_unique($chartTypes);
|
||||
if (count($chartTypes) == 1) {
|
||||
$chartType = array_pop($chartTypes);
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo 'Chart is not yet implemented<br />';
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return $this->renderCombinationChart($groupCount, $outputDestination);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($chartType) {
|
||||
case 'area3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'areaChart':
|
||||
$this->renderAreaChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'bar3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'barChart':
|
||||
$this->renderBarChart($groupCount, $dimensions);
|
||||
|
||||
break;
|
||||
case 'line3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'lineChart':
|
||||
$this->renderLineChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'pie3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'pieChart':
|
||||
$this->renderPieChart($groupCount, $dimensions, false, false);
|
||||
|
||||
break;
|
||||
case 'doughnut3DChart':
|
||||
$dimensions = '3d';
|
||||
// no break
|
||||
case 'doughnutChart':
|
||||
$this->renderPieChart($groupCount, $dimensions, true, true);
|
||||
|
||||
break;
|
||||
case 'scatterChart':
|
||||
$this->renderScatterChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'bubbleChart':
|
||||
$this->renderBubbleChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'radarChart':
|
||||
$this->renderRadarChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'surface3DChart':
|
||||
case 'surfaceChart':
|
||||
$this->renderContourChart($groupCount);
|
||||
|
||||
break;
|
||||
case 'stockChart':
|
||||
$this->renderStockChart($groupCount);
|
||||
|
||||
break;
|
||||
default:
|
||||
echo $chartType . ' is not yet implemented<br />';
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->renderLegend();
|
||||
|
||||
$this->graph->Stroke($outputDestination);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
36
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php
vendored
Normal file
36
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart\Renderer;
|
||||
|
||||
/**
|
||||
* Jpgraph is not oficially maintained in Composer.
|
||||
*
|
||||
* This renderer implementation uses package
|
||||
* https://packagist.org/packages/mitoteam/jpgraph
|
||||
*
|
||||
* This package is up to date for August 2022 and has PHP 8.1 support.
|
||||
*/
|
||||
class MtJpGraphRenderer extends JpGraphRendererBase
|
||||
{
|
||||
protected static function init(): void
|
||||
{
|
||||
static $loaded = false;
|
||||
if ($loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
\mitoteam\jpgraph\MtJpGraph::load([
|
||||
'bar',
|
||||
'contour',
|
||||
'line',
|
||||
'pie',
|
||||
'pie3d',
|
||||
'radar',
|
||||
'regstat',
|
||||
'scatter',
|
||||
'stock',
|
||||
]);
|
||||
|
||||
$loaded = true;
|
||||
}
|
||||
}
|
23
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt
vendored
Normal file
23
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
ChartDirector
|
||||
https://www.advsofteng.com/cdphp.html
|
||||
|
||||
GraPHPite
|
||||
http://graphpite.sourceforge.net/
|
||||
|
||||
JpGraph
|
||||
https://jpgraph.net/
|
||||
Used composer packages:
|
||||
https://packagist.org/packages/jpgraph/jpgraph (\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph)
|
||||
https://packagist.org/packages/mitoteam/jpgraph (\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer)
|
||||
|
||||
LibChart
|
||||
https://naku.dohcrew.com/libchart/pages/introduction/
|
||||
|
||||
pChart
|
||||
http://pchart.sourceforge.net/
|
||||
|
||||
TeeChart
|
||||
https://www.steema.com/
|
||||
|
||||
PHPGraphLib
|
||||
http://www.ebrueggeman.com/phpgraphlib
|
85
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php
vendored
Normal file
85
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
|
||||
class Title
|
||||
{
|
||||
/**
|
||||
* Title Caption.
|
||||
*
|
||||
* @var array|RichText|string
|
||||
*/
|
||||
private $caption = '';
|
||||
|
||||
/**
|
||||
* Title Layout.
|
||||
*
|
||||
* @var ?Layout
|
||||
*/
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* Create a new Title.
|
||||
*
|
||||
* @param array|RichText|string $caption
|
||||
*/
|
||||
public function __construct($caption = '', ?Layout $layout = null)
|
||||
{
|
||||
$this->caption = $caption;
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get caption.
|
||||
*
|
||||
* @return array|RichText|string
|
||||
*/
|
||||
public function getCaption()
|
||||
{
|
||||
return $this->caption;
|
||||
}
|
||||
|
||||
public function getCaptionText(): string
|
||||
{
|
||||
$caption = $this->caption;
|
||||
if (is_string($caption)) {
|
||||
return $caption;
|
||||
}
|
||||
if ($caption instanceof RichText) {
|
||||
return $caption->getPlainText();
|
||||
}
|
||||
$retVal = '';
|
||||
foreach ($caption as $textx) {
|
||||
/** @var RichText|string */
|
||||
$text = $textx;
|
||||
if ($text instanceof RichText) {
|
||||
$retVal .= $text->getPlainText();
|
||||
} else {
|
||||
$retVal .= $text;
|
||||
}
|
||||
}
|
||||
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set caption.
|
||||
*
|
||||
* @param array|RichText|string $caption
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCaption($caption)
|
||||
{
|
||||
$this->caption = $caption;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLayout(): ?Layout
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
}
|
226
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/TrendLine.php
vendored
Normal file
226
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/TrendLine.php
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
<?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,
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $trendLineType = 'linear'; // TRENDLINE_LINEAR
|
||||
|
||||
/** @var int */
|
||||
private $order = 2;
|
||||
|
||||
/** @var int */
|
||||
private $period = 3;
|
||||
|
||||
/** @var bool */
|
||||
private $dispRSqr = false;
|
||||
|
||||
/** @var bool */
|
||||
private $dispEq = false;
|
||||
|
||||
/** @var string */
|
||||
private $name = '';
|
||||
|
||||
/** @var float */
|
||||
private $backward = 0.0;
|
||||
|
||||
/** @var float */
|
||||
private $forward = 0.0;
|
||||
|
||||
/** @var float */
|
||||
private $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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user