public function testRenderHorizontalAxisReverse() { $chart = new ezcGraphLineChart(); $this->driver->expects($this->at(0))->method('drawLine')->with($this->equalTo(new ezcGraphCoordinate(450.0, 120.0), 1.0), $this->equalTo(new ezcGraphCoordinate(150.0, 120.0), 1.0), $this->equalTo(ezcGraphColor::fromHex('#2E3436')), $this->equalTo(1)); $this->driver->expects($this->at(1))->method('drawPolygon')->with($this->equalTo(array(new ezcGraphCoordinate(150.0, 120.0), new ezcGraphCoordinate(157.0, 116.5), new ezcGraphCoordinate(157.0, 123.5)), 1.0), $this->equalTo(ezcGraphColor::fromHex('#2E3436')), $this->equalTo(true)); $this->renderer->drawAxis(new ezcGraphBoundings(100, 20, 500, 220), new ezcGraphCoordinate(350, 100), new ezcGraphCoordinate(50, 100), $chart->yAxis); }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->properties['pieChartShadowSize'] = 0; $this->properties['pieChartShadowTransparency'] = 0.3; $this->properties['pieChartShadowColor'] = ezcGraphColor::fromHex('#000000'); parent::__construct($options); }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->properties['width'] = null; $this->properties['height'] = null; $this->properties['lineSpacing'] = 0.1; $this->properties['shadeCircularArc'] = 0.5; $this->properties['font'] = new ezcGraphFontOptions(); $this->properties['font']->color = ezcGraphColor::fromHex('#000000'); $this->properties['autoShortenString'] = true; $this->properties['autoShortenStringPostFix'] = '..'; parent::__construct($options); }
public function testRenderAxisNoInnerSteps() { $chart = new ezcGraphRadarChart(); $chart->palette = new ezcGraphPaletteBlack(); $chart->axis->axisLabelRenderer->innerStep = false; $chart->axis->axisLabelRenderer->outerStep = true; $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1)); $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawStepRadar')); $mockedRenderer->expects($this->at(0))->method('drawStepRadar')->with($this->equalTo(new ezcGraphCoordinate(204.0, 180.0), 1.0), $this->equalTo(new ezcGraphCoordinate(204.0, 183.0), 1.0), $this->equalTo(ezcGraphColor::fromHex('#EEEEEC'))); $mockedRenderer->expects($this->at(4))->method('drawStepRadar')->with($this->equalTo(new ezcGraphCoordinate(460.0, 180.0), 1.0), $this->equalTo(new ezcGraphCoordinate(460.0, 183.0), 1.0), $this->equalTo(ezcGraphColor::fromHex('#EEEEEC'))); $chart->renderer = $mockedRenderer; $chart->render(500, 200); }
/** * Draws a bar with a diamond ground shape. * * @param ezcGraphContext $context * @param ezcGraphColor $color * @param ezcGraphCoordinate $position * @param float $barWidth * @param float $offset * @param float $axisPosition * @param float $startDepth * @param float $midDepth * @param float $endDepth * @return void */ protected function drawDiamondBar(ezcGraphContext $context, ezcGraphColor $color, ezcGraphCoordinate $position, $barWidth, $offset, $axisPosition, $startDepth, $midDepth, $endDepth) { $barCoordinateArray = array('x' => array($this->dataBoundings->x0 + $this->xAxisSpace + $position->x * ($this->dataBoundings->x1 - ($this->dataBoundings->x0 + 2 * $this->xAxisSpace)) + $offset, $this->dataBoundings->x0 + $this->xAxisSpace + $position->x * ($this->dataBoundings->x1 - ($this->dataBoundings->x0 + 2 * $this->xAxisSpace)) + $offset + $barWidth * 0.7, $this->dataBoundings->x0 + $this->xAxisSpace + $position->x * ($this->dataBoundings->x1 - ($this->dataBoundings->x0 + 2 * $this->xAxisSpace)) + $offset + $barWidth, $this->dataBoundings->x0 + $this->xAxisSpace + $position->x * ($this->dataBoundings->x1 - ($this->dataBoundings->x0 + 2 * $this->xAxisSpace)) + $offset + $barWidth * 0.3), 'y' => array($this->dataBoundings->y0 + $this->yAxisSpace + $axisPosition * ($this->dataBoundings->y1 - ($this->dataBoundings->y0 + 2 * $this->yAxisSpace)), $this->dataBoundings->y0 + $this->yAxisSpace + $position->y * ($this->dataBoundings->y1 - ($this->dataBoundings->y0 + 2 * $this->yAxisSpace)))); // Left side $this->barPostProcessing[] = array('index' => $barCoordinateArray['x'][0], 'method' => 'drawPolygon', 'context' => $context, 'parameters' => array(array($this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][0], $barCoordinateArray['y'][0]), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][0], $barCoordinateArray['y'][1]), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $barCoordinateArray['y'][1]), $startDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $barCoordinateArray['y'][0]), $startDepth)), $color, true)); // Right side $this->barPostProcessing[] = array('index' => $barCoordinateArray['x'][1], 'method' => 'drawPolygon', 'context' => $context, 'parameters' => array(array($this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][2], $barCoordinateArray['y'][0]), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][2], $barCoordinateArray['y'][1]), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $barCoordinateArray['y'][1]), $startDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $barCoordinateArray['y'][0]), $startDepth)), $color->darken($this->options->barDarkenSide), true)); $topLocation = min($barCoordinateArray['y'][0], $barCoordinateArray['y'][1]); // Top side $this->barPostProcessing[] = array('index' => $barCoordinateArray['x'][0], 'method' => 'drawPolygon', 'context' => $context, 'parameters' => array(array($this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $topLocation), $startDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][2], $topLocation), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][3], $topLocation), $endDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][0], $topLocation), $midDepth)), $color->darken($this->options->barDarkenTop), true)); // Top side gleam if ($this->options->barChartGleam !== false) { $this->barPostProcessing[] = array('index' => $barCoordinateArray['x'][0] + 1, 'method' => 'drawPolygon', 'context' => $context, 'parameters' => array(array($this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][1], $topLocation), $startDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][2], $topLocation), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][3], $topLocation), $endDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][0], $topLocation), $midDepth)), new ezcGraphLinearGradient($this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][2], $topLocation), $midDepth), $this->get3dCoordinate(new ezcGraphCoordinate($barCoordinateArray['x'][0], $topLocation), $midDepth), ezcGraphColor::fromHex('#FFFFFFFF'), ezcGraphColor::fromHex('#FFFFFF')->transparent(1 - $this->options->barChartGleam)), true)); } }
public function testDrawTextWithMinimizedBorderAndBackgroundBottomRight() { $filename = $this->tempDir . __FUNCTION__ . '.png'; $this->driver->options->font->border = ezcGraphColor::fromHex('#555555'); $this->driver->options->font->background = ezcGraphColor::fromHex('#DDDDDD'); $this->driver->options->font->minimizeBorder = true; $this->driver->options->font->padding = 2; $this->driver->drawTextBox('Some test string', new ezcGraphCoordinate(10, 10), 150, 70, ezcGraph::RIGHT | ezcGraph::BOTTOM); $this->driver->render($filename); $this->assertTrue(file_exists($filename), 'No image was generated.'); $this->assertImageSimilar($filename, $this->basePath . 'compare/' . 'ezcGraphCairoDriverTest' . '_' . __FUNCTION__ . '.png', 'Image does not look as expected.', 2000); }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->properties['name'] = 'sans-serif'; // $this->properties['path'] = 'Graph/tests/data/font.ttf'; $this->properties['path'] = ''; $this->properties['type'] = ezcGraph::TTF_FONT; $this->properties['minFontSize'] = 6; $this->properties['maxFontSize'] = 96; $this->properties['minimalUsedFont'] = 96; $this->properties['color'] = ezcGraphColor::fromHex('#000000'); $this->properties['background'] = false; $this->properties['border'] = false; $this->properties['borderWidth'] = 1; $this->properties['padding'] = 0; $this->properties['minimizeBorder'] = true; $this->properties['textShadow'] = false; $this->properties['textShadowOffset'] = 1; $this->properties['textShadowColor'] = false; parent::__construct($options); }
/** * Draws a circular arc * * @param ezcGraphCoordinate $center Center of ellipse * @param integer $width Width of ellipse * @param integer $height Height of ellipse * @param integer $size Height of border * @param float $startAngle Starting angle of circle sector * @param float $endAngle Ending angle of circle sector * @param ezcGraphColor $color Color of Border * @param bool $filled * @return void */ public function drawCircularArc(ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true) { $this->createDocument(); // Normalize angles if ($startAngle > $endAngle) { $tmp = $startAngle; $startAngle = $endAngle; $endAngle = $tmp; } if ($endAngle - $startAngle > 180 || $startAngle % 180 != 0 && $endAngle % 180 != 0 && ($startAngle % 360 > 180 xor $endAngle % 360 > 180)) { // Border crosses he 180 degrees border $intersection = floor($endAngle / 180) * 180; while ($intersection >= $endAngle) { $intersection -= 180; } $this->drawCircularArc($center, $width, $height, $size, $startAngle, $intersection, $color, $filled); $this->drawCircularArc($center, $width, $height, $size, $intersection, $endAngle, $color, $filled); return; } // We need the radius $width /= 2; $height /= 2; $Xstart = $center->x + $this->options->graphOffset->x + $width * cos(-deg2rad($startAngle)); $Ystart = $center->y + $this->options->graphOffset->y + $height * sin(deg2rad($startAngle)); $Xend = $center->x + $this->options->graphOffset->x + $width * cos(-deg2rad($endAngle)); $Yend = $center->y + $this->options->graphOffset->y + $height * sin(deg2rad($endAngle)); if ($filled === true) { $arc = $this->dom->createElement('path'); $arc->setAttribute('d', sprintf('M %.2F,%.2F A %.2F,%.2F 0 %d,0 %.2F,%.2F L %.2F,%.2F A %.2F,%2F 0 %d,1 %.2F,%.2F z', $Xend, $Yend + $size, $width, $height, $endAngle - $startAngle > 180, $Xstart, $Ystart + $size, $Xstart, $Ystart, $width, $height, $endAngle - $startAngle > 180, $Xend, $Yend)); } else { $arc = $this->dom->createElement('path'); $arc->setAttribute('d', sprintf('M %.2F,%.2F A %.2F,%.2F 0 %d,1 %.2F,%.2F', $Xstart, $Ystart, $width, $height, $endAngle - $startAngle > 180, $Xend, $Yend)); } $arc->setAttribute('style', $this->getStyle($color, $filled)); $arc->setAttribute('id', $id = $this->options->idPrefix . 'CircularArc_' . ++$this->elementID); $this->elements->appendChild($arc); if ($this->options->shadeCircularArc !== false && $filled) { $gradient = new ezcGraphLinearGradient(new ezcGraphCoordinate($center->x - $width, $center->y), new ezcGraphCoordinate($center->x + $width, $center->y), ezcGraphColor::fromHex('#FFFFFF')->transparent($this->options->shadeCircularArc * 1.5), ezcGraphColor::fromHex('#000000')->transparent($this->options->shadeCircularArc)); $arc = $this->dom->createElement('path'); $arc->setAttribute('d', sprintf('M %.2F,%.2F A %.2F,%.2F 0 %d,0 %.2F,%.2F L %.2F,%.2F A %.2F,%2F 0 %d,1 %.2F,%.2F z', $Xend, $Yend + $size, $width, $height, $endAngle - $startAngle > 180, $Xstart, $Ystart + $size, $Xstart, $Ystart, $width, $height, $endAngle - $startAngle > 180, $Xend, $Yend)); $arc->setAttribute('style', $this->getStyle($gradient, $filled)); $arc->setAttribute('id', $id = $this->options->idPrefix . 'CircularArc_' . ++$this->elementID); $this->elements->appendChild($arc); } return $id; }
public function testDrawGridLines() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; $chart = new ezcGraphRadarChart(); $chart->palette = new ezcGraphPaletteBlack(); $chart->data['sample'] = new ezcGraphArrayDataSet($this->getRandomData(6)); $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawGridLine')); $mockedRenderer->expects($this->at(0))->method('drawGridLine')->with($this->equalTo(new ezcGraphCoordinate(338.0, 93.8), 0.1), $this->equalTo(new ezcGraphCoordinate(300.0, 80.0), 0.1), $this->equalTo(ezcGraphColor::fromHex('#888A85'))); $mockedRenderer->expects($this->at(1))->method('drawGridLine')->with($this->equalTo(new ezcGraphCoordinate(343.75, 92.90000000000001), 0.1), $this->equalTo(new ezcGraphCoordinate(300.0, 77.0), 0.1), $this->equalTo(ezcGraphColor::fromHex('#888A8588'))); // Next axis $mockedRenderer->expects($this->at(21))->method('drawGridLine')->with($this->equalTo(new ezcGraphCoordinate(323.5, 116.2), 0.1), $this->equalTo(new ezcGraphCoordinate(338.0, 93.8), 0.1), $this->equalTo(ezcGraphColor::fromHex('#888A85'))); $chart->renderer = $mockedRenderer; $chart->render(500, 200); }
public function testChartElementAxisPropertyMinorGrid() { $options = new ezcGraphChartElementNumericAxis(); $this->assertSame(false, $options->minorGrid, 'Wrong default value for property minorGrid in class ezcGraphChartElementNumericAxis'); $options->minorGrid = $color = ezcGraphColor::fromHex('#FFFFFF'); $this->assertSame($color, $options->minorGrid, 'Setting property value did not work for property minorGrid in class ezcGraphChartElementNumericAxis'); try { $options->minorGrid = false; } catch (ezcGraphUnknownColorDefinitionException $e) { return true; } $this->fail('Expected ezcGraphUnknownColorDefinitionException.'); }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->properties['seperateLines'] = true; $this->properties['fillAxis'] = 0.8; $this->properties['fillGrid'] = 0; $this->properties['depth'] = 0.1; $this->properties['pieChartHeight'] = 10.0; $this->properties['pieChartRotation'] = 0.6; $this->properties['pieChartShadowSize'] = 0; $this->properties['pieChartShadowTransparency'] = 0.3; $this->properties['pieChartShadowColor'] = ezcGraphColor::fromHex('#000000'); $this->properties['pieChartGleam'] = false; $this->properties['pieChartGleamColor'] = ezcGraphColor::fromHex('#FFFFFF'); $this->properties['barDarkenSide'] = 0.2; $this->properties['barDarkenTop'] = 0.4; $this->properties['barChartGleam'] = false; parent::__construct($options); }
public function testChangeDefaultRenderSettings() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; $this->driver->options->strokeLineJoin = 'bevel'; $this->driver->options->strokeLineCap = 'square'; $this->driver->options->shapeRendering = 'optimizeSpeed'; $this->driver->options->colorRendering = 'optimizeSpeed'; $this->driver->options->textRendering = 'optimizeSpeed'; $return = $this->driver->drawPolygon(array(new ezcGraphCoordinate(45, 12), new ezcGraphCoordinate(122, 34), new ezcGraphCoordinate(12, 71)), ezcGraphColor::fromHex('#3465A4'), false); $this->driver->render($filename); $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'); $this->assertEquals('ezcGraphPolygon_1', $return, 'Expected xml id as return value.'); }
public function testRenderToOutput() { $filename = $this->tempDir . __FUNCTION__ . '.swf'; $this->driver->drawLine(new ezcGraphCoordinate(12, 45), new ezcGraphCoordinate(134, 12), ezcGraphColor::fromHex('#3465A4')); $this->assertEquals($this->driver->getMimeType(), 'application/x-shockwave-flash', 'Wrong mime type returned.'); ob_start(); // Suppress header already sent warning @$this->driver->renderToOutput(); file_put_contents($filename, ob_get_clean()); $this->swfCompare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'); }
public function testLegendSetBorder() { $chart = new ezcGraphPieChart(); $chart->legend->border = '#FF0000'; $this->assertEquals(ezcGraphColor::fromHex('#FF0000'), $chart->legend->border); }
public function testDataSetSetSingleColor() { $chart = new ezcGraphPieChart(); $chart->data['income'] = new ezcGraphArrayDataSet(array(2000 => 2345.2, 2456.3, 2567.4)); $chart->data['income']->color[2001] = '#FF0000'; $this->assertEquals(ezcGraphColor::fromHex('#FF0000'), $chart->data['income']->color[2001]); }
public function testRenderAxisGridFromBottom() { $chart = new ezcGraphLineChart(); $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer(); $chart->yAxis->position = ezcGraph::BOTTOM; $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1)); $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawGridLine')); $mockedRenderer->expects($this->at(0))->method('drawGridLine')->with($this->equalTo(new ezcGraphCoordinate(140.0, 148.0), 1.0), $this->equalTo(new ezcGraphCoordinate(460.0, 148.0), 1.0), $this->equalTo(ezcGraphColor::fromHex('#888A85'))); $chart->renderer = $mockedRenderer; $chart->render(500, 200); }
/** * Constructor * * @param array $options Default option array * @return void * @ignore */ public function __construct(array $options = array()) { $this->properties['maxLabelHeight'] = 0.1; $this->properties['showSymbol'] = true; $this->properties['symbolSize'] = 6; $this->properties['moveOut'] = 0.1; $this->properties['titlePosition'] = ezcGraph::TOP; $this->properties['titleAlignement'] = ezcGraph::MIDDLE | ezcGraph::CENTER; $this->properties['dataBorder'] = 0.5; $this->properties['barMargin'] = 0.1; $this->properties['barPadding'] = 0.05; $this->properties['pieChartOffset'] = 0; $this->properties['pieChartSymbolColor'] = ezcGraphColor::fromHex('#000000'); $this->properties['pieChartGleam'] = false; $this->properties['pieChartGleamColor'] = ezcGraphColor::fromHex('#FFFFFF'); $this->properties['pieChartGleamBorder'] = 0; $this->properties['legendSymbolGleam'] = false; $this->properties['legendSymbolGleamSize'] = 0.9; $this->properties['legendSymbolGleamColor'] = ezcGraphColor::fromHex('#FFFFFF'); $this->properties['pieVerticalSize'] = 0.5; $this->properties['pieHorizontalSize'] = 0.25; $this->properties['syncAxisFonts'] = true; parent::__construct($options); }
public function testRadialGradientSetProperties() { $color = new ezcGraphRadialGradient(new ezcGraphCoordinate(0, 0), 10, 20, ezcGraphColor::fromHex('#FFFFFF'), ezcGraphColor::fromHex('#000000')); $color->center = new ezcGraphCoordinate(5, 5); $color->width = 15; $color->height = 25; $color->startColor = ezcGraphColor::fromHex('#000000'); $color->endColor = ezcGraphColor::fromHex('#FFFFFF'); $this->assertEquals($color->center, new ezcGraphCoordinate(5, 5)); $this->assertEquals($color->width, 15); $this->assertEquals($color->height, 25); $this->assertEquals($color->startColor, ezcGraphColor::fromHex('#000000')); $this->assertEquals($color->endColor, ezcGraphColor::fromHex('#FFFFFF00')); }
public function testISO_8859_15SpecialCharsFlash() { if (!ezcBaseFeatures::hasExtensionSupport("ming")) { $this->markTestSkipped("ext/ming not found"); } $filename = $this->tempDir . __FUNCTION__ . '.swf'; $driver = new ezcGraphFlashDriver(); $driver->options->font->path = $this->basePath . 'fdb_font.fdb'; $driver->options->width = 200; $driver->options->height = 100; $driver->drawPolygon(array(new ezcGraphCoordinate(10, 10), new ezcGraphCoordinate(160, 10), new ezcGraphCoordinate(160, 80), new ezcGraphCoordinate(10, 80)), ezcGraphColor::fromHex('#eeeeec'), true); $driver->drawTextBox(iconv('UTF-8', 'ISO-8859-15', 'öäüÖÄÜß'), new ezcGraphCoordinate(10, 10), 150, 70, ezcGraph::LEFT); $driver->render($filename); $this->swfCompare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf'); }
/** * Draws a circular arc * * @param ezcGraphCoordinate $center Center of ellipse * @param integer $width Width of ellipse * @param integer $height Height of ellipse * @param integer $size Height of border * @param float $startAngle Starting angle of circle sector * @param float $endAngle Ending angle of circle sector * @param ezcGraphColor $color Color of Border * @param bool $filled * @return void */ public function drawCircularArc(ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true) { if ($startAngle > $endAngle) { $tmp = $startAngle; $startAngle = $endAngle; $endAngle = $tmp; } $id = $this->simulateCircularArc($center, $width, $height, $size, $startAngle, $endAngle, $color, $filled); if ($this->options->shadeCircularArc !== false && $filled) { $gradient = new ezcGraphLinearGradient(new ezcGraphCoordinate($center->x - $width, $center->y), new ezcGraphCoordinate($center->x + $width, $center->y), ezcGraphColor::fromHex('#FFFFFF')->transparent($this->options->shadeCircularArc * 1.5), ezcGraphColor::fromHex('#000000')->transparent($this->options->shadeCircularArc * 1.5)); $this->simulateCircularArc($center, $width, $height, $size, $startAngle, $endAngle, $gradient, $filled); } return $id; }
public function testPieRenderPieSegmentsWithLabelCallback() { $chart = new ezcGraphPieChart(); $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987)); $chart->data['sample']->highlight['wget'] = true; $chart->options->labelCallback = create_function('$label, $value, $percent', "return 'Callback: ' . \$label;"); $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawPieSegment')); $mockedRenderer->expects($this->at(0))->method('drawPieSegment')->with($this->equalTo(new ezcGraphBoundings(80, 0, 400, 200)), $this->equalTo(new ezcGraphContext('sample', 'Mozilla')), $this->equalTo(ezcGraphColor::fromHex('#3465A4')), $this->equalTo(0.0, 1.0), $this->equalTo(220.5, 0.1), $this->equalTo('Callback: Mozilla'), $this->equalTo(false)); $mockedRenderer->expects($this->at(1))->method('drawPieSegment')->with($this->equalTo(new ezcGraphBoundings(80, 0, 400, 200)), $this->equalTo(new ezcGraphContext('sample', 'IE')), $this->equalTo(ezcGraphColor::fromHex('#4E9A06')), $this->equalTo(220.5, 0.1), $this->equalTo(238.0, 1.0), $this->equalTo('Callback: IE'), $this->equalTo(false)); $mockedRenderer->expects($this->at(2))->method('drawPieSegment')->with($this->equalTo(new ezcGraphBoundings(80, 0, 400, 200)), $this->equalTo(new ezcGraphContext('sample', 'Opera')), $this->equalTo(ezcGraphColor::fromHex('#CC0000')), $this->equalTo(238.0, 1.0), $this->equalTo(298.6, 1.0), $this->equalTo('Callback: Opera'), $this->equalTo(false)); $mockedRenderer->expects($this->at(3))->method('drawPieSegment')->with($this->equalTo(new ezcGraphBoundings(80, 0, 400, 200)), $this->equalTo(new ezcGraphContext('sample', 'wget')), $this->equalTo(ezcGraphColor::fromHex('#EDD400')), $this->equalTo(298.6, 1.0), $this->equalTo(310.0, 1.0), $this->equalTo('Callback: wget'), $this->equalTo(true)); $mockedRenderer->expects($this->at(4))->method('drawPieSegment')->with($this->equalTo(new ezcGraphBoundings(80, 0, 400, 200)), $this->equalTo(new ezcGraphContext('sample', 'Safari')), $this->equalTo(ezcGraphColor::fromHex('#75505B')), $this->equalTo(310.0, 1.0), $this->equalTo(360.0, 1.0), $this->equalTo('Callback: Safari'), $this->equalTo(false)); $chart->renderer = $mockedRenderer; $chart->render(400, 200); }
public function testRenderChartSymbols() { $chart = new ezcGraphLineChart(); $chart->palette = new ezcGraphPaletteBlack(); $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1)); $chart->data['sampleData']->symbol = ezcGraph::DIAMOND; $chart->data['sampleData']->symbol['sample 3'] = ezcGraph::CIRCLE; $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawDataLine')); $mockedRenderer->expects($this->at(0))->method('drawDataLine')->with($this->equalTo(new ezcGraphBoundings(140.0, 20.0, 460.0, 180.0), 1.0), $this->equalTo(new ezcGraphContext('sampleData', 'sample 1')), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(new ezcGraphCoordinate(0.0, 0.415), 0.05), $this->equalTo(new ezcGraphCoordinate(0.0, 0.415), 0.05), $this->equalTo(0), $this->equalTo(1), $this->equalTo(ezcGraph::DIAMOND), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(null)); $mockedRenderer->expects($this->at(2))->method('drawDataLine')->with($this->equalTo(new ezcGraphBoundings(140.0, 20.0, 460.0, 180.0), 1.0), $this->equalTo(new ezcGraphContext('sampleData', 'sample 3')), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(new ezcGraphCoordinate(0.25, 0.9475), 0.05), $this->equalTo(new ezcGraphCoordinate(0.5, 0.19), 0.05), $this->equalTo(0), $this->equalTo(1), $this->equalTo(ezcGraph::CIRCLE), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(null)); $mockedRenderer->expects($this->at(4))->method('drawDataLine')->with($this->equalTo(new ezcGraphBoundings(140.0, 20.0, 460.0, 180.0), 1.0), $this->equalTo(new ezcGraphContext('sampleData', 'sample 5')), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(new ezcGraphCoordinate(0.75, 0.7), 0.05), $this->equalTo(new ezcGraphCoordinate(1.0, 0.9975000000000001), 0.05), $this->equalTo(0), $this->equalTo(1), $this->equalTo(ezcGraph::DIAMOND), $this->equalTo(ezcGraphColor::fromHex('#729FCF')), $this->equalTo(null)); $chart->renderer = $mockedRenderer; $chart->render(500, 200); }
public function testModifyPaletteDatasetColorArray() { $palette = new ezcGraphPaletteTango(); $palette->dataSetColor = array('#ABCDEF', array(255, 255, 255)); $this->assertEquals($palette->dataSetColor, ezcGraphColor::fromHex('#ABCDEF')); try { $palette->dataSetColor = '#FFFFFF'; } catch (ezcBaseValueException $e) { return true; } $this->fail('expected ezcBaseValueException.'); }
public function testSetOptionsBorderLineChart() { $lineChart = new ezcGraphLineChart(); $lineChart->background = '#FF0000'; $this->assertEquals(ezcGraphColor::fromHex('FF0000'), $lineChart->background->color); }
/** * Ensure value to be a color * * @param mixed $color Color to transform into a ezcGraphColor object * @return ezcGraphColor */ protected function checkColor(&$color) { if ($color == null) { return ezcGraphColor::fromHex('#000000FF'); } elseif (!$color instanceof ezcGraphColor) { $color = ezcGraphColor::create($color); } return $color; }
/** * Tries to detect type of color color definition and returns an * ezcGraphColor object * * @param mixed $color Some kind of color definition * @return ezcGraphColor */ public static function create($color) { if ($color instanceof ezcGraphColor) { return $color; } elseif (is_string($color)) { return ezcGraphColor::fromHex($color); } elseif (is_array($color)) { $testElement = reset($color); if (is_int($testElement)) { return ezcGraphColor::fromIntegerArray($color); } else { return ezcGraphColor::fromFloatArray($color); } } else { throw new ezcGraphUnknownColorDefinitionException($color); } }
/** * Draws a circular arc * * @param ezcGraphCoordinate $center Center of ellipse * @param integer $width Width of ellipse * @param integer $height Height of ellipse * @param integer $size Height of border * @param float $startAngle Starting angle of circle sector * @param float $endAngle Ending angle of circle sector * @param ezcGraphColor $color Color of Border * @param bool $filled * @return void */ public function drawCircularArc(ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true) { $this->initiliazeSurface(); // Normalize angles if ($startAngle > $endAngle) { $tmp = $startAngle; $startAngle = $endAngle; $endAngle = $tmp; } $this->simulateCircularArc($center, $width, $height, $size, $startAngle, $endAngle, $color, $filled); if ($this->options->shadeCircularArc !== false && $filled) { $gradient = new ezcGraphLinearGradient(new ezcGraphCoordinate($center->x - $width, $center->y), new ezcGraphCoordinate($center->x + $width, $center->y), ezcGraphColor::fromHex('#FFFFFF')->transparent($this->options->shadeCircularArc * 1.5), ezcGraphColor::fromHex('#000000')->transparent($this->options->shadeCircularArc * 1.5)); $this->simulateCircularArc($center, $width, $height, $size, $startAngle, $endAngle, $gradient, $filled); } // Create polygon array to return $polygonArray = array(); for ($angle = $startAngle; $angle < $endAngle; $angle += $this->options->imageMapResolution) { $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($angle)) * $width / 2, $center->y + sin(deg2rad($angle)) * $height / 2); } $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($endAngle)) * $width / 2, $center->y + sin(deg2rad($endAngle)) * $height / 2); for ($angle = $endAngle; $angle > $startAngle; $angle -= $this->options->imageMapResolution) { $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($angle)) * $width / 2 + $size, $center->y + sin(deg2rad($angle)) * $height / 2); } $polygonArray[] = new ezcGraphCoordinate($center->x + cos(deg2rad($startAngle)) * $width / 2 + $size, $center->y + sin(deg2rad($startAngle)) * $height / 2); return $polygonArray; }
public function testDrawJpeg() { $filename = $this->tempDir . __FUNCTION__ . '.jpg'; $this->driver->options->imageFormat = IMG_JPEG; $this->driver->drawPolygon(array(new ezcGraphCoordinate(45, 12), new ezcGraphCoordinate(122, 34), new ezcGraphCoordinate(12, 71)), ezcGraphColor::fromHex('#3465A4'), true); $this->driver->render($filename); $this->assertTrue(file_exists($filename), 'No image was generated.'); $this->assertImageSimilar($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.jpg', 'Image does not look as expected.', 2000); }
public function testRenderer2dOptionsPropertyPieChartShadowColor() { $options = new ezcGraphRenderer2dOptions(); $this->assertEquals(ezcGraphColor::fromHex('#000000'), $options->pieChartShadowColor, 'Wrong default value for property pieChartShadowColor in class ezcGraphRenderer2dOptions'); $options->pieChartShadowColor = $color = ezcGraphColor::fromHex('#FFFFFF'); $this->assertSame($color, $options->pieChartShadowColor, 'Setting property value did not work for property pieChartShadowColor in class ezcGraphRenderer2dOptions'); try { $options->pieChartShadowColor = false; } catch (ezcGraphUnknownColorDefinitionException $e) { return true; } $this->fail('Expected ezcGraphUnknownColorDefinitionException.'); }
public function testSetOptionsBorder() { $pieChart = new ezcGraphPieChart(); $pieChart->background->border = '#FF0000'; $this->assertEquals(ezcGraphColor::fromHex('FF0000'), $pieChart->background->border); }