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();
 }
Example #2
0
function create_common_image($title, $width, $height, $data, $chart_type = 'line')
{
    global $pchart_path;
    /* Create the pChart object */
    $myPicture = new pImage($width, $height, $data);
    /* Draw the background */
    $Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 185, "DashG" => 225, "DashB" => 255);
    $myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
    /* Overlay with a gradient */
    $Settings = array("StartR" => 206, "StartG" => 235, "StartB" => 235, "EndR" => 71, "EndG" => 150, "EndB" => 205, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
    $myPicture->drawGradientArea(0, 0, $width, 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" => $pchart_path . "/fonts/arialbd.ttf", "FontSize" => 9));
    $myPicture->drawText(24, 12, win2uni($title), array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLELEFT));
    $myPicture->drawFromPNG(4, 4, "includes/design/images/chart_pie.png");
    if ($chart_type == 'line') {
        $myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/arial.ttf", "FontSize" => 8));
        /* Draw the scale and the 1st chart */
        $myPicture->setGraphArea(60, 64, 450 + 200, 190);
        $myPicture->drawFilledRectangle(60, 50, 450 + 200, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -255, "Alpha" => 60));
        $myPicture->drawScale(array("Mode" => SCALE_MODE_START0, "DrawSubTicks" => FALSE, "GridR" => 151, "GridG" => 197, "GridB" => 254, "GridAlpha" => 30));
        $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    }
    $myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/pf_arma_five.ttf", "FontSize" => 6));
    return $myPicture;
}
 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");
 }
