/** * Main display method for the web interface. * @param boolean $supress_output */ protected function displayWeb($supress_output = false) { $this->completeChart(); if (!$supress_output) { $this->chartImage->stroke(); } }
function index() { /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(getGenders($this->db), "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("Female", "Male"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(240, 180, $MyData, TRUE); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 3, "Y" => 3, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw a splitted pie chart */ $PieChart->draw3DPie(120, 90, array("Radius" => 100, "DataGapAngle" => 12, "DataGapRadius" => 10, "Border" => TRUE)); /* Write the legend box */ $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 0, "G" => 0, "B" => 0)); $PieChart->drawPieLegend(140, 160, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->stroke(); //$myPicture->autoOutput("pictures/example.draw3DPie.transparent.png"); }
function index() { $width = 600; $height = 230; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Female"); $MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Male"); //$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3"); $MyData->setSerieTicks("Male", 4); $MyData->setAxisName(0, "Number of males, females"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage($width, $height, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, $width, $height, $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, $width, $height, 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, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ //$myPicture->setFontProperties(array("FontName"=>pClass."fonts/Silkscreen.ttf","FontSize"=>6)); //$myPicture->drawText(10,13,"drawBarChart() - draw a bar chart",array("R"=>255,"G"=>255,"B"=>255)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(250, 55, "Average time to find a set", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw the scale and the 1st chart */ $myPicture->setGraphArea(60, 60, 450, 190); $myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("DrawSubTicks" => TRUE)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => pClass . "fonts/pf_arma_five.ttf", "FontSize" => 10)); $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 30)); //$myPicture->drawBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>30)); $myPicture->setShadow(FALSE); /* Draw the scale and the 2nd chart */ /* $myPicture->setGraphArea(500,60,670,190); $myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); $myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE)); $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); $myPicture->drawBarChart(); $myPicture->setShadow(FALSE); */ /* Write the chart legend */ //$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); $myPicture->drawLegend(500, 105, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); /* Render the picture (choose the best way) */ $myPicture->stroke(); }
$myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255); $myPicture->drawText($anchura / 2, 25, $title, $TextSettings); $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 10)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 0, "G" => 0, "B" => 0); $myPicture->drawText($anchura / 2, $altura - 20, "Evaluaciones", $TextSettings); $myPicture->setShadow(FALSE); $myPicture->setGraphArea(50, 50, $anchura - 25, $altura - 40); $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); $AxisBoundaries = array(0 => array("Min" => 0, "Max" => 10)); $ScaleSettings = array("Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "DrawSubTicks" => TRUE, "DrawArrows" => TRUE, "ArrowSize" => 6); $myPicture->drawScale($ScaleSettings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10)); if ($valores == "on") { $Config = array("DisplayValues" => 1); } else { $Config = ""; } $myPicture->{$dibujo}($Config); //$Config = array("FontR"=>0, "FontG"=>0, "FontB"=>0, "FontName"=>"fonts/pf_arma_five.ttf", "FontSize"=>6, "Margin"=>6, "Alpha"=>30, "BoxSize"=>5, "Style"=>LEGEND_NOBORDER //, "Mode"=>LEGEND_HORIZONTAL //); $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_LINE); $myPicture->drawLegend($anchura - 200, 6, $Config); $myPicture->stroke();
function PlotLine($rowX, $rowY, $name, $ch) { 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($rowX, "Serie1"); $myData->setSerieDescription("Serie1", $name); //$myData->setSerieOnAxis("Serie1",0); $myData->addPoints($rowY, "Absissa"); $myData->setAbscissa("Absissa"); //$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa"); //$myData->setAbscissa("Absissa"); $myData->setAxisPosition(0, AXIS_POSITION_LEFT); //$myData->setAxisName(0,"1st axis"); $myData->setAxisUnit(0, ""); $myPicture = new pImage(700, 230, $myData); $Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); $Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20)); $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, 190); //$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)); $Config = ""; if ($ch == 1) { $myPicture->drawSplineChart($Config); } if ($ch == 2) { $myPicture->drawBarChart($Config); } if ($ch == 3) { $myPicture->drawLineChart($Config); } if ($ch == 4) { $myPicture->drawPlotChart($Config); } if ($ch == 5) { $myPicture->drawStepChart($Config); } if ($ch == 6) { $myPicture->drawAreaChart($Config); } if ($ch == 7) { $myPicture->drawFilledSplineChart($Config); } if ($ch == 8) { $myPicture->drawFilledStepChart($Config); } if ($ch == 9) { $myPicture->drawStackedAreaChart($Config); } $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL); $myPicture->drawLegend(563, 16, $Config); $myPicture->stroke(); }
$myData->setSerieOnAxis("Serie2", 0); $myData->addPoints($rounds, "Absissa"); $myData->setAbscissa("Absissa"); $myData->setAxisPosition(0, AXIS_POSITION_LEFT); $myData->setAxisName(0, "Players"); $myData->setAxisUnit(0, ""); $myPicture = new pImage(600, 300, $myData, TRUE); $myPicture->setFontProperties(array("FontName" => "../pchart/fonts/Forgotte.ttf", "FontSize" => 12)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 150, "G" => 150, "B" => 150); // if so, this is a server stats page if (!empty($sid)) { $myPicture->drawText(297, 18, "Joins and leaves of this server in last " . $limit . " rounds.", $TextSettings); } else { $myPicture->drawText(297, 18, "Joins and leaves of these servers in last " . $limit . " rounds.", $TextSettings); } $myPicture->setShadow(FALSE); $myPicture->setGraphArea(50, 50, 576, 270); $myPicture->setFontProperties(array("R" => 150, "G" => 150, "B" => 150, "FontName" => "../pchart/fonts/pf_arma_five.ttf", "FontSize" => 6)); $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 150, "GridG" => 150, "GridB" => 150, "GridAlpha" => 50, "TickR" => 150, "TickG" => 150, "TickB" => 150, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 0, "DrawSubTicks" => 1, "SubTickR" => 150, "SubTickG" => 150, "SubTickB" => 150, "SubTickAlpha" => 50, "DrawYLines" => NONE, "AxisR" => 150, "AxisG" => 150, "AxisB" => 150); $myPicture->drawScale($Settings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10)); $Config = ""; $myPicture->drawSplineChart($Config); $Config = array("FontR" => 150, "FontG" => 150, "FontB" => 150, "FontName" => "../pchart/fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL); $myPicture->drawLegend(529, 12, $Config); $myPicture->stroke($BrowserExpire = TRUE); } else { // start outputting the image header("Content-type: image/png"); echo file_get_contents('./images/error.png'); }
$data->setAxisName(0, "Gigabytes"); } } } // Read data from the database, and add it $data->addPoints($times, "Labels"); $data->setSerieDescription("Labels", "Time of day"); $data->setAbscissa("Labels"); $chart = new pImage(700, 230, $data); /* Turn of Antialiasing */ $chart->Antialias = FALSE; /* Add a border to the picture */ $chart->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $chart->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 11)); $chart->drawText(150, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $chart->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $chart->setGraphArea(60, 40, 650, 200); /* Draw the scale */ $chart->drawScale($scaleSettings); /* Write the chart legend */ $chart->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Turn on Antialiasing */ $chart->Antialias = TRUE; /* Draw the area chart */ $chart->drawAreaChart(); /* Render the picture (choose the best way) */ $chart->stroke();
function pch_threshold_graph($graph_type, $index, $data, $width, $height, $font, $antialiasing, $xaxisname = "", $yaxisname = "", $title = "", $show_values = false, $show_legend = false, $font_size) { /* CAT:Threshold Chart */ /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($data, "DEFCA"); $MyData->setAxisName(0, $yaxisname); $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY); $MyData->addPoints($index, "Labels"); $MyData->setSerieDescription("Labels", $xaxisname); $MyData->setAbscissa("Labels"); $MyData->setPalette("DEFCA", array("R" => 55, "G" => 91, "B" => 127)); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 100)); $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size)); $myPicture->drawText(60, 35, $title, array("FontSize" => $font_size, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Do some cosmetic and draw the chart */ $myPicture->setGraphArea(60, 40, 670, 190); $myPicture->drawFilledRectangle(60, 40, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("GridR" => 180, "GridG" => 180, "GridB" => 180, "Mode" => SCALE_MODE_START0)); $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size)); $settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayValues" => $show_values, "DisplayZeroValues" => FALSE, "DisplayR" => 100, "DisplayG" => 100, "DisplayB" => 100, "DisplayShadow" => TRUE, "Surrounding" => 5, "AroundZero" => FALSE); $myPicture->drawSplineChart($settings); $myPicture->setShadow(FALSE); if ($show_legend) { /* Write the chart legend */ $myPicture->drawLegend(643, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); } /* Render the picture */ $myPicture->stroke(); }
/** * Output rendering to browser */ public function sendToBrowser() { $this->pImage->stroke(); }
/** * Frequency * * This uses the pChart library to graph the frequency. * * Upon browser request, this script will run with the specificed * percentage ($value) as a parameter. The pChart script will generate * a graph image on-the-fly which will then be displayed on the * variant page. As stated, they are on-the-fly images that are returned * at runtime and are not actually saved anywhere. * * The pChart library that can be found in application/third_party/pChart/ * More info on pChart at http://www.pchart.net/ * * @author Nikhil Anand * @author Sean Ephraim * @access public * @return void */ public function frequency() { // this is needed to allow stroke() to modify headers ob_end_clean(); // pChart Classes require_once APPPATH . "third_party/pChart/class/pDraw.class.php"; require_once APPPATH . "third_party/pChart/class/pImage.class.php"; // Validate precent value if (isset($_GET["value"]) && is_numeric($_GET["value"])) { $percent = trim($_GET["value"]); } else { print "Invalid value.\n"; exit; } // Set default size $size = 200; if (isset($_GET["small"])) { $size = 60; } // Small bug with 0% if ($percent == 0) { $percent = 0.001; } /* Initialize object */ $myPicture = new pImage($size, 12); $myPicture->setFontProperties(array("FontName" => APPPATH . "third_party/pChart/fonts/GeosansLight.ttf", "FontSize" => 15)); /* Set options */ $progressOptions = array("Width" => $size - 1, "Height" => 11, "R" => 8, "G" => 160, "B" => 43, "Surrounding" => 0, "BoxBorderR" => 204, "BoxBorderG" => 204, "BoxBorderB" => 204, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "RFade" => 206, "GFade" => 133, "BFade" => 30, "ShowLabel" => FALSE); /* Draw a progress bar */ $myPicture->drawProgress(0, 0, $percent, $progressOptions); $myPicture->stroke(); }
public static function drawchart($data) { // Include the chart libraries. $plib = '../iomad/pchart'; require_once "{$plib}/class/pDraw.class.php"; require_once "{$plib}/class/pPie.class.php"; require_once "{$plib}/class/pImage.class.php"; require_once "{$plib}/class/pData.class.php"; // Chart data. $chartdata = new pData(); $chartdata->addPoints(array($data->notstarted, $data->inprogress, $data->completed), "Value"); // Labels. $chartdata->addPoints(array('Not started', 'In progress', 'Completed'), "Legend"); $chartdata->setAbscissa("Legend"); // Chart object. $chart = new pImage(350, 180, $chartdata); // Pie chart object. $pie = new pPie($chart, $chartdata); $chart->setShadow(false); $chart->setFontProperties(array("FontName" => "{$plib}/fonts/GeosansLight.ttf", "FontSize" => 11)); $pie->setSliceColor(0, array("R" => 200, "G" => 0, "B" => 0)); $pie->setSliceColor(1, array("R" => 200, "G" => 200, "B" => 0)); $pie->setSliceColor(2, array("R" => 0, "G" => 200, "B" => 0)); $pie->draw3Dpie(175, 100, array("Radius" => 80, "DrawLabels" => true, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => true)); // Display the chart. $chart->stroke(); }