public function testDrawBasicPieGraph() { // Dataset definition $DataSet = new pData(); $DataSet->addPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->addPoints(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->setAbscissaLabelSeries("Serie2"); $this->assertEquals(array(0 => array('Serie1' => 10, 'Name' => 0, 'Serie2' => 'Jan'), 1 => array('Serie1' => 2, 'Name' => 1, 'Serie2' => 'Feb'), 2 => array('Serie1' => 3, 'Name' => 2, 'Serie2' => 'Mar'), 3 => array('Serie1' => 5, 'Name' => 3, 'Serie2' => 'Apr'), 4 => array('Serie1' => 3, 'Name' => 4, 'Serie2' => 'May')), $DataSet->getData()); $this->assertEquals(array(0 => 'Serie1', 1 => 'Serie2'), $DataSet->getDataDescription()->values); // Initialise the graph $canvas = new TestCanvas(); $Test = new PieChart(300, 200, $canvas); $Test->loadColorPalette(dirname(__FILE__) . "/../sample/softtones.txt"); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, ShadowProperties::NoShadow(), 70, PIE_PERCENTAGE, new Color(255, 255, 218)); $Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); $this->assertEquals('0ec1d5de67ae53239101143106d5ee4a', md5($canvas->getActionLog())); }
<?php /* Example14: A smooth flat pie graph */ // Standard inclusions require_once "../lib/pData.php"; require_once "../lib/pChart.php"; require_once '../lib/GDCanvas.php'; require_once '../lib/BackgroundStyle.php'; require_once '../lib/PieChart.php'; // Definitions $DataSet = new pData(); $Canvas = new GDCanvas(300, 200); $Chart = new PieChart(300, 200, $Canvas); // Dataset $DataSet->AddPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->AddPoints(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries("Serie2"); // Initialise the graph $Chart->loadColorPalette("../sample/softtones.txt"); // Draw the pie chart $Chart->setFontProperties("../Fonts/tahoma.ttf", 8); $shadowProperties = ShadowProperties::FromSettings(2, 2, new Color(200)); $Chart->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE, 8, 0, $shadowProperties); //$Chart->drawFlatPieGra $Chart->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); $Chart->Render("Example14.png"); header("Content-Type:image/png"); readfile("Example14.png");