$DataSet = new pData; $DataSet->AddPoint($series[1], "Serie1"); // Invert/Reverse Hebrew labels so it can be rendered using PHP imagettftext() foreach ($series[0] as $key => $value) { $invertedlabels[$key] = strip_tags((preg_match("/[\xE0-\xFA]/", iconv("UTF-8", "ISO-8859-8", $value))) ? $reportclass->utf8_strrev($value) : $value); } $DataSet->AddPoint($invertedlabels /* $series[0] */, "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $Test = new pChart(450, 200 + (count($series[0]) * 10)); $Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230); $Test->createColorGradientPalette(195, 204, 56, 223, 110, 41, 5); // Draw the pie chart $Test->setFontProperties($CFG->dirroot . "/blocks/cobalt_reports/lib/Fonts/tahoma.ttf", 8); $Test->AntialiasQuality = 0; //$Test->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,60,TRUE,10); //$Test->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,70,PIE_PERCENTAGE,255,255,218); $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 150, 90, 110, PIE_PERCENTAGE, TRUE, 50, 20, 5); $Test->drawPieLegend(300, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); ob_clean(); // Hack to clear output and send only IMAGE data to browser $Test->Stroke(); } } }
$point2[] = "Pass"; $point1[] = $pass; } if ($fail) { $point2[] = "Fail"; $point1[] = $fail; } $DataSet->AddPoint($point1, "Serie1"); $DataSet->AddPoint($point2, "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $Test = new pChart(345, 200); $Test->drawFilledRoundedRectangle(7, 7, 413, 243, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 415, 245, 5, 230, 230, 230); $Test->createColorGradientPalette(1, 6); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); if ($pass == 0 && $fail > 0) { $Test->setColorPalette(0, 243, 134, 48); } $Test->AntialiasQuality = 0; $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 150, 90, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5); $Test->drawPieLegend(280, 5, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); // Write the title $Test->setFontProperties("Fonts/MankSans.ttf", 10); //$Test->drawTitle(10,20,"Covidien",100,100,100); //$Test->Render("example10.png"); $Test->stroke(); /* header('Content-type: image/png'); imagepng($Test);
<?php include "./includes/pdata.php"; include "./includes/pchart.php"; if (!isset($_GET['cc']) || !isset($_GET['cn'])) { exit; } $cc = explode(",", $_GET['cc']); $cn = explode(",", $_GET['cn']); $data = new pData(); $data->AddPoint($cn, "Serie1"); $data->AddPoint($cc, "Serie2"); $data->AddAllSeries(); $data->SetAbsciseLabelSerie("Serie2"); $chart = new pChart(350, 180); $chart->createColorGradientPalette(235, 72, 225, 6, 199, 244, 5); $chart->setFontProperties("includes/tahoma.dat", 8); $chart->AntialiasQuality = 0; $chart->drawPieGraph($data->GetData(), $data->GetDataDescription(), 150, 90, 90, PIE_PERCENTAGE_LABEL, FALSE, 35, 15, 5); $chart->drawPieLegend(300, 20, $data->GetData(), $data->GetDataDescription(), 255, 255, 255); $chart->Stroke();
private function getRadar($localGraphId, $title, $xLabels, $sery1, $legend, $r = "208", $g = "2", $b = "57") { // Dataset definition if (count($sery1) == 0) { throw common_exception_ClientException("Empty data set"); } $dataSet = new \pData(); $dataSet->AddPoint($xLabels, "Label"); $dataSet->AddPoint($sery1, "Serie1"); $dataSet->AddSerie("Serie1"); $dataSet->SetAbsciseLabelSerie("Label"); $dataSet->SetSerieName($legend, "Serie1"); // Initialise the graph $graph = new \pChart(500, 500); $graph->createColorGradientPalette($r, $g, $b, $r, $g, $b, 5); // aa is way too slow here $graph->Antialias = false; $graph->setFontProperties(fontName, 8); $graph->drawFilledRoundedRectangle(7, 7, 493, 493, 5, 240, 240, 240); $graph->drawRoundedRectangle(5, 5, 493, 493, 5, 230, 230, 230); $graph->setGraphArea(120, 70, 420, 420); $graph->drawFilledRoundedRectangle(30, 30, 470, 470, 5, 254, 254, 254); $graph->drawRoundedRectangle(30, 30, 470, 470, 5, 220, 220, 220); // Draw the radar graph $graph->drawRadarAxis($dataSet->GetData(), $dataSet->GetDataDescription(), true, 20, 120, 120, 120, 5, 5, 5); $graph->drawFilledRadar($dataSet->GetData(), $dataSet->GetDataDescription(), 50, 20); // Finish the graph $graph->setFontProperties(fontName, 9); $graph->drawLegend(32, 32, $dataSet->GetDataDescription(), 255, 255, 255); $graph->setFontProperties(fontName, 10); $graph->drawTitle(0, 22, $title, 50, 50, 50, 400); $url = $this->getUniqueMediaFileName($localGraphId, "png"); $graph->Render(ROOT_PATH . $url); return ROOT_URL . $url; }