コード例 #1
0
ファイル: Example14.php プロジェクト: OmondiKevin/CD4
echo $data1 = 0;
echo $data2 = 0;
echo $data3 = 0;
echo $data4 = 0;
echo $data5 = 400;
echo $data6 = 0;
$val = "";
for ($i = 1; $i < 7; $i++) {
}
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
//  Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array($data1, $data2, $data3, $data4, $data5, $data6), "Serie1");
$DataSet->AddPoint(array("January", "February", "March", "April", "May", "June"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test = new pChart(300, 200);
$Test->loadColorPalette("Sample/softtones.txt");
$Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);
// This will draw a shadow under the pie chart
$Test->drawFilledCircle(122, 102, 70, 200, 200, 200);
// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->AntialiasQuality = 0;
$Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218);
$Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
$Test->Render("example14.png");
コード例 #2
0
$pChartCfg->centerY = intval($pChartCfg->YSize / 2);
$pChartCfg->radius = 150;
$pChartCfg->legendX = 10;
$pChartCfg->legendY = 15;
$graph = new stdClass();
$graph->data = $DataSet->GetData();
$graph->description = $DataSet->GetDataDescription();
$Test = new pChart($pChartCfg->XSize, $pChartCfg->YSize);
foreach ($series_color as $key => $hexrgb) {
    $rgb = str_split($hexrgb, 2);
    $Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// Draw the pie chart
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->AntialiasQuality = 0;
$Test->drawBasicPieGraph($graph->data, $graph->description, $pChartCfg->centerX, $pChartCfg->centerY, $pChartCfg->radius, PIE_PERCENTAGE, 255, 255, 218);
$Test->drawPieLegend($pChartCfg->legendX, $pChartCfg->legendY, $graph->data, $graph->description, 250, 250, 250);
$Test->Stroke();
function checkRights(&$db, &$user)
{
    return $user->hasRight($db, 'testplan_metrics');
}
/**
 * 
 *
 */
function init_args()
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->tplan_id = $_REQUEST['tplan_id'];
コード例 #3
0
ファイル: swgraph_pchart.php プロジェクト: JorgeUlises/higia
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setYAxisName($this->ytitle);
     $graphData->AddPoint($this->xlabels, "xaxis");
     //$graphData->SetSerieName("xaxis","xaxis");
     $graphData->SetAbsciseLabelSerie("xaxis");
     $graphData->setXAxisName($this->xtitle);
     // 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->AddPoint($v["data"], $series);
         $graphData->SetSerieName($v["legend"], $series);
         $graphData->AddSerie($series);
     }
     /*
     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($this->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 $this->width_pdf_actual.",".$this->height_pdf_actual."<BR>";
     $graphImage = new pChart($this->width_pdf_actual, $this->height_pdf_actual);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = htmltorgb("#ffffff");
     //$graphImage->drawGradientArea(0,0,$width,$height,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,$width - 1,$height - 1,200,200,200);
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xaxisfont, $this->xaxisfontsize);
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright_actual, $this->height_pdf_actual - $this->marginbottom_actual);
     $graphImage->drawFilledRoundedRectangle(3, 3, $this->width_pdf_actual - 3, $this->height_pdf_actual - 3, 5, 240, 240, 240);
     $graphImage->drawRoundedRectangle(1, 1, $this->width_pdf_actual - 1, $this->height_pdf_actual - 1, 5, 230, 230, 230);
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $linedrawn = false;
     $scatterdrawn = false;
     $piedrawn = false;
     $stackedexists = false;
     $overlayexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "OVERLAYBAR") {
             $overlayexists = true;
         }
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
         // Set plot colors
         if ($v["linecolor"]) {
             $graphImage->Palette[$k] = htmltorgb_pchart($v["linecolor"]);
         }
         $url .= "&plotlinecolor{$k}=" . $v["linecolor"];
     }
     $scale_drawing_mode = SCALE_NORMAL;
     $scale_drawing_mode = SCALE_START0;
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $scale_drawing_mode = SCALE_ADDALL;
         $scaleMin = "Unknown";
         $scaleMax = 0;
         $min = false;
         $max = false;
         foreach ($plot as $k => $v) {
             if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                 $series = $v["name"] . $k;
                 minmaxValueOfSeries($v["data"], $min, $max);
                 if ($scaleMin == "Unknown" || $min < $scaleMin) {
                     $scaleMin = $min;
                 }
                 $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));
     } else {
         if ($barexists || $overlayexists) {
             $scaleMin = "Unknown";
             $scaleMax = 0;
             $min = false;
             $max = false;
             foreach ($this->plot as $k => $v) {
                 if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                     $series = $v["name"] . $k;
                     minmaxValueOfSeries($v["data"], $min, $max);
                     if ($scaleMin == "Unknown" || $min < $scaleMin) {
                         $scaleMin = $min;
                     }
                     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));
         }
     }
     //echo "<PRE>";
     //var_dump($graphData->GetDataDescription());
     //die;
     // Find out if a scale is required, will be except for pie charts
     $scalerequired = false;
     foreach ($this->plot as $k => $v) {
         switch ($v["type"]) {
             case "BAR":
             case "STACKEDBAR":
             case "OVERLAYBAR":
             case "LINE":
                 $scalerequired = "NORMAL";
                 break;
             case "SCATTER":
                 $scalerequired = "SCATTER";
                 break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->xtitlefontsize);
     if ($scalerequired) {
         $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom_actual);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -20);
         // Automatic generation of x tick interval based on number of ticks
         if ($this->xticklabelinterval_actual == "AUTO") {
             $labct = count($this->plot[0]["data"]);
             $this->xticklabelinterval_actual = floor($labct / 35) + 1;
         }
         if ($scalerequired == "NORMAL") {
             $graphImage->drawScale($graphData->GetData(), $graphData->GetDataDescription(), $scale_drawing_mode, 0, 0, 0, TRUE, 40, FALSE, TRUE, $this->xticklabelinterval_actual, FALSE);
         }
         $graphImage->drawGrid(2, TRUE, 230, 230, 230, 45);
     } else {
         $this->marginright = 5;
         $this->marginbottom = 5;
         $this->marginleft = 5;
         $this->marginright_actual = 5;
         $this->marginbottom_actual = 5;
         $this->marginleft_actual = 5;
         //$this->margintop_actual = 5;
         $graphImage->setGraphArea($this->marginleft, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -10);
     }
     // If there's a Pie chart we want to draw different legends
     $piechart = false;
     foreach ($this->plot as $k => $v) {
         disableAllSeries($this->plot, $graphData);
         $series = $v["name"] . $k;
         setSerieDrawable($this->plot, $graphData, $series, TRUE);
         switch ($v["type"]) {
             case "PIE":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawFilledCircle($this->width_pdf_actual / 2 + 2, $this->margintop_actual + 2 + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45 + 1, 200, 200, 200);
                 $graphImage->drawBasicPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45, PIE_PERCENTAGE_LABEL, 255, 255, 218);
                 break;
             case "PIE3D":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.5, PIE_PERCENTAGE_LABEL, true, 60, 20, 0, 0);
                 break;
             case "OVERLAYBAR":
             case "STACKEDBAR":
             case "BAR":
                 if ($stackeddrawn) {
                     break;
                 }
                 if ($barexists || $overlayexists) {
                     foreach ($this->plot as $k1 => $v1) {
                         if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
                             setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                         }
                     }
                 }
                 $stackeddrawn = true;
                 if ($stackedexists) {
                     $graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                 } else {
                     if ($overlayexists) {
                         $graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                     } else {
                         $graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
                     }
                 }
                 break;
             case "SCATTER":
                 if ($scatterdrawn) {
                     break;
                 }
                 $scatterdrawn = true;
                 $series1 = false;
                 $series2 = false;
                 $graphImage->reportWarnings("GD");
                 $ct = 0;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "SCATTER") {
                         if ($ct == 0) {
                             $series1 = $v1["name"] . $k1;
                         }
                         if ($ct == 1) {
                             $series2 = $v1["name"] . $k1;
                         }
                         $ct++;
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->drawXYScale($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2, 0, 0, 0);
                 //$graphImage->drawXYGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->drawXYPlotGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->writeValues($graphData->GetData(), $graphData->GetDataDescription(), $series2);
                 break;
             case "LINE":
             default:
                 if ($linedrawn) {
                     break;
                 }
                 $linedrawn = true;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "LINE") {
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->LineWidth = 1;
                 $graphImage->drawLineGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->drawPlotGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->LineWidth = 1;
                 break;
         }
     }
     foreach ($this->plot as $k1 => $v1) {
         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
     }
     // Draw Legend if legend value has been set
     $drawlegend = false;
     foreach ($this->plot as $k => $v) {
         if (isset($v["legend"]) && $v["legend"]) {
             // Temporarily Dont draw legend for Pie
             //if ( $piechart )
             //$graphImage->drawPieLegend($this->width_pdf_actual - 180,30,$graphData->GetData(), $graphData->GetDataDescription(), 250, 250, 250);
             if (!$piechart) {
                 $graphImage->drawLegend($this->width_pdf_actual - 120, 30, $graphData->GetDataDescription(), 254, 254, 254, 0, 0, 0);
             }
             break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->titlefontsize);
     $graphImage->drawTitle(0, 24, $this->title_actual, 50, 50, 50, $this->width_pdf_actual);
     //$graphImage->setShadow(TRUE,array("X"=>0,"Y"=>0,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
     //$graphImage->Render("example.png");
     //$graphImage->Stroke();
     $graphImage->render($outputfile);
     return true;
 }
コード例 #4
0
 public function pchartAction()
 {
     //		$this->_helper->layout->disableLayout();
     $this->_helper->layout->setLayout("layout_admin");
     include "pData.class";
     include "pChart.class";
     $this->view->showArray = $this->testdemoAction();
     $showdate = array();
     $showreport = array();
     foreach ($this->view->showArray as $show) {
         array_push($showdate, substr($show['date'], strlen($show['date']) - 4, 4));
         array_push($showreport, $show['count']);
     }
     // Dataset definition
     $DataSet = new pData();
     $DataSet->AddPoint(array_slice($showreport, 0, 26), "Serie1");
     $DataSet->AddPoint(array_slice($showdate, 0, 26), "Serie2");
     $DataSet->AddSerie("Serie1");
     $DataSet->SetAbsciseLabelSerie("Serie2");
     $DataSet->SetSerieName("Reports", "Serie1");
     $DataSet->SetYAxisName('Report Count');
     $DataSet->SetXAxisName('Date');
     // Initialise the graph
     $Test = new pChart(900, 250);
     $Test->setFontProperties("xihei.ttf", 8);
     $Test->setGraphArea(50, 30, 780, 200);
     $Test->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255);
     $Test->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230);
     $Test->drawGraphArea(255, 255, 255, TRUE);
     $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
     $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
     // Draw the 0 line
     $Test->setFontProperties("xihei.ttf", 6);
     $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     // Draw the bar graph
     $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
     // Finish the graph
     $Test->setFontProperties("xihei.ttf", 8);
     $Test->drawLegend(596, 50, $DataSet->GetDataDescription(), 255, 255, 255);
     $Test->setFontProperties("xihei.ttf", 10);
     $Test->drawTitle(200, 22, "Reports by Day in Jue.", 50, 50, 50, 585);
     $Test->Render("Naked1.png");
     //=====================================================================================
     // Dataset definition
     $DataSet2 = new pData();
     $DataSet2->AddPoint(array(38, 22, 606), "Serie1");
     $DataSet2->AddPoint(array("Male", "Female", "Unkown"), "Serie2");
     $DataSet2->AddAllSeries();
     $DataSet2->SetAbsciseLabelSerie("Serie2");
     // Initialise the graph
     $Test2 = new pChart(300, 200);
     $Test2->loadColorPalette("softtones.txt");
     $Test2->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 255, 255, 255);
     $Test2->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);
     // This will draw a shadow under the pie chart
     $Test2->drawFilledCircle(122, 102, 70, 200, 200, 200);
     // Draw the pie chart
     $Test2->setFontProperties("tahoma.ttf", 8);
     $Test2->drawBasicPieGraph($DataSet2->GetData(), $DataSet2->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218);
     $Test2->drawPieLegend(230, 15, $DataSet2->GetData(), $DataSet2->GetDataDescription(), 250, 250, 250);
     $Test2->Render("Naked2.png");
     //=====================================================================================
     // select province
     $db = Zend_Registry::get('db');
     $selectprovince = $db->select();
     $selectprovince->from('consumer', array("province", "count(*) as count"))->where("pest is null")->group("consumer.province")->order("count desc");
     $provinceArray = $db->fetchAll($selectprovince);
     $this->view->showprovince = '';
     $this->view->showprovincecount = '';
     $showprovince = array();
     $showprovincecount = array();
     foreach ($provinceArray as $province) {
         if ($province['province'] == null || $province['province'] == '') {
             array_push($showprovince, 'Unkown');
         } else {
             array_push($showprovince, $province['province']);
         }
         array_push($showprovincecount, $province['count']);
     }
     // Dataset definition
     $DataSet3 = new pData();
     $DataSet3->AddPoint(array_slice($showprovincecount, 0, 20), "Serie1");
     $DataSet3->AddPoint(array_slice($showprovince, 0, 20), "Serie2");
     $DataSet3->AddSerie("Serie1");
     $DataSet3->SetAbsciseLabelSerie("Serie2");
     $DataSet3->SetSerieName("Spark Count", "Serie1");
     $DataSet3->SetYAxisName('Spark Count');
     $DataSet3->SetXAxisName('Province');
     Zend_Debug::dump($DataSet3->GetDataDescription());
     // Initialise the graph
     $Test3 = new pChart(900, 250);
     $Test3->setFontProperties("xihei.ttf", 8);
     $Test3->setGraphArea(50, 30, 780, 200);
     $Test3->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255);
     $Test3->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230);
     $Test3->drawGraphArea(255, 255, 255, TRUE);
     $Test3->drawScale($DataSet3->GetData(), $DataSet3->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
     $Test3->drawGrid(4, TRUE, 230, 230, 230, 50);
     // Draw the 0 line
     $Test3->setFontProperties("xihei.ttf", 6);
     $Test3->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     // Draw the bar graph
     $Test3->drawBarGraph($DataSet3->GetData(), $DataSet3->GetDataDescription(), TRUE);
     // Finish the graph
     $Test3->setFontProperties("xihei.ttf", 8);
     $Test3->drawLegend(596, 50, $DataSet3->GetDataDescription(), 255, 255, 255);
     $Test3->setFontProperties("xihei.ttf", 10);
     $Test3->drawTitle(200, 22, "Reports by Day in Jue.", 50, 50, 50, 585);
     $Test3->Render("Naked3.png");
 }
コード例 #5
0
    //$margintop = 5;
    $graphImage->setGraphArea($marginleft, $margintop, $width - $marginright, $height - $marginbottom);
    $graphImage->drawGraphAreaGradient(240, 240, 240, -10);
}
// If there's a Pie chart we want to draw different legends
$piechart = false;
foreach ($plot as $k => $v) {
    disableAllSeries($plot, $graphData);
    $series = $v["name"] . $k;
    setSerieDrawable($plot, $graphData, $series, TRUE);
    switch ($v["type"]) {
        case "PIE":
            $piedrawn = true;
            $piechart = true;
            $graphImage->drawFilledCircle($width / 2 + 2, $margintop + 2 + ($height - $margintop - $marginbottom) / 2, ($height - $marginbottom - $margintop - 20) * 0.45 + 1, 200, 200, 200);
            $graphImage->drawBasicPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $width / 2, $margintop + ($height - $margintop - $marginbottom) / 2, ($height - $marginbottom - $margintop - 20) * 0.45, PIE_PERCENTAGE_LABEL, 255, 255, 218);
            break;
        case "PIE3D":
            $piedrawn = true;
            $piechart = true;
            $graphImage->drawPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $width / 2, $margintop + ($height - $margintop - $marginbottom) / 2, ($height - $marginbottom - $margintop - 20) * 0.5, PIE_PERCENTAGE_LABEL, true, 60, 20, 0, 0);
            break;
        case "OVERLAYBAR":
        case "STACKEDBAR":
        case "BAR":
            if ($stackeddrawn) {
                break;
            }
            if ($barexists || $overlayexists) {
                foreach ($plot as $k1 => $v1) {
                    if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
コード例 #6
0
ファイル: stats.php プロジェクト: j0rpi/SFSDB
$Test->setFontProperties("arial.ttf", 8);
$Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218);
$Test->drawPieLegend(200, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
$Test->Render("accs.png");
// Profit Pie
$DataSet2 = new pData();
$DataSet2->AddPoint(array($functions->GetTotalProfitUser("j0rpi"), $functions->GetTotalProfitUser("fallbacken")), "Serie3");
$DataSet2->AddPoint(array("\$" . $functions->GetTotalProfitUser("j0rpi"), "\$" . $functions->GetTotalProfitUser("fallbacken")), "Serie2");
$DataSet2->AddAllSeries();
$DataSet2->SetAbsciseLabelSerie("Serie2");
$Test2 = new pChart(300, 200);
$Test2->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test2->drawRoundedRectangle(5, 5, 295, 195, 5, 0, 0, 0);
$Test2->drawFilledCircle(121, 101, 75, 255, 255, 255);
$Test2->setFontProperties("arial.ttf", 8);
$Test2->drawBasicPieGraph($DataSet2->GetData(), $DataSet2->GetDataDescription(), 120, 100, 70, PIE_LABELS, 255, 255, 218);
$Test2->drawPieLegend(200, 15, $DataSet2->GetData(), $DataSet2->GetDataDescription(), 250, 250, 250);
$Test2->Render("users.png");
echo "<font style='font-family: Helvetica'>";
echo "<img src='stats.png' />";
echo "<br /><img src='users.png' /><br /><br /><br />";
echo "Right now, we have <b>" . mysql_num_rows($accs) . "</b> Steam accounts in the database, where <b>" . mysql_num_rows($sold) . "</b> has been sold.</br >";
echo "We have also made a total of <b>\$";
echo $functions->GetTotalProfit() . " </b> profit, where j0rpi has made <b>\$" . $functions->GetTotalProfitUser("j0rpi") . "</b>, and FallbackeN has made <b>\$" . $functions->GetTotalProfitUser('fallbacken') . "</b>";
echo "</font>";
?>

</table>
</div>
<br>
<br>
コード例 #7
0
 protected function _createSourcesGraph()
 {
     // load pChart graphic library
     $this->_loadLibs();
     // définition des données à afficher
     $dataSet = new pData();
     // need config, to know which data user wants to display : visits, unique visitors, pageviews
     $sefConfig = Sh404sefFactory::getConfig();
     // Google does not allow combining dimension=ga:medium with metric = unique visitors
     $dataType = $sefConfig->analyticsDashboardDataType == 'ga:visitors' ? 'ga:visits' : $sefConfig->analyticsDashboardDataType;
     $dataTypeString = str_replace('ga:', '', $dataType);
     // sort data for proper display
     usort($this->_rawData['sources'], array($this, '_sortSourcesDataCompareFunction'));
     // we walk the array, pulling out alternatively
     // the first and last items
     // making the new array having the largest item
     // followed by the smallest, then second largest
     // then second smallest, ...
     // which makes drawing labels much easier
     $tmpArray = array();
     $even = false;
     $max = count($this->_rawData['sources']);
     for ($i = 0; $i < $max; $i++) {
         if ($even) {
             // pull last item in sorted array
             $tmpArray[] = array_pop($this->_rawData['sources']);
         } else {
             // pull array first item
             $tmpArray[] = array_shift($this->_rawData['sources']);
         }
         // flag inversion
         $even = !$even;
     }
     // get data from response
     $data = array();
     $types = array();
     foreach ($tmpArray as $entry) {
         $value = $entry->{$dataTypeString};
         // do not add empty values, as pChart would choke on that and display a warning
         if (!empty($value)) {
             $data[] = $value;
             $types[] = Sh404sefHelperAnalytics::getReferralLabel($entry->dimension['medium']);
         }
     }
     $dataSet->AddPoint($data, "visits");
     $dataSet->AddPoint($types, "types");
     $dataSet->addSerie('visits');
     $dataSet->SetAbsciseLabelSerie("types");
     $label = JText::_('COM_SH404SEF_ANALYTICS_REPORT_SOURCES') . JText::_('COM_SH404SEF_ANALYTICS_REPORT_BY_LABEL') . Sh404sefHelperAnalytics::getDataTypeTitle();
     $dataSet->SetSerieName($label, "visits");
     // Initialise the graph
     $w = intval(0.45 * $this->_options['cpWidth']);
     $w = empty($w) ? 160 : $w;
     $radius = intval($w * 0.22);
     $margin = 5;
     $h = intval($w * 0.8);
     $centreX = intval(0.5 * $w);
     $centreY = intval(0.5 * $h);
     $chart = new pChart($w, $h);
     $fontSize = 8;
     // prepare graph
     $chart->setFontProperties($this->_baseChartPath . DS . 'Fonts/arial.ttf', $fontSize);
     $chart->loadColorPalette($this->_baseChartPath . DS . 'palettes' . DS . 'tones-2-green-soft.php');
     $chart->setGraphArea($margin, $margin, $w - $margin, $h - $margin);
     // This will draw a shadow under the pie chart
     $chart->drawFilledCircle($centreX + 4, $centreY + 4, $radius, 200, 200, 200);
     // Draw the pie chart
     $d = $dataSet->GetData();
     if (!empty($d)) {
         $chart->drawBasicPieGraph($d, $dataSet->GetDataDescription(), $centreX, $centreY, $radius, PIE_PERCENTAGE_LABEL_VALUE, 255, 255, 218);
     }
     // create a temporary file for
     $user =& JFactory::getUser();
     // make sure the root tmp dir exists
     $rootDir = 'tmp' . DS . 'sh404sef_analytics';
     Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $rootDir);
     // file name is variable to avoid browser cache
     $basePath = $rootDir . DS . md5('useless_' . $user->id . '_hashing') . DS;
     // create path and make sure there's an index.html file in it
     Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $basePath);
     $imageFileName = Sh404sefHelperAnalytics::createTempFile($basePath, $this->_options['report'] . '.' . $this->_options['accountId'] . '.sources.' . $dataTypeString);
     $chart->Render(JPATH_ROOT . DS . $imageFileName);
     // need cleaning up, so let's remove all report files for that user older than an hour or so
     Sh404sefHelperAnalytics::cleanReportsImageFiles(JPATH_ROOT . DS . $basePath, $age = 4000);
     return JURI::root() . $imageFileName;
 }
コード例 #8
0
ファイル: pie.php プロジェクト: cdkisa/majordomo
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 10);
$Test->drawTitle(2, 15, $title, 150, 150, 150);
//---------------------------- Font
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 8);
//---------------------------- Set GraphArea
$Test->setGraphArea(0, 0, $w, $h);
//---------------------------- Set background graphics (R,G,G,1/Y)
if ($bg_r != 0 && $bg_g != 0 && $bg_b != 0) {
    $Test->drawGraphAreaGradient($bg_r, $bg_g, $bg_b, 5);
}
//---------------------------- Calc center
$midX = $w / 2;
$midY = $h / 2;
//---------------------------- Draw pie
if ($_GET['gtype'] == 'pie') {
    $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, $cbg, $cbg, $cbg, 1);
} elseif ($_GET['gtype'] == 'pie2') {
    $Test->drawFlatPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, 5, 1);
} elseif ($_GET['gtype'] == 'pie3') {
    $Test->setShadowProperties(3, 3, $csh, $csh, $csh, 90);
    $Test->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, 5, 1);
} elseif ($_GET['gtype'] == 'pie4') {
    $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, TRUE, 60, 20, 5, 1);
} else {
    //
}
//---------------------------- Border
if ($_GET['border'] == '1') {
    $Test->AddBorder(1, 200, 200, 200);
}
//---------------------------- Image PNG
コード例 #9
0
ファイル: Example14.php プロジェクト: andersongimino/area51
<?php

/*
    Example14: A smooth flat pie graph
*/
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(10, 2, 3, 5, 3), "Serie1");
$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test = new pChart(300, 200);
$Test->loadColorPalette("Sample/softtones.txt");
$Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);
// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 70, TRUE, 255, 255, 218);
$Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
$Test->Render("example14.png");
コード例 #10
0
ファイル: Charts.php プロジェクト: ohjack/mallerp_standard
 function pieChart($r, $percents, $legend, $imgname = '', $title = '', $bottom_label = '', $config = array())
 {
     $settings = array('Skew' => 90, 'SpliceHeight' => 10, 'SpliceDistance' => 0, 'PieFontSize' => 8, 'TitleFontSize' => 10, 'LegendFontSize' => 8, 'LabelFontSize' => 10, 'PieFontName' => 'tahoma.ttf', 'TitleFontName' => 'tahoma.ttf', 'LegendFontName' => 'tahoma.ttf', 'LabelFontName' => 'tahoma.ttf', 'TitleBGR' => 0, 'TitleBGG' => 0, 'TitleBGB' => 0, 'TitleFGR' => 0, 'TitleFGG' => 0, 'TitleFGB' => 0, 'ImgR' => 240, 'ImgG' => 240, 'ImgB' => 240, 'BorderR' => 0, 'BorderG' => 0, 'BorderB' => 0, 'LegendR' => 250, 'LegendG' => 250, 'LegendB' => 250, 'LabelBGR' => 0, 'LabelBGG' => 0, 'LabelBGB' => 0, 'LabelFGR' => 0, 'LabelFGG' => 0, 'LabelFGB' => 0);
     // Get the custom settings
     if (is_array($config)) {
         foreach ($config as $key => $val) {
             $settings[$key] = $val;
         }
     }
     if ($settings['SpliceHeight'] == 0) {
         $settings['SpliceHeight'] = 1;
     }
     // avoid division by zero in pChart
     $PieFontSize = $settings['PieFontSize'];
     $TitleFontSize = $settings['TitleFontSize'];
     $LegendFontSize = $settings['LegendFontSize'];
     $LabelFontSize = $settings['LabelFontSize'];
     $PieFontName = $this->_ext_path . "/fonts/" . $settings['PieFontName'];
     $TitleFontName = $this->_ext_path . "/fonts/" . $settings['TitleFontName'];
     $LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName'];
     $LabelFontName = $this->_ext_path . "/fonts/" . $settings['LabelFontName'];
     $Skew = $settings['Skew'];
     // Calc legend size
     $Wmax = 0;
     $TextHeight = 0;
     foreach ($legend as $lg) {
         $Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $lg);
         $TextWidth = $Position[2] - $Position[0];
         $TextHeight = $TextHeight + $Position[1] - $Position[7];
         $Wmax = $TextWidth > $Wmax ? $TextWidth : $Wmax;
         // Maximum width of the legend
     }
     $legendW = $Wmax + 30;
     if (strlen($title) > 0) {
         $Position = imageftbbox($TitleFontSize, 0, $TitleFontName, $title);
         $titleWidth = $Position[2] - $Position[0] + 40;
         $titleHeight = $Position[1] - $Position[7] + 8;
     } else {
         $titleWidth = 0;
         $titleHeight = 0;
     }
     if (strlen($bottom_label) > 0) {
         $Position = imageftbbox($LabelFontSize, 0, $LabelFontName, $bottom_label);
         $labelWidth = $Position[2] - $Position[0] + 8;
         $labelHeight = $Position[1] - $Position[7] + 8;
     } else {
         $labelWidth = 0;
         $labelHeight = 0;
     }
     // Calculate  pie size based on fontsize radius and skew
     $Position = imageftbbox($PieFontSize, 0, $PieFontName, '199%');
     $pieWidth = ($Position[2] - $Position[0]) * 2 + $r * 2;
     $sin = $Skew != 90 ? abs(sin(deg2rad($Skew))) : 1;
     // if skewed the height goes with sin($skew)
     $SpliceHeight = $Skew != 90 ? $settings['SpliceHeight'] : 0;
     // if skewed add the SpliceHeight
     $SpliceDistance = $settings['SpliceDistance'] * 2 + 30;
     $pieHeight = intval(($Position[1] - $Position[7]) * 2 + $r * 2 * $sin + $SpliceHeight);
     $h = intval($pieHeight + $SpliceDistance * $sin);
     // Img Height
     $y = intval(($pieHeight - $SpliceHeight) / 2 + $SpliceDistance / 2);
     // center y pos
     $x = intval($pieWidth / 2) + $SpliceDistance / 2;
     // center x pos
     $w = $x * 2 + ($legendW > $labelWidth ? $legendW : $labelWidth) + 10;
     if ($titleWidth > $w) {
         $w = $titleWidth;
     }
     $h2 = $labelHeight + $titleHeight + $TextHeight + 60;
     // If the legend has big height
     if ($h2 > $h) {
         $h = $h2;
     }
     //Add pixels for the title
     $h = $h + $titleHeight + 10;
     // Real height
     $y = $y + $titleHeight + 10;
     // Real center y
     // Dataset definition
     $DataSet = new pData();
     $DataSet->AddPoint($percents, "Serie1");
     $DataSet->AddPoint($legend, "Serie2");
     $DataSet->AddAllSeries();
     $DataSet->SetAbsciseLabelSerie("Serie2");
     // Initialise the graph
     $Test = new pChart($w, $h);
     $red = $settings['ImgR'];
     $g = $settings['ImgG'];
     $b = $settings['ImgB'];
     $Test->drawFilledRoundedRectangle(7, 7, $w - 7, $h - 7, 5, $red, $g, $b);
     $red = $settings['BorderR'];
     $g = $settings['BorderG'];
     $b = $settings['BorderB'];
     $Test->drawRoundedRectangle(5, 5, $w - 5, $h - 5, 5, $red, $g, $b);
     // Draw the pie chart
     $Test->setFontProperties($PieFontName, $PieFontSize);
     if ($Skew != 90) {
         $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $x, $y, $r, PIE_PERCENTAGE, TRUE, $Skew, $settings['SpliceHeight'], $settings['SpliceDistance']);
     } else {
         if ($settings['SpliceDistance'] == 0) {
             $Test->drawFilledCircle($x + 2, $y + 2, $r, 0, 0, 0);
             // This will draw a shadow under the pie chart
             $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $x, $y, $r, PIE_PERCENTAGE, 255, 255, 218);
         } else {
             $Test->setShadowProperties(2, 2, 200, 200, 200);
             $Test->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), $x, $y, $r, PIE_PERCENTAGE, $settings['SpliceDistance']);
         }
     }
     // Draw the legend
     $x1 = $x * 2 - 5;
     $r = $settings['LegendR'];
     $g = $settings['LegendG'];
     $b = $settings['LegendB'];
     $Test->setFontProperties($LegendFontName, $LegendFontSize);
     $Test->drawPieLegend($x1, $titleHeight + 30, $DataSet->GetData(), $DataSet->GetDataDescription(), $r, $g, $b);
     //Draw the title
     if (strlen($title) > 0) {
         $Test->setFontProperties($TitleFontName, $TitleFontSize);
         $r = $settings['TitleFGR'];
         $g = $settings['TitleFGG'];
         $b = $settings['TitleFGB'];
         $r1 = $settings['TitleBGR'];
         $g1 = $settings['TitleBGG'];
         $b1 = $settings['TitleBGB'];
         $Test->drawTextBox(6, 6, $w - 5, $titleHeight + 10, $title, 0, $r, $g, $b, ALIGN_CENTER, FALSE, $r1, $g1, $b1, 50);
     }
     if (strlen($bottom_label) > 0) {
         $Test->setFontProperties($LabelFontName, $LabelFontSize);
         $r = $settings['LabelFGR'];
         $g = $settings['LabelFGG'];
         $b = $settings['LabelFGB'];
         $r1 = $settings['LabelBGR'];
         $g1 = $settings['LabelBGG'];
         $b1 = $settings['LabelBGB'];
         $x1 = $x * 2 - 10;
         $Test->drawTextBox($x1, $h - $labelHeight - 15, $w - 10, $h - 10, $bottom_label, 0, $r, $g, $b, ALIGN_CENTER, FALSE, $r1, $g1, $b1, 20);
     }
     if (strlen($imgname)) {
         $imgname = $this->_img_path . "/" . $imgname;
     } else {
         $this->obj->load->helper('string');
         $imgname = $this->_img_path . "/pie-" . random_string('alnum', 16) . ".png";
     }
     $Test->Render($imgname);
     return array("name" => '/' . $imgname, "w" => $w, "h" => $h);
 }
