File tree Expand file tree Collapse file tree 2 files changed +88
-2
lines changed Expand file tree Collapse file tree 2 files changed +88
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,20 @@ class Chart extends AbstractStyle
51
51
* @var array
52
52
*/
53
53
private $ colors = array ();
54
+
55
+ /**
56
+ * Chart title
57
+ *
58
+ * @var string
59
+ */
60
+ private $ title = null ;
61
+
62
+ /**
63
+ * Chart legend visibility
64
+ *
65
+ * @var bool
66
+ */
67
+ private $ showLegend = false ;
54
68
55
69
/**
56
70
* A list of display options for data labels
@@ -220,6 +234,50 @@ public function setColors($value = array())
220
234
221
235
return $ this ;
222
236
}
237
+
238
+ /**
239
+ * Get the chart title
240
+ *
241
+ * @return string
242
+ */
243
+ public function getTitle ()
244
+ {
245
+ return $ this ->title ;
246
+ }
247
+
248
+ /**
249
+ * Set the chart title
250
+ *
251
+ * @param string $value
252
+ */
253
+ public function setTitle ($ value = null )
254
+ {
255
+ $ this ->title = $ value ;
256
+
257
+ return $ this ;
258
+ }
259
+
260
+ /**
261
+ * Get chart legend visibility
262
+ *
263
+ * @return bool
264
+ */
265
+ public function getShowLegend ()
266
+ {
267
+ return $ this ->showLegend ;
268
+ }
269
+
270
+ /**
271
+ * Set chart legend visibility
272
+ *
273
+ * @param bool $value
274
+ */
275
+ public function setShowLegend ($ value = false )
276
+ {
277
+ $ this ->showLegend = $ value ;
278
+
279
+ return $ this ;
280
+ }
223
281
224
282
/*
225
283
* Show labels for axis
Original file line number Diff line number Diff line change @@ -105,8 +105,6 @@ private function writeChart(XMLWriter $xmlWriter)
105
105
{
106
106
$ xmlWriter ->startElement ('c:chart ' );
107
107
108
- $ xmlWriter ->writeElementBlock ('c:autoTitleDeleted ' , 'val ' , 1 );
109
-
110
108
$ this ->writePlotArea ($ xmlWriter );
111
109
112
110
$ xmlWriter ->endElement (); // c:chart
@@ -130,6 +128,36 @@ private function writePlotArea(XMLWriter $xmlWriter)
130
128
$ type = $ this ->element ->getType ();
131
129
$ style = $ this ->element ->getStyle ();
132
130
$ this ->options = $ this ->types [$ type ];
131
+
132
+ $ title = $ style ->getTitle ();
133
+ $ showLegend = $ style ->getShowLegend ();
134
+
135
+ //Chart title
136
+ if ($ title ){
137
+ $ xmlWriter ->startElement ('c:title ' );
138
+ $ xmlWriter ->startElement ('c:tx ' );
139
+ $ xmlWriter ->startElement ('c:rich ' );
140
+ $ xmlWriter ->writeRaw ('
141
+ <a:bodyPr/>
142
+ <a:lstStyle/>
143
+ <a:p>
144
+ <a:pPr>
145
+ <a:defRPr/></a:pPr><a:r><a:rPr/><a:t> ' .$ title .'</a:t></a:r>
146
+ <a:endParaRPr/>
147
+ </a:p> ' );
148
+
149
+ $ xmlWriter ->endElement (); // c:rich
150
+ $ xmlWriter ->endElement (); // c:tx
151
+ $ xmlWriter ->endElement (); // c:title
152
+
153
+ }else {
154
+ $ xmlWriter ->writeElementBlock ('c:autoTitleDeleted ' , 'val ' , 1 );
155
+ }
156
+
157
+ //Chart legend
158
+ if ($ showLegend ){
159
+ $ xmlWriter ->writeRaw ('<c:legend><c:legendPos val="r"/></c:legend> ' );
160
+ }
133
161
134
162
$ xmlWriter ->startElement ('c:plotArea ' );
135
163
$ xmlWriter ->writeElement ('c:layout ' );
You can’t perform that action at this time.
0 commit comments