@@ -46,6 +46,60 @@ class Chart extends AbstractStyle
46
46
private $ is3d = false ;
47
47
48
48
/**
49
+ * A list of colors to use in the chart
50
+ *
51
+ * @var array
52
+ */
53
+ private $ colors = array ();
54
+
55
+ /**
56
+ * A list of display options for data labels
57
+ *
58
+ * @var array
59
+ */
60
+ private $ dataLabelOptions = array (
61
+ 'showVal ' => true , // value
62
+ 'showCatName ' => true , // category name
63
+ 'showLegendKey ' => false , //show the cart legend
64
+ 'showSerName ' => false , // series name
65
+ 'showPercent ' => false ,
66
+ 'showLeaderLines ' => false ,
67
+ 'showBubbleSize ' => false ,
68
+ );
69
+
70
+ /**
71
+ * A string that tells the writer where to write chart labels or to skip
72
+ * "nextTo" - sets labels next to the axis (bar graphs on the left) (default)
73
+ * "low" - labels on the left side of the graph
74
+ * "high" - labels on the right side of the graph
75
+ *
76
+ * @var string
77
+ */
78
+ private $ categoryLabelPosition = 'nextTo ' ;
79
+
80
+ /**
81
+ * A string that tells the writer where to write chart labels or to skip
82
+ * "nextTo" - sets labels next to the axis (bar graphs on the bottom) (default)
83
+ * "low" - labels are below the graph
84
+ * "high" - labels above the graph
85
+ *
86
+ * @var string
87
+ */
88
+ private $ valueLabelPosition = 'nextTo ' ;
89
+
90
+ /**
91
+ * @var string
92
+ */
93
+ private $ categoryAxisTitle ;
94
+
95
+ /**
96
+ * @var string
97
+ */
98
+ private $ valueAxisTitle ;
99
+
100
+ private $ majorTickMarkPos = 'none ' ;
101
+
102
+ /*
49
103
* Show labels for axis
50
104
*
51
105
* @var bool
@@ -146,6 +200,28 @@ public function set3d($value = true)
146
200
}
147
201
148
202
/**
203
+ * Get the list of colors to use in a chart.
204
+ *
205
+ * @return array
206
+ */
207
+ public function getColors ()
208
+ {
209
+ return $ this ->colors ;
210
+ }
211
+
212
+ /**
213
+ * Set the colors to use in a chart.
214
+ *
215
+ * @param array $value a list of colors to use in the chart
216
+ */
217
+ public function setColors ($ value = array ())
218
+ {
219
+ $ this ->colors = $ value ;
220
+
221
+ return $ this ;
222
+ }
223
+
224
+ /*
149
225
* Show labels for axis
150
226
*
151
227
* @return bool
@@ -169,6 +245,31 @@ public function setShowAxisLabels($value = true)
169
245
}
170
246
171
247
/**
248
+ * get the list of options for data labels
249
+ *
250
+ * @return array
251
+ */
252
+ public function getDataLabelOptions ()
253
+ {
254
+ return $ this ->dataLabelOptions ;
255
+ }
256
+
257
+ /**
258
+ * Set values for data label options.
259
+ * This will only change values for options defined in $this->dataLabelOptions, and cannot create new ones.
260
+ *
261
+ * @param array $values [description]
262
+ */
263
+ public function setDataLabelOptions ($ values = array ())
264
+ {
265
+ foreach (array_keys ($ this ->dataLabelOptions ) as $ option ) {
266
+ if (isset ($ values [$ option ])) {
267
+ $ this ->dataLabelOptions [$ option ] = $ this ->setBoolVal ($ values [$ option ], $ this ->dataLabelOptions [$ option ]);
268
+ }
269
+ }
270
+ }
271
+
272
+ /*
172
273
* Show Gridlines for Y-Axis
173
274
*
174
275
* @return bool
@@ -192,6 +293,117 @@ public function setShowGridY($value = true)
192
293
}
193
294
194
295
/**
296
+ * Get the categoryLabelPosition setting
297
+ *
298
+ * @return string
299
+ */
300
+ public function getCategoryLabelPosition ()
301
+ {
302
+ return $ this ->categoryLabelPosition ;
303
+ }
304
+
305
+ /**
306
+ * Set the categoryLabelPosition setting
307
+ * "none" - skips writing labels
308
+ * "nextTo" - sets labels next to the (bar graphs on the left)
309
+ * "low" - labels on the left side of the graph
310
+ * "high" - labels on the right side of the graph
311
+ *
312
+ * @param mixed $labelPosition
313
+ * @return self
314
+ */
315
+ public function setCategoryLabelPosition ($ labelPosition )
316
+ {
317
+ $ enum = array ('nextTo ' , 'low ' , 'high ' );
318
+ $ this ->categoryLabelPosition = $ this ->setEnumVal ($ labelPosition , $ enum , $ this ->categoryLabelPosition );
319
+
320
+ return $ this ;
321
+ }
322
+
323
+ /**
324
+ * Get the valueAxisLabelPosition setting
325
+ *
326
+ * @return string
327
+ */
328
+ public function getValueLabelPosition ()
329
+ {
330
+ return $ this ->valueLabelPosition ;
331
+ }
332
+
333
+ /**
334
+ * Set the valueLabelPosition setting
335
+ * "none" - skips writing labels
336
+ * "nextTo" - sets labels next to the value
337
+ * "low" - sets labels are below the graph
338
+ * "high" - sets labels above the graph
339
+ *
340
+ * @param string
341
+ * @param mixed $labelPosition
342
+ */
343
+ public function setValueLabelPosition ($ labelPosition )
344
+ {
345
+ $ enum = array ('nextTo ' , 'low ' , 'high ' );
346
+ $ this ->valueLabelPosition = $ this ->setEnumVal ($ labelPosition , $ enum , $ this ->valueLabelPosition );
347
+
348
+ return $ this ;
349
+ }
350
+
351
+ /**
352
+ * Get the categoryAxisTitle
353
+ * @return string
354
+ */
355
+ public function getCategoryAxisTitle ()
356
+ {
357
+ return $ this ->categoryAxisTitle ;
358
+ }
359
+
360
+ /**
361
+ * Set the title that appears on the category side of the chart
362
+ * @param string $axisTitle
363
+ */
364
+ public function setCategoryAxisTitle ($ axisTitle )
365
+ {
366
+ $ this ->categoryAxisTitle = $ axisTitle ;
367
+
368
+ return $ this ;
369
+ }
370
+
371
+ /**
372
+ * Get the valueAxisTitle
373
+ * @return string
374
+ */
375
+ public function getValueAxisTitle ()
376
+ {
377
+ return $ this ->valueAxisTitle ;
378
+ }
379
+
380
+ /**
381
+ * Set the title that appears on the value side of the chart
382
+ * @param string $axisTitle
383
+ */
384
+ public function setValueAxisTitle ($ axisTitle )
385
+ {
386
+ $ this ->valueAxisTitle = $ axisTitle ;
387
+
388
+ return $ this ;
389
+ }
390
+
391
+ public function getMajorTickPosition ()
392
+ {
393
+ return $ this ->majorTickMarkPos ;
394
+ }
395
+
396
+ /**
397
+ * set the position for major tick marks
398
+ * @param string $position [description]
399
+ */
400
+ public function setMajorTickPosition ($ position )
401
+ {
402
+ $ enum = array ('in ' , 'out ' , 'cross ' , 'none ' );
403
+ $ this ->majorTickMarkPos = $ this ->setEnumVal ($ position , $ enum , $ this ->majorTickMarkPos );
404
+ }
405
+
406
+ /*
195
407
* Show Gridlines for X-Axis
196
408
*
197
409
* @return bool
0 commit comments