Example #4
0
function plot($lift)
{
    $MyData = new pData();
    $positivelift = array();
    $negativelift = array();
    foreach ($lift as $heading => $fpm) {
        if ($fpm > 0) {
            $positivelift[$heading] = $fpm;
            $negativelift[$heading] = 0;
        } else {
            $negativelift[$heading] = -$fpm;
            $positivelift[$heading] = 0;
        }
    }
    $MyData->addPoints($positivelift, "ScoreA");
    // green
    $MyData->addPoints($negativelift, "ScoreB");
    // red
    $MyData->addPoints(array_keys($lift), "Coord");
    $MyData->setAbscissa("Coord");
    $myPicture = new pImage(700, 700, $MyData);
    $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $SplitChart = new pRadar();
    $myPicture->setGraphArea(10, 10, 690, 690);
    $Options = array("LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "DrawPoly" => TRUE, "PolyAlpha" => 50, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6);
    $SplitChart->drawPolar($myPicture, $MyData, $Options);
    $myPicture->autoOutput("lift.png");
}
Example #5
0
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 func_bargraphGenerate($student_id, $time, $type, $basepath, $success, $r = "", $g = "", $b = "", $name)
 {
     $bookIdResult = $this->func_getBookId('1,2');
     $bookID = array();
     foreach ($bookIdResult as $book) {
         $bookID[] = $book['book_id'];
     }
     $getActivityTypeIdResult = $this->func_getActivityTypeId('WORD HUNT');
     foreach ($getActivityTypeIdResult as $activityTypeId) {
         $activityTypeId = $activityTypeId['activity_type_id'];
     }
     $getActivityIdResult = $this->func_getActivityId($bookID, $activityTypeId);
     $actId = array();
     foreach ($getActivityIdResult as $activityId) {
         $actId[] = $activityId['activity_id'];
     }
     $actNewId = implode(',', $actId);
     $k = 0;
     $j = 0;
     for ($i = 0; $i < 5; $i = $i + 1) {
         $date[$k] = date("Y-m-d", strtotime("-{$i} day"));
         $dateRec[] = date('M d', strtotime("-{$i} day"));
         $k = $k + 1;
     }
     $successaccessmentResult = $this->fun_getAssmentResult($student_id, $actNewId, '', $date, "word_hunt", $success);
     $totalaccessmentResult = $this->fun_getAssmentResult($student_id, $actNewId, '', $date, "word_hunt", '0,1');
     for ($i = 0; $i < 5; $i = $i + 1) {
         $j = $i;
         if ($totalaccessmentResult['0']['count_' . $j] == "0") {
             $totalaccessmentResult['0']['count_' . $j] = 1;
         }
         $per[$i] = $successaccessmentResult['0']['count_' . $j] / $totalaccessmentResult['0']['count_' . $j] * 100;
     }
     $MyData = new pData();
     $MyData->addPoints($per, "Server A");
     $MyData->setAxisName(0, "Percentage");
     $MyData->addPoints(array_reverse($dateRec), "Months");
     $MyData->setSerieDescription("Months", "Month");
     $MyData->setAbscissa("Months");
     $myPicture = new pImage(350, 230, $MyData);
     /* Turn of Antialiasing */
     $myPicture->Antialias = FALSE;
     /* Add a border to the picture */
     $myPicture->drawGradientArea(0, 0, 400, 230, DIRECTION_VERTICAL, array("StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 100));
     // $myPicture->drawRectangle(0,0,400,229,array("R"=>0,"G"=>0,"B"=>0));
     /* Set the default font */
     $myPicture->setFontProperties(array("FontName" => $basepath . "Silkscreen.ttf", "FontSize" => 6));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, 350, 200);
     /* Draw the scale */
     $scaleSettings = array("GridR" => 300, "GridG" => 300, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => FALSE, "Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_MANUAL, "LabelingMethod" => LABELING_ALL);
     $myPicture->drawScale($scaleSettings);
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw the chart */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $settings = array("Surrounding" => -30, "InnerSurrounding" => 30, "Mode" => 0);
     $myPicture->drawBarChart($settings, $r, $g, $b);
     /* Render the picture (choose the best way) */
     $picname = $student_id . '_' . $name . '_' . $time . '.png';
     $this->fun_getImageLog($student_id, $picname, $type, $time, $name);
     $myPicture->render("uploads/graph/" . $picname);
 }
 function GetGraphImageTag($_data, $_texts, $_metric = true)
 {
     if (!StatisticProvider::$DrawChartImages || !function_exists("gd_info")) {
         return "";
     }
     require_once LIVEZILLA_PATH . "_lib/trdp/pchart/class/pData.class.php";
     require_once LIVEZILLA_PATH . "_lib/trdp/pchart/class/pDraw.class.php";
     require_once LIVEZILLA_PATH . "_lib/trdp/pchart/class/pImage.class.php";
     $MyData = new pData();
     $dobject = array();
     foreach ($_data as $obid => $values) {
         foreach ($values as $key => $val) {
             $values[$key] = round($val, 1);
         }
         $dv1[] = $values[0];
         if (count($values) > 1) {
             $dv2[] = $values[1];
         }
         if (count($values) > 2) {
             $dv3[] = $values[2];
         }
         if (count($values) > 3) {
             $dv4[] = $values[3];
         }
         $dobject[] = $obid;
         if (count($dobject) == 5) {
             break;
         }
     }
     $MyData->addPoints($dv1, $_texts[1] . "   ");
     if (isset($dv2)) {
         $MyData->addPoints($dv2, $_texts[2] . "   ");
     }
     if (isset($dv3)) {
         $MyData->addPoints($dv3, $_texts[3] . "   ");
     }
     if (isset($dv4)) {
         $MyData->addPoints($dv4, $_texts[4] . "   ");
     }
     $MyData->setAxisName(0, $_texts[0]);
     $MyData->setAxisDisplay(0, $_metric ? AXIS_FORMAT_METRIC : AXIS_FORMAT_RAW);
     $MyData->addPoints($dobject, "Groups");
     $MyData->setSerieDescription("Groups", "Group");
     $MyData->setAbscissa("Groups");
     $myPicture = new pImage(630, 210, $MyData);
     $myPicture->Antialias = FALSE;
     $myPicture->setFontProperties(array("FontName" => LIVEZILLA_PATH . "_lib/trdp/pchart/fonts/arimo.ttf", "FontSize" => 8, "R" => 120, "G" => 120, "B" => 120));
     $myPicture->setGraphArea(46, 0, 620, 160);
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "YMargin" => 12, "CycleBackground" => TRUE);
     $myPicture->drawScale($scaleSettings);
     $myPicture->drawLegend(40, 190, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL, "BoxSize" => 4, "R" => 200, "G" => 200, "B" => 200, "Surrounding" => 20, "Alpha" => 30));
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $settings = array("Surrounding" => -30, "InnerSurrounding" => 30, "DisplayValues" => TRUE);
     $myPicture->drawBarChart($settings);
     $file = PATH_STATS . $this->Type . "/temp.png";
     $myPicture->render($file);
     return "<img src=\"data:image/png;base64," . IOStruct::ToBase64($file) . "\" />";
 }
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->loadPalette("../palettes/blind.color", TRUE);
$MyData->addPoints(array(150, 220, 300, 250, 420, 200, 300, 200, 110), "Server A");
$MyData->addPoints(array("January", "February", "March", "April", "May", "Juin", "July", "August", "September"), "Months");
$MyData->setSerieDescription("Months", "Month");
$MyData->setAbscissa("Months");
/* Create the floating 0 data serie */
$MyData->addPoints(array(60, 80, 20, 40, 40, 50, 90, 30, 100), "Floating 0");
$MyData->setSerieDrawable("Floating 0", FALSE);
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 110, "G" => 110, "B" => 110));
/* Write the title */
$myPicture->drawText(10, 13, "Net Income 2k8");
/* Set the graphical area  */
$myPicture->setGraphArea(50, 30, 680, 180);
/* Draw the scale  */
$AxisBoundaries = array(0 => array("Min" => 0, "Max" => 500));
$myPicture->drawScale(array("InnerTickWidth" => 0, "OuterTickWidth" => 0, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "LabelRotation" => 45, "DrawXLines" => FALSE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridTicks" => 0, "GridAlpha" => 30, "AxisAlpha" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$settings = array("Floating0Serie" => "Floating 0", "Surrounding" => 10);
$myPicture->drawBarChart($settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBarChart.span.png");
 protected function drawBarChart(ChartDataset $CDs)
 {
     if (!extension_loaded("gd") && !extension_loaded("gd2")) {
         /* Extension not loaded */
         // NO BARCHARTS AND ERRORS FOR YOU!
         return;
     }
     /* Create and populate the pData object */
     $MyData = new pData();
     if (empty($CDs->data)) {
         return;
     }
     //print_r($CDs->data);
     foreach ($CDs->data as $points) {
         //print_r($points);
         $MyData->addPoints($points["points"], $points["label"]);
     }
     $MyData->setAxisName(0, "Amount Sold");
     $MyData->setSerieDescription($points["label"], $points["label"]);
     $MyData->setAbscissa($points["label"]);
     /* Create the pChart object */
     $myPicture = new pImage(1000, 230, $MyData);
     // the horrible way to add fonts is just one bunch of f****d up shit, not making sense. bullshit parameters and paths.
     //$myPicture->setFontProperties(array("FontName"=>"Bedizen"));
     $myPicture->setFontProperties(array("FontName" => "pChart2.1.4//fonts/calibri.ttf", "FontSize" => 11));
     //print_r(is_file("C:/xampp_jan2015/htdocs/hackerbar/web/fonts/GeosansLight.ttf"));
     /* Turn of Antialiasing */
     $myPicture->Antialias = false;
     /* Add a border to the picture */
     $myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
     $myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
     $myPicture->drawRectangle(0, 0, 999, 229, array("R" => 0, "G" => 0, "B" => 0));
     /* Set the default font */
     //$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, 850, 200);
     /* Draw the scale */
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
     $myPicture->drawScale($scaleSettings);
     /* Write the chart legend */
     $myPicture->drawLegend(860, 25, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw the chart */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $settings = array("Surrounding" => -30, "InnerSurrounding" => 30);
     $myPicture->drawBarChart($settings);
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput("images/barcharts/" . $points["label"] . ".png");
     //$myPicture->auto
     $myPicture->render("myfile.png");
 }
if ($g_enabled == "on") {
    list($StartR, $StartG, $StartB) = extractColors($g_gradient_start);
    list($EndR, $EndG, $EndB) = extractColors($g_gradient_end);
    $Settings = array("StartR" => $StartR, "StartG" => $StartG, "StartB" => $StartB, "EndR" => $EndR, "EndG" => $EndG, "EndB" => $EndB, "Alpha" => 50);
    //$Settings = array("StartR"=>125, "StartG"=>92, "StartB"=>231, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
    if ($g_direction == "vertical") {
        $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_VERTICAL, $Settings);
    } else {
        $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_HORIZONTAL, $Settings);
    }
} else {
    $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_VERTICAL, $Settings);
}
$myPicture->drawRectangle(0, 0, $anchura - 1, $altura - 1, 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" => 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));
Example #11
0
function RenderValueChart(&$debug2)
{
    $conditions = [["BETWEEN 1 AND 19"], ["BETWEEN 20 AND 49"], ["BETWEEN 50 AND 99"], ["BETWEEN 100 AND 199"], ["BETWEEN 200 AND 299"], ["BETWEEN 300 AND 499"], ["BETWEEN 500 AND 999"], ["> 999"]];
    $label = ["1-19", "20-49", "50-99", "100-199", "200-299", "300-499", "500-999", ">1000"];
    coinValueCount($conditions, $array_result);
    /* Create and populate the pData object */
    $MyData = new pData();
    $MyData->addPoints($array_result, "Värde (kr)");
    $MyData->setAxisName(0, "Antal");
    $MyData->addPoints($label, "Months");
    $MyData->setSerieDescription("Months", "Month");
    $MyData->setAbscissa("Months");
    /* Create the cache object */
    $myCache1 = new pCache(array("CacheFolder" => PCHART_PATH . "/class/cache"));
    /* Compute the hash linked to the chart data */
    $ChartHash1 = $myCache1->getHash($MyData);
    /* Test if we got this hash in our cache already */
    if ($myCache1->isInCache($ChartHash1)) {
        /* If we have it, get the picture from the cache! */
        $myCache1->saveFromCache($ChartHash1, WWW_PATH . "/tmp/valuechart.png");
        $debug2 = "Old image";
    } else {
        /* Create the pChart object */
        $myPicture = new pImage(700, 400, $MyData);
        /* Turn of Antialiasing */
        $myPicture->Antialias = TRUE;
        /* Add a border to the picture */
        $myPicture->drawRectangle(0, 0, 699, 399, array("R" => 0, "G" => 0, "B" => 0));
        /* Set the default font */
        $myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/Forgotte.ttf", "FontSize" => 15, "R" => 80, "G" => 80, "B" => 80));
        /* Define the chart area */
        $myPicture->setGraphArea(60, 40, 650, 350);
        /* Draw the scale */
        $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_START0);
        $myPicture->drawScale($scaleSettings);
        /* Write the chart legend */
        $myPicture->drawLegend(340, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
        /* Turn on shadow computing */
        $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
        /* Draw the chart */
        $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
        $settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255, "DisplayShadow" => TRUE, "Surrounding" => 10);
        $myPicture->drawBarChart();
        /* Push the rendered picture to the cache */
        $myCache1->writeToCache($ChartHash1, $myPicture);
        /* Render the picture (choose the best way) */
        $myPicture->Render(WWW_PATH . "/tmp/valuechart.png");
        $debug2 = "Picture rendered";
    }
}
Example #12
0
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");
}
Example #13
0
 private function drawBarChart($filename, $yAxisLabel, $dataSeries, $labelSeries)
 {
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints($dataSeries, "Members");
     $MyData->setAxisName(0, "Members");
     $MyData->addPoints($labelSeries, "Languages");
     $MyData->setSerieDescription("Languages", "Languages");
     $MyData->setAbscissa("Languages");
     /* Create the pChart object */
     $myPicture = new pImage(400, 250, $MyData, true);
     //$myPicture->drawGradientArea(0,0,500,500,DIRECTION_VERTICAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>100));
     //$myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>20));
     $myPicture->setFontProperties(array("FontName" => "../lib/pchart-2.1.3/fonts/verdana.ttf", "FontSize" => 6));
     /* Draw the chart scale */
     $myPicture->setGraphArea(70, 20, 380, 200);
     $myPicture->drawScale(array("CycleBackground" => TRUE, "LabelRotation" => 30, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10));
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Create the per bar palette */
     $Palette = array("0" => array("R" => 188, "G" => 224, "B" => 46, "Alpha" => 100), "1" => array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 100), "2" => array("R" => 224, "G" => 214, "B" => 46, "Alpha" => 100), "3" => array("R" => 46, "G" => 151, "B" => 224, "Alpha" => 100), "4" => array("R" => 176, "G" => 46, "B" => 224, "Alpha" => 100), "5" => array("R" => 224, "G" => 46, "B" => 117, "Alpha" => 100), "6" => array("R" => 92, "G" => 224, "B" => 46, "Alpha" => 100), "7" => array("R" => 224, "G" => 176, "B" => 46, "Alpha" => 100), "8" => array("R" => 120, "G" => 59, "B" => 19, "Alpha" => 100), "9" => array("R" => 10, "G" => 79, "B" => 39, "Alpha" => 100), "10" => array("R" => 100, "G" => 200, "B" => 59, "Alpha" => 100));
     /* Draw the chart */
     $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_OUTSIDE, "DisplayValues" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
     /* Write the legend */
     $myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     $myPicture->render($filename . ".png");
 }
