File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ class Chart extends AbstractStyle
66
66
*/
67
67
private $ showLegend = false ;
68
68
69
+ /**
70
+ * Chart legend Position.
71
+ *
72
+ * @var string
73
+ */
74
+ private $ legendPosition = 'r ' ;
75
+
69
76
/**
70
77
* A list of display options for data labels
71
78
*
@@ -285,6 +292,35 @@ public function setShowLegend($value = false)
285
292
return $ this ;
286
293
}
287
294
295
+ /**
296
+ * Get chart legend position
297
+ *
298
+ * @return string
299
+ */
300
+ public function getLegendPosition ()
301
+ {
302
+ return $ this ->legendPosition ;
303
+ }
304
+
305
+ /**
306
+ * Set chart legend position. choices:
307
+ * "r" - right of chart
308
+ * "b" - bottom of chart
309
+ * "t" - top of chart
310
+ * "l" - left of chart
311
+ * "tr" - top right of chart
312
+ *
313
+ * default: right
314
+ *
315
+ * @param bool $value
316
+ */
317
+ public function setLegendPosition ($ value = 'r ' )
318
+ {
319
+ $ this ->legendPosition = $ value ;
320
+
321
+ return $ this ;
322
+ }
323
+
288
324
/*
289
325
* Show labels for axis
290
326
*
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ private function writePlotArea(XMLWriter $xmlWriter)
131
131
132
132
$ title = $ style ->getTitle ();
133
133
$ showLegend = $ style ->isShowLegend ();
134
+ $ legendPosition = $ style ->getLegendPosition ();
134
135
135
136
//Chart title
136
137
if ($ title ) {
@@ -154,7 +155,7 @@ private function writePlotArea(XMLWriter $xmlWriter)
154
155
155
156
//Chart legend
156
157
if ($ showLegend ) {
157
- $ xmlWriter ->writeRaw ('<c:legend><c:legendPos val="r "/></c:legend> ' );
158
+ $ xmlWriter ->writeRaw ('<c:legend><c:legendPos val=" ' . $ legendPosition . ' "/></c:legend> ' );
158
159
}
159
160
160
161
$ xmlWriter ->startElement ('c:plotArea ' );
You can’t perform that action at this time.
0 commit comments