chart - Add dynamic Legend positions (#1)
* Writer/Part/chart.php - Add dynamic Legend positions The position of the legend of charts was always fixed to the right. Adding in the option to set it dynamically via a new option under styles/chart * Update Styles/Chart.php Add in the public functions to getStyle() to get and set the legend position
This commit is contained in:
parent
85e9144822
commit
9e572ecd9b
|
|
@ -66,6 +66,13 @@ class Chart extends AbstractStyle
|
|||
*/
|
||||
private $showLegend = false;
|
||||
|
||||
/**
|
||||
* Chart legend Position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $legendPosition = 'r';
|
||||
|
||||
/**
|
||||
* A list of display options for data labels
|
||||
*
|
||||
|
|
@ -285,6 +292,34 @@ class Chart extends AbstractStyle
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get chart legend position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLegendPosition()
|
||||
{
|
||||
return $this->legendPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set chart legend position. choices:
|
||||
* "r" - right of chart
|
||||
* "b" - bottom of chart
|
||||
* "t" - top of chart
|
||||
* "l" - left of chart
|
||||
*
|
||||
* default: right
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setLegendPosition($value = 'r')
|
||||
{
|
||||
$this->legendPosition = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Show labels for axis
|
||||
*
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ class Chart extends AbstractPart
|
|||
|
||||
$title = $style->getTitle();
|
||||
$showLegend = $style->isShowLegend();
|
||||
$legendPosition = $style->getLegendPosition();
|
||||
|
||||
//Chart title
|
||||
if ($title) {
|
||||
|
|
@ -154,7 +155,7 @@ class Chart extends AbstractPart
|
|||
|
||||
//Chart legend
|
||||
if ($showLegend) {
|
||||
$xmlWriter->writeRaw('<c:legend><c:legendPos val="r"/></c:legend>');
|
||||
$xmlWriter->writeRaw('<c:legend><c:legendPos val="'.$legendPosition.'"/></c:legend>');
|
||||
}
|
||||
|
||||
$xmlWriter->startElement('c:plotArea');
|
||||
|
|
|
|||
Loading…
Reference in New Issue