Example #14
0
 protected function render_graph($title, pData $MyData, $zoom, $width = 0, $height = 0)
 {
     // Check graph size sanity
     $width = intval($width);
     if ($width <= 50 || $width > 4096) {
         $width = 700;
     }
     $height = intval($height);
     if ($height <= 60 || $height > 4096) {
         $height = 260;
     }
     $MyData->setSerieDescription("TimeStamp", "time");
     $MyData->setAbscissa("TimeStamp");
     switch ($zoom) {
         case 'hour':
             $MyData->setXAxisDisplay(AXIS_FORMAT_TIME, "H:00");
             break;
         case 'year':
             $MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y");
             break;
         case 'month':
             $MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m");
             break;
         case 'day':
             $MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m-d");
             break;
     }
     /* Create the pChart object */
     $myPicture = new pImage($width, $height, $MyData);
     /* Turn of Antialiasing */
     $myPicture->Antialias = FALSE;
     /* Draw a background */
     $Settings = array("R" => 90, "G" => 90, "B" => 90, "Dash" => 1, "DashR" => 120, "DashG" => 120, "DashB" => 120);
     $myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
     /* Overlay with a gradient */
     $Settings = array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 50);
     $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
     $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, $Settings);
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
     /* Write the chart title */
     $myPicture->setFontProperties(array("FontName" => AmpConfig::get('prefix') . "/modules/pChart/fonts/Forgotte.ttf", "FontSize" => 11));
     $myPicture->drawText(150, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
     /* Set the default font */
     $myPicture->setFontProperties(array("FontName" => AmpConfig::get('prefix') . "/modules/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, $width - 20, $height - 50);
     /* Draw the scale */
     $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "RemoveSkippedAxis" => TRUE, "DrawSubTicks" => FALSE, "Mode" => SCALE_MODE_START0, "LabelRotation" => 45, "LabelingMethod" => LABELING_DIFFERENT);
     $myPicture->drawScale($scaleSettings);
     /* Turn on Antialiasing */
     $myPicture->Antialias = TRUE;
     /* Draw the line chart */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $myPicture->drawLineChart();
     /* Write a label over the chart */
     $myPicture->writeLabel("Inbound", 720);
     /* Write the chart legend */
     $myPicture->drawLegend(280, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     header("Content-Disposition: filename=\"ampache-graph.png\"");
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput();
 }
Example #15
0
 public static function tests_pchart3()
 {
     /* @ 700x230 Filled spline chart drawing example. */
     /* pChart library inclusions */
     include 'lib/pChart/class/pData.class';
     include 'lib/pChart/class/pDraw.class';
     include 'lib/pChart/class/pImage.class';
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->setAxisName(0, "Strength");
     for ($i = 0; $i <= 720; $i = $i + 20) {
         $MyData->addPoints(cos(deg2rad($i)) * 100, "Probe 1");
         $MyData->addPoints(cos(deg2rad($i + 90)) * 60, "Probe 2");
     }
     /* Create the pChart object */
     $myPicture = new pImage(847, 304, $MyData);
     $myPicture->drawGradientArea(0, 0, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 17, "EndG" => 17, "EndB" => 17, "Alpha" => 100));
     $myPicture->drawGradientArea(0, 250, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 27, "EndG" => 27, "EndB" => 27, "Alpha" => 100));
     $myPicture->drawLine(0, 249, 847, 249, array("R" => 0, "G" => 0, "B" => 0));
     $myPicture->drawLine(0, 250, 847, 250, array("R" => 70, "G" => 70, "B" => 70));
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, 846, 303, array("R" => 204, "G" => 204, "B" => 204));
     /* Write the picture title */
     $myPicture->setFontProperties(array("FontName" => CINTIENT_INSTALL_DIR . "lib/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6));
     $myPicture->drawText(423, 14, "Cyclic magnetic field strength", array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
     /* Define the chart area */
     $myPicture->setGraphArea(58, 27, 816, 228);
     /* Draw a rectangle */
     $myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
     /* Draw the scale */
     $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
     $ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
     $myPicture->drawScale($ScaleSettings);
     /* Draw the spline chart */
     $myPicture->drawFilledSplineChart();
     /* Write the chart boundaries */
     $BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
     $myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
     /* Write the 0 line */
     $myPicture->drawThreshold(0, array("WriteCaption" => TRUE));
     /* Write the chart legend */
     $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
     $myPicture->drawLegend(560, 266, array("Style" => LEGEND_NOBORDER));
     /* Write the 1st data series statistics */
     $Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
     $myPicture->drawText(620, 270, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings);
     $myPicture->drawText(680, 270, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings);
     $myPicture->drawText(740, 270, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings);
     /* Write the 2nd data series statistics */
     $Settings = array("R" => 224, "G" => 100, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
     $myPicture->drawText(620, 283, "Max : " . ceil($MyData->getMax("Probe 2")), $Settings);
     $myPicture->drawText(680, 283, "Min : " . ceil($MyData->getMin("Probe 2")), $Settings);
     $myPicture->drawText(740, 283, "Avg : " . ceil($MyData->getSerieAverage("Probe 2")), $Settings);
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
 }
Example #16
0
function block_mystats_quiz_chart($avg, $high, $strAvg, $strHigh, $strTitle, $strScale, $userid)
{
    $myQuizData = new pData();
    $myQuizData->addPoints(array($avg), "Serie1");
    $myQuizData->setSerieDescription("Serie1", $strAvg);
    $myQuizData->setSerieOnAxis("Serie1", 0);
    $myQuizData->addPoints(array($high), "Serie2");
    $myQuizData->setSerieDescription("Serie2", $strHigh);
    $myQuizData->setSerieOnAxis("Serie2", 0);
    $myQuizData->addPoints(array(" "), "Absissa");
    $myQuizData->setAbscissa("Absissa");
    $myQuizData->setAxisPosition(0, AXIS_POSITION_LEFT);
    $myQuizData->setAxisName(0, $strScale);
    $myQuizData->setAxisUnit(0, "");
    $myQuizPicture = new pImage(350, 230, $myQuizData);
    $quizSettings = array("R" => 255, "G" => 255, "B" => 255);
    $myQuizPicture->drawFilledRectangle(0, 0, 350, 230, $quizSettings);
    $myQuizPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
    $myQuizPicture->setFontProperties(array("FontName" => "../blocks/mystats/pChart2.1.3/fonts/GeosansLight.ttf", "FontSize" => 14));
    $TextSettings = array("Align" => TEXT_ALIGN_TOPLEFT, "R" => 0, "G" => 0, "B" => 0);
    $myQuizPicture->drawText(25, 25, $strTitle, $TextSettings);
    $myQuizPicture->setShadow(FALSE);
    $myQuizPicture->setGraphArea(25, 70, 325, 210);
    $myQuizPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "../blocks/mystats/pChart2.1.3/fonts/pf_arma_five.ttf", "FontSize" => 8));
    $AxisBoundaries = array(0 => array("Min" => 0, "Max" => 110), 1 => array("Min" => 00, "Max" => 1));
    $quizSettings = array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "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);
    $myQuizPicture->drawScale($quizSettings);
    $myQuizPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
    $quizConfig = array("DisplayValues" => 1, "Rounded" => 1, "AroundZero" => 1);
    $myQuizPicture->drawBarChart($quizConfig);
    $quizConfig = array("R" => 0, "G" => 0, "B" => 0, "Alpha" => 50, "AxisID" => 0, "Ticks" => 4, "Caption" => "Threshold");
    $myQuizPicture->drawThreshold(0, $quizConfig);
    $quizConfig = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "../blocks/mystats/pChart2.1.3/fonts/pf_arma_five.ttf", "FontSize" => 8, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_ROUND, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_CIRCLE);
    $myQuizPicture->drawLegend(240, 16, $quizConfig);
    $imgName = sha1($userid . $strTitle) . '.png';
    $myQuizPicture->Render('../blocks/mystats/img/' . $imgName);
    return '<img src="../blocks/mystats/img/' . $imgName . '" alt="' . $strAvg . ': ' . $avg . ', ' . $strHigh . ': ' . $high . '">';
}
 public function actionGraph2()
 {
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints(array(13251, 4118, 3087, 1460, 1248, 156, 26, 9, 8), "Hits");
     $MyData->setAxisName(0, "Hits");
     $MyData->addPoints(array("Firefox", "Chrome", "Internet Explorer", "Opera", "Safari", "Mozilla", "SeaMonkey", "Camino", "Lunascape"), "Browsers");
     $MyData->setSerieDescription("Browsers", "Browsers");
     $MyData->setAbscissa("Browsers");
     /* Create the pChart object */
     $myPicture = new pImage(500, 500, $MyData);
     $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
     $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
     $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
     /* Draw the chart scale */
     $myPicture->setGraphArea(100, 30, 480, 480);
     $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM));
     //
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw the chart */
     $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30));
     /* Write the legend */
     $myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput("pictures/example.drawBarChart.vertical.png");
 }
