diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2009-05-28 14:33:36 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2009-05-28 14:33:36 +0000 |
commit | eb36eb0b72d1e0b01b46f4570c2f6e77ba723e63 (patch) | |
tree | 4cf08c70237495df7c39cd2a828515e2c59895d1 /src | |
parent | b24c848560db8723e04cffe2d04c0a6f7089181e (diff) | |
download | zetacomponents-graph-eb36eb0b72d1e0b01b46f4570c2f6e77ba723e63.zip zetacomponents-graph-eb36eb0b72d1e0b01b46f4570c2f6e77ba723e63.tar.gz |
- Fixed #14857: Highlight text misplaced in charts with multiple bar data
sets.
Diffstat (limited to 'src')
-rw-r--r-- | src/charts/line.php | 82 | ||||
-rw-r--r-- | src/interfaces/renderer.php | 6 | ||||
-rw-r--r-- | src/renderer/2d.php | 20 | ||||
-rw-r--r-- | src/renderer/3d.php | 6 |
4 files changed, 90 insertions, 24 deletions
diff --git a/src/charts/line.php b/src/charts/line.php index 08d8650..3348920 100644 --- a/src/charts/line.php +++ b/src/charts/line.php @@ -302,6 +302,27 @@ class ezcGraphLineChart extends ezcGraphChart $yAxisNullPosition, ( $data->lineThickness->default ? $data->lineThickness->default : $this->options->lineThickness ) ); + + // Render highlight string if requested + if ( $data->highlight[$key] ) + { + $renderer->drawDataHighlightText( + $boundings, + new ezcGraphContext( $datasetName, $key, $data->url[$key] ), + $point, + $yAxisNullPosition, + $nr[$data->displayType->default], + $count[$data->displayType->default], + $this->options->highlightFont, + ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), + $this->options->highlightSize + $this->options->highlightFont->padding * 2, + ( $this->options->highlightLines ? $data->color[$key] : null ), + ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), + ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), + 0., + ezcGraph::LINE + ); + } break; case ( $data->displayType->default === ezcGraph::BAR ) && $this->options->stackBars : @@ -356,6 +377,27 @@ class ezcGraphLineChart extends ezcGraphChart $stackedSymbol[(int) ( $point->x * 10000 )], $yAxisNullPosition ); + + // Render highlight string if requested + if ( $data->highlight[$key] ) + { + $renderer->drawDataHighlightText( + $boundings, + new ezcGraphContext( $datasetName, $key, $data->url[$key] ), + $point, + $yAxisNullPosition, + $nr[$data->displayType->default], + $count[$data->displayType->default], + $this->options->highlightFont, + ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), + $this->options->highlightSize + $this->options->highlightFont->padding * 2, + ( $this->options->highlightLines ? $data->color[$key] : null ), + ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), + ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), + 0., + ezcGraph::LINE + ); + } break; case $data->displayType->default === ezcGraph::BAR: $renderer->drawBar( @@ -369,30 +411,32 @@ class ezcGraphLineChart extends ezcGraphChart $data->symbol[$key], $yAxisNullPosition ); + + // Render highlight string if requested + if ( $data->highlight[$key] ) + { + $renderer->drawDataHighlightText( + $boundings, + new ezcGraphContext( $datasetName, $key, $data->url[$key] ), + $point, + $yAxisNullPosition, + $nr[$data->displayType->default], + $count[$data->displayType->default], + $this->options->highlightFont, + ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), + $this->options->highlightSize + $this->options->highlightFont->padding * 2, + ( $this->options->highlightLines ? $data->color[$key] : null ), + ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), + ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), + $width, + $data->displayType->default + ); + } break; default: throw new ezcGraphInvalidDisplayTypeException( $data->displayType->default ); break; } - - // Render highlight string if requested - if ( $data->highlight[$key] ) - { - $renderer->drawDataHighlightText( - $boundings, - new ezcGraphContext( $datasetName, $key, $data->url[$key] ), - $point, - $yAxisNullPosition, - $nr[$data->displayType->default], - $count[$data->displayType->default], - $this->options->highlightFont, - ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), - $this->options->highlightSize + $this->options->highlightFont->padding * 2, - ( $this->options->highlightLines ? $data->color[$key] : null ), - ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), - ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ) - ); - } // Store last point, used to connect lines in line chart. $lastPoint = $point; diff --git a/src/interfaces/renderer.php b/src/interfaces/renderer.php index 115a6ef..3262dcf 100644 --- a/src/interfaces/renderer.php +++ b/src/interfaces/renderer.php @@ -253,6 +253,8 @@ abstract class ezcGraphRenderer * @param ezcGraphColor $markLines * @param int $xOffset * @param int $yOffset + * @param float $stepSize + * @param int $type * @return void */ abstract public function drawDataHighlightText( @@ -267,7 +269,9 @@ abstract class ezcGraphRenderer $size, ezcGraphColor $markLines = null, $xOffset = 0, - $yOffset = 0 + $yOffset = 0, + $stepSize = 0., + $type = ezcGraph::LINE ); /** diff --git a/src/renderer/2d.php b/src/renderer/2d.php index 64e5d9a..082f2c3 100644 --- a/src/renderer/2d.php +++ b/src/renderer/2d.php @@ -532,7 +532,7 @@ class ezcGraphRenderer2d $margin = $stepSize * $this->options->barMargin; $padding = $stepSize * $this->options->barPadding; $barWidth = ( $stepSize - $margin ) / $dataCount - $padding; - $offset = - $stepSize / 2 + $margin / 2 + ( $dataCount - $dataNumber -1 ) * ( $padding + $barWidth ) + $padding / 2; + $offset = - $stepSize / 2 + $margin / 2 + ( $dataCount - $dataNumber - 1 ) * ( $padding + $barWidth ) + $padding / 2; $barPointArray = array( new ezcGraphCoordinate( @@ -948,6 +948,8 @@ class ezcGraphRenderer2d * @param ezcGraphColor $markLines * @param int $xOffset * @param int $yOffset + * @param float $stepSize + * @param int $type * @return void */ public function drawDataHighlightText( @@ -962,13 +964,25 @@ class ezcGraphRenderer2d $size, ezcGraphColor $markLines = null, $xOffset = 0, - $yOffset = 0 ) + $yOffset = 0, + $stepSize = 0., + $type = ezcGraph::LINE ) { + // Bar specific calculations + if ( $type !== ezcGraph::LINE ) + { + $margin = $stepSize * $this->options->barMargin; + $padding = $stepSize * $this->options->barPadding; + $barWidth = ( $stepSize - $margin ) / $dataCount - $padding; + $offset = -( $dataNumber + ( $dataCount - 1 ) / -2 ) * ( $barWidth + $padding ); + } + $this->driver->options->font = $font; $width = $boundings->width / $dataCount; $dataPoint = new ezcGraphCoordinate( - $boundings->x0 + ( $boundings->width ) * $end->x + $xOffset, + $boundings->x0 + ( $boundings->width ) * $end->x + $xOffset + + ( $type === ezcGraph::LINE ? 0 : $offset ), $boundings->y0 + ( $boundings->height ) * $end->y + $yOffset ); diff --git a/src/renderer/3d.php b/src/renderer/3d.php index 1978c2a..c730a6e 100644 --- a/src/renderer/3d.php +++ b/src/renderer/3d.php @@ -1552,6 +1552,8 @@ class ezcGraphRenderer3d * @param ezcGraphColor $markLines * @param int $xOffset * @param int $yOffset + * @param float $stepSize + * @param int $type * @return void */ public function drawDataHighlightText( @@ -1566,7 +1568,9 @@ class ezcGraphRenderer3d $size, ezcGraphColor $markLines = null, $xOffset = 0, - $yOffset = 0 ) + $yOffset = 0, + $stepSize = 0., + $type = ezcGraph::LINE ) { $this->driver->options->font = $font; $width = $this->dataBoundings->width / $dataCount; |