本文整理汇总了PHP中ezcGraphColor类的典型用法代码示例。如果您正苦于以下问题:PHP ezcGraphColor类的具体用法?PHP ezcGraphColor怎么用?PHP ezcGraphColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcGraphColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
/**
* __set
*
* @param mixed $propertyName
* @param mixed $propertyValue
* @throws ezcBaseValueException
* If a submitted parameter was out of range or type.
* @throws ezcBasePropertyNotFoundException
* If a the value for the property options is not an instance of
* @return void
* @ignore
*/
public function __set($propertyName, $propertyValue)
{
switch ($propertyName) {
case 'startPoint':
if (!$propertyValue instanceof ezcGraphCoordinate) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphCoordinate');
} else {
$this->properties['startPoint'] = $propertyValue;
}
break;
case 'endPoint':
if (!$propertyValue instanceof ezcGraphCoordinate) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphCoordinate');
} else {
$this->properties['endPoint'] = $propertyValue;
}
break;
case 'startColor':
$this->properties['startColor'] = ezcGraphColor::create($propertyValue);
break;
case 'endColor':
$this->properties['endColor'] = ezcGraphColor::create($propertyValue);
break;
}
}
示例2: testRenderHorizontalAxisReverse
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);
}
示例3: __set
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set($propertyName, $propertyValue)
{
switch ($propertyName) {
case 'borderWidth':
case 'markerWidth':
if (!is_numeric($propertyValue) || $propertyValue < 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 1');
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'borderColor':
case 'startColor':
case 'endColor':
$this->properties[$propertyName] = ezcGraphColor::create($propertyValue);
break;
case 'odometerHeight':
if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1');
}
$this->properties[$propertyName] = (double) $propertyValue;
break;
default:
return parent::__set($propertyName, $propertyValue);
}
}
示例4: __construct
/**
* 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);
}
示例5: __set
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set($propertyName, $propertyValue)
{
switch ($propertyName) {
case 'minFontSize':
if (!is_numeric($propertyValue) || $propertyValue < 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 1');
}
// Ensure min font size is smaller or equal max font size.
if ($propertyValue > $this->properties['maxFontSize']) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float <= ' . $this->properties['maxFontSize']);
}
$this->properties[$propertyName] = (double) $propertyValue;
break;
case 'maxFontSize':
if (!is_numeric($propertyValue) || $propertyValue < 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 1');
}
// Ensure max font size is greater or equal min font size.
if ($propertyValue < $this->properties['minFontSize']) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float >= ' . $this->properties['minFontSize']);
}
$this->properties[$propertyName] = (double) $propertyValue;
break;
case 'minimalUsedFont':
$propertyValue = (double) $propertyValue;
if ($propertyValue < $this->minimalUsedFont) {
$this->properties['minimalUsedFont'] = $propertyValue;
}
break;
case 'color':
case 'background':
case 'border':
case 'textShadowColor':
$this->properties[$propertyName] = ezcGraphColor::create($propertyValue);
break;
case 'borderWidth':
case 'padding':
case 'textShadowOffset':
if (!is_numeric($propertyValue) || $propertyValue < 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'minimizeBorder':
case 'textShadow':
if (!is_bool($propertyValue)) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'bool');
}
$this->properties[$propertyName] = (bool) $propertyValue;
break;
case 'name':
if (is_string($propertyValue)) {
$this->properties['name'] = $propertyValue;
} else {
throw new ezcBaseValueException($propertyName, $propertyValue, 'string');
}
break;
case 'path':
if (is_file($propertyValue) && is_readable($propertyValue)) {
$this->properties['path'] = $propertyValue;
$parts = pathinfo($this->properties['path']);
switch (strtolower($parts['extension'])) {
case 'fdb':
$this->properties['type'] = ezcGraph::PALM_FONT;
break;
case 'pfb':
$this->properties['type'] = ezcGraph::PS_FONT;
break;
case 'ttf':
$this->properties['type'] = ezcGraph::TTF_FONT;
break;
case 'svg':
$this->properties['type'] = ezcGraph::SVG_FONT;
$this->properties['name'] = ezcGraphSvgFont::getFontName($propertyValue);
break;
default:
throw new ezcGraphUnknownFontTypeException($propertyValue, $parts['extension']);
}
$this->pathChecked = true;
} else {
throw new ezcBaseFileNotFoundException($propertyValue, 'font');
}
break;
case 'type':
if (is_int($propertyValue)) {
$this->properties['type'] = $propertyValue;
} else {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int');
}
break;
default:
//.........这里部分代码省略.........
示例6: __set
/**
* __set
*
* @param mixed $propertyName
* @param mixed $propertyValue
* @throws ezcBaseValueException
* If a submitted parameter was out of range or type.
* @throws ezcBasePropertyNotFoundException
* If a the value for the property options is not an instance of
* @return void
*/
public function __set($propertyName, $propertyValue)
{
switch ($propertyName) {
case 'nullPosition':
$this->properties['nullPosition'] = (double) $propertyValue;
break;
case 'axisSpace':
if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue >= 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float < 1');
}
$this->properties['axisSpace'] = (double) $propertyValue;
break;
case 'outerAxisSpace':
if (!is_null($propertyValue) && (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue >= 1)) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'null, or 0 <= float < 1');
}
$this->properties['outerAxisSpace'] = $propertyValue;
break;
case 'majorGrid':
$this->properties['majorGrid'] = ezcGraphColor::create($propertyValue);
break;
case 'minorGrid':
$this->properties['minorGrid'] = ezcGraphColor::create($propertyValue);
break;
case 'majorStep':
if (!is_numeric($propertyValue) || $propertyValue <= 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0');
}
$this->properties['majorStep'] = (double) $propertyValue;
break;
case 'minorStep':
if (!is_numeric($propertyValue) || $propertyValue <= 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0');
}
$this->properties['minorStep'] = (double) $propertyValue;
break;
case 'formatString':
$this->properties['formatString'] = (string) $propertyValue;
break;
case 'label':
$this->properties['label'] = (string) $propertyValue;
break;
case 'labelSize':
if (!is_numeric($propertyValue) || $propertyValue <= 6) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 6');
}
$this->properties['labelSize'] = (int) $propertyValue;
break;
case 'labelMargin':
if (!is_numeric($propertyValue) || $propertyValue <= 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
}
$this->properties['labelMargin'] = (int) $propertyValue;
break;
case 'maxArrowHeadSize':
if (!is_numeric($propertyValue) || $propertyValue <= 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
}
$this->properties['maxArrowHeadSize'] = (int) $propertyValue;
break;
case 'minArrowHeadSize':
if (!is_numeric($propertyValue) || $propertyValue <= 0) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0');
}
$this->properties['minArrowHeadSize'] = (int) $propertyValue;
break;
case 'axisLabelRenderer':
if ($propertyValue instanceof ezcGraphAxisLabelRenderer) {
$this->axisLabelRenderer = $propertyValue;
} else {
throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphAxisLabelRenderer');
}
break;
case 'labelCallback':
if (is_callable($propertyValue)) {
$this->properties['labelCallback'] = $propertyValue;
} else {
throw new ezcBaseValueException($propertyName, $propertyValue, 'callback function');
}
break;
case 'chartPosition':
if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) {
throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1');
}
$this->properties['chartPosition'] = (double) $propertyValue;
break;
case 'labelRotation':
if (!is_numeric($propertyValue)) {
throw new ezcBaseValueException($propertyName, $propertyValue, 'float');
//.........这里部分代码省略.........
示例7: testRenderAxisNoInnerSteps
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);
}
示例8: drawCircularArc
/**
* 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;
}
示例9: checkValue
/**
* Converts value to an {@link ezcGraphColor} object
*
* @param & $value
* @return void
*/
protected function checkValue(&$value)
{
$value = ezcGraphColor::create($value);
return true;
}
示例10: testDrawTextWithMinimizedBorderAndBackgroundBottomRight
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);
}
示例11: testRenderAxisGridFromBottom
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);
}
示例12: testDrawJpeg
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);
}
示例13: create
/**
* 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);
}
}
示例14: testSetOptionsBorderLineChart
public function testSetOptionsBorderLineChart()
{
$lineChart = new ezcGraphLineChart();
$lineChart->background = '#FF0000';
$this->assertEquals(ezcGraphColor::fromHex('FF0000'), $lineChart->background->color);
}
示例15: testRenderChartSymbols
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);
}