/* Create a solid background */
$Settings = array("R" => 179, "G" => 217, "B" => 91, "Dash" => 1, "DashR" => 199, "DashG" => 237, "DashB" => 111);
$myPicture->drawFilledRectangle(0, 0, 210, 100, $Settings);
/* Do a gradient overlay */
$Settings = array("StartR" => 194, "StartG" => 231, "StartB" => 44, "EndR" => 43, "EndG" => 107, "EndB" => 58, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 210, 100, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 210, 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, 209, 99, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "pSurface() :: Surface charts", array("R" => 255, "G" => 255, "B" => 255));
/* Define the charting area */
$myPicture->setGraphArea(50, 60, 180, 80);
$myPicture->drawFilledRectangle(50, 60, 180, 80, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 20));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1));
/* Create the surface object */
$mySurface = new pSurface($myPicture);
/* Set the grid size */
$mySurface->setGrid(9, 1);
/* Write the axis labels */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->setFontProperties(array("FontName" => "../fonts/Bedizen.ttf", "FontSize" => 7));
$mySurface->writeXLabels(array("Angle" => 45, "Labels" => array("Run 1", "Run 2", "Run 3", "Run 4", "Run 5", "Run 6", "Run 7", "Run 8", "Run 9", "Run 10")));
$mySurface->writeYLabels(array("Labels" => array("Probe 1", "Probe 2")));
/* Add random values */
for ($i = 0; $i <= 10; $i++) {
    $mySurface->addPoint($i, rand(0, 1), rand(0, 100));
}
/* Draw the surface chart */
$mySurface->drawSurface(array("Border" => TRUE, "Surrounding" => 40));
Example #19
0
/**
 * Helper method to draw bar graph
 * parameters have same meaning as displayGraph's parameters
 */
