$value) { $totalGenotypes += $value; } // Finally calculate the percentages which will show the // distribution of genotypes. Computed as: // 100 * some_genotype / total_number_of_genotypes $dataValues = array(); foreach ($dataGenotypeValue as $key => $value) { array_push($dataValues, intval(100 * $value / $totalGenotypes)); } //DEBUG: Debug the percentages to make sure we did that correctly //print_r($dataValues); // Dataset definition $DataSet = new pData; $DataSet->AddPoint($dataValues,"Serie1"); $DataSet->AddPoint($dataGenotypeName,"Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $PGS_ONE = new pChart(420,250); $PGS_ONE->drawFilledRoundedRectangle(7,7,413,243,5,240,240,240); $PGS_ONE->drawRoundedRectangle(5,5,415,245,5,230,230,230); $PGS_ONE->createColorGradientPalette(195,204,56,223,110,41,5); // Draw the pie chart $PGS_ONE->setFontProperties("Fonts/tahoma.ttf",8); $PGS_ONE->AntialiasQuality = 8; $PGS_ONE->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,130,110,PIE_PERCENTAGE_LABEL,FALSE,50,20,5); $PGS_ONE->drawPieLegend(350,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250); // Write the title $PGS_ONE->setFontProperties("Fonts/MankSans.ttf",10); $PGS_ONE->drawTitle(10,20,"PGS ONE",100,100,100); // Set content-type to PNG. Disable this for previous DEBUG instances. header('Content-Type: image/png'); // Render! Disable this for the previous DEBUG instances. $PGS_ONE->Stroke(); ?>