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
6666 */
6767 private $ showLegend = false ;
6868
69+ /**
70+ * Chart legend Position.
71+ *
72+ * @var string
73+ */
74+ private $ legendPosition = 'r ' ;
75+
6976 /**
7077 * A list of display options for data labels
7178 *
@@ -285,6 +292,35 @@ public function setShowLegend($value = false)
285292 return $ this ;
286293 }
287294
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+
288324 /*
289325 * Show labels for axis
290326 *
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ private function writePlotArea(XMLWriter $xmlWriter)
131131
132132 $ title = $ style ->getTitle ();
133133 $ showLegend = $ style ->isShowLegend ();
134+ $ legendPosition = $ style ->getLegendPosition ();
134135
135136 //Chart title
136137 if ($ title ) {
@@ -154,7 +155,7 @@ private function writePlotArea(XMLWriter $xmlWriter)
154155
155156 //Chart legend
156157 if ($ showLegend ) {
157- $ xmlWriter ->writeRaw ('<c:legend><c:legendPos val="r "/></c:legend> ' );
158+ $ xmlWriter ->writeRaw ('<c:legend><c:legendPos val=" ' . $ legendPosition . ' "/></c:legend> ' );
158159 }
159160
160161 $ xmlWriter ->startElement ('c:plotArea ' );
You can’t perform that action at this time.
0 commit comments