function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $graphOptions)
{
    // getting data from DB
    if (is_int($frid) && $frid > 0) {
        $dbData = getData($frid, $fid);
    } else {
        $dbData = getData("", $fid);
    }
    foreach ($dbData as $entry) {
        // mayor - OR array of mayors if there's more than one in the dataset, depending on the one-to-may in a relationship
        $dataRawValue = display($entry, $dataElement);
        // city_name;
        $labelRawValue = display($entry, $labelElement);
        if (!is_array($dataRawValue) && $dataRawValue) {
            $dataRawValue = array($dataRawValue);
        }
        if (!is_array($labelRawValue)) {
            $labelRawValue = array($labelRawValue);
        }
        foreach ($labelRawValue as $thisLabelValue) {
            if ($dataPoints[$thisLabelValue]) {
                $dataPoints[$thisLabelValue] = array_merge($dataPoints[$thisLabelValue], $dataRawValue);
            } else {
                $dataPoints[$thisLabelValue] = $dataRawValue;
            }
        }
    }
    // Oct 29 Update for column heading for graphs:
    $elementHandler = xoops_getmodulehandler('elements', 'formulize');
    $elementObject = $elementHandler->get($labelElement);
    $labelElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    $elementObject = $elementHandler->get($dataElement);
    $dataElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    // end of Update
    switch ($operation) {
        case "count":
            // count the values in each label of the array
            foreach (array_keys($dataPoints) as $key) {
                if (!empty($dataPoints[$key])) {
                    $dataPoints[$key] = count($dataPoints[$key]);
                } else {
                    $dataPoints[$key] = 0;
                }
            }
            if ($labelElement == $dataElement) {
                $dataElement = "count of " . $labelElement;
            } else {
                $dataElement = "count of " . $dataElement;
            }
            break;
        case "sum":
        case "display":
            // TODO: Check this!
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = array_sum($theseValues);
            }
            $dataElement = ($operation == "display" ? "number of " : "sum of ") . $dataElement;
            break;
        case "count-unique":
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = count(array_unique($theseValues));
            }
            if ($dataElement == $labelElement) {
                $dataElement = "count of unique " . $labelElement;
            } else {
                $dataElement = "count of unique " . $dataElement;
            }
            break;
        default:
            echo "Sorry, the operation \"{$operation}\" for Bar graph is not supported at the moment!";
            return;
    }
    // print("dataElement: ".$dataElement." ");
    // print("labelElement: ".$labelElement." ");
    // process the graph options
    // these defaults will be used, unless overwritten by values from the $graphOptions array
    $sizeMultiplier = sizeof(array_keys($dataPoints));
    $BAR_THICKNESS = 40;
    $IMAGE_WIDTH = 600;
    $IMAGE_DEFAULT_WIDTH = $IMAGE_WIDTH;
    if ($sizeMultiplier > 1) {
        $IMAGE_HEIGHT = $BAR_THICKNESS * $sizeMultiplier / 0.5;
    } else {
        $IMAGE_HEIGHT = $BAR_THICKNESS * 4;
    }
    $IMAGE_DEFAULT_HEIGHT = $IMAGE_HEIGHT;
    $IMAGE_ORIENTATION = "vertical";
    $BACKGROUND_R = 141;
    $BACKGROUND_G = 189;
    $BACKGROUND_B = 225;
    $BARCOLOR_R = 143;
    $BARCOLOR_G = 190;
    $BARCOLOR_B = 88;
    if (sizeof($graphOptions) > 0) {
        foreach ($graphOptions as $graphoption => $value) {
            switch ($graphoption) {
                case "width":
                    $IMAGE_WIDTH = $value;
                    break;
                case "height":
                    $IMAGE_HEIGHT = $value;
                    break;
                case "orientation":
                    $IMAGE_ORIENTATION = $value;
                    if ($IMAGE_ORIENTATION == "horizontal") {
                        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
                            $IMAGE_HEIGHT = 500;
                        } else {
                            if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
                                $IMAGE_WIDTH = $BAR_THICKNESS * $sizeMultiplier / 0.5;
                            }
                        }
                    }
                    break;
                case "backgroundcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BACKGROUND_R = $colorvalue;
                                break;
                            case "G":
                                $BACKGROUND_G = $colorvalue;
                                break;
                            case "B":
                                $BACKGROUND_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                case "barcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BARCOLOR_R = $colorvalue;
                                break;
                            case "G":
                                $BARCOLOR_G = $colorvalue;
                                break;
                            case "B":
                                $BARCOLOR_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                default:
                    echo "Sorry, the graph option \"{$graphoption}\" for Bar graph is not supported at the moment!<br>";
                    break;
            }
        }
    }
    // reset width/height of the image in case the label is too long
    if (strlen($labelElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($labelElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    }
    // Code straightly copied from pChart documentation to draw the graph
    $myData = new pData();
    $myData->addPoints(array_values($dataPoints), $dataElement);
    $myData->setAxisName(0, $dataElement);
    $myData->addPoints(array_keys($dataPoints), $labelElement);
    $myData->setSerieDescription($labelElement, $labelElement);
    $myData->setAbscissa($labelElement);
    $myData->setAbscissaName($labelElement);
    // $myData -> setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat");
    /* Create the pChart object */
    $myPicture = new pImage($IMAGE_WIDTH, $IMAGE_HEIGHT, $myData);
    $myPicture->drawGradientArea(0, 0, $IMAGE_WIDTH, $IMAGE_HEIGHT, DIRECTION_VERTICAL, array("StartR" => $BACKGROUND_R, "StartG" => $BACKGROUND_G, "StartB" => $BACKGROUND_B, "EndR" => $BACKGROUND_R, "EndG" => $BACKGROUND_G, "EndB" => $BACKGROUND_B, "Alpha" => 100));
    $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 30));
    $myPicture->setFontProperties(array("FontName" => "modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8));
    $paddingtoLeft = $IMAGE_WIDTH * 0.15;
    $paddingtoTop = $IMAGE_HEIGHT * 0.2;
    if ($paddingtoTop > 50) {
        $paddingtoTop = 50;
    }
    /* Draw the chart scale */
    $myPicture->setGraphArea($paddingtoLeft, $paddingtoTop, $IMAGE_WIDTH * 0.9, $IMAGE_HEIGHT * 0.88);
    if ($IMAGE_ORIENTATION == "vertical") {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    } else {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    }
    /* Turn on shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $Palette = array("0" => array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100));
    for ($i = 1; $i < $sizeMultiplier; $i++) {
        $Palette[$i] = array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100);
    }
    // print_r($Palette);
    $myPicture->drawBarChart(array("OverrideColors" => $Palette));
    /* Draw the chart */
    $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
    renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions);
    return;
}
 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();
 }
 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;
 }
