chart doc/sample/code comments

This commit is contained in:
csk83 2020-08-29 20:41:25 +08:00
parent 6f1b18937c
commit d42854ddb6
3 changed files with 20 additions and 5 deletions

View File

@ -201,6 +201,7 @@ Available Chart style options:
- ``colors``. A list of colors to use in the chart. - ``colors``. A list of colors to use in the chart.
- ``title``. The title for the chart. - ``title``. The title for the chart.
- ``showLegend``. Show legend, *true* or *false*. - ``showLegend``. Show legend, *true* or *false*.
- ``LegendPosition``. Legend position, *r* (default), *b*, *t*, *l* or *tr*.
- ``categoryLabelPosition``. Label position for categories, *nextTo* (default), *low* or *high*. - ``categoryLabelPosition``. Label position for categories, *nextTo* (default), *low* or *high*.
- ``valueLabelPosition``. Label position for values, *nextTo* (default), *low* or *high*. - ``valueLabelPosition``. Label position for values, *nextTo* (default), *low* or *high*.
- ``categoryAxisTitle``. The title for the category axis. - ``categoryAxisTitle``. The title for the category axis.

View File

@ -25,6 +25,9 @@ $series2 = array(3, 1, 7, 2, 6);
$series3 = array(8, 3, 2, 5, 4); $series3 = array(8, 3, 2, 5, 4);
$showGridLines = false; $showGridLines = false;
$showAxisLabels = false; $showAxisLabels = false;
$showLegend = true;
$legendPosition = 't';
// r = right, l = left, t = top, b = bottom, tr = top right
foreach ($chartTypes as $chartType) { foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2); $section->addTitle(ucfirst($chartType), 2);
@ -33,6 +36,8 @@ foreach ($chartTypes as $chartType) {
$chart->getStyle()->setShowGridX($showGridLines); $chart->getStyle()->setShowGridX($showGridLines);
$chart->getStyle()->setShowGridY($showGridLines); $chart->getStyle()->setShowGridY($showGridLines);
$chart->getStyle()->setShowAxisLabels($showAxisLabels); $chart->getStyle()->setShowAxisLabels($showAxisLabels);
$chart->getStyle()->setShowLegend($showLegend);
$chart->getStyle()->setLegendPosition($legendPosition);
if (in_array($chartType, $twoSeries)) { if (in_array($chartType, $twoSeries)) {
$chart->addSeries($categories, $series2); $chart->addSeries($categories, $series2);
} }

View File

@ -67,7 +67,8 @@ class Chart extends AbstractStyle
private $showLegend = false; private $showLegend = false;
/** /**
* Chart legend Position. * Chart legend Position.
* Possible values are 'r', 't', 'b', 'l', 'tr'
* *
* @var string * @var string
*/ */
@ -240,6 +241,7 @@ class Chart extends AbstractStyle
* Set the colors to use in a chart. * Set the colors to use in a chart.
* *
* @param array $value a list of colors to use in the chart * @param array $value a list of colors to use in the chart
* @return self
*/ */
public function setColors($value = array()) public function setColors($value = array())
{ {
@ -262,6 +264,7 @@ class Chart extends AbstractStyle
* Set the chart title * Set the chart title
* *
* @param string $value * @param string $value
* @return self
*/ */
public function setTitle($value = null) public function setTitle($value = null)
{ {
@ -284,6 +287,7 @@ class Chart extends AbstractStyle
* Set chart legend visibility * Set chart legend visibility
* *
* @param bool $value * @param bool $value
* @return self
*/ */
public function setShowLegend($value = false) public function setShowLegend($value = false)
{ {
@ -312,11 +316,13 @@ class Chart extends AbstractStyle
* *
* default: right * default: right
* *
* @param bool $value * @param string $legendPosition
* @return self
*/ */
public function setLegendPosition($value = 'r') public function setLegendPosition($legendPosition = 'r')
{ {
$this->legendPosition = $value; $enum = array('r', 'b', 't', 'l', 'tr');
$this->legendPosition = $this->setEnumVal($legendPosition, $enum, $this->legendPosition);
return $this; return $this;
} }
@ -364,7 +370,10 @@ class Chart extends AbstractStyle
{ {
foreach (array_keys($this->dataLabelOptions) as $option) { foreach (array_keys($this->dataLabelOptions) as $option) {
if (isset($values[$option])) { if (isset($values[$option])) {
$this->dataLabelOptions[$option] = $this->setBoolVal($values[$option], $this->dataLabelOptions[$option]); $this->dataLabelOptions[$option] = $this->setBoolVal(
$values[$option],
$this->dataLabelOptions[$option]
);
} }
} }
} }