Adjust PieCharts that are rendered without labels

Center and resize PieCharts to use the full width and height of the available view port
This commit is contained in:
Matthias Jentsch 2014-08-28 18:25:19 +02:00
parent e799d65d3f
commit a26370bb12
2 changed files with 8 additions and 3 deletions

View File

@ -18,11 +18,11 @@ class PieChart extends Inline
public function render($output = true)
{
$pie = new PieChartRenderer();
$pie->alignTopLeft();
$pie->disableLegend();
$pie->drawPie(array(
'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels
));
$pie->setWidth($this->width)->setHeight($this->height);
if ($output) {
echo $pie->render();
} else {

View File

@ -122,11 +122,16 @@ class PieChart extends Chart
*/
public function toSvg(RenderContext $ctx)
{
$outerBox = new Canvas('outerGraph', new LayoutBox(33, -5, 40, 40));
$innerBox = new Canvas('graph', new LayoutBox(0, 0, 100, 100));
$labelBox = $ctx->getDocument()->createElement('g');
if (!$this->noCaption) {
// Scale SVG to make room for captions
$outerBox = new Canvas('outerGraph', new LayoutBox(33, -5, 40, 40));
$innerBox = new Canvas('graph', new LayoutBox(0, 0, 100, 100));
$innerBox->getLayout()->setPadding(10, 10, 10, 10);
} else {
$outerBox = new Canvas('outerGraph', new LayoutBox(1.5, -10, 124, 124));
$innerBox = new Canvas('graph', new LayoutBox(0, 0, 100, 100));
$innerBox->getLayout()->setPadding(0, 0, 0, 0);
}
$this->createContentClipBox($innerBox);
$this->renderPies($innerBox, $labelBox);