require_once 'pChart/class/pDraw.class.php';
require_once 'pChart/class/pImage.class.php';
require_once 'pChart/class/pData.class.php';
require_once 'pChart/class/pPie.class.php';
// Exemplo extraido do site da lib
// precisamos ter dados para montar os gráficos
$DataSet = new pData();
// Adicionando os pontos de um gráfico de pizza
// horas de trabalho na semana
$DataSet->addPoints(array(45, 30, 40), "Serie1");
// valores
$DataSet->setSerieDescription("Serie1", "Horas Trabalhadas");
$DataSet->addPoints(array("João", 'Pedro', 'Manuel'), "Labels");
$DataSet->setAbscissa("Labels");
// Inicializando o gráfico - Largura e Altura
$Graph = new pImage(450, 230, $DataSet);
$Graph->setFontProperties(array('FontName' => "pChart/fonts/verdana.ttf", 'FontSize' => 10));
// Desenha dois retangulo arredondado
$settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$Graph->drawFilledRectangle(0, 0, 300, 300, $settings);
$Graph->drawRectangle(0, 0, 299, 259, array("R" => 0, "G" => 0, "B" => 0));
$Graph->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50));
$PieChart = new pPie($Graph, $DataSet);
$PieChart->draw2DPie(160, 140, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE));
/* Caixa de legenda */
$Graph->setShadow(FALSE);
$PieChart->drawPieLegend(15, 40, array("Alpha" => 20));
// Cria a imagem e salva em arquivo
//$Graph->autoOutput("/tmp/teste.png");
// Cria a imagem e devolve para o browser
$Graph->autoOutput();
 protected function plotBarChart(pImage $picture, $options = array())
 {
     $picture->setShadow(FALSE);
     $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "DrawXLines" => FALSE, "DrawYLines" => ALL, "GridTicks" => 1, "GridR" => 168, "GridG" => 186, "GridB" => 203, "GridAlpha" => 30, "AxisR" => 40, "AxisG" => 40, "AxisB" => 43, "AxisAlpha" => 100, "TickR" => 40, "TickG" => 40, "TickB" => 43, "TickAlpha" => 50, "DrawSubTicks" => 1, "SubTickR" => 168, "SubTickG" => 186, "SubTickB" => 203, "SubTickAlpha" => 100, "DrawArrows" => false, "CycleBackground" => false, "LabelRotation" => 90);
     $Settings = array_merge($Settings, $options);
     $picture->drawScale($Settings);
     $options = array('AroundZero' => true, 'Draw0Line' => true);
     $picture->drawBarChart($options);
     $Config = array("FontName" => sfConfig::get('sf_web_dir') . "/fonts/Ubuntu-R.ttf", "FontSize" => 6, "FontR" => 40, "FontG" => 40, "FontB" => 43, "Margin" => 6, "Alpha" => 100, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_LINE);
     $picture->drawLegend(655, 50, $Config);
     return $picture;
 }
