Merge pull request #1 from Stephan212/develop
Add Option for Dynamic Chart Legend Position
This commit is contained in:
commit
9945240ea8
|
|
@ -66,6 +66,13 @@ class Chart extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
private $showLegend = false;
|
private $showLegend = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chart legend Position.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $legendPosition = 'r';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of display options for data labels
|
* A list of display options for data labels
|
||||||
*
|
*
|
||||||
|
|
@ -285,6 +292,35 @@ class Chart extends AbstractStyle
|
||||||
return $this;
|
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
|
||||||
|
* "tr" - top right of chart
|
||||||
|
*
|
||||||
|
* default: right
|
||||||
|
*
|
||||||
|
* @param bool $value
|
||||||
|
*/
|
||||||
|
public function setLegendPosition($value = 'r')
|
||||||
|
{
|
||||||
|
$this->legendPosition = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show labels for axis
|
* Show labels for axis
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ class Chart extends AbstractPart
|
||||||
|
|
||||||
$title = $style->getTitle();
|
$title = $style->getTitle();
|
||||||
$showLegend = $style->isShowLegend();
|
$showLegend = $style->isShowLegend();
|
||||||
|
$legendPosition = $style->getLegendPosition();
|
||||||
|
|
||||||
//Chart title
|
//Chart title
|
||||||
if ($title) {
|
if ($title) {
|
||||||
|
|
@ -154,7 +155,7 @@ class Chart extends AbstractPart
|
||||||
|
|
||||||
//Chart legend
|
//Chart legend
|
||||||
if ($showLegend) {
|
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');
|
$xmlWriter->startElement('c:plotArea');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue