Ensure that PieCharts are centered and that labels dont leave the viewBox

Add scaling and transformations to move the PieChart into a valid coordinate system and reduce the offset of the labels to make more efficient use of available space.
This commit is contained in:
Matthias Jentsch 2014-08-28 16:42:31 +02:00
parent c5cface661
commit 00a2d225a2
2 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class PieChart extends Chart
*/
public function toSvg(RenderContext $ctx)
{
$outerBox = new Canvas('outerGraph', new LayoutBox(0, 0, 100, 100));
$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) {

View File

@ -159,7 +159,7 @@ class PieSlice extends Animatable implements Drawable
// Draw the handle
$path = new Path(array($midX, $midY));
$midX += ($addOffset + $r/1.8) * ($midRadius > M_PI ? -1 : 1);
$midX += ($addOffset + $r/3) * ($midRadius > M_PI ? -1 : 1);
$path->append(array($midX, $midY))->toAbsolute();
$midX += intval($r/2 * sin(M_PI/9)) * ($midRadius > M_PI ? -1 : 1);