diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-06-20 11:16:48 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-06-20 11:16:48 +0000 |
commit | f2e9c24c161e235778ca2bfb3c8bbccef35b4567 (patch) | |
tree | bd1deb78f8c4d299901dc4cb920b9ff7a2048a50 /src/charts/pie.php | |
parent | 92a19bdd0c69dfa780f23fc4c38b64ad6f1d4ce9 (diff) | |
download | zetacomponents-graph-f2e9c24c161e235778ca2bfb3c8bbccef35b4567.zip zetacomponents-graph-f2e9c24c161e235778ca2bfb3c8bbccef35b4567.tar.gz |
- Added option to remove symbol lines from pie charts
- Decrease size of pie charts for images with too less width
Diffstat (limited to 'src/charts/pie.php')
-rw-r--r-- | src/charts/pie.php | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/src/charts/pie.php b/src/charts/pie.php index 67a628f..3dd397f 100644 --- a/src/charts/pie.php +++ b/src/charts/pie.php @@ -69,10 +69,12 @@ class ezcGraphPieChart extends ezcGraphChart (int) round( $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2 ), (int) round( $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2 ) ); + + // Limit radius to fourth of width and half of height at maximum $radius = min( - $boundings->x1 - $boundings->x0, - $boundings->y1 - $boundings->y0 - ) / 2; + ( $boundings->x1 - $boundings->x0 ) / 4, + ( $boundings->y1 - $boundings->y0 ) / 2 + ); // Draw all data $angle = 0.; @@ -130,38 +132,47 @@ class ezcGraphPieChart extends ezcGraphChart // Determine position of label $minHeight += round( max( 0, $height - $minHeight ) / ( $boundings->y1 - $boundings->y0 ) * $toShare ); $labelPosition = new ezcGraphCoordinate( - (int) round( $center->x - $sign * ( cos ( asin ( ( $center->y - $minHeight - $labelHeight / 2 ) / $radius ) ) * $radius + $symbolSize ) ), + (int) round( + $center->x - + $sign * ( + cos ( asin ( ( $center->y - $minHeight - $labelHeight / 2 ) / $radius ) ) * $radius + + $symbolSize * (int) $this->options->showSymbol + ) + ), (int) round( $minHeight + $labelHeight / 2 ) ); - // Draw label - $renderer->drawLine( - $this->options->font->color, - $label[0], - $labelPosition, - false - ); - - $renderer->drawSymbol( - $this->options->font->color, - new ezcGraphCoordinate( - $label[0]->x - $symbolSize / 2, - $label[0]->y - $symbolSize / 2 - ), - $symbolSize, - $symbolSize, - ezcGraph::BULLET - ); - $renderer->drawSymbol( - $this->options->font->color, - new ezcGraphCoordinate( - $labelPosition->x - $symbolSize / 2, - $labelPosition->y - $symbolSize / 2 - ), - $symbolSize, - $symbolSize, - ezcGraph::BULLET - ); + if ( $this->options->showSymbol ) + { + // Draw label + $renderer->drawLine( + $this->options->font->color, + $label[0], + $labelPosition, + false + ); + + $renderer->drawSymbol( + $this->options->font->color, + new ezcGraphCoordinate( + $label[0]->x - $symbolSize / 2, + $label[0]->y - $symbolSize / 2 + ), + $symbolSize, + $symbolSize, + ezcGraph::BULLET + ); + $renderer->drawSymbol( + $this->options->font->color, + new ezcGraphCoordinate( + $labelPosition->x - $symbolSize / 2, + $labelPosition->y - $symbolSize / 2 + ), + $symbolSize, + $symbolSize, + ezcGraph::BULLET + ); + } $renderer->drawTextBox( new ezcGraphCoordinate( |