11
11
use PhpOffice \PhpSpreadsheet \Chart \Layout ;
12
12
use PhpOffice \PhpSpreadsheet \Chart \Legend ;
13
13
use PhpOffice \PhpSpreadsheet \Chart \PlotArea ;
14
- use PhpOffice \PhpSpreadsheet \Chart \Properties ;
14
+ use PhpOffice \PhpSpreadsheet \Chart \Properties as ChartProperties ;
15
15
use PhpOffice \PhpSpreadsheet \Chart \Title ;
16
16
use PhpOffice \PhpSpreadsheet \Chart \TrendLine ;
17
17
use PhpOffice \PhpSpreadsheet \RichText \RichText ;
@@ -113,6 +113,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
113
113
$ plotSeries = $ plotAttributes = [];
114
114
$ catAxRead = false ;
115
115
$ plotNoFill = false ;
116
+ /** @var SimpleXMLElement $chartDetail */
116
117
foreach ($ chartDetails as $ chartDetailKey => $ chartDetail ) {
117
118
switch ($ chartDetailKey ) {
118
119
case 'spPr ' :
@@ -121,17 +122,18 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
121
122
$ plotNoFill = true ;
122
123
}
123
124
if (isset ($ possibleNoFill ->gradFill ->gsLst )) {
125
+ /** @var SimpleXMLElement $gradient */
124
126
foreach ($ possibleNoFill ->gradFill ->gsLst ->gs as $ gradient ) {
125
127
/** @var float */
126
128
$ pos = self ::getAttribute ($ gradient , 'pos ' , 'float ' );
127
129
$ gradientArray [] = [
128
- $ pos / Properties ::PERCENTAGE_MULTIPLIER ,
130
+ $ pos / ChartProperties ::PERCENTAGE_MULTIPLIER ,
129
131
new ChartColor ($ this ->readColor ($ gradient )),
130
132
];
131
133
}
132
134
}
133
135
if (isset ($ possibleNoFill ->gradFill ->lin )) {
134
- $ gradientLin = Properties ::XmlToAngle ((string ) self ::getAttribute ($ possibleNoFill ->gradFill ->lin , 'ang ' , 'string ' ));
136
+ $ gradientLin = ChartProperties ::XmlToAngle ((string ) self ::getAttribute ($ possibleNoFill ->gradFill ->lin , 'ang ' , 'string ' ));
135
137
}
136
138
137
139
break ;
@@ -464,12 +466,13 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType
464
466
$ pointSize = null ;
465
467
$ noFill = false ;
466
468
$ bubble3D = false ;
467
- $ dPtColors = [];
469
+ $ dptColors = [];
468
470
$ markerFillColor = null ;
469
471
$ markerBorderColor = null ;
470
472
$ lineStyle = null ;
471
473
$ labelLayout = null ;
472
474
$ trendLines = [];
475
+ /** @var SimpleXMLElement $seriesDetail */
473
476
foreach ($ seriesDetails as $ seriesKey => $ seriesDetail ) {
474
477
switch ($ seriesKey ) {
475
478
case 'idx ' :
@@ -487,7 +490,6 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType
487
490
break ;
488
491
case 'spPr ' :
489
492
$ children = $ seriesDetail ->children ($ this ->aNamespace );
490
- $ ln = $ children ->ln ;
491
493
if (isset ($ children ->ln )) {
492
494
$ ln = $ children ->ln ;
493
495
if (is_countable ($ ln ->noFill ) && count ($ ln ->noFill ) === 1 ) {
@@ -1161,15 +1163,15 @@ private function setChartAttributes(Layout $plotArea, $plotAttributes): void
1161
1163
}
1162
1164
}
1163
1165
1164
- private function readEffects (SimpleXMLElement $ chartDetail , ?Properties $ chartObject ): void
1166
+ private function readEffects (SimpleXMLElement $ chartDetail , ?ChartProperties $ chartObject ): void
1165
1167
{
1166
1168
if (!isset ($ chartObject , $ chartDetail ->spPr )) {
1167
1169
return ;
1168
1170
}
1169
1171
$ sppr = $ chartDetail ->spPr ->children ($ this ->aNamespace );
1170
1172
1171
1173
if (isset ($ sppr ->effectLst ->glow )) {
1172
- $ axisGlowSize = (float ) self ::getAttribute ($ sppr ->effectLst ->glow , 'rad ' , 'integer ' ) / Properties ::POINTS_WIDTH_MULTIPLIER ;
1174
+ $ axisGlowSize = (float ) self ::getAttribute ($ sppr ->effectLst ->glow , 'rad ' , 'integer ' ) / ChartProperties ::POINTS_WIDTH_MULTIPLIER ;
1173
1175
if ($ axisGlowSize != 0.0 ) {
1174
1176
$ colorArray = $ this ->readColor ($ sppr ->effectLst ->glow );
1175
1177
$ chartObject ->setGlowProperties ($ axisGlowSize , $ colorArray ['value ' ], $ colorArray ['alpha ' ], $ colorArray ['type ' ]);
@@ -1180,7 +1182,7 @@ private function readEffects(SimpleXMLElement $chartDetail, ?Properties $chartOb
1180
1182
/** @var string */
1181
1183
$ softEdgeSize = self ::getAttribute ($ sppr ->effectLst ->softEdge , 'rad ' , 'string ' );
1182
1184
if (is_numeric ($ softEdgeSize )) {
1183
- $ chartObject ->setSoftEdges ((float ) Properties ::xmlToPoints ($ softEdgeSize ));
1185
+ $ chartObject ->setSoftEdges ((float ) ChartProperties ::xmlToPoints ($ softEdgeSize ));
1184
1186
}
1185
1187
}
1186
1188
@@ -1195,28 +1197,28 @@ private function readEffects(SimpleXMLElement $chartDetail, ?Properties $chartOb
1195
1197
if ($ type !== '' ) {
1196
1198
/** @var string */
1197
1199
$ blur = self ::getAttribute ($ sppr ->effectLst ->$ type , 'blurRad ' , 'string ' );
1198
- $ blur = is_numeric ($ blur ) ? Properties ::xmlToPoints ($ blur ) : null ;
1200
+ $ blur = is_numeric ($ blur ) ? ChartProperties ::xmlToPoints ($ blur ) : null ;
1199
1201
/** @var string */
1200
1202
$ dist = self ::getAttribute ($ sppr ->effectLst ->$ type , 'dist ' , 'string ' );
1201
- $ dist = is_numeric ($ dist ) ? Properties ::xmlToPoints ($ dist ) : null ;
1203
+ $ dist = is_numeric ($ dist ) ? ChartProperties ::xmlToPoints ($ dist ) : null ;
1202
1204
/** @var string */
1203
1205
$ direction = self ::getAttribute ($ sppr ->effectLst ->$ type , 'dir ' , 'string ' );
1204
- $ direction = is_numeric ($ direction ) ? Properties ::xmlToAngle ($ direction ) : null ;
1206
+ $ direction = is_numeric ($ direction ) ? ChartProperties ::xmlToAngle ($ direction ) : null ;
1205
1207
$ algn = self ::getAttribute ($ sppr ->effectLst ->$ type , 'algn ' , 'string ' );
1206
1208
$ rot = self ::getAttribute ($ sppr ->effectLst ->$ type , 'rotWithShape ' , 'string ' );
1207
1209
$ size = [];
1208
1210
foreach (['sx ' , 'sy ' ] as $ sizeType ) {
1209
1211
$ sizeValue = self ::getAttribute ($ sppr ->effectLst ->$ type , $ sizeType , 'string ' );
1210
1212
if (is_numeric ($ sizeValue )) {
1211
- $ size [$ sizeType ] = Properties ::xmlToTenthOfPercent ((string ) $ sizeValue );
1213
+ $ size [$ sizeType ] = ChartProperties ::xmlToTenthOfPercent ((string ) $ sizeValue );
1212
1214
} else {
1213
1215
$ size [$ sizeType ] = null ;
1214
1216
}
1215
1217
}
1216
1218
foreach (['kx ' , 'ky ' ] as $ sizeType ) {
1217
1219
$ sizeValue = self ::getAttribute ($ sppr ->effectLst ->$ type , $ sizeType , 'string ' );
1218
1220
if (is_numeric ($ sizeValue )) {
1219
- $ size [$ sizeType ] = Properties ::xmlToAngle ((string ) $ sizeValue );
1221
+ $ size [$ sizeType ] = ChartProperties ::xmlToAngle ((string ) $ sizeValue );
1220
1222
} else {
1221
1223
$ size [$ sizeType ] = null ;
1222
1224
}
@@ -1273,7 +1275,7 @@ private function readColor(SimpleXMLElement $colorXml): array
1273
1275
return $ result ;
1274
1276
}
1275
1277
1276
- private function readLineStyle (SimpleXMLElement $ chartDetail , ?Properties $ chartObject ): void
1278
+ private function readLineStyle (SimpleXMLElement $ chartDetail , ?ChartProperties $ chartObject ): void
1277
1279
{
1278
1280
if (!isset ($ chartObject , $ chartDetail ->spPr )) {
1279
1281
return ;
@@ -1287,7 +1289,7 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?Properties $chart
1287
1289
/** @var string */
1288
1290
$ lineWidthTemp = self ::getAttribute ($ sppr ->ln , 'w ' , 'string ' );
1289
1291
if (is_numeric ($ lineWidthTemp )) {
1290
- $ lineWidth = Properties ::xmlToPoints ($ lineWidthTemp );
1292
+ $ lineWidth = ChartProperties ::xmlToPoints ($ lineWidthTemp );
1291
1293
}
1292
1294
/** @var string */
1293
1295
$ compoundType = self ::getAttribute ($ sppr ->ln , 'cmpd ' , 'string ' );
@@ -1296,15 +1298,13 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?Properties $chart
1296
1298
/** @var string */
1297
1299
$ capType = self ::getAttribute ($ sppr ->ln , 'cap ' , 'string ' );
1298
1300
if (isset ($ sppr ->ln ->miter )) {
1299
- $ joinType = Properties ::LINE_STYLE_JOIN_MITER ;
1301
+ $ joinType = ChartProperties ::LINE_STYLE_JOIN_MITER ;
1300
1302
} elseif (isset ($ sppr ->ln ->bevel )) {
1301
- $ joinType = Properties ::LINE_STYLE_JOIN_BEVEL ;
1303
+ $ joinType = ChartProperties ::LINE_STYLE_JOIN_BEVEL ;
1302
1304
} else {
1303
1305
$ joinType = '' ;
1304
1306
}
1305
- $ headArrowType = '' ;
1306
1307
$ headArrowSize = '' ;
1307
- $ endArrowType = '' ;
1308
1308
$ endArrowSize = '' ;
1309
1309
/** @var string */
1310
1310
$ headArrowType = self ::getAttribute ($ sppr ->ln ->headEnd , 'type ' , 'string ' );
@@ -1403,7 +1403,7 @@ private function setAxisProperties(SimpleXMLElement $chartDetail, ?Axis $whichAx
1403
1403
/** @var string */
1404
1404
$ textRotation = self ::getAttribute ($ children ->bodyPr , 'rot ' , 'string ' );
1405
1405
if (is_numeric ($ textRotation )) {
1406
- $ whichAxis ->setAxisOption ('textRotation ' , (string ) Properties ::xmlToAngle ($ textRotation ));
1406
+ $ whichAxis ->setAxisOption ('textRotation ' , (string ) ChartProperties ::xmlToAngle ($ textRotation ));
1407
1407
}
1408
1408
}
1409
1409
}
0 commit comments