Example #24
0
/**
 * eval_ccpc_genGraphPie - Génère un graphique de type camenbert sous forme d'image au format PNG
 *
 * @category : eval_ccpc_functions
 * @param array $data Données à partir desquelles le graphique est généré
 * @return string URL de l'image générée
 *
 * @Author Ali Bellamine
 *
 * Structure de $data :<br>
 * 	['data'][nom du label] => (int) Valeur liée au label<br>
 * 	['settings']['height'] => (int) Hauteur du graphique (en px)<br>
 * 	['settings']['width'] => (int) Largeur du graphique (en px)
 *
 */
function eval_ccpc_genGraphPie($data)
{
    // On vérifie les données fournit
    if (isset($data) && isset($data['data']) && count($data['data']) > 0) {
        // On récupère le hash de $data
        $hash = md5(json_encode($data));
        // Chemin du fichier
        $filePath = PLUGIN_PATH . 'cache/' . $hash . '.png';
        $filePathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.png';
        // Si le hash existe déjà : on renvoie le lien de l'image // sinon en crée le graphique
        if (is_file($filePath)) {
            return $filePathURI;
        } else {
            // On crée l'image
            /* On inclut la librairie */
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pData.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pDraw.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pImage.class.php';
            /* On crée l'objet pData */
            // Préparation des données
            $tempDataArray = array();
            // Contient les données chiffrés de chaque part du camenbert
            $tempLegendArray = array();
            // Contient la légend chaque part de camenbert
            foreach ($data['data'] as $tempDataLegend => $tempDataValue) {
                $tempLegendArray[] = $tempDataLegend;
                if (isset($tempDataValue) && is_numeric($tempDataValue)) {
                    $tempDataArray[] = $tempDataValue;
                } else {
                    return FALSE;
                }
            }
            $MyData = new pData();
            $MyData->addPoints($tempDataArray, 'Values');
            $MyData->addPoints($tempLegendArray, 'Label');
            $MyData->setAbscissa("Label");
            /* On crée l'objet pChart */
            if (isset($data['settings']['width'])) {
                $width = $data['settings']['width'];
            } else {
                $width = 600;
            }
            if (isset($data['settings']['height'])) {
                $height = $data['settings']['height'];
            } else {
                $height = 300;
            }
            $myPicture = new pImage($width, $height, $MyData);
            $myPicture->setFontProperties(array("FontName" => PLUGIN_PATH . 'core/pChart2.1.4/fonts/verdana.ttf', "FontSize" => 8, "R" => 223, "G" => 223, "B" => 223));
            /* Set the graph area */
            $myPicture->setGraphArea(10, 20, $width - 20, $height - 20);
            $myPicture->drawGradientArea(10, 20, $width - 20, $height - 20, DIRECTION_HORIZONTAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
            /* Draw the chart scale */
            $scaleSettings = array("RemoveXAxis" => TRUE, "AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM);
            $myPicture->drawScale($scaleSettings);
            /* Turn on shadow computing */
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
            /* Draw the chart */
            $myPicture->drawBarChartAli(array("DisplayValues" => TRUE, "DisplayShadow" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Rounded" => TRUE, "Surrounding" => 30));
            $myPicture->render($filePath);
            return $filePathURI;
        }
    } else {
        return FALSE;
    }
}
Example #25
0
 /**
  * 绘制图表并生成图片
  * @method drawChart
  * @return [type]    [description]
  */
 protected function drawChart($data_arr, $lab_arr, $pic_name)
 {
     /* pChart library inclusions */
     include "libs/pChart2.1.4/class/pData.class.php";
     include "libs/pChart2.1.4/class/pDraw.class.php";
     include "libs/pChart2.1.4/class/pPie.class.php";
     include "libs/pChart2.1.4/class/pImage.class.php";
     /* pData object creation */
     $MyData = new \pData();
     /* Data definition */
     $MyData->addPoints($data_arr, "Value");
     /* Labels definition */
     $MyData->addPoints($lab_arr, "Legend");
     $MyData->setAbscissa("Legend");
     /* Create the pChart object */
     $myPicture = new \pImage(500, 150, $MyData);
     /* Draw a gradient background */
     $myPicture->drawGradientArea(0, 0, 500, 150, DIRECTION_HORIZONTAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
     /* Add a border to the picture */
     // $myPicture->drawRectangle(0,0,399,149,array("R"=>0,"G"=>0,"B"=>0));
     /* Create the pPie object */
     $PieChart = new \pPie($myPicture, $MyData);
     /* Enable shadow computing */
     $myPicture->setShadow(FALSE);
     /* Set the default font properties */
     $myPicture->setFontProperties(array("FontName" => __DIR__ . "/libs/pChart2.1.4/fonts/msyh.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     /* Draw a splitted pie chart */
     $PieChart->draw3DPie(250, 100, array("Radius" => 80, "DrawLabels" => TRUE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => FALSE));
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput(public_path() . '/pictures/' . $pic_name);
 }
 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;
 }
/* CAT:Stacked chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(4, VOID, VOID, 12, 8, 3), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, 5, 5), "Frontend #2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15));
/* Write a label */
$myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE));
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.shaded.png");
Example #28
0
function buildgraph($MyData, $xsize, $ysize, $title, $minscale, $maxscale, $date, $type, $imagefilename)
{
    //include("../cfg/nmcgraph_cfg.php");
    /* Create and populate the pData object */
    $MyData = new pData();
    load_nmc_data($MyData, $date, $type, $minscale, $maxscale);
    //var_dump($MyData);
    //echo $minscale." ".$maxscale; exit;
    //printf("minscale: $minscale maxscale: $maxscale <br />\n");
    //buildgraph( $MyData, $xsize, $ysize, $title  );
    $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "฿");
    //$MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time");
    //$MyData->setAbscissa("Months");
    //$MyData->setAxisName(0,"Price in BTC");
    //$MyData->setSerieDescription("Time","Hour of the day");
    /* Create the pChart object */
    $myPicture = new pImage($xsize, $ysize, $MyData);
    /* Draw the background */
    $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
    $myPicture->drawFilledRectangle(0, 0, $xsize, $ysize, $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, $xsize, $ysize, DIRECTION_VERTICAL, $Settings);
    /* Draw the border */
    $myPicture->drawRectangle(0, 0, $xsize - 1, $ysize - 1, array("R" => 0, "G" => 0, "B" => 0));
    /* Write the title */
    $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . "/../../fonts/verdana.ttf", "FontSize" => 9));
    $myPicture->drawText(70, 45, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT));
    /* Draw the 1st scale */
    $myPicture->setGraphArea(70, 60, $xsize - 40, $ysize - 30);
    $myPicture->drawFilledRectangle(70, 60, $xsize - 40, $ysize - 30, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
    // Y scale
    $AxisBoundariesY = array(0 => array("Min" => $minscale, "Max" => $maxscale));
    $myPicture->drawScale(array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundariesY));
    //X scale
    //$AxisBoundariesX = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
    //$MyData->setSerieDescription("Labels","Months");
    //$MyData->setAbscissa("Labels");
    $MyData->setXAxisDisplay(0, AXIS_FORMAT_TIME, "H");
    //$myPicture->drawScale(array("DrawXLines"=>array(0)));
    /* Draw the 1st stock chart */
    $mystockChart = new pStock($myPicture, $MyData);
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30));
    $mystockChart->drawStockChart();
    /* Reset the display mode because of the graph small size */
    //$MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT);
    /* Draw the 2nd scale */
    //$myPicture->setShadow(FALSE);
    //$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));
    /* Draw the 2nd stock chart */
    //$mystockChart = new pStock($myPicture,$MyData);
    //$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
    //$mystockChart->drawStockChart();
    /* Render the picture (choose the best way) */
    //$myPicture->autoOutput("pictures/example.drawStockChart.png");
    $myPicture->render($imagefilename);
    $current_time = time();
    $graphgendate = $current_time;
    return $graphgendate;
}
Example #29
0
 /**
  * Desenha um gráfico de torta
  * @param $title título do graico
  * @param $data vetor contendo os dados do gráfico
  * @param $width largura do gráfico
  * @param $height altura do gráfico
  * @param $outputPath caminho de saída do gráfico
  */
 public function drawPieChart($title, $data, $width, $height, $outputPath)
 {
     // cria o modelo de dados
     $modelo = new pData();
     $newdata = array();
     foreach ($data as $legend => $value) {
         $newdata[] = $value == NULL ? VOID : $value;
         $labels[] = $legend;
     }
     $modelo->addPoints($newdata, "ScoreA");
     /* Define the absissa serie */
     $modelo->addPoints($labels, "Labels");
     $modelo->setAbscissa("Labels");
     // cria o objeto que irá conter a imagem do gráfico
     $imagem = new pImage($width, $height, $modelo);
     // adiciona uma borda na forma de um retângulo dentro da imagem
     $imagem->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
     // escreve um título dentro do gráfico
     $imagem->setFontProperties(array("FontName" => "app/lib/pchart/fonts/Forgotte.ttf", "FontSize" => 11));
     $imagem->drawText(60, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT));
     // define a fonte dos dados do gráfico
     $imagem->setFontProperties(array("FontName" => "app/lib/pchart/fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     // cria o gráfico de torta
     $pie = new pPie($imagem, $modelo);
     // desenha o gráfico de torta
     $pie->draw3DPie($width / 2, $height / 2, array('WriteValues' => TRUE, 'DrawLabels' => TRUE, "Radius" => $width / 4, 'ValueR' => 0, 'ValueG' => 0, 'ValueB' => 0, 'ValueAlpha' => 80));
     // desenha a legenda do gráfico
     $imagem->setShadow(FALSE);
     $pie->drawPieLegend(15, 40, array("Alpha" => 20));
     // grava o gráfico em um arquivo
     $imagem->render($outputPath);
 }
Example #30
0
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();
}