コード例 #11
0
ファイル: Grafico.php プロジェクト: hackultura/novosalic
 public function gerarGraficoPizza($tipoPizza)
 {
     // Montando plotagens com os arrays de dados passados
     $DataSet = new pData();
     // Definindo labels dos eixos
     if (!empty($this->_tituloEixoX)) {
         $DataSet->SetXAxisName($this->_tituloEixoX);
         $DataSet->SetYAxisName($this->_tituloEixoY);
     }
     // Definindo labels dos dados
     if (count($this->_tituloItens) > 0) {
         $DataSet->AddPoint($this->_tituloItens, "labels");
         $DataSet->SetAbsciseLabelSerie("labels");
     }
     // Montando plotagens com os arrays de dados passados
     for ($i = 0; $i < count($this->_dados); $i++) {
         $DataSet->AddPoint($this->_dados[$i], $this->_tituloDados[$i]);
         $DataSet->AddSerie($this->_tituloDados[$i]);
         // Initialise the graph
         /*$Test = new pChart($this->_larguraGrafico,$this->_alturaGrafico);
           $Test->setFontProperties(CAMINHO_PCHART_FONT."/tahoma.ttf",8);
           $Test->setGraphArea($this->_margem,$this->_margem+30,75*$this->_larguraGrafico/100,80*$this->_alturaGrafico/100-15);
           $Test->drawFilledRoundedRectangle(7,7,98*$this->_larguraGrafico/100,98*$this->_alturaGrafico/100,5,$this->_corFundo["r"],$this->_corFundo["g"],$this->_corFundo["b"]);
           $Test->drawRoundedRectangle(5,5,98*$this->_larguraGrafico/100+3,98*$this->_alturaGrafico/100+3,5,$this->_corMargem["r"],$this->_corMargem["g"],$this->_corMargem["b"]);*/
         $Test = new pChart($this->_larguraGrafico * 2, $this->_alturaGrafico * 2);
         $Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 8);
         $Test->setGraphArea($this->_margem + 100, $this->_margem + 50, 120 * $this->_larguraGrafico / 100, 130 * $this->_alturaGrafico / 100 - 10);
         $Test->drawFilledRoundedRectangle(7, 7, 190 * $this->_larguraGrafico / 100, 130 * $this->_alturaGrafico / 100, 5, $this->_corFundo["r"], $this->_corFundo["g"], $this->_corFundo["b"]);
         $Test->drawRoundedRectangle(5, 5, 190 * $this->_larguraGrafico / 100 + 3, 130 * $this->_alturaGrafico / 100 + 3, 5, $this->_corMargem["r"], $this->_corMargem["g"], $this->_corMargem["b"]);
         // Draw the 0 line
         $Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 10);
         if ($this->_exibirValores == true) {
             $auxExibirValores = PIE_VALUES;
         } else {
             $auxExibirValores = PIE_NOLABEL;
         }
         // Draw the limit graph
         if ($tipoPizza == "pizza") {
             $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 35 * $this->_larguraGrafico / 100, 55 * $this->_alturaGrafico / 100 - 15, 25 * $this->_larguraGrafico / 100, $auxExibirValores, TRUE, 50, 20, 5);
         } else {
             $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 35 * $this->_larguraGrafico / 100, 55 * $this->_alturaGrafico / 100 - 15, 25 * $this->_larguraGrafico / 100, $auxExibirValores, TRUE, 50, 20, 5);
         }
         $Test->drawPieLegend(70 * $this->_larguraGrafico / 100, 35 * $this->_alturaGrafico / 100 - 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 255, 249, 223, 15, 15, 15);
         $Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 14);
         $Test->drawTitle($this->_larguraGrafico / 2 - 20, 30, $this->_tituloGrafico . ": " . $this->_tituloDados[$i], $this->_corLabels["r"], $this->_corLabels["g"], $this->_corLabels["b"]);
         $Test->Render(CAMINHO_PCHART . "/../../../../../public/pizza{$i}.png");
         echo "<img src='" . $_SERVER['REQUEST_URI'] . "/../../public/pizza{$i}.png'>";
         $DataSet->removeAllSeries();
     }
 }
