diff options
-rw-r--r-- | src/driver/svg.php | 107 | ||||
-rw-r--r-- | src/exceptions/invalid_id.php | 26 | ||||
-rw-r--r-- | src/graph_autoload.php | 1 | ||||
-rw-r--r-- | src/options/chart.php | 2 | ||||
-rw-r--r-- | src/options/svg_driver.php | 61 | ||||
-rw-r--r-- | tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg | 38 | ||||
-rw-r--r-- | tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg | 38 | ||||
-rw-r--r-- | tests/data/template.svg | 233 | ||||
-rw-r--r-- | tests/driver_svg_test.php | 52 |
9 files changed, 516 insertions, 42 deletions
diff --git a/src/driver/svg.php b/src/driver/svg.php index 768f091..53bb73c 100644 --- a/src/driver/svg.php +++ b/src/driver/svg.php @@ -57,24 +57,49 @@ class ezcGraphSvgDriver extends ezcGraphDriver { if ( $this->dom === null ) { - $this->dom = new DOMDocument(); - $svg = $this->dom->createElementNS( 'http://www.w3.org/2000/svg', 'svg' ); - $this->dom->appendChild( $svg ); - - $svg->setAttribute( 'width', $this->options->width ); - $svg->setAttribute( 'height', $this->options->height ); - $svg->setAttribute( 'version', '1.0' ); - $svg->setAttribute( 'id', 'ezcGraph' ); - - $this->defs = $this->dom->createElement( 'defs' ); - $this->defs = $svg->appendChild( $this->defs ); - - $this->elements = $this->dom->createElement( 'g' ); - $this->elements->setAttribute( 'id', 'chart' ); - $this->elements->setAttribute( 'color-rendering', $this->options->colorRendering ); - $this->elements->setAttribute( 'shape-rendering', $this->options->shapeRendering ); - $this->elements->setAttribute( 'text-rendering', $this->options->textRendering ); - $this->elements = $svg->appendChild( $this->elements ); + if ( $this->options->templateDocument !== false ) + { + $this->dom = new DOMDocument(); + $this->dom->load( $this->options->templateDocument ); + + $this->defs = $this->dom->getElementsByTagName( 'defs' )->item( 0 ); + $svg = $this->dom->getElementsByTagName( 'svg' )->item( 0 ); + } + else + { + $this->dom = new DOMDocument(); + $svg = $this->dom->createElementNS( 'http://www.w3.org/2000/svg', 'svg' ); + $this->dom->appendChild( $svg ); + + $svg->setAttribute( 'width', $this->options->width ); + $svg->setAttribute( 'height', $this->options->height ); + $svg->setAttribute( 'version', '1.0' ); + $svg->setAttribute( 'id', 'ezcGraph' ); + + $this->defs = $this->dom->createElement( 'defs' ); + $this->defs = $svg->appendChild( $this->defs ); + } + + if ( $this->options->insertIntoGroup !== false ) + { + // getElementById only works for Documents validated against a certain + // schema, so that the use of XPath should be faster in most cases. + $xpath = new DomXPath( $this->dom ); + $this->elements = $xpath->query( '//*[@id = \'' . $this->options->insertIntoGroup . '\']' )->item( 0 ); + if ( !$this->elements ) + { + throw new ezcGraphSvgDriverInvalidIdException( $this->options->insertIntoGroup ); + } + } + else + { + $this->elements = $this->dom->createElement( 'g' ); + $this->elements->setAttribute( 'id', 'chart' ); + $this->elements->setAttribute( 'color-rendering', $this->options->colorRendering ); + $this->elements->setAttribute( 'shape-rendering', $this->options->shapeRendering ); + $this->elements->setAttribute( 'text-rendering', $this->options->textRendering ); + $this->elements = $svg->appendChild( $this->elements ); + } } } @@ -92,15 +117,15 @@ class ezcGraphSvgDriver extends ezcGraphDriver $lastPoint = end( $points ); $pointString = sprintf( ' M %.4f,%.4f', - $lastPoint->x, - $lastPoint->y + $lastPoint->x + $this->options->graphOffset->x, + $lastPoint->y + $this->options->graphOffset->y ); foreach ( $points as $point ) { $pointString .= sprintf( ' L %.4f,%.4f', - $point->x, - $point->y + $point->x + $this->options->graphOffset->x, + $point->y + $this->options->graphOffset->y ); } $pointString .= ' z '; @@ -151,10 +176,10 @@ class ezcGraphSvgDriver extends ezcGraphDriver $this->createDocument(); $pointString = sprintf( ' M %.4f,%.4f L %.4f,%.4f', - $start->x, - $start->y, - $end->x, - $end->y + $start->x + $this->options->graphOffset->x, + $start->y + $this->options->graphOffset->y, + $end->x + $this->options->graphOffset->x, + $end->y + $this->options->graphOffset->y ); $path = $this->dom->createElement( 'path' ); @@ -320,9 +345,9 @@ class ezcGraphSvgDriver extends ezcGraphDriver } $textNode = $this->dom->createElement( 'text', $string ); - $textNode->setAttribute( 'x', $position->x ); + $textNode->setAttribute( 'x', $position->x + $this->options->graphOffset->x ); $textNode->setAttribute( 'text-length', ( $size * strlen( $string ) * $this->options->assumedCharacterWidth ) . 'px' ); - $textNode->setAttribute( 'y', $position->y ); + $textNode->setAttribute( 'y', $position->y + $this->options->graphOffset->y ); $textNode->setAttribute( 'style', sprintf( @@ -369,15 +394,15 @@ class ezcGraphSvgDriver extends ezcGraphDriver $width /= 2; $height /= 2; - $Xstart = $center->x + $width * cos( ( -$startAngle / 180 ) * M_PI ); - $Ystart = $center->y + $height * sin( ( $startAngle / 180 ) * M_PI ); - $Xend = $center->x + $width * cos( ( -( $endAngle ) / 180 ) * M_PI ); - $Yend = $center->y + $height * sin( ( ( $endAngle ) / 180 ) * M_PI ); + $Xstart = $center->x + $this->options->graphOffset->x + $width * cos( ( -$startAngle / 180 ) * M_PI ); + $Ystart = $center->y + $this->options->graphOffset->y + $height * sin( ( $startAngle / 180 ) * M_PI ); + $Xend = $center->x + $this->options->graphOffset->x + $width * cos( ( -( $endAngle ) / 180 ) * M_PI ); + $Yend = $center->y + $this->options->graphOffset->y + $height * sin( ( ( $endAngle ) / 180 ) * M_PI ); $arc = $this->dom->createElement( 'path' ); $arc->setAttribute('d', sprintf('M %.2f,%.2f L %.2f,%.2f A %.2f,%2f 0 %d,1 %.2f,%.2f z', // Middle - $center->x, $center->y, + $center->x + $this->options->graphOffset->x, $center->y + $this->options->graphOffset->y, // Startpoint $Xstart, $Ystart, // Radius @@ -447,10 +472,10 @@ class ezcGraphSvgDriver extends ezcGraphDriver $width /= 2; $height /= 2; - $Xstart = $center->x + $width * cos( ( -$startAngle / 180 ) * M_PI ); - $Ystart = $center->y + $height * sin( ( $startAngle / 180 ) * M_PI ); - $Xend = $center->x + $width * cos( ( -( $endAngle ) / 180 ) * M_PI ); - $Yend = $center->y + $height * sin( ( ( $endAngle ) / 180 ) * M_PI ); + $Xstart = $center->x + $this->options->graphOffset->x + $width * cos( ( -$startAngle / 180 ) * M_PI ); + $Ystart = $center->y + $this->options->graphOffset->y + $height * sin( ( $startAngle / 180 ) * M_PI ); + $Xend = $center->x + $this->options->graphOffset->x + $width * cos( ( -( $endAngle ) / 180 ) * M_PI ); + $Yend = $center->y + $this->options->graphOffset->y + $height * sin( ( ( $endAngle ) / 180 ) * M_PI ); $arc = $this->dom->createElement( 'path' ); $arc->setAttribute('d', sprintf(' M %.2f,%.2f @@ -505,8 +530,8 @@ class ezcGraphSvgDriver extends ezcGraphDriver $this->createDocument(); $ellipse = $this->dom->createElement('ellipse'); - $ellipse->setAttribute( 'cx', $center->x ); - $ellipse->setAttribute( 'cy', $center->y ); + $ellipse->setAttribute( 'cx', $center->x + $this->options->graphOffset->x ); + $ellipse->setAttribute( 'cy', $center->y + $this->options->graphOffset->y ); $ellipse->setAttribute( 'rx', $width / 2 ); $ellipse->setAttribute( 'ry', $height / 2 ); @@ -556,8 +581,8 @@ class ezcGraphSvgDriver extends ezcGraphDriver $data = getimagesize( $file ); $image = $this->dom->createElement( 'image' ); - $image->setAttribute( 'x', $position->x ); - $image->setAttribute( 'y', $position->y ); + $image->setAttribute( 'x', $position->x + $this->options->graphOffset->x ); + $image->setAttribute( 'y', $position->y + $this->options->graphOffset->y ); $image->setAttribute( 'width', $width . 'px' ); $image->setAttribute( 'height', $height . 'px' ); $image->setAttributeNS( diff --git a/src/exceptions/invalid_id.php b/src/exceptions/invalid_id.php new file mode 100644 index 0000000..d849f13 --- /dev/null +++ b/src/exceptions/invalid_id.php @@ -0,0 +1,26 @@ +<?php +/** + * File containing the ezcGraphSvgDriverInvalidIdException class + * + * @package Graph + * @version //autogen// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Exception thrown when a id could not be found in a SVG document to insert + * elements in. + * + * @package Graph + * @version //autogen// + */ +class ezcGraphSvgDriverInvalidIdException extends ezcGraphException +{ + public function __construct( $id ) + { + parent::__construct( "Could not find element with id <{$id}> in SVG document." ); + } +} + +?> + diff --git a/src/graph_autoload.php b/src/graph_autoload.php index 5e50522..15703ea 100644 --- a/src/graph_autoload.php +++ b/src/graph_autoload.php @@ -45,6 +45,7 @@ return array( 'ezcGraphGdDriverUnsupportedImageTypeException' => 'Graph/exceptions/unsupported_image_type.php', 'ezcGraphSvgDriver' => 'Graph/driver/svg.php', 'ezcGraphSvgDriverOptions' => 'Graph/options/svg_driver.php', + 'ezcGraphSvgDriverInvalidIdException' => 'Graph/exceptions/invalid_id.php', 'ezcGraphInvalidDriverException' => 'Graph/exceptions/invalid_driver.php', 'ezcGraphVerboseDriver' => 'Graph/driver/verbose.php', diff --git a/src/options/chart.php b/src/options/chart.php index 788a03b..edfe012 100644 --- a/src/options/chart.php +++ b/src/options/chart.php @@ -36,7 +36,7 @@ class ezcGraphChartOptions extends ezcBaseOptions */ protected $font; - public function __construct( array $options=array() ) + public function __construct( array $options = array() ) { $this->font = new ezcGraphFontOptions(); diff --git a/src/options/svg_driver.php b/src/options/svg_driver.php index 6bd4ff8..f372b8b 100644 --- a/src/options/svg_driver.php +++ b/src/options/svg_driver.php @@ -60,6 +60,37 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions protected $textRendering = 'optimizeLegibility'; /** + * Use existing SVG document as template to insert graph into. If + * insertIntoGroup is not set, a new group will be inserted in the svg + * root node. + * + * @var string + */ + protected $templateDocument = false; + + /** + * ID of a SVG group node to insert the graph. Only works with a custom + * template document. + * + * @var mixed + * @access protected + */ + protected $insertIntoGroup = false; + + /** + * Offset of the graph in the svg + * + * @var ezcGraphCoordinate + */ + protected $graphOffset; + + public function __construct( array $options = array() ) + { + $this->graphOffset = new ezcGraphCoordinate( 0, 0 ); + parent::__construct( $options ); + } + + /** * Set an option value * * @param string $propertyName @@ -145,6 +176,36 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); } break; + case 'templateDocument': + if ( !is_file( $propertyValue ) || !is_readable( $propertyValue ) ) + { + throw new ezcBaseFileNotFoundException( $propertyValue ); + } + else + { + $this->templateDocument = realpath( $propertyValue ); + } + break; + case 'insertIntoGroup': + if ( !is_string( $propertyValue ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'string' ); + } + else + { + $this->insertIntoGroup = $propertyValue; + } + break; + case 'graphOffset': + if ( $propertyValue instanceof ezcGraphCoordinate ) + { + $this->graphOffset = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' ); + } + break; default: parent::__set( $propertyName, $propertyValue ); break; diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg new file mode 100644 index 0000000..a9c2b79 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplate.svg @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="600" height="400" id="svg2" sodipodi:version="0.32" inkscape:version="0.44" version="1.0" sodipodi:docbase="/home/kore/devel/ezcomponents/trunk/Graph/tests/data" sodipodi:docname="template.svg"> + <defs id="defs4"> + <linearGradient inkscape:collect="always" id="linearGradient3675"> + <stop style="stop-color:black;stop-opacity:1;" offset="0" id="stop3677"/> + <stop style="stop-color:black;stop-opacity:0;" offset="1" id="stop3679"/> + </linearGradient> + <linearGradient inkscape:collect="always" id="linearGradient2762"> + <stop style="stop-color:black;stop-opacity:1;" offset="0" id="stop2764"/> + <stop style="stop-color:black;stop-opacity:0;" offset="1" id="stop2766"/> + </linearGradient> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2768" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" gradientUnits="userSpaceOnUse"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2772" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2776" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2780" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <linearGradient inkscape:collect="always" xlink:href="#linearGradient3675" id="linearGradient3681" x1="288.77252" y1="-51.406147" x2="288.77252" y2="-106.853" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.670753,0,0,0.670754,118.9625,-5.977359)"/> + </defs> + <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="300" inkscape:cy="200" inkscape:document-units="px" inkscape:current-layer="layer1" width="600px" height="400px" inkscape:window-width="1024" inkscape:window-height="698" inkscape:window-x="0" inkscape:window-y="24"/> + <metadata id="metadata7"> + <rdf:RDF> + <cc:Work rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> + </cc:Work> + </rdf:RDF> + </metadata> + <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2768);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path1874" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(16,15)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2772);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2770" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(513.514,15.48056)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2776);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2774" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(513.514,311.4806)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2780);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2778" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(16.514,312.4806)"/> + <text xml:space="preserve" style="font-size:35.13032532px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" x="108.9454" y="52.191841" id="text2782" transform="scale(1.024845,0.975757)"><tspan sodipodi:role="line" id="tspan2784" x="108.9454" y="52.191841">Graph in a template</tspan></text> + <text transform="scale(0.936858,-1.067397)" id="text2786" y="-48.451878" x="119.17722" style="font-size:38.42963028px;font-style:normal;font-weight:normal;opacity:0.16860465;fill:url(#linearGradient3681);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" xml:space="preserve"><tspan y="-48.451878" x="119.17722" id="tspan2788" sodipodi:role="line" style="fill:url(#linearGradient3681);fill-opacity:1">Graph in a template</tspan></text> + <rect style="fill:white;fill-opacity:1;stroke:#999;stroke-width:1.12038434;stroke-opacity:1" id="rect1872" width="501" height="301" x="49.5" y="69.5"/> + <g id="graph_root_node"/> + </g> +<g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 0.0000,300.0000 L 0.0000,0.0000 L 500.0000,0.0000 L 500.0000,300.0000 L 0.0000,300.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 0.0000,300.0000 L 0.0000,0.0000 L 100.0000,0.0000 L 100.0000,300.0000 L 0.0000,300.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;"/><path d=" M 2.0000,33.0000 L 2.0000,19.0000 L 16.0000,19.0000 L 16.0000,33.0000 L 2.0000,33.0000 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 2.0000,51.0000 L 2.0000,37.0000 L 16.0000,37.0000 L 16.0000,51.0000 L 2.0000,51.0000 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 2.0000,69.0000 L 2.0000,55.0000 L 16.0000,55.0000 L 16.0000,69.0000 L 2.0000,69.0000 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 2.0000,87.0000 L 2.0000,73.0000 L 16.0000,73.0000 L 16.0000,87.0000 L 2.0000,87.0000 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 2.0000,105.0000 L 2.0000,91.0000 L 16.0000,91.0000 L 16.0000,105.0000 L 2.0000,105.0000 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 343.09,111.98 A 90.00,49.000000 0 0,0 252.20,113.48 L 252.20,103.48 A 90.00,49.000000 0 0,1 343.09,101.98 z" style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 358.15,117.60 A 90.00,49.000000 0 0,0 343.09,111.98 L 343.09,101.98 A 90.00,49.000000 0 0,1 358.15,107.60 z" style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 252.20,113.48 A 90.00,49.000000 0 0,0 231.59,123.16 L 231.59,113.16 A 90.00,49.000000 0 0,1 252.20,103.48 z" style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 390.00,155.00 A 90.00,49.000000 0 0,0 358.15,117.60 L 358.15,107.60 A 90.00,49.000000 0 0,1 390.00,145.00 z" style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 343.0898,101.9811 L 300.0000,145.0000 L 300.0000,155.0000 L 343.0898,111.9811 L 343.0898,101.9811 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 343.0898,101.9811 L 300.0000,145.0000 L 300.0000,155.0000 L 343.0898,111.9811 L 343.0898,101.9811 z " style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 343.0898,101.9811 L 300.0000,145.0000 L 300.0000,155.0000 L 343.0898,111.9811 L 343.0898,101.9811 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 343.0898,101.9811 L 300.0000,145.0000 L 300.0000,155.0000 L 343.0898,111.9811 L 343.0898,101.9811 z " style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 252.1962,103.4835 L 300.0000,145.0000 L 300.0000,155.0000 L 252.1962,113.4835 L 252.1962,103.4835 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 252.1962,103.4835 L 300.0000,145.0000 L 300.0000,155.0000 L 252.1962,113.4835 L 252.1962,103.4835 z " style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 252.1962,103.4835 L 300.0000,145.0000 L 300.0000,155.0000 L 252.1962,113.4835 L 252.1962,103.4835 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 252.1962,103.4835 L 300.0000,145.0000 L 300.0000,155.0000 L 252.1962,113.4835 L 252.1962,103.4835 z " style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 358.1502,107.6012 L 300.0000,145.0000 L 300.0000,155.0000 L 358.1502,117.6012 L 358.1502,107.6012 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 358.1502,107.6012 L 300.0000,145.0000 L 300.0000,155.0000 L 358.1502,117.6012 L 358.1502,107.6012 z " style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 358.1502,107.6012 L 300.0000,145.0000 L 300.0000,155.0000 L 358.1502,117.6012 L 358.1502,107.6012 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 358.1502,107.6012 L 300.0000,145.0000 L 300.0000,155.0000 L 358.1502,117.6012 L 358.1502,107.6012 z " style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 231.5905,113.1598 L 300.0000,145.0000 L 300.0000,155.0000 L 231.5905,123.1598 L 231.5905,113.1598 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 231.5905,113.1598 L 300.0000,145.0000 L 300.0000,155.0000 L 231.5905,123.1598 L 231.5905,113.1598 z " style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 231.5905,113.1598 L 300.0000,145.0000 L 300.0000,155.0000 L 231.5905,123.1598 L 231.5905,113.1598 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 231.5905,113.1598 L 300.0000,145.0000 L 300.0000,155.0000 L 231.5905,123.1598 L 231.5905,113.1598 z " style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 390.0000,145.0000 L 300.0000,145.0000 L 300.0000,155.0000 L 390.0000,155.0000 L 390.0000,145.0000 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 390.0000,145.0000 L 300.0000,145.0000 L 300.0000,155.0000 L 390.0000,155.0000 L 390.0000,145.0000 z " style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 390.0000,145.0000 L 300.0000,145.0000 L 300.0000,155.0000 L 390.0000,155.0000 L 390.0000,145.0000 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 390.0000,145.0000 L 300.0000,145.0000 L 300.0000,155.0000 L 390.0000,155.0000 L 390.0000,145.0000 z " style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 231.59,123.16 A 90.00,49.000000 0 1,0 390.00,155.00 L 390.00,145.00 A 90.00,49.000000 0 1,1 231.59,113.16 z" style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 390.00,145.00 A 90.00,49.000000 0 1,1 231.59,113.16 z" style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 390.00,145.00 A 90.00,49.000000 0 1,1 231.59,113.16 z" style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 300.00,145.00 L 231.59,113.16 A 90.00,49.000000 0 0,1 252.20,103.48 z" style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 231.59,113.16 A 90.00,49.000000 0 0,1 252.20,103.48 z" style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 300.00,145.00 L 252.20,103.48 A 90.00,49.000000 0 0,1 343.09,101.98 z" style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 252.20,103.48 A 90.00,49.000000 0 0,1 343.09,101.98 z" style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 300.00,145.00 L 343.09,101.98 A 90.00,49.000000 0 0,1 358.15,107.60 z" style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 343.09,101.98 A 90.00,49.000000 0 0,1 358.15,107.60 z" style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 300.00,145.00 L 358.15,107.60 A 90.00,49.000000 0 0,1 390.00,145.00 z" style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d="M 300.00,145.00 L 358.15,107.60 A 90.00,49.000000 0 0,1 390.00,145.00 z" style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 298.1792,109.0166 L 225.6948,76.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="298.17919395494" cy="109.0165804915" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="225.69476794592" cy="76.963055416875" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 260.8118,117.7394 L 198.0108,121.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="260.81181529129" cy="117.7393502549" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="198.01078321789" cy="121.96305541687" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 279.2200,178.7720 L 195.4492,166.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="279.21997746908" cy="178.77200969592" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="195.44922754781" cy="166.96305541687" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 333.9216,115.3056 L 380.6363,83.4461" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="333.92163212695" cy="115.30561947803" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="380.63629043296" cy="83.446080878682" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 354.4335,129.8567 L 403.6495,128.4461" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="354.43348875685" cy="129.85674048849" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="403.64951904905" cy="128.44608087868" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><text x="50" text-length="0px" y="16" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;"></text><text x="17" text-length="53.9px" y="33" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Mozilla</text><text x="17" text-length="15.4px" y="51" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">IE</text><text x="17" text-length="38.5px" y="69" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Opera</text><text x="17" text-length="30.8px" y="87" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">wget</text><text x="17" text-length="46.2px" y="105" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Safari</text><text x="136.09476794592" text-length="83.6px" y="80.963055416875" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Opera: 1204 (16.9%)</text><text x="130.41078321789" text-length="61.6px" y="125.96305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">IE: 345 (4.8%)</text><text x="154.24922754781" text-length="35.2px" y="166.91305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Mozilla:</text><text x="136.64922754781" text-length="52.8px" y="175.71305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">4375 (61.3%)</text><text x="386.63629043296" text-length="70.4px" y="87.446080878682" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">wget: 231 (3.2%)</text><text x="409.64951904905" text-length="83.6px" y="132.44608087868" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Safari: 987 (13.8%)</text></g></svg> diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg new file mode 100644 index 0000000..55b4bae --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawChartInTemplateCustomGroup.svg @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="600" height="400" id="svg2" sodipodi:version="0.32" inkscape:version="0.44" version="1.0" sodipodi:docbase="/home/kore/devel/ezcomponents/trunk/Graph/tests/data" sodipodi:docname="template.svg"> + <defs id="defs4"> + <linearGradient inkscape:collect="always" id="linearGradient3675"> + <stop style="stop-color:black;stop-opacity:1;" offset="0" id="stop3677"/> + <stop style="stop-color:black;stop-opacity:0;" offset="1" id="stop3679"/> + </linearGradient> + <linearGradient inkscape:collect="always" id="linearGradient2762"> + <stop style="stop-color:black;stop-opacity:1;" offset="0" id="stop2764"/> + <stop style="stop-color:black;stop-opacity:0;" offset="1" id="stop2766"/> + </linearGradient> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2768" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" gradientUnits="userSpaceOnUse"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2772" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2776" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <radialGradient inkscape:collect="always" xlink:href="#linearGradient2762" id="radialGradient2780" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" cx="34.486028" cy="56.519441" fx="34.486028" fy="56.519441" r="20.013971"/> + <linearGradient inkscape:collect="always" xlink:href="#linearGradient3675" id="linearGradient3681" x1="288.77252" y1="-51.406147" x2="288.77252" y2="-106.853" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.670753,0,0,0.670754,118.9625,-5.977359)"/> + </defs> + <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="300" inkscape:cy="200" inkscape:document-units="px" inkscape:current-layer="layer1" width="600px" height="400px" inkscape:window-width="1024" inkscape:window-height="698" inkscape:window-x="0" inkscape:window-y="24"/> + <metadata id="metadata7"> + <rdf:RDF> + <cc:Work rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> + </cc:Work> + </rdf:RDF> + </metadata> + <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2768);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path1874" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(16,15)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2772);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2770" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(513.514,15.48056)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2776);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2774" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(513.514,311.4806)"/> + <path sodipodi:type="star" style="opacity:0.7906977;fill:url(#radialGradient2780);fill-opacity:1;stroke:#999;stroke-opacity:1" id="path2778" sodipodi:sides="5" sodipodi:cx="36" sodipodi:cy="56" sodipodi:r1="21.095022" sodipodi:r2="10.547512" sodipodi:arg1="0.5485494" sodipodi:arg2="1.1768679" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " transform="translate(16.514,312.4806)"/> + <text xml:space="preserve" style="font-size:35.13032532px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" x="108.9454" y="52.191841" id="text2782" transform="scale(1.024845,0.975757)"><tspan sodipodi:role="line" id="tspan2784" x="108.9454" y="52.191841">Graph in a template</tspan></text> + <text transform="scale(0.936858,-1.067397)" id="text2786" y="-48.451878" x="119.17722" style="font-size:38.42963028px;font-style:normal;font-weight:normal;opacity:0.16860465;fill:url(#linearGradient3681);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" xml:space="preserve"><tspan y="-48.451878" x="119.17722" id="tspan2788" sodipodi:role="line" style="fill:url(#linearGradient3681);fill-opacity:1">Graph in a template</tspan></text> + <rect style="fill:white;fill-opacity:1;stroke:#999;stroke-width:1.12038434;stroke-opacity:1" id="rect1872" width="501" height="301" x="49.5" y="69.5"/> + <g id="graph_root_node"><path d=" M 50.0000,370.0000 L 50.0000,70.0000 L 550.0000,70.0000 L 550.0000,370.0000 L 50.0000,370.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 50.0000,370.0000 L 50.0000,70.0000 L 150.0000,70.0000 L 150.0000,370.0000 L 50.0000,370.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;"/><path d=" M 52.0000,103.0000 L 52.0000,89.0000 L 66.0000,89.0000 L 66.0000,103.0000 L 52.0000,103.0000 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 52.0000,121.0000 L 52.0000,107.0000 L 66.0000,107.0000 L 66.0000,121.0000 L 52.0000,121.0000 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 52.0000,139.0000 L 52.0000,125.0000 L 66.0000,125.0000 L 66.0000,139.0000 L 52.0000,139.0000 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 52.0000,157.0000 L 52.0000,143.0000 L 66.0000,143.0000 L 66.0000,157.0000 L 52.0000,157.0000 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 52.0000,175.0000 L 52.0000,161.0000 L 66.0000,161.0000 L 66.0000,175.0000 L 52.0000,175.0000 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 393.09,181.98 A 90.00,49.000000 0 0,0 302.20,183.48 L 302.20,173.48 A 90.00,49.000000 0 0,1 393.09,171.98 z" style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 408.15,187.60 A 90.00,49.000000 0 0,0 393.09,181.98 L 393.09,171.98 A 90.00,49.000000 0 0,1 408.15,177.60 z" style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 302.20,183.48 A 90.00,49.000000 0 0,0 281.59,193.16 L 281.59,183.16 A 90.00,49.000000 0 0,1 302.20,173.48 z" style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 440.00,225.00 A 90.00,49.000000 0 0,0 408.15,187.60 L 408.15,177.60 A 90.00,49.000000 0 0,1 440.00,215.00 z" style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 393.0898,171.9811 L 350.0000,215.0000 L 350.0000,225.0000 L 393.0898,181.9811 L 393.0898,171.9811 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 393.0898,171.9811 L 350.0000,215.0000 L 350.0000,225.0000 L 393.0898,181.9811 L 393.0898,171.9811 z " style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 393.0898,171.9811 L 350.0000,215.0000 L 350.0000,225.0000 L 393.0898,181.9811 L 393.0898,171.9811 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 393.0898,171.9811 L 350.0000,215.0000 L 350.0000,225.0000 L 393.0898,181.9811 L 393.0898,171.9811 z " style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 302.1962,173.4835 L 350.0000,215.0000 L 350.0000,225.0000 L 302.1962,183.4835 L 302.1962,173.4835 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 302.1962,173.4835 L 350.0000,215.0000 L 350.0000,225.0000 L 302.1962,183.4835 L 302.1962,173.4835 z " style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 302.1962,173.4835 L 350.0000,215.0000 L 350.0000,225.0000 L 302.1962,183.4835 L 302.1962,173.4835 z " style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d=" M 302.1962,173.4835 L 350.0000,215.0000 L 350.0000,225.0000 L 302.1962,183.4835 L 302.1962,173.4835 z " style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 408.1502,177.6012 L 350.0000,215.0000 L 350.0000,225.0000 L 408.1502,187.6012 L 408.1502,177.6012 z " style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d=" M 408.1502,177.6012 L 350.0000,215.0000 L 350.0000,225.0000 L 408.1502,187.6012 L 408.1502,177.6012 z " style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 408.1502,177.6012 L 350.0000,215.0000 L 350.0000,225.0000 L 408.1502,187.6012 L 408.1502,177.6012 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 408.1502,177.6012 L 350.0000,215.0000 L 350.0000,225.0000 L 408.1502,187.6012 L 408.1502,177.6012 z " style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 281.5905,183.1598 L 350.0000,215.0000 L 350.0000,225.0000 L 281.5905,193.1598 L 281.5905,183.1598 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 281.5905,183.1598 L 350.0000,215.0000 L 350.0000,225.0000 L 281.5905,193.1598 L 281.5905,183.1598 z " style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 281.5905,183.1598 L 350.0000,215.0000 L 350.0000,225.0000 L 281.5905,193.1598 L 281.5905,183.1598 z " style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d=" M 281.5905,183.1598 L 350.0000,215.0000 L 350.0000,225.0000 L 281.5905,193.1598 L 281.5905,183.1598 z " style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 440.0000,215.0000 L 350.0000,215.0000 L 350.0000,225.0000 L 440.0000,225.0000 L 440.0000,215.0000 z " style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d=" M 440.0000,215.0000 L 350.0000,215.0000 L 350.0000,225.0000 L 440.0000,225.0000 L 440.0000,215.0000 z " style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 440.0000,215.0000 L 350.0000,215.0000 L 350.0000,225.0000 L 440.0000,225.0000 L 440.0000,215.0000 z " style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d=" M 440.0000,215.0000 L 350.0000,215.0000 L 350.0000,225.0000 L 440.0000,225.0000 L 440.0000,215.0000 z " style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 281.59,193.16 A 90.00,49.000000 0 1,0 440.00,225.00 L 440.00,215.00 A 90.00,49.000000 0 1,1 281.59,183.16 z" style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 440.00,215.00 A 90.00,49.000000 0 1,1 281.59,183.16 z" style="fill: #4e9a06; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 440.00,215.00 A 90.00,49.000000 0 1,1 281.59,183.16 z" style="fill: none; stroke: #274d03; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 350.00,215.00 L 281.59,183.16 A 90.00,49.000000 0 0,1 302.20,173.48 z" style="fill: #cc0000; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 281.59,183.16 A 90.00,49.000000 0 0,1 302.20,173.48 z" style="fill: none; stroke: #660000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 350.00,215.00 L 302.20,173.48 A 90.00,49.000000 0 0,1 393.09,171.98 z" style="fill: #edd400; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 302.20,173.48 A 90.00,49.000000 0 0,1 393.09,171.98 z" style="fill: none; stroke: #776a00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 350.00,215.00 L 393.09,171.98 A 90.00,49.000000 0 0,1 408.15,177.60 z" style="fill: #75505b; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 393.09,171.98 A 90.00,49.000000 0 0,1 408.15,177.60 z" style="fill: none; stroke: #3b282e; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d="M 350.00,215.00 L 408.15,177.60 A 90.00,49.000000 0 0,1 440.00,215.00 z" style="fill: #f57900; fill-opacity: 1.00; stroke: none;"/><path d="M 350.00,215.00 L 408.15,177.60 A 90.00,49.000000 0 0,1 440.00,215.00 z" style="fill: none; stroke: #7b3d00; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><path d=" M 348.1792,179.0166 L 275.6948,146.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="348.17919395494" cy="179.0165804915" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="275.69476794592" cy="146.96305541687" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 310.8118,187.7394 L 248.0108,191.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="310.81181529129" cy="187.7393502549" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="248.01078321789" cy="191.96305541687" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 329.2200,248.7720 L 245.4492,236.9631" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="329.21997746908" cy="248.77200969592" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="245.44922754781" cy="236.96305541687" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 383.9216,185.3056 L 430.6363,153.4461" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="383.92163212695" cy="185.30561947803" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="430.63629043296" cy="153.44608087868" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><path d=" M 404.4335,199.8567 L 453.6495,198.4461" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/><ellipse cx="404.43348875685" cy="199.85674048849" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><ellipse cx="453.64951904905" cy="198.44608087868" rx="3" ry="3" style="fill: #000000; fill-opacity: 1.00; stroke: none;"/><text x="100" text-length="0px" y="86" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;"></text><text x="67" text-length="53.9px" y="103" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Mozilla</text><text x="67" text-length="15.4px" y="121" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">IE</text><text x="67" text-length="38.5px" y="139" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Opera</text><text x="67" text-length="30.8px" y="157" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">wget</text><text x="67" text-length="46.2px" y="175" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Safari</text><text x="186.09476794592" text-length="83.6px" y="150.96305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Opera: 1204 (16.9%)</text><text x="180.41078321789" text-length="61.6px" y="195.96305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">IE: 345 (4.8%)</text><text x="204.24922754781" text-length="35.2px" y="236.91305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Mozilla:</text><text x="186.64922754781" text-length="52.8px" y="245.71305541687" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">4375 (61.3%)</text><text x="436.63629043296" text-length="70.4px" y="157.44608087868" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">wget: 231 (3.2%)</text><text x="459.64951904905" text-length="83.6px" y="202.44608087868" style="font-size: 8px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">Safari: 987 (13.8%)</text></g> + </g> +</svg> diff --git a/tests/data/template.svg b/tests/data/template.svg new file mode 100644 index 0000000..17add75 --- /dev/null +++ b/tests/data/template.svg @@ -0,0 +1,233 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="600" + height="400" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.44" + version="1.0" + sodipodi:docbase="/home/kore/devel/ezcomponents/trunk/Graph/tests/data" + sodipodi:docname="template.svg"> + <defs + id="defs4"> + <linearGradient + inkscape:collect="always" + id="linearGradient3675"> + <stop + style="stop-color:black;stop-opacity:1;" + offset="0" + id="stop3677" /> + <stop + style="stop-color:black;stop-opacity:0;" + offset="1" + id="stop3679" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + id="linearGradient2762"> + <stop + style="stop-color:black;stop-opacity:1;" + offset="0" + id="stop2764" /> + <stop + style="stop-color:black;stop-opacity:0;" + offset="1" + id="stop2766" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2762" + id="radialGradient2768" + cx="34.486028" + cy="56.519441" + fx="34.486028" + fy="56.519441" + r="20.013971" + gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" + gradientUnits="userSpaceOnUse" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2762" + id="radialGradient2772" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" + cx="34.486028" + cy="56.519441" + fx="34.486028" + fy="56.519441" + r="20.013971" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2762" + id="radialGradient2776" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" + cx="34.486028" + cy="56.519441" + fx="34.486028" + fy="56.519441" + r="20.013971" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2762" + id="radialGradient2780" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1,0,0,1.024223,0,-1.369049)" + cx="34.486028" + cy="56.519441" + fx="34.486028" + fy="56.519441" + r="20.013971" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3675" + id="linearGradient3681" + x1="288.77252" + y1="-51.406147" + x2="288.77252" + y2="-106.853" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.670753,0,0,0.670754,118.9625,-5.977359)" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1" + inkscape:cx="300" + inkscape:cy="200" + inkscape:document-units="px" + inkscape:current-layer="layer1" + width="600px" + height="400px" + inkscape:window-width="1024" + inkscape:window-height="698" + inkscape:window-x="0" + inkscape:window-y="24" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + sodipodi:type="star" + style="opacity:0.7906977;fill:url(#radialGradient2768);fill-opacity:1;stroke:#999;stroke-opacity:1" + id="path1874" + sodipodi:sides="5" + sodipodi:cx="36" + sodipodi:cy="56" + sodipodi:r1="21.095022" + sodipodi:r2="10.547512" + sodipodi:arg1="0.5485494" + sodipodi:arg2="1.1768679" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " + transform="translate(16,15)" /> + <path + sodipodi:type="star" + style="opacity:0.7906977;fill:url(#radialGradient2772);fill-opacity:1;stroke:#999;stroke-opacity:1" + id="path2770" + sodipodi:sides="5" + sodipodi:cx="36" + sodipodi:cy="56" + sodipodi:r1="21.095022" + sodipodi:r2="10.547512" + sodipodi:arg1="0.5485494" + sodipodi:arg2="1.1768679" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " + transform="translate(513.514,15.48056)" /> + <path + sodipodi:type="star" + style="opacity:0.7906977;fill:url(#radialGradient2776);fill-opacity:1;stroke:#999;stroke-opacity:1" + id="path2774" + sodipodi:sides="5" + sodipodi:cx="36" + sodipodi:cy="56" + sodipodi:r1="21.095022" + sodipodi:r2="10.547512" + sodipodi:arg1="0.5485494" + sodipodi:arg2="1.1768679" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " + transform="translate(513.514,311.4806)" /> + <path + sodipodi:type="star" + style="opacity:0.7906977;fill:url(#radialGradient2780);fill-opacity:1;stroke:#999;stroke-opacity:1" + id="path2778" + sodipodi:sides="5" + sodipodi:cx="36" + sodipodi:cy="56" + sodipodi:r1="21.095022" + sodipodi:r2="10.547512" + sodipodi:arg1="0.5485494" + sodipodi:arg2="1.1768679" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 53.999999,66.999999 L 40.048335,65.739661 L 31.100684,76.518203 L 27.988036,62.859916 L 14.972057,57.680948 L 26.999999,50.5 L 27.903332,36.520679 L 38.449658,45.740897 L 52.023927,42.28017 L 46.513972,55.159526 L 53.999999,66.999999 z " + transform="translate(16.514,312.4806)" /> + <text + xml:space="preserve" + style="font-size:35.13032532px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + x="108.9454" + y="52.191841" + id="text2782" + transform="scale(1.024845,0.975757)"><tspan + sodipodi:role="line" + id="tspan2784" + x="108.9454" + y="52.191841">Graph in a template</tspan></text> + <text + transform="scale(0.936858,-1.067397)" + id="text2786" + y="-48.451878" + x="119.17722" + style="font-size:38.42963028px;font-style:normal;font-weight:normal;opacity:0.16860465;fill:url(#linearGradient3681);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="-48.451878" + x="119.17722" + id="tspan2788" + sodipodi:role="line" + style="fill:url(#linearGradient3681);fill-opacity:1">Graph in a template</tspan></text> + <rect + style="fill:white;fill-opacity:1;stroke:#999;stroke-width:1.12038434;stroke-opacity:1" + id="rect1872" + width="501" + height="301" + x="49.5" + y="69.5"/> + <g id="graph_root_node"/> + </g> +</svg> diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php index 36a87db..5c19c0a 100644 --- a/tests/driver_svg_test.php +++ b/tests/driver_svg_test.php @@ -822,6 +822,58 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } + + public function testDrawChartInTemplate() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphPieChart(); + $chart['sample'] = array( + 'Mozilla' => 4375, + 'IE' => 345, + 'Opera' => 1204, + 'wget' => 231, + 'Safari' => 987, + ); + + $chart->driver = new ezcGraphSvgDriver(); + $chart->driver->options->templateDocument = dirname( __FILE__ ) . '/data/template.svg'; + + $chart->renderer = new ezcGraphRenderer3d(); + $chart->render( 500, 300, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testDrawChartInTemplateCustomGroup() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphPieChart(); + $chart['sample'] = array( + 'Mozilla' => 4375, + 'IE' => 345, + 'Opera' => 1204, + 'wget' => 231, + 'Safari' => 987, + ); + + $chart->driver = new ezcGraphSvgDriver(); + $chart->driver->options->templateDocument = dirname( __FILE__ ) . '/data/template.svg'; + $chart->driver->options->insertIntoGroup = 'graph_root_node'; + $chart->driver->options->graphOffset = new ezcGraphCoordinate( 50, 70 ); + + $chart->renderer = new ezcGraphRenderer3d(); + $chart->render( 500, 300, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } ?> |