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 = (bool) $smoothLine; $this->plotStyle = $plotStyle; if ($plotDirection === null) { $plotDirection = self::DIRECTION_COL; } $this->plotDirection = $plotDirection; } /** * Get Plot Type. */ public function getPlotType(): ?string { return $this->plotType; } /** * Set Plot Type. * * @return $this */ public function setPlotType(string $plotType): static { $this->plotType = $plotType; return $this; } /** * Get Plot Grouping Type. */ public function getPlotGrouping(): ?string { return $this->plotGrouping; } /** * Set Plot Grouping Type. * * @return $this */ public function setPlotGrouping(string $groupingType): static { $this->plotGrouping = $groupingType; return $this; } /** * Get Plot Direction. */ public function getPlotDirection(): string { return $this->plotDirection; } /** * Set Plot Direction. * * @return $this */ public function setPlotDirection(string $plotDirection): static { $this->plotDirection = $plotDirection; return $this; } /** * Get Plot Order. * * @return int[] */ public function getPlotOrder(): array { return $this->plotOrder; } /** * Get Plot Labels. * * @return DataSeriesValues[] */ public function getPlotLabels(): array { return $this->plotLabel; } /** * Get Plot Label by Index. * * @return DataSeriesValues|false */ public function getPlotLabelByIndex(int $index): bool|DataSeriesValues { $keys = array_keys($this->plotLabel); if (in_array($index, $keys)) { return $this->plotLabel[$index]; } return false; } /** * Get Plot Categories. * * @return DataSeriesValues[] */ public function getPlotCategories(): array { return $this->plotCategory; } /** * Get Plot Category by Index. * * @return DataSeriesValues|false */ public function getPlotCategoryByIndex(int $index): bool|DataSeriesValues { $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. */ public function getPlotStyle(): ?string { return $this->plotStyle; } /** * Set Plot Style. * * @return $this */ public function setPlotStyle(?string $plotStyle): static { $this->plotStyle = $plotStyle; return $this; } /** * Get Plot Values. * * @return DataSeriesValues[] */ public function getPlotValues(): array { return $this->plotValues; } /** * Get Plot Values by Index. * * @return DataSeriesValues|false */ public function getPlotValuesByIndex(int $index): bool|DataSeriesValues { $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. */ public function getPlotSeriesCount(): int { return count($this->plotValues); } /** * Get Smooth Line. */ public function getSmoothLine(): bool { return $this->smoothLine; } /** * Set Smooth Line. * * @return $this */ public function setSmoothLine(bool $smoothLine): static { $this->smoothLine = $smoothLine; return $this; } public function refresh(Worksheet $worksheet): void { foreach ($this->plotValues as $plotValues) { $plotValues->refresh($worksheet, true); } foreach ($this->plotLabel as $plotValues) { $plotValues->refresh($worksheet, true); } foreach ($this->plotCategory as $plotValues) { $plotValues->refresh($worksheet, false); } } /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ public function __clone() { $plotLabels = $this->plotLabel; $this->plotLabel = []; foreach ($plotLabels as $plotLabel) { $this->plotLabel[] = $plotLabel; } $plotCategories = $this->plotCategory; $this->plotCategory = []; foreach ($plotCategories as $plotCategory) { $this->plotCategory[] = clone $plotCategory; } $plotValues = $this->plotValues; $this->plotValues = []; foreach ($plotValues as $plotValue) { $this->plotValues[] = clone $plotValue; } $plotBubbleSizes = $this->plotBubbleSizes; $this->plotBubbleSizes = []; foreach ($plotBubbleSizes as $plotBubbleSize) { $this->plotBubbleSizes[] = clone $plotBubbleSize; } } }