function ring2d($x, $y, $name) { $MyData = new pData(); $MyData->addPoints($x, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($y, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(500, 250, $MyData); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 500, 500, $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, 500, 500, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 500, 30, 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, 500, 250, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12)); $myPicture->drawText(15, 20, $name, array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12, "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 an AA pie chart */ $PieChart->draw2DRing(390, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE)); /* Write the legend box */ $myPicture->setShadow(FALSE); $PieChart->drawPieLegend(10, 50, array("Alpha" => 20)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("2dring.png"); }
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"); }
$MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("A0", "B1", "C2", "D3", "E4", "F5", "G6", "H7", "I8", "J9"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* 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); $myPicture->drawGradientArea(0, 0, 300, 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, 299, 259, 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 ring 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 an AA pie chart */ $PieChart->draw2DRing(160, 140, array("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.draw2DRing.png");
/* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($number, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($maps, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(600, 300, $MyData, TRUE); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../pchart/fonts/Forgotte.ttf", "FontSize" => 12)); $myPicture->drawText(170, 24, "Maps played in percent from greatest to least.", array("R" => 150, "G" => 150, "B" => 150)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../pchart/fonts/pf_arma_five.ttf", "FontSize" => 6, "R" => 150, "G" => 150, "B" => 150)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw an AA pie chart */ $PieChart->draw2DRing(300, 150, array("WriteValues" => TRUE, "ValueR" => 150, "ValueG" => 150, "ValueB" => 150, "Border" => TRUE)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../pchart/fonts/pf_arma_five.ttf", "FontSize" => 6, "R" => 150, "G" => 150, "B" => 150)); /* Write the legend box */ $myPicture->setShadow(FALSE); $PieChart->drawPieLegend(480, 10, array("Alpha" => 0)); /* Render the picture */ $myPicture->stroke($BrowserExpire = TRUE); } } else { // start outputting the image header("Content-type: image/png"); echo file_get_contents('./images/error.png'); }
/* 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("ImageMap2DRingChart", IMAGE_MAP_STORAGE_FILE, "2DRingChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap2DRingChart", IMAGE_MAP_STORAGE_FILE, "2DRingChart", "../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->draw2DRing(160, 125, $PieSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/2DRingChart.png");
$MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("A0", "B1", "C2", "D3", "E4", "F5", "G6", "H7", "I8", "J9"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* 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); $myPicture->drawGradientArea(0, 0, 300, 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, 299, 259, 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 ring 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 an AA pie chart */ $PieChart->draw2DRing(160, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "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.draw2DRingValue.png");