/** * Creates a Chart Image with the count(Year(fecha_nacimiento)) * * @param DomDocument $qResult The query result * * @return string with the binary stream of a png picture. * @see listadoPersonasXedad() */ public static function listadoPersonasXedadCreateChart(DomDocument $qResult) { // Todo: add chart to /result/chart $xPath = new DOMXPath($qResult); $countedNodes = $xPath->query('/result/Persona_Collection/Persona/counted/text()'); $count = array(); foreach ($countedNodes as $node) { $count[] = $node->nodeValue; } $fechaNodes = $xPath->query('/result/Persona_Collection/Persona/years/text()'); $years = array(); foreach ($fechaNodes as $node) { $years[] = $node->nodeValue; } /* Create and populate the pData object */ $myData = new pData(); $myData->addPoints($count, "Years"); $myData->setSerieDescription("Years", "Año de Nacimiento de las personas"); /* Define the absissa serie */ $myData->addPoints($years, "Labels"); $myData->setAbscissa("Labels"); $myPicture = self::listadoPersonasXedadConfigChart($myData); /* Create the pPie object */ $pieChart = new pPie($myPicture, $myData); /* Draw AA pie chart */ $pieChart->draw2DPie(200, 100, array("Border" => TRUE)); /* Write a legend box under the 1st chart */ $pieChart->drawPieLegend(90, 176, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $fname = PathsUtils::createChartFileName(); $myPicture->render($fname); $picFile = file_get_contents($fname); return $picFile; }
function DrawPieChart($pChart, $pChartPicture, $x, $y, $name, $values, $labels) { $pChart->removeSerie("Serie"); $pChart->removeSerie("Labels"); $pChart->addPoints($values, "Serie"); $pChart->setSerieDescription("Serie", ""); $pChart->addPoints($labels, "Labels"); $pChart->setAbscissa("Labels"); $text = array("Align" => TEXT_ALIGN_BOTTOMMIDDLE, "FontName" => "pChart/fonts/arial.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80); $pChartPicture->setFontProperties($text); $pChartPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); $PieChart = new pPie($pChartPicture, $pChart); $PieChart->draw2DPie($x, $y, array("Radius" => 150, "ValuePosition" => PIE_VALUE_INSIDE, "WriteValues" => PIE_VALUE_PERCENTAGE, "ValueR" => 80, "ValueG" => 80, "ValueB" => 80, "LabelStacked" => TRUE, "DrawLabels" => TRUE, "Border" => TRUE)); $pChartPicture->setShadow(FALSE); $nameText = array("Align" => TEXT_ALIGN_BOTTOMMIDDLE, "FontName" => "pChart/fonts/arialbd.ttf", "FontSize" => 11, "R" => 80, "G" => 80, "B" => 80); $pChartPicture->drawText($x, $y - 200, ucfirst($name), $nameText); $PieChart->drawPieLegend($x + 250, $y - 150, array("Alpha" => 20, "BoxSize" => 10)); }
function RenderQualityQuota(&$debug1) { $parameters = [[10, 8, 6, 4, 2]]; coinQualityCount($parameters[0], $array_result); $MyData = new pData(); $MyData->addPoints($array_result, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($parameters[0], "Labels"); $MyData->setAbscissa("Labels"); /* Create the cache object */ $myCache = new pCache(array("CacheFolder" => PCHART_PATH . "/class/cache")); /* Compute the hash linked to the chart data */ $ChartHash = $myCache->getHash($MyData); /* Test if we got this hash in our cache already */ if ($myCache->isInCache($ChartHash)) { /* If we have it, get the picture from the cache! */ $myCache->saveFromCache($ChartHash, WWW_PATH . "/tmp/qualityquota.png"); $debug1 = "Old image"; } else { /* Create the pChart object */ $myPicture = new pImage(470, 310, $MyData, TRUE); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw a splitted pie chart */ $myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/GeosansLight.ttf", "FontSize" => 12, "R" => 0, "G" => 0, "B" => 0)); $PieChart->draw2DPie(210, 130, array("Radius" => 100, "DataGapAngle" => 0, "DataGapRadius" => 10, "DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE, "WriteValues" => TRUE, "ValuePosition" => PIE_VALUE_INSIDE, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValuePadding" => -20, "SecondPass" => TRUE)); /* Write the legend box */ $myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/GeosansLight.ttf", "FontSize" => 12, "R" => 0, "G" => 0, "B" => 0)); $PieChart->drawPieLegend(10, 300, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Push the rendered picture to the cache */ $myCache->writeToCache($ChartHash, $myPicture); /* Render the picture */ $myPicture->Render(WWW_PATH . "/tmp/qualityquota.png"); $debug1 = "Picture rendered"; } }
function buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, $recordImageMap) { $PieChart = new pPie($chartPicture, $chartData); $x = 0; foreach ($reportData as $row) { $PieChart->setSliceColor($x, $this->getColour($row[$xName], true)); $x++; } $PieChart->draw2DPie($imageWidth / 3, $imageHeight / 2, array("Border" => TRUE, 'Radius' => 200, '' => true, "RecordImageMap" => $recordImageMap)); $PieChart->drawPieLegend($imageWidth * 0.7, $imageHeight / 3, array('FontSize' => 10, "FontName" => "modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", 'BoxSize' => 14)); }
/* Draw a gradient overlay */ $Settings = array("StartR" => 209, "StartG" => 150, "StartB" => 231, "EndR" => 111, "EndG" => 3, "EndB" => 138, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "pPie - Draw 2D pie charts", array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw a simple pie chart */ $PieChart->draw2DPie(120, 125, array("SecondPass" => FALSE)); /* Draw an AA pie chart */ $PieChart->draw2DPie(340, 125, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); /* Draw a splitted pie chart */ $PieChart->draw2DPie(560, 125, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); /* Write the legend */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); $myPicture->drawText(120, 200, "Single AA pass", array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Align" => TEXT_ALIGN_TOPMIDDLE)); $myPicture->drawText(440, 200, "Extended AA pass / Splitted", array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Align" => TEXT_ALIGN_TOPMIDDLE)); /* Write the legend box */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255)); $PieChart->drawPieLegend(380, 8, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.draw2DPie.png");
/* Draw the background */ $Settings = array("R" => 39, "G" => 43, "B" => 48, "Dash" => 1, "DashR" => 122, "DashG" => 130, "DashB" => 136); $myPicture->drawFilledRectangle(0, 0, 700, 330, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 39, "StartG" => 43, "StartB" => 48, "EndR" => 122, "EndG" => 130, "EndB" => 136, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 330, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 329, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255)); $myPicture->drawText(10, 13, "Repartition des surfaces (m carre)", array("R" => 255, "G" => 255, "B" => 255)); /* Define the default font */ $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Draw the Pie Chart */ $PieChart = new pPie($myPicture, $MyData); $PieChart->draw2DPie(350, 165, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); if ($consult_date != "Donnée actuelle") { $myPicture->Render("images/rds_graph_render_{$consult_date}.png"); } else { $myPicture->Render("images/rds_graph_render.png"); } } else { $error = 1; } } } catch (Exception $e) { // Catch des erreurs et écriture dans le fichier de log require 'error_log.php'; }
$os_name = trim($os_name); if (trim($os_name) == '') { $os_name = 'Unknown'; } array_push($points_labels, $os_name . ' (' . sprintf("%01.2f", $count / $sum * 100) . '%)'); array_push($points_values, $count); } $MyDataOS = new pData(); $MyDataOS->addPoints($points_values, "OS values"); $MyDataOS->setSerieDescription("OS values", "Application A"); $MyDataOS->addPoints($points_labels, "Labels"); $MyDataOS->setAbscissa("Labels"); $myPicture = create_common_image($lang['OS popularity'], 680, 250, $MyDataOS, 'pie'); $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); $PieChart = new pPie($myPicture, $MyDataOS); $PieChart->draw2DPie(220, 125, array("ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValueAlpha" => 80, "ValuePosition" => PIE_VALUE_OUTSIDE, "LabelStacked" => TRUE, "DrawLabels" => TRUE, "DataGapAngle" => 8, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); $myPicture->drawText(220, 230, "Operating systems", array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Align" => TEXT_ALIGN_TOPMIDDLE)); // Additional OS statistics $win64_list = array(); if (!$pony_db->get_64bit_stats($win64_list)) { die; } if (!isset($win64_list['0'])) { $win64_list['0'] = '0'; } if (!isset($win64_list['1'])) { $win64_list['1'] = '0'; } $admin_list = array(); if (!$pony_db->get_admin_stats($admin_list)) {
/** * Get image with a pie chart * * @author kuma * @param string $title * @param array $values */ private function getPieChart($title, $values, &$chartObj) { include_once "../lib/pChart2.1.4/class/pData.class.php"; include_once "../lib/pChart2.1.4/class/pDraw.class.php"; include_once "../lib/pChart2.1.4/class/pPie.class.php"; include_once "../lib/pChart2.1.4/class/pImage.class.php"; $MyData = new pData(); $MyData->addPoints($values, "ScoreA"); $MyData->setSerieDescription("ScoreA", $title); $MyData->addPoints(array_keys($values), "Labels"); $MyData->setAbscissa("Labels"); $myPicture = new pImage(250, 150, $MyData); $myPicture->setFontProperties(array("FontName" => "../lib/pChart2.1.4/fonts/verdana.ttf", "FontSize" => 13, "R" => 0, "G" => 0, "B" => 0)); $myPicture->drawText(10, 23, $title, array("R" => 255, "G" => 255, "B" => 255)); $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); $PieChart = new pPie($myPicture, $MyData); $PieChart->draw2DPie(125, 80, array("Radius" => 50, "WriteValues" => PIE_VALUE_PERCENTAGE, "ValuePadding" => 10, "DataGapAngle" => 0, "DataGapRadius" => 0, "Border" => FALSE, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "Shadow" => FALSE)); /* $PieChart->drawPieLegend(300, 18, array( "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "BoxSize" => 25, "FontSize" => 10, "Margin" => 20 )); */ $chartObj = $PieChart; ob_start(); imagepng($myPicture->Picture); $img = ob_get_contents(); ob_end_clean(); return base64_encode($img); }
$WriteValues = NULL; if ($pieValue == 1) { $WriteValues = PIE_VALUE_NATURAL; } if ($pieValue == 2) { $WriteValues = PIE_VALUE_PERCENTAGE; } // 显示总量 if ($pieSum == 1) { $myPicture->drawText($width - $marg - 2, $marg + 2, $pieValueKeyLabel . ":" . $pieValueKey . " 总量:" . array_sum($arrPieValues), array("Align" => TEXT_ALIGN_TOPRIGHT, "BorderOffset" => 5, "R" => 55, "G" => 55, "B" => 55, "DrawBox" => TRUE, "BoxRounded" => TRUE, "BoxR" => 100, "BoxG" => 100, "BoxB" => 100, "BoxAlpha" => 20)); } $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 4, "R" => 150, "G" => 150, "B" => 150, "Alpha" => 80)); $pieSettings = array("DrawLabels" => TRUE, "LabelStacked" => FALSE, "LabelColor" => PIE_LABEL_COLOR_MANUAL, "WriteValues" => $WriteValues, "ValuePosition" => PIE_VALUE_INSIDE); // 画2D饼图 if ($chartType == 'pie2d') { $PieChart->draw2DPie($width * 0.4, $height * 0.53, array("Radius" => min($height, $width * 0.7) * 0.3, "Border" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "ValueAlpha" => 100, "LabelStacked" => FALSE) + $pieSettings); } // 画3D饼图 if ($chartType == 'pie3d') { $PieChart->draw3DPie($width * 0.5, $height * 0.57, array("Radius" => min($height, $width * 0.7) * 0.4, "SliceHeight" => min($height, $width * 0.7) * 0.08, "DataGapAngle" => 5, "DataGapRadius" => min($height, $width * 0.7) * 0.02, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValueAlpha" => 60, "LabelStacked" => FALSE) + $pieSettings); } /* Draw Pie Legend */ // 根据设置显示图例,1:纵向,2:横向,否则不显示 if ($legend == 1) { $PieChart->drawPieLegend($width * 0.9 - 60, $marg + $font_t * 3, array("Align" => TEXT_ALIGN_TOPRIGHT, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); } if ($legend == 2) { $PieChart->drawPieLegend($marg, $height - $marg - $font * 2, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); } } else { $nSerie = 0;
/* Define the absissa serie */ $MyData->addPoints(array("<10", "10<>20", "20<>40", "40<>60", "60<>80", ">80"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMap2DPieChart", IMAGE_MAP_STORAGE_FILE, "2DPieChart", "../pChart2.1.4/tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap2DPieChart", IMAGE_MAP_STORAGE_FILE, "2DPieChart", "../pChart2.1.4/tmp"); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 300, 300, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 300, 260, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 299, 259, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $Settings = array("RecordImageMap" => TRUE); $PieChart = new pPie($myPicture, $MyData, $Settings); /* Draw an AA pie chart */ $PieSettings = array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE, "RecordImageMap" => TRUE); $PieChart->draw2DPie(160, 125, $PieSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/2DPieChart.png");
/* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawPieLegend - Draw pie charts legend", array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 150, "G" => 150, "B" => 150, "Alpha" => 100)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw two AA pie chart */ $PieChart->draw2DPie(200, 100, array("Border" => TRUE)); $PieChart->draw2DPie(440, 115, array("Border" => TRUE)); /* Write down the legend next to the 2nd chart*/ $PieChart->drawPieLegend(550, 70); /* Write a legend box under the 1st chart */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $PieChart->drawPieLegend(90, 176, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL)); /* Write the bottom legend box */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawGradientArea(1, 200, 698, 228, DIRECTION_VERTICAL, array("StartR" => 247, "StartG" => 247, "StartB" => 247, "EndR" => 217, "EndG" => 217, "EndB" => 217, "Alpha" => 20)); $myPicture->drawLine(1, 199, 698, 199, array("R" => 100, "G" => 100, "B" => 100, "Alpha" => 20)); $myPicture->drawLine(1, 200, 698, 200, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 20)); $PieChart->drawPieLegend(10, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawPieLegend.png");
function pch_pie_graph($graph_type, $data_values, $legend_values, $width, $height, $font, $water_mark, $font_size) { /* CAT:Pie charts */ /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($data_values, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($legend_values, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage($width, $height, $MyData, TRUE); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size, "R" => 80, "G" => 80, "B" => 80)); $water_mark_height = 0; $water_mark_width = 0; if (!empty($water_mark)) { $size_water_mark = getimagesize($water_mark); $water_mark_height = $size_water_mark[1]; $water_mark_width = $size_water_mark[0]; $myPicture->drawFromPNG($width - $water_mark_width, $height - $water_mark_height - 50, $water_mark); } /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw an AA pie chart */ switch ($graph_type) { case "pie2d": $PieChart->draw2DPie($width / 4, $height / 2, array("DataGapAngle" => 0, "DataGapRadius" => 0, "Border" => FALSE, "BorderR" => 200, "BorderG" => 200, "BorderB" => 200, "Radius" => $width / 4, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "WriteValues" => TRUE)); break; case "pie3d": $PieChart->draw3DPie($width / 4, $height / 2, array("DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "Radius" => $width / 4, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "WriteValues" => TRUE)); break; } /* Write down the legend next to the 2nd chart*/ //Calculate the bottom margin from the size of string in each index $max_chars = 0; foreach ($legend_values as $string_legend) { if (empty($string_legend)) { continue; } $len = strlen($string_legend); if ($len > $max_chars) { $max_chars = $len; } } $legend_with_aprox = 32 + 7 * $max_chars; $PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R" => 255, "G" => 255, "B" => 255, "BoxSize" => 10)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 3, "Y" => 3, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Render the picture */ $myPicture->stroke(); }
public function generate_chart($chart_name) { include_once "pchart/class/pPie.class.php"; global $wgBugzillaChartStorage; global $wgBugzillaFontStorage; // TODO: Make all this size stuff trivial for other // graph types to plug into switch ($this->_get_size()) { case 'small': $imgX = 200; $imgY = 65; $radius = 30; $font = 6; break; case 'medium': $imgX = 400; $imgY = 125; $radius = 60; $font = 7; break; case 'large': default: $imgX = 500; $imgY = 245; $radius = 120; $font = 9; } $padding = 5; $startX = isset($startX) ? $startX : $radius; $startY = isset($startY) ? $startY : $radius; $pData = new pData(); $pData->addPoints($this->query->data['data'], 'Counts'); $pData->setAxisName(0, 'Bugs'); $pData->addPoints($this->query->data['x_labels'], "Bugs"); $pData->setSerieDescription("Bugs", "Bugs"); $pData->setAbscissa("Bugs"); $pImage = new pImage($imgX, $imgY, $pData); $pImage->setFontProperties(array('FontName' => $wgBugzillaFontStorage . '/verdana.ttf', 'FontSize' => $font)); $pPieChart = new pPie($pImage, $pData); $pPieChart->draw2DPie($startX, $startY, array("Radius" => $radius, "ValuePosition" => PIE_VALUE_INSIDE, "WriteValues" => PIE_VALUE_NATURAL, "DrawLabels" => FALSE, "LabelStacked" => TRUE, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "Border" => TRUE)); // Legend $pImage->setShadow(FALSE); $pPieChart->drawPieLegend(2 * $radius + 2 * $padding, $padding, array("Alpha" => 20)); $pImage->render($wgBugzillaChartStorage . '/' . $chart_name . '.png'); $cache = $this->_getCache(); $cache->set($chart_name, $chart_name . '.png'); return $chart_name; }
$graphImage->drawScale($scaleSettings); // If there's a Pie chart we want to draw different legends $piechart = false; foreach ($plot as $k => $v) { foreach ($plot as $k1 => $v1) { $series = $v1["name"] . $k1; $graphData->setSerieDrawable($series, FALSE); } $series = $v["name"] . $k; $graphData->setSerieDrawable($series, TRUE); switch ($v["type"]) { case "PIE": $piechart = true; $pie = new pPie($graphImage, $graphData); //$pie->draw2DPie($width / 2,$height / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE)); $pie->draw2DPie($width / 2, $height / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); break; case "PIE3D": $piechart = true; $pie = new pPie($graphImage, $graphData); $pie->draw3DPie($width / 2, $height / 2, 80, array("SecondPass" => FALSE)); break; case "STACKEDBAR": case "BAR": if ($stackeddrawn) { break; } if ($barexists) { foreach ($plot as $k1 => $v1) { if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") { $graphData->setSerieDrawable($v1["name"] . $k1, TRUE);
static function makePieTopEditors($title, $total, &$data, $lang) { global $wt, $I18N; $font = PCHART_FONTS_PATH . "/LiberationSans-Regular.ttf"; if (in_array($wt->uselang, array("zh", "ja", "jp", "ko"))) { $font = PCHART_FONTS_PATH . "/wqy-microhei.ttf"; } if (in_array($wt->uselang, array("he", "bn", "vi", "fa", "ar", "th", "ta", "ka", "hi", "hy", "ml"))) { $font = PCHART_FONTS_PATH . "/unifont.ttf"; } $i = 0; foreach ($data as $user => $details) { $val = number_format($details["all"] / $total * 100, 1); $users[] = $user . " · {$val}%"; $values[] = $val; $colors[] = str_replace("#", "", self::GetColorList($i)); $i++; if ($i == 9) { break; } } $users[] = $I18N->msg("others"); $colors[] = str_replace("#", "", self::GetColorList(100)); $values[] = 100 - array_sum($values); $MyData = new pData(); $MyData->addPoints($values, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); $MyData->addPoints($users, "Labels"); $MyData->setAbscissa("Labels"); $myPicture = new pImage(500, 250, $MyData, TRUE); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => 9)); $myPicture->drawText(150, 16, $title, array("R" => 0, "G" => 0, "B" => 0)); $PieChart = new pPie($myPicture, $MyData); foreach ($colors as $i => $color) { $PieChart->setSliceColor($i, self::hex2rgb($color, 200, true)); } $PieChart->draw2DPie(150, 140, array("Radius" => 100, "SecondPass" => true, "DrawLabels" => false, "Border" => TRUE)); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => 9, "R" => 34, "G" => 34, "B" => 34)); $PieChart->drawPieLegend(320, 55, array("Style" => LEGEND_NOBORDER, "BoxSize" => 12, "Mode" => LEGEND_VERTICAL)); ob_start(); imagepng($myPicture->Picture); $imgdata = ob_get_contents(); ob_end_clean(); $rimg = "data:image/png;base64," . base64_encode($imgdata); return $rimg; }
function PlotPie($rowA, $rowB, $name, $cch) { include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php"; $MyData = new pData(); $MyData->addPoints($rowA, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($rowB, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 630, $MyData); $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30); //$myPicture->drawText(350,25,$name,$TextSettings); $myPicture->setShadow(FALSE); $myPicture->setGraphArea(50, 50, 675, 690); //$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6)); $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL); //$myPicture->drawScale($Settings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw an AA pie chart */ if ($cch == 11) { $PieChart->draw2DPie(160, 140, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); } if ($cch == 12) { $PieChart->draw2DRing(160, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE)); } if ($cch == 13) { $PieChart->draw3DPie(160, 140, array("Radius" => 70, "DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); } /* Write the legend box */ $myPicture->setShadow(FALSE); $PieChart->drawPieLegend(15, 40, array("Alpha" => 20)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.draw2DPie.labels.png"); }
function generate_graph_image($outputfile) { // Create Graph Dataset and set axis attributes $graphData = new pData(); $graphData->setAxisName(0, $this->ytitle_actual); $graphData->addPoints($this->xlabels, "xaxis"); $graphData->setSerieDescription("xaxis", "xaxis"); $graphData->setAbscissa("xaxis"); $graphData->setXAxisName("ooo"); // Add each series of plot values to dataset, but Reportico will // duplicate series were the same data are displayed in different forms // so only add each unique series once $seriesadded = array(); foreach ($this->plot as $k => $v) { $series = $v["name"] . $k; $graphData->addPoints($v["data"], $series); $graphData->setSerieDescription($series, $v["legend"]); } /* $graph->xgrid->SetColor($this->xgridcolor); $graph->ygrid->SetColor($this->ygridcolor); */ /* switch ( $this->xgriddisplay ) { case "all": $graph->xgrid->Show(true,true); break; case "major": $graph->xgrid->Show(true,false); break; case "minor": $graph->xgrid->Show(false,true); break; case "none": default: $graph->xgrid->Show(false,false); break; } switch ( $this->ygriddisplay ) { case "all": $graph->ygrid->Show(true,true); break; case "major": $graph->ygrid->Show(true,false); break; case "minor": $graph->ygrid->Show(false,true); break; case "none": default: $graph->ygrid->Show(false,false); break; } */ /* $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize); $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor); $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize); $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor); $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize); $graph->xaxis->title->SetColor($xtitlecolor); $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize); $graph->yaxis->title->SetColor($ytitlecolor); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelMargin(15); $graph->yaxis->SetLabelMargin(15); $graph->xaxis->SetTickLabels($xlabels); $graph->xaxis->SetTextLabelInterval($xticklabint); $graph->yaxis->SetTextLabelInterval($yticklabint); $graph->xaxis->SetTextTickInterval($xtickinterval); $graph->yaxis->SetTextTickInterval($ytickinterval); */ /* if ( $gridpos == "front" ) $graph->SetGridDepth(DEPTH_FRONT); */ // Display the graph /*?$graph->Stroke();*/ $this->apply_defaults_internal(); //echo "oo<BR>"; //echo "<PRE>"; //var_dump($graphData); //echo $this->width."<BR>"; //echo $this->height_actual."<BR>"; $graphImage = new pImage($this->width_actual, $this->height_actual, $graphData); /* Turn of Antialiasing */ $graphImage->Antialias = TRUE; // Add gradient fill from chosen background color to white $startgradient = $this->htmltorgb("#ffffff"); $color = $this->htmltorgb($this->graphcolor); $graphImage->drawGradientArea(0, 0, $this->width_actual, $this->height_actual, DIRECTION_VERTICAL, array("StartR" => $startgradient[0], "StartG" => $startgradient[1], "StartB" => $startgradient[2], "EndR" => $color[0], "EndG" => $color[1], "EndB" => $color[2], "Alpha" => 100)); /* Add a border to the picture */ $graphImage->drawRectangle(0, 0, $this->width_actual - 1, $this->height_actual - 1, array("R" => 200, "G" => 200, "B" => 200)); /* Set the title font and draw it */ $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->titlefont, "FontSize" => $this->titlefontsize)); $this->titlecolor = $this->htmltorgb($this->titlecolor); $graphImage->drawText(20, 30, $this->title_actual, array("R" => $this->titlecolor[0], "G" => $this->titlecolor[1], "B" => $this->titlecolor[2])); /* Set the default font from the X title font */ $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->xtitlefont, "FontSize" => $this->xtitlefontsize)); /* Define the chart area */ $graphImage->setGraphArea($this->marginleft, $this->margintop, $this->width_actual - $this->marginright, $this->height_actual - $this->marginbottom); //$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"LabelRotation"=>30); //$graphImage->drawScale($scaleSettings); //$settings = array("Surrounding"=>-30,"InnerSurrounding"=>30); //$graphImage->drawBarChart($settings); //$graphImage->autoOutput("pictures/example.drawBarChart.simple.png"); //return; // Before plotting a series ensure they are all not drawable. /// Plot the chart data $stackeddrawn = false; $stackedexists = false; $barexists = false; foreach ($this->plot as $k => $v) { if ($v["type"] == "STACKEDBAR") { $stackedexists = true; } if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") { $barexists = true; } } /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30); // For stacked charts fix up the Max and Min values; if ($stackedexists) { $scaleMin = "Unknown"; $scaleMax = 0; foreach ($this->plot as $k => $v) { if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") { $series = $v["name"] . $k; $min = $graphData->getMin($series); if ($scaleMin == "Unknown" || $min < $scaleMin) { $scaleMin = $min; } $scaleMax = $scaleMax + $graphData->getMax($series); } } if ($scaleMin > 0) { $scaleMin = 0; } $range = $scaleMax - $scaleMin; // Make scales based on 5% of the range of values $scaleMax = round($range * 0.05 + $scaleMax); if ($scaleMin < 0) { $scaleMin = $scaleMin - round($range * 0.05); } $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax)); $scaleSettings["Mode"] = SCALE_MODE_MANUAL; $scaleSettings["ManualScale"] = $AxisBoundaries; } else { if ($barexists) { $scaleMin = "Unknown"; $scaleMax = 0; foreach ($this->plot as $k => $v) { if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") { $series = $v["name"] . $k; $min = $graphData->getMin($series); if ($scaleMin == "Unknown" || $min < $scaleMin) { $scaleMin = $min; } $max = $graphData->getMax($series); if ($scaleMax == "Unknown" || $max > $scaleMax) { $scaleMax = $max; } } } if ($scaleMin > 0) { $scaleMin = 0; } $range = $scaleMax - $scaleMin; // Make scales based on 5% of the range of values $scaleMax = round($range * 0.05 + $scaleMax); if ($scaleMin < 0) { $scaleMin = $scaleMin - round($range * 0.05); } $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax)); $scaleSettings["Mode"] = SCALE_MODE_MANUAL; $scaleSettings["ManualScale"] = $AxisBoundaries; } } $graphImage->drawScale($scaleSettings); // If there's a Pie chart we want to draw different legends $piechart = false; foreach ($this->plot as $k => $v) { foreach ($this->plot as $k1 => $v1) { $series = $v1["name"] . $k1; $graphData->setSerieDrawable($series, FALSE); } $series = $v["name"] . $k; $graphData->setSerieDrawable($series, TRUE); switch ($v["type"]) { case "PIE": $piechart = true; $pie = new pPie($graphImage, $graphData); //$pie->draw2DPie($width_actual / 2,$height_actual / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE)); $pie->draw2DPie($width_actual / 2, $height_actual / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); break; case "PIE3D": $piechart = true; $pie = new pPie($graphImage, $graphData); $pie->draw3DPie($this->width_actual / 2, $this->height_actual / 2, 80, array("SecondPass" => FALSE)); break; case "STACKEDBAR": case "BAR": if ($stackeddrawn) { break; } if ($barexists) { foreach ($this->plot as $k1 => $v1) { if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") { $graphData->setSerieDrawable($v1["name"] . $k1, TRUE); } } } $stackeddrawn = true; $settings = array("Surrounding" => -30, "InnerSurrounding" => 30); if ($stackedexists) { $graphImage->drawStackedBarChart($settings); } else { $graphImage->drawBarChart($settings); } break; case "LINE": default: if (count($v["data"]) == 1) { $v["data"][] = 0; } $graphImage->drawLineChart($settings); break; } } $graphData->drawAll(); if ($piechart) { $pie->drawPieLegend($this->width_actual - 100, 30, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); } else { $graphImage->drawLegend($this->width_actual - 180, 22, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); } $graphImage->setShadow(TRUE, array("X" => 0, "Y" => 0, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $graphImage->render($outputfile); return true; }
private function drawPieChart($filename, $dataSeries, $labelSeries) { $dataSeries = array_values($dataSeries); /* Create and populate the pData object */ $data = new pData(); $data->addPoints($dataSeries); /* Calculate percentage and add to the labels */ $total = array_sum($dataSeries); for ($i = 0; $i < count($dataSeries); $i++) { $labelSeries[$i] .= " (" . ceil($dataSeries[$i] / $total * 100) . "%)"; } /* Define the absissa serie */ $data->addPoints($labelSeries, "Labels"); $data->setAbscissa("Labels"); /* Create the pChart object */ $picture = new pImage(400, 250, $data, true); /* Set the default font properties */ $picture->setFontProperties(array("FontName" => "../lib/pchart-2.1.3/fonts/verdana.ttf", "FontSize" => 8)); /* Enable shadow computing */ $picture->setShadow(true, array("X" => 2, "Y" => 2, "R" => 150, "G" => 150, "B" => 150, "Alpha" => 100)); /* Create the pPie object */ $pieChart = new pPie($picture, $data); /* Draw a simple pie chart */ $pieChart->draw2DPie(115, 125, array("Radius" => 110, "SecondPass" => true)); $pieChart->drawPieLegend(250, 10); $picture->render($filename . '.png'); }
public function drawImage() { $qr_result = $this->values; //var_dump($qr_result);die(); $va_columns = $this->parameters["columns"]; $width = $this->parameters["width"]; $format = $this->parameters["format"]; $va_charting_columns = $this->parameters["charting_columns"]; $va_chart_types = $this->parameters["chart_types"]; $qr_result->seek(); if ($qr_result->numRows() == 0) { //if no result nothing to do return false; } // Loading chart format specifications // TODO : this coding part should be out of this function, sending values in 1 parameter if (is_array($va_chart_types)) { foreach ($va_chart_types as $type => $settings) { if ($type == $format) { $chart_type = $settings["googletype"]; $message = $settings["message"]; } } } /* Create and populate the pData object */ $MyData = new pData(); // Fulfillment of the results $va_row_no = 0; $va_content = array(); while ($qr_result->nextRow()) { $va_column_no = 0; foreach ($va_columns as $va_column => $va_column_label) { // only render columns specified in XML field charting_columns if (in_array($va_column_label, $va_charting_columns)) { $va_content[$va_column_label][$va_row_no] = $qr_result->get($va_column_label); $va_column_no++; } } $va_row_no++; } //var_dump($va_content); $va_row_no = 0; foreach ($va_charting_columns as $va_column_label) { //print "MyData->addPoints(\"".implode("\",\"",$va_content[$va_column_label])."\",\"".$va_column_label."\");<br/>"; $MyData->addPoints($va_content[$va_column_label], $va_column_label); if ($va_row_no == 0) { //print "MyData->setAbscissa(\"Labels\")<br/>"; $MyData->setAbscissa($va_column_label); } else { //print "MyData->setSerieDescription(\"".$va_column_label."\",\"".$va_column_label."\");<br/>"; $MyData->setSerieDescription($va_column_label, $va_column_label); } $va_row_no++; } /* Create the pChart object */ $myPicture = new pImage($width, $width / 2, $MyData); /* Set the common properties */ $myPicture->setFontProperties(array("FontName" => __CA_STATISTICSVIEWER_CLASS_DIR__ . "/fonts/verdana.ttf", "FontSize" => 0.014 * $width, "R" => 80, "G" => 80, "B" => 80)); $RectangleSettings = array("R" => 200, "G" => 200, "B" => 200); $myPicture->drawRectangle(1, 1, $width - 1, $width / 2 - 1, $RectangleSettings); $myPicture->setGraphArea($width / 9, $width / 10, $width * 0.75, $width * 0.4); // if not pie, draw the legend if ($format != "pie") { $myPicture->drawLegend($width * 0.8, $width * 0.05, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); } switch ($format) { case "bar": $myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "DrawSubTicks" => FALSE, "RemoveYAxis" => TRUE, "GridAlpha" => 90, "DrawXLines" => FALSE)); $myPicture->drawBarChart(); break; case "column": $myPicture->drawScale(array("DrawSubTicks" => FALSE, "RemoveYAxis" => TRUE, "GridAlpha" => 90, "DrawXLines" => FALSE)); $myPicture->drawBarChart(); break; case "step": $myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127)); $myPicture->drawStepChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO)); break; case "area": $myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127)); $myPicture->drawAreaChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO)); break; case "pie": $PieChart = new pPie($myPicture, $MyData); $PieChart->draw2DPie(0.4 * $width, 0.25 * $width, array("WriteValues" => PIE_VALUE_PERCENTAGE, "ValueR" => 95, "ValueG" => 95, "ValueB" => 95, "ValuePadding" => 0.03 * $width, "Radius" => 0.16 * $width, "SecondPass" => TRUE, "Border" => TRUE, "Precision" => 0)); $myPicture->setShadow(FALSE); $myPicture->setFontProperties(array("FontName" => __CA_STATISTICSVIEWER_CLASS_DIR__ . "/fonts/verdana.ttf", "FontSize" => 0.018 * $width, "R" => 80, "G" => 80, "B" => 80)); $PieChart->drawPieLegend(0.8 * $width, 0.05 * $width, array("Style" => LEGEND_NOBORDER, "BoxSize" => $width / 60, "FontR" => 0, "FontG" => 0, "FontB" => 0)); break; case "line": default: $myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127)); $myPicture->drawLineChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO)); break; } /* Render the picture (choose the best way) */ $myPicture->autoOutput(); }
/* Draw a gradient overlay */ $Settings = array("StartR" => 209, "StartG" => 150, "StartB" => 231, "EndR" => 111, "EndG" => 3, "EndB" => 138, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "pPie - Draw 2D pie charts", array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw a simple pie chart */ $PieChart->draw2DPie(120, 125, array("SecondPass" => FALSE)); /* Draw an AA pie chart */ $PieChart->draw2DPie(340, 125, array("DrawLabels" => TRUE, "Border" => TRUE)); /* Draw a splitted pie chart */ $PieChart->draw2DPie(560, 125, array("DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); /* Write the legend */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); $myPicture->drawText(120, 200, "Single AA pass", array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Align" => TEXT_ALIGN_TOPMIDDLE)); $myPicture->drawText(440, 200, "Extended AA pass / Splitted", array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Align" => TEXT_ALIGN_TOPMIDDLE)); /* Write the legend box */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255)); $PieChart->drawPieLegend(380, 8, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.draw2DPie.png");