Skip to content

Commit c22c6df

Browse files
authored
Charts Additional Support for Layout and DataSeriesValues (#2922)
* Charts Additional Support for Layout and DataSeriesValues The dLbls tag in more or less the Xml equivalent of the Layout class. It is currently read and written only for the Chart as a whole. It can, however, also be applied to DataSeriesValues. Further it has properties which are currently ignored, namely label fill, border, and font colors. All of these omissions are handled by this PR. There are other properties which can be applied to the labels, but, for now, only the 3 colors are added. DataSeriesValues can have effects (like glow). Since DSV now descends from Properties, these are already supported, but support needs to be added to the Reader and Writer to handle them. This PR adds the support. * Add Unit Tests Based on new samples. * Minor Improvements Slight increase to coverage.
1 parent faf6d81 commit c22c6df

File tree

14 files changed

+493
-331
lines changed

14 files changed

+493
-331
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
4949
- Time interval formatting [Issue #2768](https://github.com/PHPOffice/PhpSpreadsheet/issues/2768) [PR #2772](https://github.com/PHPOffice/PhpSpreadsheet/pull/2772)
5050
- Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](https://github.com/PHPOffice/PhpSpreadsheet/pull/2788)
5151
- Html Reader converting cell containing 0 to null string [Issue #2810](https://github.com/PHPOffice/PhpSpreadsheet/issues/2810) [PR #2813](https://github.com/PHPOffice/PhpSpreadsheet/pull/2813)
52-
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [Issue #2219](https://github.com/PHPOffice/PhpSpreadsheet/issues/2219) [Issue #2863](https://github.com/PHPOffice/PhpSpreadsheet/issues/2863) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852) [PR #2856](https://github.com/PHPOffice/PhpSpreadsheet/pull/2856) [PR #2865](https://github.com/PHPOffice/PhpSpreadsheet/pull/2865) [PR #2872](https://github.com/PHPOffice/PhpSpreadsheet/pull/2872) [PR #2879](https://github.com/PHPOffice/PhpSpreadsheet/pull/2879) [PR #2898](https://github.com/PHPOffice/PhpSpreadsheet/pull/2898) [PR #2906](https://github.com/PHPOffice/PhpSpreadsheet/pull/2906)
52+
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [Issue #2219](https://github.com/PHPOffice/PhpSpreadsheet/issues/2219) [Issue #2863](https://github.com/PHPOffice/PhpSpreadsheet/issues/2863) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852) [PR #2856](https://github.com/PHPOffice/PhpSpreadsheet/pull/2856) [PR #2865](https://github.com/PHPOffice/PhpSpreadsheet/pull/2865) [PR #2872](https://github.com/PHPOffice/PhpSpreadsheet/pull/2872) [PR #2879](https://github.com/PHPOffice/PhpSpreadsheet/pull/2879) [PR #2898](https://github.com/PHPOffice/PhpSpreadsheet/pull/2898) [PR #2906](https://github.com/PHPOffice/PhpSpreadsheet/pull/2906) [PR #2922](https://github.com/PHPOffice/PhpSpreadsheet/pull/2922)
5353
- Calculating Engine regexp for Column/Row references when there are multiple quoted worksheet references in the formula [Issue #2874](https://github.com/PHPOffice/PhpSpreadsheet/issues/2874) [PR #2899](https://github.com/PHPOffice/PhpSpreadsheet/pull/2899)
5454

5555
## 1.23.0 - 2022-04-24

phpstan-baseline.neon

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,46 +1185,6 @@ parameters:
11851185
count: 1
11861186
path: src/PhpSpreadsheet/Chart/PlotArea.php
11871187

1188-
-
1189-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getArrayElementsValue\\(\\) has no return type specified\\.$#"
1190-
count: 1
1191-
path: src/PhpSpreadsheet/Chart/Properties.php
1192-
1193-
-
1194-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getArrayElementsValue\\(\\) has parameter \\$elements with no type specified\\.$#"
1195-
count: 1
1196-
path: src/PhpSpreadsheet/Chart/Properties.php
1197-
1198-
-
1199-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getArrayElementsValue\\(\\) has parameter \\$properties with no type specified\\.$#"
1200-
count: 1
1201-
path: src/PhpSpreadsheet/Chart/Properties.php
1202-
1203-
-
1204-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getLineStyleArrowSize\\(\\) has no return type specified\\.$#"
1205-
count: 1
1206-
path: src/PhpSpreadsheet/Chart/Properties.php
1207-
1208-
-
1209-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getLineStyleArrowSize\\(\\) has parameter \\$arrayKaySelector with no type specified\\.$#"
1210-
count: 1
1211-
path: src/PhpSpreadsheet/Chart/Properties.php
1212-
1213-
-
1214-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getLineStyleArrowSize\\(\\) has parameter \\$arraySelector with no type specified\\.$#"
1215-
count: 1
1216-
path: src/PhpSpreadsheet/Chart/Properties.php
1217-
1218-
-
1219-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getShadowPresetsMap\\(\\) has no return type specified\\.$#"
1220-
count: 1
1221-
path: src/PhpSpreadsheet/Chart/Properties.php
1222-
1223-
-
1224-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Properties\\:\\:getShadowPresetsMap\\(\\) has parameter \\$presetsOption with no type specified\\.$#"
1225-
count: 1
1226-
path: src/PhpSpreadsheet/Chart/Properties.php
1227-
12281188
-
12291189
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\:\\:\\$layout \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\|null\\.$#"
12301190
count: 1
@@ -4020,61 +3980,6 @@ parameters:
40203980
count: 1
40213981
path: src/PhpSpreadsheet/Writer/Xlsx.php
40223982

4023-
-
4024-
message: "#^Parameter \\#1 \\$plotSeriesValues of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:writeBubbles\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues\\|null, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues\\|false given\\.$#"
4025-
count: 1
4026-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4027-
4028-
-
4029-
message: "#^Parameter \\#1 \\$rawTextData of method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\XMLWriter\\:\\:writeRawData\\(\\) expects array\\<string\\>\\|string\\|null, int given\\.$#"
4030-
count: 1
4031-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4032-
4033-
-
4034-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, float given\\.$#"
4035-
count: 6
4036-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4037-
4038-
-
4039-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, float\\|int given\\.$#"
4040-
count: 4
4041-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4042-
4043-
-
4044-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int given\\.$#"
4045-
count: 41
4046-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4047-
4048-
-
4049-
message: "#^Parameter \\#6 \\$yAxis of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:writeCategoryAxis\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\|null given\\.$#"
4050-
count: 1
4051-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4052-
4053-
-
4054-
message: "#^Parameter \\#7 \\$xAxis of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:writeValueAxis\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\|null given\\.$#"
4055-
count: 2
4056-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4057-
4058-
-
4059-
message: "#^Parameter \\#8 \\$majorGridlines of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:writeValueAxis\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\|null given\\.$#"
4060-
count: 2
4061-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4062-
4063-
-
4064-
message: "#^Parameter \\#9 \\$minorGridlines of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:writeValueAxis\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\|null given\\.$#"
4065-
count: 2
4066-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4067-
4068-
-
4069-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:\\$calculateCellValues has no type specified\\.$#"
4070-
count: 1
4071-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4072-
4073-
-
4074-
message: "#^Strict comparison using \\=\\=\\= between PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\PlotArea and null will always evaluate to false\\.$#"
4075-
count: 1
4076-
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
4077-
40783983
-
40793984
message: "#^Parameter \\#1 \\$string of function substr expects string, int given\\.$#"
40803985
count: 1

samples/Chart/33_Chart_create_bubble.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
$series->setPlotBubbleSizes($dataSeriesBubbles);
9090

9191
// Set the series in the plot area
92-
$plotArea = new PlotArea(null, [$series]);
92+
$plotArea = new PlotArea();
93+
$plotArea->setPlotSeries([$series]);
9394
// Set the chart legend
9495
$legend = new ChartLegend(ChartLegend::POSITION_RIGHT, null, false);
9596

11.4 KB
Binary file not shown.
13.2 KB
Binary file not shown.

src/PhpSpreadsheet/Chart/DataSeriesValues.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class DataSeriesValues extends Properties
8585
/** @var bool */
8686
private $bubble3D = false;
8787

88+
/** @var ?Layout */
89+
private $labelLayout;
90+
8891
/**
8992
* Create a new DataSeriesValues object.
9093
*
@@ -562,4 +565,16 @@ public function setSmoothLine($smoothLine)
562565

563566
return $this;
564567
}
568+
569+
public function getLabelLayout(): ?Layout
570+
{
571+
return $this->labelLayout;
572+
}
573+
574+
public function setLabelLayout(?Layout $labelLayout): self
575+
{
576+
$this->labelLayout = $labelLayout;
577+
578+
return $this;
579+
}
565580
}

0 commit comments

Comments
 (0)