summaryrefslogtreecommitdiffstats
path: root/src/driver/svg.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-03-29 12:20:03 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-03-29 12:20:03 +0000
commitd96fa2d3668219a4105e986b3b75dd69a0d8ff37 (patch)
treeb123498c093978bcac9b0a30d38ad18099f1e1cf /src/driver/svg.php
parent46b36627ff6184fed301ab68c428a26ac5412cda (diff)
downloadzetacomponents-graph-d96fa2d3668219a4105e986b3b75dd69a0d8ff37.zip
zetacomponents-graph-d96fa2d3668219a4105e986b3b75dd69a0d8ff37.tar.gz
- Started implementing feature request #9404 (Rotated labels on axis)
# Works only with SVG driver now. # Angle needs to be set manually, no automatic optimal angle detection yet.
Diffstat (limited to 'src/driver/svg.php')
-rw-r--r--src/driver/svg.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/driver/svg.php b/src/driver/svg.php
index a32f541..daaa7c5 100644
--- a/src/driver/svg.php
+++ b/src/driver/svg.php
@@ -422,9 +422,10 @@ class ezcGraphSvgDriver extends ezcGraphDriver
* @param float $width Width of text box
* @param float $height Height of text box
* @param int $align Alignement of text
+ * @param ezcGraphRotation $rotation
* @return void
*/
- public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align )
+ public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null )
{
$padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 );
@@ -462,6 +463,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
'height' => $height,
'align' => $align,
'font' => $this->options->font,
+ 'rotation' => $rotation,
);
return $id;
@@ -559,9 +561,19 @@ class ezcGraphSvgDriver extends ezcGraphDriver
foreach ( $this->strings as $text )
{
// Add all text elements into one group
- $this->elements = $this->dom->createElement( 'g' );
- $this->elements->setAttribute( 'id', $text['id'] );
- $this->elements = $elementsRoot->appendChild( $this->elements );
+ $group = $this->dom->createElement( 'g' );
+ $group->setAttribute( 'id', $text['id'] );
+
+ if ( $text['rotation'] !== null )
+ {
+ $group->setAttribute( 'transform', sprintf( 'rotate( %.2f %.4f %.4f )',
+ $text['rotation']->getRotation(),
+ $text['rotation']->getCenter()->x,
+ $text['rotation']->getCenter()->y
+ ) );
+ }
+
+ $group = $elementsRoot->appendChild( $group );
$size = $text['font']->minimalUsedFont;
$font = $text['font']->name;
@@ -651,6 +663,9 @@ class ezcGraphSvgDriver extends ezcGraphDriver
);
}
+ // Set elements root temporary to local text group to ensure
+ // background and border beeing elements of text group
+ $this->elements = $group;
if ( $text['font']->background !== false )
{
$this->drawPolygon(
@@ -680,6 +695,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
$text['font']->borderWidth
);
}
+ $this->elements = $elementsRoot;
// Bottom line for SVG fonts is lifted a bit
$text['position']->y += $size * .85;
@@ -731,7 +747,7 @@ class ezcGraphSvgDriver extends ezcGraphDriver
1 - ( $text['font']->textShadowColor->alpha / 255 )
)
);
- $this->elements->appendChild( $textNode );
+ $group->appendChild( $textNode );
}
// Finally draw text
@@ -752,13 +768,11 @@ class ezcGraphSvgDriver extends ezcGraphDriver
1 - ( $text['font']->color->alpha / 255 )
)
);
- $this->elements->appendChild( $textNode );
+ $group->appendChild( $textNode );
$text['position']->y += $size + $size * $this->options->lineSpacing;
}
}
-
- $this->elements = $elementsRoot;
}
/**
OpenPOWER on IntegriCloud