Example #1
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()
 {
     $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 #3
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");
}
<?php

/* CAT:Drawing */
/* pChart library inclusions */
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create the pChart object */
$myPicture = new pImage(700, 230);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawRectangle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255));
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw a rectangle */
$RectangleSettings = array("R" => 181, "G" => 209, "B" => 27, "Alpha" => 100);
$myPicture->drawRectangle(20, 60, 400, 170, $RectangleSettings);
/* Draw a rectangle */
$RectangleSettings = array("R" => 209, "G" => 134, "B" => 27, "Alpha" => 30);
$myPicture->drawRectangle(30, 30, 200, 200, $RectangleSettings);
/* Draw a rectangle */
$RectangleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100);
$myPicture->drawRectangle(480, 50, 650, 80, $RectangleSettings);
for ($i = 0; $i <= 10; $i = $i + 0.2) {
    $MyData->addPoints(log($i + 1) * 10, "Bounds 1");
    $MyData->addPoints(log($i + 3) * 10 + rand(0, 2) - 1, "Probe 1");
    $MyData->addPoints(log($i + 6) * 10, "Bounds 2");
    $MyData->addPoints($i * 10, "Labels");
}
$MyData->setAxisName(0, "Size (cm)");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
$MyData->setAbscissaName("Time (years)");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background and the border  */
$myPicture->drawFilledRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 100, "EndG" => 100, "EndB" => 100, "Alpha" => 30));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, "Size by time generations", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(40, 40, 680, 200);
/* Draw the scale */
$scaleSettings = array("LabelSkip" => 4, "XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridAlpha" => 30, "GridR" => 140, "GridG" => 140, "GridB" => 140, "DrawSubTicks" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the line chart */
//$myData->setSerieOnAxis("Serie2",0);
//
//$myData->addPoints(array(16,46,-32,35,32,-15,40,29),"Serie3");
//$myData->setSerieDescription("Serie3","Serie 3");
//$myData->setSerieOnAxis("Serie3",0);
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
$myData->setAxisName(0, "Notas");
$myData->setAxisUnit(0, "");
$myData->addPoints(array("1er Trimestre", "2ndo Trimestre", "3er Trimestre"), "Absissa");
$myData->setAbscissa("Absissa");
//$myData->addPoints(array("1","2","3"),"Labels");
//$myData->setSerieDescription("Labels","Evaluaciones");
//$myData->setAbscissa("Labels");
$myPicture = new pImage($anchura, $altura, $myData);
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, $anchura, $altura, $Settings);
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));
<?php

