/** * __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; } }
/** * 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); } }
/** * __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 'center': if (!$propertyValue instanceof ezcGraphCoordinate) { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphCoordinate'); } else { $this->properties['center'] = $propertyValue; } break; case 'width': if (!is_numeric($propertyValue) || $propertyValue <= 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties['width'] = (double) $propertyValue; break; case 'height': if (!is_numeric($propertyValue) || $propertyValue <= 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties['height'] = (double) $propertyValue; break; case 'offset': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties['offset'] = $propertyValue; break; case 'startColor': $this->properties['startColor'] = ezcGraphColor::create($propertyValue); break; case 'endColor': $this->properties['endColor'] = ezcGraphColor::create($propertyValue); break; } }
/** * __set * * @param mixed $propertyName Property name * @param mixed $propertyValue Property value * @access public * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'axisColor': case 'majorGridColor': case 'minorGridColor': case 'fontColor': case 'chartBackground': case 'chartBorderColor': case 'elementBackground': case 'elementBorderColor': $this->{$propertyName} = ezcGraphColor::create($propertyValue); break; case 'dataSetColor': if (!is_array($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'array( ezcGraphColor )'); } $this->dataSetColor = array(); foreach ($propertyValue as $value) { $this->dataSetColor[] = ezcGraphColor::create($value); } $this->colorIndex = -1; break; case 'dataSetSymbol': if (!is_array($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'array( (int) ezcGraph::SYMBOL_TYPE )'); } $this->dataSetSymbol = array(); foreach ($propertyValue as $value) { $this->dataSetSymbol[] = (int) $value; } $this->symbolIndex = -1; break; case 'fontName': $this->{$propertyName} = (string) $propertyValue; break; case 'chartBorderWidth': case 'elementBorderWidth': case 'padding': case 'margin': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->{$propertyName} = (int) $propertyValue; break; default: throw new ezcBasePropertyNotFoundException($propertyName); } }
/** * Converts value to an {@link ezcGraphColor} object * * @param & $value * @return void */ protected function checkValue(&$value) { $value = ezcGraphColor::create($value); return true; }
/** * __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 'title': $this->properties['title'] = (string) $propertyValue; break; case 'background': $this->properties['background'] = ezcGraphColor::create($propertyValue); break; case 'border': $this->properties['border'] = ezcGraphColor::create($propertyValue); break; case 'padding': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties['padding'] = (int) $propertyValue; break; case 'margin': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties['margin'] = (int) $propertyValue; break; case 'borderWidth': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties['borderWidth'] = (int) $propertyValue; break; case 'font': if ($propertyValue instanceof ezcGraphFontOptions) { $this->properties['font'] = $propertyValue; } elseif (is_string($propertyValue)) { if (!$this->fontCloned) { $this->properties['font'] = clone $this->font; $this->properties['fontCloned'] = true; } $this->properties['font']->path = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcGraphFontOptions'); } break; case 'position': $positions = array(ezcGraph::TOP, ezcGraph::BOTTOM, ezcGraph::LEFT, ezcGraph::RIGHT); if (in_array($propertyValue, $positions, true)) { $this->properties['position'] = $propertyValue; } else { throw new ezcBaseValueException('position', $propertyValue, 'integer'); } break; case 'maxTitleHeight': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties['maxTitleHeight'] = (int) $propertyValue; break; case 'portraitTitleSize': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties['portraitTitleSize'] = (double) $propertyValue; break; case 'landscapeTitleSize': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties['landscapeTitleSize'] = (double) $propertyValue; break; default: throw new ezcBasePropertyNotFoundException($propertyName); break; } }
/** * 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: throw new ezcBasePropertyNotFoundException($propertyName); break; } }
public function testInvertRandomColor() { $color = ezcGraphColor::create('#123456')->invert(); $this->assertEquals($color, ezcGraphColor::create('#EDCBA9')); }
/** * 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 'pieChartShadowSize': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float >= 0'); } $this->properties['pieChartShadowSize'] = (int) $propertyValue; break; case 'pieChartShadowTransparency': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties['pieChartShadowTransparency'] = (double) $propertyValue; break; case 'pieChartShadowColor': $this->properties['pieChartShadowColor'] = ezcGraphColor::create($propertyValue); break; default: return parent::__set($propertyName, $propertyValue); } }
/** * __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'); } $this->properties['labelRotation'] = fmod((double) $propertyValue, 360.0); break; default: parent::__set($propertyName, $propertyValue); break; } }
/** * 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 'dataBorder': case 'pieChartGleam': case 'legendSymbolGleam': if ($propertyValue !== false && !is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'false OR 0 <= float <= 1'); } $this->properties[$propertyName] = $propertyValue === false ? false : (double) $propertyValue; break; case 'maxLabelHeight': case 'moveOut': case 'barMargin': case 'barPadding': case 'legendSymbolGleamSize': case 'pieVerticalSize': case 'pieHorizontalSize': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'symbolSize': case 'titlePosition': case 'titleAlignement': case 'pieChartGleamBorder': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties[$propertyName] = (int) $propertyValue; break; case 'showSymbol': case 'syncAxisFonts': if (!is_bool($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'bool'); } $this->properties[$propertyName] = (bool) $propertyValue; break; case 'pieChartOffset': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 360) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 360'); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'pieChartSymbolColor': case 'pieChartGleamColor': case 'legendSymbolGleamColor': $this->properties[$propertyName] = ezcGraphColor::create($propertyValue); break; default: return parent::__set($propertyName, $propertyValue); } }
/** * 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 'fillAxis': case 'fillGrid': if ($propertyValue !== false && !is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'false OR 0 <= float <= 1'); } $this->properties[$propertyName] = $propertyValue === false ? false : (double) $propertyValue; break; case 'depth': case 'pieChartRotation': case 'pieChartShadowTransparency': case 'barDarkenSide': case 'barDarkenTop': case 'barChartGleam': if (!is_numeric($propertyValue) || $propertyValue < 0 || $propertyValue > 1) { throw new ezcBaseValueException($propertyName, $propertyValue, '0 <= float <= 1'); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'pieChartHeight': case 'pieChartShadowSize': if (!is_numeric($propertyValue) || $propertyValue <= 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 0'); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'seperateLines': if (!is_bool($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'bool'); } $this->properties['seperateLines'] = $propertyValue; break; case 'pieChartShadowColor': $this->properties['pieChartShadowColor'] = ezcGraphColor::create($propertyValue); break; default: return parent::__set($propertyName, $propertyValue); } }
<?php require_once 'tutorial_autoload.php'; $graph = new ezcGraphPieChart(); $graph->title = 'Access statistics'; $graph->options->label = '%2$d (%3$.1f%%)'; $graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474)); $graph->data['Access statistics']->highlight['Explorer'] = true; $graph->data['Access statistics']->symbol = ezcGraph::BULLET; $graph->renderer = new ezcGraphRenderer3d(); $graph->renderer->options->pieChartShadowSize = 5; $graph->renderer->options->pieChartShadowColor = ezcGraphColor::create('#000000'); $graph->renderer->options->pieChartGleam = 0.5; $graph->renderer->options->dataBorder = false; $graph->renderer->options->pieChartHeight = 8; $graph->renderer->options->pieChartSymbolColor = '#888A8588'; $graph->renderer->options->pieChartRotation = 0.8; $graph->renderer->options->legendSymbolGleam = 0.5; $graph->renderer->options->legendSymbolGleamSize = 0.9; $graph->renderer->options->legendSymbolGleamColor = '#FFFFFF'; $graph->driver = new ezcGraphCairoDriver(); $graph->render(400, 150, 'tutorial_driver_cairo.png');
public function testRenderOdometerMarker() { $chart = new ezcGraphOdometerChart(); $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 1, 'sample 5' => 120)); $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawOdometerMarker')); $mockedRenderer->expects($this->at(0))->method('drawOdometerMarker')->with($this->equalTo(new ezcGraphBoundings(25.0, 50.0, 475.0, 150.0), 1.0), $this->equalTo(new ezcGraphCoordinate(0.585, 0.0), 0.001), $this->equalTo(ezcGraph::NO_SYMBOL), $this->equalTo(ezcGraphColor::create('#3465A4')), $this->equalTo(2)); $mockedRenderer->expects($this->at(1))->method('drawOdometerMarker')->with($this->equalTo(new ezcGraphBoundings(25.0, 50.0, 475.0, 150.0), 1.0), $this->equalTo(new ezcGraphCoordinate(0.0525, 0.0), 0.001), $this->equalTo(ezcGraph::NO_SYMBOL), $this->equalTo(ezcGraphColor::create('#4E9A06')), $this->equalTo(2)); $mockedRenderer->expects($this->at(2))->method('drawOdometerMarker')->with($this->equalTo(new ezcGraphBoundings(25.0, 50.0, 475.0, 150.0), 1.0), $this->equalTo(new ezcGraphCoordinate(0.8100000000000001, 0.0), 0.001), $this->equalTo(ezcGraph::NO_SYMBOL), $this->equalTo(ezcGraphColor::create('#CC0000')), $this->equalTo(2)); $chart->renderer = $mockedRenderer; $chart->render(500, 200); }