コード例 #12
0
ファイル: whois.php プロジェクト: kostya1017/our
 function genratePieChartImage($dataAr)
 {
     //debug('DATA',$dataAr,2);
     $s1 = array();
     $s2 = array();
     foreach ($dataAr as $key => $val) {
         $s1[] = $val;
         $s2[] = $key;
     }
     // Dataset definition
     require_once APPPATH . '3rdparty/pchart/pChart/pData.class';
     require_once APPPATH . '3rdparty/pchart/pChart/pChart.class';
     $path = $this->config->item('csv_upload_path');
     $DataSet = new pData();
     $DataSet->AddPoint($s1, "Serie1");
     $DataSet->AddPoint($s2, "Serie2");
     $DataSet->AddAllSeries();
     $DataSet->SetAbsciseLabelSerie("Serie2");
     // Initialise the graph
     $Test = new pChart(1000, 458);
     $Test->drawBackground(232, 234, 234);
     $Test->loadColorPalette(APPPATH . '3rdparty/pchart/softtones.txt');
     // Draw the pie chart
     $Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 8);
     $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 480, 229, 175);
     $Test->drawPieLegend(650, 75, $DataSet->GetData(), $DataSet->GetDataDescription(), 232, 234, 234);
     $imgName = uniqid('graph_') . '.png';
     $Test->Render($path . $imgName);
     return upload_to_amazon_graphImage($imgName, $path);
 }