/* CAT:Drawing */
/* pChart library inclusions */
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create the pChart object */
$myPicture = new pImage(700, 230);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawFilledRectangle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw a customized filled rectangle */
$RectangleSettings = array("R" => 150, "G" => 200, "B" => 170, "Dash" => TRUE, "DashR" => 170, "DashG" => 220, "DashB" => 190, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255);
$myPicture->drawFilledRectangle(20, 60, 400, 170, $RectangleSettings);
/* Draw a customized filled rectangle */
$RectangleSettings = array("R" => 209, "G" => 134, "B" => 27, "Alpha" => 30);
$myPicture->drawFilledRectangle(30, 30, 200, 200, $RectangleSettings);
/* Draw a customized filled rectangle */
$RectangleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100, "Surrounding" => 30);
$myPicture->drawFilledRectangle(480, 50, 650, 80, $RectangleSettings);
Example #8
0
/* Create the pChart object */
$myPicture = new pImage($width, $height, $myData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
/* Draw the background */
$bgcolor = array("R" => 180, "G" => 180, "B" => 180);
$scaleRGB = array("GridR" => 200, "GridG" => 200, "GridB" => 200);
if ($bg == 0) {
    $myPicture->drawRectangle(1, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
} else {
    if ($bg == 1) {
        if (isset($palette)) {
            $bgcolor = $palette['bgcolor'];
        }
        $myPicture->drawFilledRectangle(3, 0, $width - 1, $height - 4, array("R" => $bgcolor['R'], "G" => $bgcolor['G'], "B" => $bgcolor['B'], "Dash" => 0, "DashR" => 255, "DashG" => 255, "DashB" => 255));
        $myPicture->drawRectangle(3, 0, $width - 1, $height - 4, array("R" => 0, "G" => 0, "B" => 0));
        $myPicture->drawFilledRectangle(0, 3, $width - 4, $height - 1, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 90));
        $myPicture->drawRectangle(0, 3, $width - 4, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
        $scaleRGB = array("GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10);
    } else {
        if ($bg == 2) {
            $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 80, "EndG" => 80, "EndB" => 80, "Alpha" => 100));
            $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 80, "EndG" => 80, "EndB" => 80, "Alpha" => 20));
            $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
            $myPicture->setFontProperties(array("FontName" => "./fonts/msyh.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
            $scaleRGB = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "GridAlpha" => 100);
        } else {
            if ($bg == 3) {
                $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
                $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(2, 7, 5, 18, 19, 22, 23, 25, 22, 12, 10, 10), "DEFCA");
$MyData->setAxisName(0, "\$ Incomes");
$MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY);
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$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" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(60, 35, "2k9 Average Incomes", array("FontSize" => 20, "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));
/* Draw a spline chart on top */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawFilledSplineChart();
$myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawSplineChart();
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(643, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawSimple.png");
Example #10
0
 //$MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time");
 $MyData->setAbscissa("Time");
 //$MyData->setAxisName(0,"Price in BTC");
 //$MyData->setSerieDescription("Time","Hour of the day");
 /* Create the pChart object */
 $myPicture = new pImage($xsize, $ysize, $MyData);
 $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" => "../../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));
 $AxisBoundaries = array(0 => array("Min" => $minscale, "Max" => $maxscale));
 $myPicture->drawScale(array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries));
 /* 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);
 function generateGraphByStatus($periodData, $periods, $statuses)
 {
     global $configArray;
     global $interface;
     $reportData = new pData();
     //Add points for each status
     $periodsFormatted = array();
     foreach ($statuses as $status => $statusLabel) {
         $statusData = array();
         foreach ($periodData as $date => $periodInfo) {
             $periodsFormatted[$date] = date('M-d-Y', $date);
             $statusData[$date] = isset($periodInfo[$status]) ? $periodInfo[$status] : 0;
         }
         $reportData->addPoints($statusData, $status);
     }
     $reportData->setAxisName(0, "Number of files");
     $reportData->addPoints($periodsFormatted, "Dates");
     $reportData->setAbscissa("Dates");
     /* Create the pChart object */
     $myPicture = new pImage(700, 290, $reportData);
     /* Draw the background */
     $Settings = array("R" => 225, "G" => 225, "B" => 225);
     $myPicture->drawFilledRectangle(0, 0, 700, 290, $Settings);
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, 699, 289, array("R" => 0, "G" => 0, "B" => 0));
     $myPicture->setFontProperties(array("FontName" => "sys/pChart/Fonts/verdana.ttf", "FontSize" => 9));
     $myPicture->setGraphArea(50, 30, 670, 190);
     //$myPicture->drawFilledRectangle(30,30,670,150,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
     $myPicture->drawScale(array("DrawSubTicks" => TRUE, "LabelRotation" => 90));
     $myPicture->setFontProperties(array("FontName" => "sys/pChart/Fonts/verdana.ttf", "FontSize" => 9));
     $myPicture->drawLineChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO));
     /* Write the chart legend */
     $myPicture->drawLegend(80, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Render the picture (choose the best way) */
     $chartHref = "/images/charts/eContentImportSummaryByStatus" . time() . ".png";
     $chartPath = $configArray['Site']['local'] . $chartHref;
     $myPicture->render($chartPath);
     $interface->assign('chartByStatus', $chartHref);
 }
Example #12
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;
}
<?php

/* CAT:Surface chart*/
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
include "../class/pSurface.class.php";
/* Create the pChart object */
$myPicture = new pImage(400, 400);
/* Create a solid background */
$Settings = array("R" => 179, "G" => 217, "B" => 91, "Dash" => 1, "DashR" => 199, "DashG" => 237, "DashB" => 111);
$myPicture->drawFilledRectangle(0, 0, 400, 400, $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, 400, 400, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 400, 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, 399, 399, 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() :: 2D surface charts", array("R" => 255, "G" => 255, "B" => 255));
/* Define the charting area */
$myPicture->setGraphArea(20, 40, 380, 380);
$myPicture->drawFilledRectangle(20, 40, 380, 380, 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(20, 20);
/* Write the axis labels */
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();
<?php

/* CAT:Drawing */
/* pChart library inclusions */
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create the pChart object */
$myPicture = new pImage(700, 230);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "setShadow() - Add shadows", array("R" => 255, "G" => 255, "B" => 255));
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw a filled circle */
$formSettings = array("R" => 201, "G" => 230, "B" => 40, "Alpha" => 100, "Surrounding" => 30);
$myPicture->drawFilledCircle(90, 120, 30, $formSettings);
/* Draw a filled rectangle */
$formSettings = array("R" => 231, "G" => 197, "B" => 40, "Alpha" => 100, "Surrounding" => 30);
$myPicture->drawFilledRectangle(160, 90, 280, 150, $formSettings);
/* Draw a filled rounded rectangle */
$formSettings = array("R" => 231, "G" => 102, "B" => 40, "Alpha" => 100, "Surrounding" => 70);
$myPicture->drawRoundedFilledRectangle(320, 90, 440, 150, 5, $formSettings);
<?php

/* CAT:Surface chart*/
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
include "../class/pSurface.class.php";
/* Create the pChart object */
$myPicture = new pImage(210, 100);
/* 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 */
/* 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(24, -25, 26, 25, 25), "Temperature");
$MyData->setAxisName(0, "Temperatures");
$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);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawThreshold() - draw a treshold in the charting area", array("R" => 255, "G" => 255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and do some cosmetics */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(70, 70, 440, 180, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
Example #18
0
 foreach ($datas as $data) {
     $room_value[] = $data['room_usable_power'] - $data['room_used_power'];
     $room_name[] = $data['room_name'];
 }
 /* Create and populate the pData object */
 $MyData = new pData();
 $MyData->addPoints($room_value, "Capacite electrique disponible (kW)");
 $MyData->setAxisName(0, "Capacite electrique disponible (kW)");
 $MyData->addPoints($room_name, "Salles");
 $MyData->setAbscissa("Salles");
 /* Create the pChart object */
 $myPicture = new pImage(65 * $nbr_room + 65, 330, $MyData);
 // Taille dynamique de l'image en fonction du nombre de réponse SQL
 /* Draw the background */
 $Settings = array("R" => 39, "G" => 43, "B" => 48, "Dash" => 1, "DashR" => 122, "DashG" => 130, "DashB" => 136);
 $myPicture->drawFilledRectangle(0, 0, 65 * $nbr_room + 65, 330, $Settings);
 /* Overlay with a gradient */
 $Settings = array("StartR" => 39, "StartG" => 43, "StartB" => 48, "EndR" => 122, "EndG" => 130, "EndB" => 136, "Alpha" => 50);
 $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 330, DIRECTION_VERTICAL, $Settings);
 $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 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, 65 * $nbr_room + 64, 329, array("R" => 0, "G" => 0, "B" => 0));
 /* Write the chart title */
 $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255));
 $myPicture->drawText(10, 13, "Capacite electrique disponible (kW)", array("R" => 255, "G" => 255, "B" => 255));
 /* Define the default font */
 $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10));
 $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
 /* Set the graph area */
 $myPicture->setGraphArea(50, 40, 65 * $nbr_room + 35, 290);
 $myPicture->drawGradientArea(50, 40, 65 * $nbr_room + 35, 290, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
Example #19
0
function PlotLine($rowX, $rowY, $name, $ch)
{
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php";
    //**************************************
    $myData = new pData();
    $myData->addPoints($rowX, "Serie1");
    $myData->setSerieDescription("Serie1", $name);
    //$myData->setSerieOnAxis("Serie1",0);
    $myData->addPoints($rowY, "Absissa");
    $myData->setAbscissa("Absissa");
    //$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa");
    //$myData->setAbscissa("Absissa");
    $myData->setAxisPosition(0, AXIS_POSITION_LEFT);
    //$myData->setAxisName(0,"1st axis");
    $myData->setAxisUnit(0, "");
    $myPicture = new pImage(700, 230, $myData);
    $Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261);
    $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
    $Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
    $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
    $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14));
    $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30);
    //$myPicture->drawText(350,25,$name,$TextSettings);
    $myPicture->setShadow(FALSE);
    $myPicture->setGraphArea(50, 50, 675, 190);
    //$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
    $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
    $myPicture->drawScale($Settings);
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
    $Config = "";
    if ($ch == 1) {
        $myPicture->drawSplineChart($Config);
    }
    if ($ch == 2) {
        $myPicture->drawBarChart($Config);
    }
    if ($ch == 3) {
        $myPicture->drawLineChart($Config);
    }
    if ($ch == 4) {
        $myPicture->drawPlotChart($Config);
    }
    if ($ch == 5) {
        $myPicture->drawStepChart($Config);
    }
    if ($ch == 6) {
        $myPicture->drawAreaChart($Config);
    }
    if ($ch == 7) {
        $myPicture->drawFilledSplineChart($Config);
    }
    if ($ch == 8) {
        $myPicture->drawFilledStepChart($Config);
    }
    if ($ch == 9) {
        $myPicture->drawStackedAreaChart($Config);
    }
    $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
    $myPicture->drawLegend(563, 16, $Config);
    $myPicture->stroke();
}
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(2, 7, 5, 18, VOID, 12, 10, 15, 8, 5, 6, 9), "Help Desk");
$MyData->setAxisName(0, "Incidents");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jui", "Aou", "Sep", "Oct", "Nov", "Dec"), "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" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 20));
$myPicture->drawGradientArea(0, 0, 60, 230, DIRECTION_HORIZONTAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
/* Do some cosmetics */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawLine(60, 0, 60, 230, array("R" => 70, "G" => 70, "B" => 70));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(35, 115, "Recorded cases", array("R" => 255, "G" => 255, "B" => 255, "FontSize" => 20, "Angle" => 90, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw a spline chart */
$myPicture->setGraphArea(100, 30, 680, 190);
$myPicture->drawFilledRectangle(100, 30, 680, 190, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 20));
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawScale(array("AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE));
$myPicture->drawSplineChart();
/* Write the data bounds */
$myPicture->writeBounds();
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(630, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.writeBounds.png");
Example #21
0
    $rows++;
}
$MyData->addPoints(array_reverse($timestamp[0]), "Labels");
$MyData->setAbscissa("Labels");
for ($count = 1; $count < $fields; $count++) {
    $field = mysql_fetch_field($result, $count);
    $forfields[$count] = $field->name;
    $MyData->addPoints(array_reverse($timestamp[$count]), $field->name);
    $MyData->setSerieWeight($field->name, $weight);
}
$myPicture = new pImage($width, $height, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the background */
//$myPicture->drawFilledRectangle(3,0,$width-1,$height-4,array("R"=>120, "G"=>185, "B"=>255, "Dash"=>0, "DashR"=>255, "DashG"=>255, "DashB"=>255));
$myPicture->drawFilledRectangle(3, 0, $width - 1, $height - 4, array("R" => 120, "G" => 215, "B" => 180, "Dash" => 0, "DashR" => 255, "DashG" => 255, "DashB" => 255));
$myPicture->drawRectangle(3, 0, $width - 1, $height - 4, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawFilledRectangle(0, 3, $width - 4, $height - 1, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 85));
$myPicture->drawRectangle(0, 3, $width - 4, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Overlay with a gradient */
// $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
// $myPicture->drawGradientArea(0,0,800,350,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));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(5, 5 + $font_t * 2, $chart_title);
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(55, 15 + $font_t * 2, $width * 0.9 - 50, $height - 50);
/* Draw the scale */
$scaleSettings = array("FLOATING" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_START0, "CycleBackground" => FALSE, "LabelRotation" => 30, "LabelSkip" => round($row_number / ($width / 30)));
$myPicture->drawScale($scaleSettings);
Example #22
0
    $myData->addPoints($time, "time");
    $venku = $row["value"] == NULL ? VOID : $row["value"];
    $myData->addPoints($venku, "value");
}
$myData->setSerieWeight("value", 1.5);
$myData->setAxisName(0, "Teplota");
$myData->setAxisUnit(0, "°C");
/* Create the abscissa serie */
$myData->setAbscissa("time");
//set the x line
//$myData->setAbscissaName("Den");
//$myData->setXAxisDisplay(AXIS_FORMAT_DATE);
$myPicture = new pImage($Graphwidth, $Graphheigth, $myData);
$Settings = array("R" => 240, "G" => 240, "B" => 240);
$myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8));
$myPicture->drawFilledRectangle(0, 0, $Graphwidth, $Graphheigth, $Settings);
$myPicture->drawRectangle(0, 0, $Graphwidth, $Graphheigth, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawRectangle(0, 0, $Graphwidth - 1, $Graphheigth - 1, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 30, $Graphwidth - 70, $Graphheigth - 40);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Settings = array("Mode" => SCALE_MODE_FLOATING, "DrawSubTicks" => TRUE, "DrawArrows" => TRUE, "ArrowSize" => 6, "Pos" => SCALE_POS_LEFTRIGHT, "LabelSkip" => 0, "SkippedInnerTickWidth" => 10, "LabelingMethod" => LABELING_ALL, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 20, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 20, "LabelRotation" => 90, "DrawXLines" => 1, "DrawSubTicks" => 0, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 20, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$Config = array("DisplayValues" => 0, "AroundZero" => 0, "BreakVoid" => 1, "RecordImageMap" => FALSE);
$GraphType = 'SplineChart';
switch ($GraphType) {
    case 'AreaChart':
        $myPicture->drawAreaChart($Config);
        break;
 /* Prepare some nice data & axis config */
 $MyData = new pData();
 $MyData->addPoints($tabMoyenne, "ScoreA");
 $MyData->addPoints($tabNote, "ScoreB");
 $MyData->setSerieDescription("ScoreA", "Moyenne classe");
 $MyData->setSerieDescription("ScoreB", "Notes étudiant");
 $MyData->setPalette("ScoreB", array("R" => 0, "G" => 0, "B" => 0, "Alpha" => 100));
 $MyData->setPalette("ScoreA", array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 100));
 /* Create the X serie */
 $MyData->addPoints($tabModule, "Labels");
 $MyData->setAbscissa("Labels");
 /* Create the pChart object */
 $myPicture = new pImage(1000, 460, $MyData);
 /* Draw a solid background */
 $Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 255, "DashG" => 255, "DashB" => 255);
 $myPicture->drawFilledRectangle(0, 0, 1000, 460, $Settings);
 /* Overlay some gradient areas */
 $Settings = array("StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 240, "EndG" => 255, "EndB" => 247, "Alpha" => 90);
 $myPicture->drawGradientArea(0, 0, 1000, 460, DIRECTION_VERTICAL, $Settings);
 $myPicture->drawGradientArea(0, 0, 1000, 20, DIRECTION_VERTICAL, array("StartR" => 255, "StartG" => 99, "StartB" => 71, "EndR" => 124, "EndG" => 122, "EndB" => 122, "Alpha" => 100));
 /* Draw the border */
 $myPicture->drawRectangle(0, 0, 999, 459, array("R" => 255, "G" => 99, "B" => 71));
 /* Write the title */
 $myPicture->setFontProperties(array("FontName" => "pChart2.1.4/fonts/arial.ttf", "FontSize" => 18));
 $myPicture->drawText(10, 18, $var2["shortname"] . "    " . date('d-m-Y'), array("R" => 255, "G" => 255, "B" => 255));
 /* Define general drawing parameters */
 $myPicture->setFontProperties(array("FontName" => "pChart2.1.4/fonts/arial.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
 $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
 /* Create the radar object */
 $SplitChart = new pRadar();
 /* Draw the 1st radar chart */
$myPicture = new pImage(700, 230, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Add a border to the picture */
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 80, "EndG" => 80, "EndB" => 80, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 80, "EndG" => 80, "EndB" => 80, "Alpha" => 20));
$myPicture->drawRectangle(0, 0, 699, 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, 650, 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(580, 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("Surrounding" => -30, "InnerSurrounding" => 30, "Interleave" => 0);
$myPicture->drawBarChart($settings);
/* Draw the bottom black area */
$myPicture->setShadow(FALSE);
$myPicture->drawFilledRectangle(0, 174, 700, 230, array("R" => 0, "G" => 0, "B" => 0));
/* Do the mirror effect */
$myPicture->drawAreaMirror(0, 174, 700, 48);
/* Draw the horizon line */
$myPicture->drawLine(1, 174, 698, 174, array("R" => 80, "G" => 80, "B" => 80));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawAreaMirror.png");
}
/* 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" => "../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));
Example #26
0
 public function buildChartImage(array $reportData, array $fields, $asDataURI = true, $generateImageMapId = false)
 {
     global $current_user;
     require_once 'modules/AOR_Charts/lib/pChart/pChart.php';
     if ($generateImageMapId !== false) {
         $generateImageMapId = $current_user->id . "-" . $generateImageMapId;
     }
     $html = '';
     if (!in_array($this->type, $this->getValidChartTypes())) {
         return $html;
     }
     $x = $fields[$this->x_field];
     $y = $fields[$this->y_field];
     if (!$x || !$y) {
         //Malformed chart object - missing an axis field
         return '';
     }
     $xName = str_replace(' ', '_', $x->label) . $this->x_field;
     $yName = str_replace(' ', '_', $y->label) . $this->y_field;
     $chartData = new pData();
     $chartData->loadPalette("modules/AOR_Charts/lib/pChart/palettes/navy.color", TRUE);
     $labels = array();
     foreach ($reportData as $row) {
         $chartData->addPoints($row[$yName], 'data');
         $chartData->addPoints($row[$xName], 'Labels');
         $labels[] = $row[$xName];
     }
     $chartData->setSerieDescription("Months", "Month");
     $chartData->setAbscissa("Labels");
     $imageHeight = 700;
     $imageWidth = 700;
     $chartPicture = new pImage($imageWidth, $imageHeight, $chartData);
     if ($generateImageMapId) {
         $imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/' . $current_user->id . '/');
         $chartPicture->initialiseImageMap($generateImageMapId, IMAGE_MAP_STORAGE_FILE, $generateImageMapId, $imageMapDir);
     }
     $chartPicture->Antialias = True;
     $chartPicture->drawFilledRectangle(0, 0, $imageWidth - 1, $imageHeight - 1, array("R" => 240, "G" => 240, "B" => 240, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
     $chartPicture->setFontProperties(array("FontName" => "modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize" => 14));
     $chartPicture->drawText($imageWidth / 2, 20, $this->name, array("R" => 0, "G" => 0, "B" => 0, 'Align' => TEXT_ALIGN_TOPMIDDLE));
     $chartPicture->setFontProperties(array("FontName" => "modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize" => 6));
     $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100);
     switch ($this->type) {
         case 'radar':
             $this->buildChartImageRadar($chartPicture, $chartData, !empty($generateImageMapId));
             break;
         case 'pie':
             $this->buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, !empty($generateImageMapId));
             break;
         case 'line':
             $this->buildChartImageLine($chartPicture, !empty($generateImageMapId));
             break;
         case 'bar':
         default:
             $this->buildChartImageBar($chartPicture, !empty($generateImageMapId));
             break;
     }
     if ($generateImageMapId) {
         $chartPicture->replaceImageMapTitle("data", $labels);
     }
     ob_start();
     $chartPicture->render('');
     $img = ob_get_clean();
     if ($asDataURI) {
         return 'data:image/png;base64,' . base64_encode($img);
     } else {
         return $img;
     }
 }
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(1700, 2500, 7800, 4500, 3150), "Distance");
$MyData->setAxisName(0, "Maximum distance");
$MyData->setAxisUnit(0, "m");
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC);
/* Create the abscissa serie */
$MyData->addPoints(array(1230768000, 1233446400, 1235865600, 1238544000, 1241136000, 1243814400), "Timestamp");
$MyData->setSerieDescription("Timestamp", "Sampled Dates");
$MyData->setAbscissa("Timestamp");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE);
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawScale() - draw the X-Y scales", array("R" => 255, "G" => 255, "B" => 255));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
/* Write the chart title */
$myPicture->setGraphArea(60, 60, 660, 190);
$myPicture->drawText(350, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
$myPicture->drawFilledRectangle(60, 60, 660, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
}
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 17, "EndG" => 17, "EndB" => 17, "Alpha" => 100));
$myPicture->drawGradientArea(0, 230, 700, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 27, "EndG" => 27, "EndB" => 27, "Alpha" => 100));
$myPicture->drawLine(0, 209, 847, 209, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawLine(0, 210, 847, 210, 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" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawText(340, 12, "Cyclic magnetic field strength", array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
/* Define the chart area */
$myPicture->setGraphArea(48, 17, 680, 190);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(53, 22, 675, 185, 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" => 5, "YMargin" => 5, "Floating" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
$myPicture->drawScale($ScaleSettings);
/* Define the visual thresholds */
$Threshold = "";
$Threshold[] = array("Min" => -100, "Max" => -35, "R" => 117, "G" => 140, "B" => 240, "Alpha" => 40);
$Threshold[] = array("Min" => -35, "Max" => 35, "R" => 240, "G" => 232, "B" => 20, "Alpha" => 60);
$Threshold[] = array("Min" => 35, "Max" => 100, "R" => 240, "G" => 121, "B" => 20, "Alpha" => 80);
/* Draw the spline chart */
$myPicture->drawFilledSplineChart(array("Threshold" => $Threshold));
/* Write the chart boundaries */
$BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
function pieGen($stats, $mode)
{
    global $centreon_path;
    // Create and populate the pData object
    $MyData = new pData();
    // print_r($stats["average"]);
    $arrPoints = array();
    $i = 0;
    // Host groups
    if ($mode == "hgs") {
        $MyData->addPoints(array($stats["average"]["UP_TP"], $stats["average"]["DOWN_TP"], $stats["average"]["UNDETERMINED_TP"], $stats["average"]["UNREACHABLE_TP"], $stats["average"]["MAINTENANCE_TP"]), "Hostgroups");
        $MyData->setSerieDescription("Hostgroups", "Hostgroups");
        $arrPoints = array("Up", "Down", "Undeterminded", "Unreachable", "Schedule Downtime");
        // Define the absissa serie
        $MyData->addPoints($arrPoints, "Labels");
        $MyData->setAbscissa("Labels");
        // Create the pChart object
        $myPicture = new pImage(120, 120, $MyData, TRUE);
        // Create the pPie object
        $PieChart = new pPie($myPicture, $MyData);
        $i = 0;
        /* Define the slice color */
        if ($stats["average"]["UP_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 25, "G" => 238, "B" => 17));
            // UP
            $i++;
        }
        if ($stats["average"]["DOWN_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 249, "G" => 30, "B" => 5));
            // DOWN
            $i++;
        }
        if ($stats["average"]["UNDETERMINED_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 248, "B" => 255));
            // UNDETERMINED
            //$PieChart->setSliceColor($i,array("R"=>240,"G"=>240,"B"=>240));
            $i++;
        }
        if ($stats["average"]["UNREACHABLE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 130, "G" => 207, "B" => 216));
            // UNREACHABLE
            $i++;
        }
        if ($stats["average"]["MAINTENANCE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 153, "B" => 255));
            // MAINTENANCE
            $i++;
        }
    }
    // Service Groups
    if ($mode == "sgs") {
        $MyData->addPoints(array($stats["average"]["OK_TP"], $stats["average"]["WARNING_TP"], $stats["average"]["CRITICAL_TP"], $stats["average"]["UNKNOWN_TP"], $stats["average"]["MAINTENANCE_TP"], $stats["average"]["UNDETERMINED_TP"]), "Servicegroups");
        $MyData->setSerieDescription("Servicegroups", "Servicegroups");
        $arrPoints = array("Ok", "Warning", "Critical", "Unknown", "Schedule Downtime", "Undeterminded");
        // Define the absissa serie
        $MyData->addPoints($arrPoints, "Labels");
        $MyData->setAbscissa("Labels");
        // Create the pChart object
        $myPicture = new pImage(120, 120, $MyData, TRUE);
        // Create the pPie object
        $PieChart = new pPie($myPicture, $MyData);
        /* Define the slice color */
        if ($stats["average"]["OK_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 13, "G" => 235, "B" => 58));
            // OK
            $i++;
        }
        if ($stats["average"]["WARNING_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 248, "G" => 199, "B" => 6));
            // DOWN
            $i++;
        }
        if ($stats["average"]["CRITICAL_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 249, "G" => 30, "B" => 5));
            // DOWN
            $i++;
        }
        if ($stats["average"]["UNKNOWN_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 220, "G" => 218, "B" => 218));
            // UNKNOWN
            $i++;
        }
        if ($stats["average"]["MAINTENANCE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 153, "B" => 255));
            // MAINTENANCE
            $i++;
        }
        if ($stats["average"]["UNDETERMINED_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 248, "B" => 255));
            // UNDETERMINED
            //$PieChart->setSliceColor($i,array("R"=>240,"G"=>240,"B"=>240)); // UNDETERMINED
            $i++;
        }
    }
    $Settings = array("R" => 255, "G" => 255, "B" => 255);
    $myPicture->drawFilledRectangle(0, 0, 120, 120, $Settings);
    //  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(60, 70, array("Radius" => 50, "DataGapAngle" => 8, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
    /* Render the picture  */
    //	$pie_file = tempnam( "/tmp" , "reportreon_pie_" );
    $pie_file = tempnam($centreon_path . "/www/modules/pdfreports/generatedFiles/tmp", "reportreon_pie_");
    $myPicture->render($pie_file . ".png");
    @unlink($pie_file);
    return $pie_file . ".png";
}
 function func_piegraphGenerate($student_id, $time, $name, $basepath)
 {
     $metricResult = $this->func_getTimeTakenResult($student_id);
     $book_name = array();
     $book_time = array();
     if (empty($metricResult)) {
         $book_name[] = "";
         $book_time[] = "";
     }
     foreach ($metricResult as $matric) {
         $book_name[] = $matric['book_name'];
         $book_time[] = $matric['book_wise_sum'];
     }
     $total_time = array_sum($book_time);
     $MyData = new pData();
     $MyData->addPoints($book_time, "ScoreA");
     /* Define the absissa serie */
     $MyData->addPoints($book_name, "Labels");
     $MyData->setAbscissa("Labels");
     /* Create the pChart object */
     $myPicture = new pImage(500, 317, $MyData, TRUE);
     /* Draw a solid background */
     $Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 0, "DashR" => 193, "DashG" => 172, "DashB" => 237);
     $myPicture->drawFilledRectangle(0, 0, 400, 230, $Settings);
     /* Draw a gradient overlay */
     $Settings = array("StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 50);
     $myPicture->drawGradientArea(0, 0, 400, 230, DIRECTION_VERTICAL, $Settings);
     $myPicture->drawGradientArea(0, 0, 0, 0, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
     /* Set the default font properties */
     $myPicture->setFontProperties(array("FontName" => $basepath . "verdana.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     /* Create the pPie object */
     $PieChart = new pPie($myPicture, $MyData);
     /* Define the slice color */
     $PieChart->setSliceColor(0, array("R" => 40, "G" => 74, "B" => 134));
     $PieChart->setSliceColor(1, array("R" => 97, "G" => 77, "B" => 63));
     $PieChart->setSliceColor(2, array("R" => 97, "G" => 113, "B" => 63));
     /* Draw a simple pie chart */
     /* Enable shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw a splitted pie chart */
     $PieChart->draw3DPie(230, 175, array("WriteValues" => TRUE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "DrawLabels" => TRUE));
     /* Render the picture (choose the best way) */
     $picname = $student_id . '_' . $name . '_' . $time . '.png';
     $this->fun_getImageLog($student_id, $picname, $name, $time, 'pie');
     $myPicture->render("uploads/graph/" . $picname);
     $book_time = array('book_time' => $book_time);
     return array_merge((array) $book_name, $book_time);
     //  return  $book_name.'-'.$book_time;
 }