Exemplo n.º 1
0
function createGraphe($vData, $hData, $titre, $vLabel, $hLabel)
{
    $MyData = new pData();
    /*Je présente ma série de données à utiliser pour le graphique et je détermine le titre de l'axe vertical avec setAxisName*/
    $MyData->addPoints($vData, "vertical");
    $MyData->setSerieWeight("vertical", 2);
    $MyData->setAxisName(0, $vLabel);
    /*J'indique les données horizontales du graphique. Il doit y avoir le même nombre que pour ma série de données précédentes (logique)*/
    $MyData->addPoints($hData, "horizontal");
    $MyData->setSerieDescription("horizontal", $hLabel);
    $MyData->setAbscissa("horizontal");
    $MyData->setPalette("vertical", array("R" => 255, "G" => 0, "B" => 0));
    /* Je crée l'image qui contiendra mon graphique précédemment crée */
    $myPicture = new pImage(900, 400, $MyData);
    /* Je crée une bordure à mon image */
    $myPicture->drawRectangle(0, 0, 899, 399, array("R" => 0, "G" => 0, "B" => 0));
    /* J'indique le titre de mon graphique, son positionnement sur l'image et sa police */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/Forgotte.ttf", "FontSize" => 11));
    $myPicture->drawText(200, 25, $titre, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
    /* Je choisi la font de mon graphique */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
    /* Je détermine la taille du graphique et son emplacement dans l'image */
    $myPicture->setGraphArea(60, 40, 800, 380);
    /* Paramètres pour dessiner le graphique à partir des deux abscisses */
    $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => TRUE, "LabelSkip" => 4);
    $myPicture->drawScale($scaleSettings);
    /* Je dessine mon graphique en fonction des paramètres précédents */
    $myPicture->drawAreaChart();
    $myPicture->drawLineChart();
    /* J'indique le chemin où je souhaite que mon image soit créée */
    $myPicture->Render("img/" . $titre . ".png");
}
Exemplo n.º 2
0
}
//取data
$rows = 0;
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    for ($count = 0; $count < $fields; $count++) {
        $timestamp[$count][$rows] = $row[$count];
    }
    $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, 1);
}
$myPicture = new pImage(950, 450, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the background */
$Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 0, "DashR" => 255, "DashG" => 255, "DashB" => 255);
$myPicture->drawFilledRectangle(0, 0, 700, 450, $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,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));
/* Add a border to the picture */
//$myPicture->drawRectangle(800,350,0,0,array("R"=>0,"G"=>0,"B"=>0));
/* Write the chart title */
// $myPicture->setFontProperties(array("FontName"=>"./fonts/simsun.ttc","FontSize"=>8,"R"=>255,"G"=>255,"B"=>255));
Exemplo n.º 3
0
}
//取data
$rows = 0;
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    for ($count = 0; $count < $fields; $count++) {
        $timestamp[$count][$rows] = $row[$count];
    }
    $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 */
<?php

/* Library settings */
define("CLASS_PATH", "../../../class");
define("FONT_PATH", "../../../fonts");
/* pChart library inclusions */
include CLASS_PATH . "/pData.class.php";
include CLASS_PATH . "/pDraw.class.php";
include CLASS_PATH . "/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Probe 1");
$MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Probe 2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Probe 3");
$MyData->setSerieTicks("Probe 2", 4);
$MyData->setSerieWeight("Probe 3", 2);
$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);
/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) {
    $myPicture->dumpImageMap("ImageMapSplineChart", IMAGE_MAP_STORAGE_FILE, "SplineChart", "../tmp");
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMapSplineChart", IMAGE_MAP_STORAGE_FILE, "SplineChart", "../tmp");
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background */
Exemplo n.º 5
0
     }
     if ($legend == 2) {
         $PieChart->drawPieLegend($marg, $height - $marg - $font * 2, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     }
 } else {
     $nSerie = 0;
     if (!isset($chart_limit)) {
         $chart_limit = 1000;
     }
     $plotShapes = array(SERIE_SHAPE_FILLEDCIRCLE, SERIE_SHAPE_FILLEDTRIANGLE, SERIE_SHAPE_FILLEDSQUARE, SERIE_SHAPE_FILLEDDIAMOND);
     reset($arrFields);
     while (list($idx, $field) = each($arrFields)) {
         if (!isset($chart_cols) or $idx == 0 or in_array($idx, $chart_cols)) {
             $arrSeries[] = $field;
             $myData->addPoints(array_reverse(array_slice($arrCols[$field], 0, $chart_limit)), $field);
             $myData->setSerieWeight($field, $weight);
             if ($plotShape >= 0 and $plotShape < count($plotShapes)) {
                 $myData->setSerieShape($field, $plotShapes[$plotShape]);
             } else {
                 $myData->setSerieShape($field, $plotShapes[array_rand($plotShapes, 1)]);
             }
             if (isset($palette)) {
                 $myData->setPalette($field, $palette['serie'][($nSerie - 1) % $palette['serie_num']]);
             }
             if ($nSerie == 0) {
                 $abscissa = $field;
                 $myData->setAbscissa($abscissa);
             } else {
                 if (isset($chart_cols2) and in_array($idx, $chart_cols2)) {
                     $arrSeriesY2[] = $field;
                     $myData->setSerieOnAxis($field, 1);
Exemplo n.º 6
0
}
$oMySQL->ExecuteSQL($SQLString);
foreach ($oMySQL->arrayedResult as $row) {
    switch ($Type) {
        case "day":
            $time = date('h:m', $row["unixtime"]);
            break;
        case "week":
            $time = date('d.m.', $row["unixtime"]);
            break;
    }
    $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);
<?php

/* CAT:Drawing */
/* 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), "My Serie 1");
$MyData->addPoints(array(80, 85, 84, 81, 82), "My Serie 2");
$MyData->addPoints(array(17, 16, 18, 18, 15), "My Serie 3");
$MyData->setSerieTicks("My Serie 1", 4);
$MyData->setSerieWeight("My Serie 2", 2);
$MyData->setSerieDescription("My Serie 1", "Temperature");
$MyData->setSerieDescription("My Serie 2", "Humidity\n(in percentage)");
$MyData->setSerieDescription("My Serie 3", "Pressure");
/* 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));
/* Draw the picture border */
$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, "drawLegend() - Write your chart legend", array("R" => 255, "G" => 255, "B" => 255));
Exemplo n.º 8
0
            $DynVarDef4 = "Core 2";
            $serieSettings4 = $serieSettingsS;
            $DynVar5[] = round(0.9 * Conv2TF($row_SysDB['TempCore3'] / 1000), 0);
            $DynVarDef5 = "Core 3";
            $serieSettings5 = $serieSettingsS;
            $DynVar6[] = round(0.9 * Conv2TF($row_SysDB['TempCore4'] / 1000), 0);
            $DynVarDef6 = "Core 4";
            $serieSettings6 = $serieSettingsS;
        }
        $DynVarUnits = "degrees F";
        break;
}
$MyData = new pData();
if (isset($DynVar2)) {
    $MyData->addPoints($DynVar2, $DynVarDef2);
    $MyData->setSerieWeight($DynVarDef2, $chWeight / 3);
    $MyData->setPalette($DynVarDef2, $serieSettings2);
}
if (isset($DynVar3)) {
    $MyData->addPoints($DynVar3, $DynVarDef3);
    $MyData->setSerieWeight($DynVarDef3, $chWeight / 3);
    $MyData->setPalette($DynVarDef3, $serieSettings3);
}
if (isset($DynVar4)) {
    $MyData->addPoints($DynVar4, $DynVarDef4);
    $MyData->setSerieWeight($DynVarDef4, $chWeight / 3);
    $MyData->setPalette($DynVarDef4, $serieSettings4);
}
if (isset($DynVar5)) {
    $MyData->addPoints($DynVar5, $DynVarDef5);
    $MyData->setSerieWeight($DynVarDef5, $chWeight / 3);
Exemplo n.º 9
0
define("CLASS_PATH", "../../../class");
define("FONT_PATH", "../../../fonts");
/* pChart library inclusions */
include CLASS_PATH . "/pData.class.php";
include CLASS_PATH . "/pDraw.class.php";
include CLASS_PATH . "/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
for ($i = 0; $i <= 20; $i++) {
    $MyData->addPoints(rand(0, 20), "Probe 1");
}
for ($i = 0; $i <= 20; $i++) {
    $MyData->addPoints(rand(0, 20), "Probe 2");
}
$MyData->setSerieShape("Probe 1", SERIE_SHAPE_FILLEDTRIANGLE);
$MyData->setSerieWeight("Probe 1", 1);
$MyData->setSerieShape("Probe 2", SERIE_SHAPE_FILLEDSQUARE);
$MyData->setSerieWeight("Probe 2", 2);
$MyData->setAxisName(0, "Temperatures");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) {
    $myPicture->dumpImageMap("ImageMap1", IMAGE_MAP_STORAGE_FILE, "PlotChart", "../tmp");
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMap1", IMAGE_MAP_STORAGE_FILE, "PlotChart", "../tmp");
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
<?php

/* CAT:Plot 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(3, 4, 7, 4, 2, 5), "User");
$MyData->addPoints(array(12, 17, 15, 18, 19, 22), "Group");
$MyData->setSeriePicture("User", "resources/serie1.png");
$MyData->setSeriePicture("Group", "resources/serie2.png");
$MyData->setSerieWeight("Group", 1);
$MyData->setSerieTicks("Group", 4);
$MyData->setAxisName(0, "Hours");
$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 */
Exemplo n.º 11
0
function pch_vertical_graph($graph_type, $index, $data, $width, $height, $rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false, $legend = array(), $font, $antialiasing, $water_mark = '', $font_size)
{
    /* CAT:Vertical Charts */
    if (!is_array($legend) || empty($legend)) {
        unset($legend);
    }
    /*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
    	 $data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
    	 $index=array(1,2,3,4);
         */
    if (is_array(reset($data))) {
        $data2 = array();
        foreach ($data as $i => $values) {
            $c = 0;
            foreach ($values as $i2 => $value) {
                $data2[$i2][$i] = $value;
                $c++;
            }
        }
        $data = $data2;
    } else {
        $data = array($data);
    }
    /* Create and populate the pData object */
    $MyData = new pData();
    foreach ($data as $i => $values) {
        if (isset($legend)) {
            $point_id = $legend[$i];
        } else {
            $point_id = $i;
        }
        $MyData->addPoints($values, $point_id);
        if (!empty($rgb_color)) {
            $MyData->setPalette($point_id, array("R" => $rgb_color[$i]['color']["R"], "G" => $rgb_color[$i]['color']["G"], "B" => $rgb_color[$i]['color']["B"], "BorderR" => $rgb_color[$i]['border']["R"], "BorderG" => $rgb_color[$i]['border']["G"], "BorderB" => $rgb_color[$i]['border']["B"], "Alpha" => $rgb_color[$i]['alpha']));
            /*$palette_color = array();
            			if (isset($rgb_color[$i]['color'])) {
            				$palette_color["R"] = $rgb_color[$i]['color']["R"];
            				$palette_color["G"] = $rgb_color[$i]['color']["G"];
            				$palette_color["B"] = $rgb_color[$i]['color']["B"];
            			}
            	 		if (isset($rgb_color[$i]['color'])) {
            				$palette_color["BorderR"] = $rgb_color[$i]['border']["R"];
            				$palette_color["BorderG"] = $rgb_color[$i]['border']["G"];
            				$palette_color["BorderB"] = $rgb_color[$i]['border']["B"];
            			}
            			if (isset($rgb_color[$i]['color'])) {
            				$palette_color["Alpha"] = $rgb_color[$i]['Alpha'];
            			}
            		
            			$MyData->setPalette($point_id, $palette_color);*/
        }
        $MyData->setSerieWeight($point_id, 1);
    }
    //$MyData->addPoints($data,"Yaxis");
    $MyData->setAxisName(0, $yaxisname);
    $MyData->addPoints($index, "Xaxis");
    $MyData->setSerieDescription("Xaxis", $xaxisname);
    $MyData->setAbscissa("Xaxis");
    /* Create the pChart object */
    $myPicture = new pImage($width, $height, $MyData);
    /* Turn of Antialiasing */
    $myPicture->Antialias = $antialiasing;
    /* Add a border to the picture */
    //$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
    /* Set the default font */
    $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size));
    if (isset($legend)) {
        /* Set horizontal legend if is posible */
        $legend_mode = LEGEND_HORIZONTAL;
        $size = $myPicture->getLegendSize(array("Style" => LEGEND_NOBORDER, "Mode" => $legend_mode));
        if ($size['Width'] > $width - 5) {
            $legend_mode = LEGEND_VERTICAL;
            $size = $myPicture->getLegendSize(array("Style" => LEGEND_NOBORDER, "Mode" => $legend_mode));
        }
        /* Write the chart legend */
        $myPicture->drawLegend($width - $size['Width'], 8, array("Style" => LEGEND_NOBORDER, "Mode" => $legend_mode));
    }
    //Calculate the bottom margin from the size of string in each index
    $max_chars = 0;
    foreach ($index as $string_index) {
        if (empty($string_index)) {
            continue;
        }
        $len = strlen($string_index);
        if ($len > $max_chars) {
            $max_chars = $len;
        }
    }
    $margin_bottom = 10 * $max_chars;
    $water_mark_height = 0;
    $water_mark_width = 0;
    if (!empty($water_mark)) {
        $size_water_mark = getimagesize($water_mark);
        $water_mark_height = $size_water_mark[1];
        $water_mark_width = $size_water_mark[0];
        $myPicture->drawFromPNG($width - $water_mark_width, $height - $water_mark_height - $margin_bottom, $water_mark);
    }
    if (isset($size['Height'])) {
        /* Define the chart area */
        $myPicture->setGraphArea(40, $size['Height'], $width - $water_mark_width, $height - $margin_bottom);
    } else {
        /* Define the chart area */
        $myPicture->setGraphArea(40, 5, $width - $water_mark_width, $height - $margin_bottom);
    }
    /* Draw the scale */
    $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_START0, "LabelRotation" => 60, "XMargin" => 0);
    $myPicture->drawScale($scaleSettings);
    /* Turn on shadow computing */
    //$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
    switch ($graph_type) {
        case 'stacked_area':
            $ForceTransparency = "-1";
            break;
        default:
            $ForceTransparency = "50";
            break;
    }
    /* Draw the chart */
    $settings = array("ForceTransparency" => $ForceTransparency, "Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayValues" => $show_values, "DisplayZeroValues" => FALSE, "DisplayR" => 100, "DisplayZeros" => FALSE, "DisplayG" => 100, "DisplayB" => 100, "DisplayShadow" => TRUE, "Surrounding" => 5, "AroundZero" => FALSE);
    switch ($graph_type) {
        case "stacked_area":
        case "area":
            $myPicture->drawAreaChart($settings);
            break;
        case "line":
            $myPicture->drawLineChart($settings);
            break;
    }
    /* Render the picture */
    $myPicture->stroke();
}
    }
    $data = array("January" => 0, "February" => 0, "March" => 0, "April" => 0, "May" => 0, "June" => 0, "July" => 0, "August" => 0, "September" => 0, "October" => 0, "November" => 0, "December" => 0);
    while ($row = $month_totals->fetch_array()) {
        $data = array_merge($data, array($row['month'] => $row['count']));
    }
    $results[$i] = array($years[$i] => $data);
}
$width = 760;
$height = 500;
$pChart = new pData();
for ($i = 0; $i < count($results); $i++) {
    foreach ($results[$i] as $year => $month_results) {
        $pChart->addPoints(array($month_results['January'], $month_results['February'], $month_results['March'], $month_results['April'], $month_results['May'], $month_results['June'], $month_results['July'], $month_results['August'], $month_results['September'], $month_results['October'], $month_results['November'], $month_results['December']), "Serie{$i}");
        $pChart->setSerieDescription("Serie{$i}", $year);
        $pChart->setSerieOnAxis("Serie{$i}", 0);
        $pChart->setSerieWeight("Serie{$i}", 0.75);
    }
}
$pChart->addPoints(array("Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu"), "Absissa");
$pChart->setAbscissa("Absissa");
$pChart->setAxisPosition(0, AXIS_POSITION_LEFT);
$pChart->setAxisName(0, "Laskentamäärä");
$pChart->setAxisUnit(0, "");
$pChartPicture = new pImage($width, $height, $pChart);
$Settings = array("R" => 255, "G" => 255, "B" => 255);
$pChartPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
$pChartPicture->setFontProperties(array("FontName" => "pChart/fonts/arial.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_BOTTOMMIDDLE, "R" => 0, "G" => 0, "B" => 0);
$pChartPicture->drawText($width / 2, 25, ucfirst($table) . " - Aikajana", $TextSettings);
$description .= GetYearsDescription($years);
$description .= " - (" . GetSeriesTotalSum($pChart) . " kpl)";
Exemplo n.º 13
0
    $venku = $row["venku"];
    $myData->addPoints($venku, "venku");
    $obyvak = $row["obyvak"];
    $myData->addPoints($obyvak, "obyvak");
    $podlaha = $row["podlaha"];
    $myData->addPoints($podlaha, "podlaha");
    $krb = $row["krb"];
    $myData->addPoints($krb, "krb");
    $krb = $row["tom"];
    $myData->addPoints($krb, "tom");
    $krb = $row["nela"];
    $myData->addPoints($krb, "nela");
    $aku = $row["aku"];
    $myData->addPoints($aku, "aku");
}
$myData->setSerieWeight("venku", 1.5);
$myData->setSerieWeight("obyvak", 1);
$myData->setSerieWeight("podlaha", 1);
$myData->setSerieWeight("krb", 1);
$myData->setSerieWeight("tom", 1);
$myData->setSerieWeight("nela", 1);
$myData->setSerieWeight("aku", 1);
$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);
Exemplo n.º 14
0
$times = date('G:i@j/m', strtotime($startdate[0]));
$startdate = $times;
$enddate = end($F1);
$enddate = explode(",", $enddate);
$times = date('G:i@j/m', strtotime($enddate[0]));
$enddate = $times;
$F2 = file("data/next_mov.csv");
$nextmov = $F2[1];
$MyData->setAxisName(0, "Prices");
$MyData->addPoints($data["bids"], "Buy");
$MyData->addPoints($data["asks"], "Sell");
$MyData->addPoints($data["prices"], "BTC/USD");
$MyData->addPoints($data["emaShort"], "EMAshort");
$MyData->addPoints($data["emaLong"], "EMAlong");
$MyData->setSerieShape("Buy", SERIE_SHAPE_FILLEDTRIANGLE);
$MyData->setSerieWeight("Buy", 2);
$MyData->setSerieShape("Sell", SERIE_SHAPE_FILLEDSQUARE);
$MyData->addPoints($data["times"], "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
$myPicture = new pImage(1400, 460, $MyData);
$myPicture->Antialias = FALSE;
$myPicture->setFontProperties(array("FontName" => "pChart/fonts/Forgotte.ttf", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(15, 22, "HAL10K by intrd", array("FontSize" => 15, "Align" => TEXT_ALIGN_BOTTOMLEFT));
//$myPicture->drawText(15,22,"HAL10K by intrd",array("FontSize"=>15,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
$myPicture->drawText(450, 20, "Período: " . $startdate . " - " . $enddate . "", array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT));
$myPicture->drawText(651, 23, $nextmov, array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT));
$myPicture->setFontProperties(array("FontName" => "pChart/fonts/pf_arma_five.ttf", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(20 * 2, 20, 650 * 2, 200 * 2);
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 500, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
 public function reportday($projectID)
 {
     /* pChart library inclusions */
     include "../p_chart/class/pData.class.php";
     include "../p_chart/class/pDraw.class.php";
     include "../p_chart/class/pImage.class.php";
     //每日剩余
     $where = "project = {$projectID} AND deleted = '0' AND status NOT IN ( 'cancel','closed') ";
     $tasks_all = $this->task->getTasksByCondition($where);
     $tasks_all_count = count($tasks_all);
     $this->view->tasks_all_count = $tasks_all_count;
     $where = "project = {$projectID} AND deleted = '0'";
     $allFinishedDate = $this->task->getAllFinishedDate($where);
     $tasks_un_finished_x = array();
     $tasks_un_finished_y = array();
     foreach (array_reverse($allFinishedDate) as $v) {
         $where = "project = {$projectID} AND deleted = '0' AND status NOT IN ( 'cancel','closed') AND finishedDate <= '{$v->date} 23:59:59' AND finishedDate != '0000-00-00 00:00:00'";
         $count = $this->task->getUnFinishedTasksPerDay($where, $tasks_all_count);
         $tasks_un_finished_x[] = date('m-d', strtotime($v->date));
         $tasks_un_finished_y[] = $count;
     }
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints($tasks_un_finished_y, "Probe 1");
     $MyData->setSerieWeight("Probe 1", 2);
     $MyData->setAxisName(0, "");
     $MyData->addPoints($tasks_un_finished_x, "Labels");
     $MyData->setSerieDescription("Labels", "Months");
     $MyData->setAbscissa("Labels");
     /* Create the pChart object */
     $myPicture = new pImage(700, 230, $MyData);
     /* Turn of Antialiasing */
     $myPicture->Antialias = FALSE;
     /* 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 chart title */
     $myPicture->setFontProperties(array("FontName" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8, "R" => 255, "G" => 255, "B" => 255));
     $myPicture->drawText(10, 16, "每日剩余任务数", array("FontSize" => 10, "Align" => TEXT_ALIGN_BOTTOMLEFT));
     /* Set the default font */
     $myPicture->setFontProperties(array("FontName" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, 650, 200);
     /* Draw the scale */
     $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
     $myPicture->drawScale($scaleSettings);
     /* Turn on Antialiasing */
     $myPicture->Antialias = TRUE;
     /* Enable shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw the line chart */
     $myPicture->drawLineChart();
     $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotBorder" => TRUE, "BorderSize" => 2, "Surrounding" => -60, "BorderAlpha" => 80));
     /* Write the chart legend */
     $myPicture->drawLegend(590, 9, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL, "FontR" => 255, "FontG" => 255, "FontB" => 255));
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput();
     $img = $myPicture->base64("output.png");
     $this->view->src_line = $img;
     //每位成员剩余
     $where = "project = {$projectID} AND deleted = '0' AND (status = 'wait' OR status = 'doing') AND assignedTo !='' ";
     $tasks_un_finished_per_member = $this->task->getUnFinishedTasksPerAssignedTo($where);
     $tasks_un_finished_member_x = array();
     $tasks_un_finished_member_y = array();
     foreach ($tasks_un_finished_per_member as $v) {
         $tasks_un_finished_member_x[] = $v->value;
         $tasks_un_finished_member_y[] = $v->name;
     }
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints($tasks_un_finished_member_x, "Hits");
     $MyData->setAxisName(0, "剩余任务数");
     $MyData->addPoints($tasks_un_finished_member_y, "Browsers");
     $MyData->setSerieDescription("Browsers", "Browsers");
     $MyData->setAbscissa("Browsers");
     //$MyData->setAbscissaName("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" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8));
     /* 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));
     /* 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));
     /* Draw the chart */
     $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
     /* Write the legend */
     $myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput();
     $img = $myPicture->base64("output.png");
     $this->view->src_bar = $img;
     $project_info = $this->loadModel('project')->getById($projectID);
     $this->view->project_info = $project_info;
     //今日完成
     $where = "project = {$projectID} AND deleted = '0' AND status = 'done' AND DATE_FORMAT(finishedDate,'%Y-%m-%d') = '" . date('Y-m-d') . "'";
     $tasks_done_today = $this->task->getTasksByCondition($where);
     $this->view->tasks_done_today = $tasks_done_today;
     //今日新增
     $where = "project = {$projectID} AND deleted = '0' AND DATE_FORMAT(openedDate,'%Y-%m-%d') = '" . date('Y-m-d') . "'";
     $tasks_opened_today = $this->task->getTasksByCondition($where);
     $this->view->tasks_opened_today = $tasks_opened_today;
     //未完成(迭代期)
     $where = "project = {$projectID} AND deleted = '0' AND (status = 'wait' OR status = 'doing')";
     $tasks_un_finished = $this->task->getTasksByCondition($where);
     $this->view->tasks_un_finished = $tasks_un_finished;
     $this->display($this->moduleName, 'reportday');
 }
Exemplo n.º 16
0
session_start();
$popularity = $_SESSION['popularity'];
$year = $_SESSION['year'];
$name = $_SESSION['name'];
/* CAT:Line 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),"Probe 1");
//$MyData->addPoints(array(3,12,15,8,5,-5),"Probe 2");
$MyData->addPoints($popularity, "{$name}");
//$MyData->setSerieTicks("Probe 2",4);
$MyData->setSerieWeight("{$name}", 2);
$MyData->setAxisName(0, "Popularity ");
$MyData->addPoints($year, "Labels");
$MyData->setSerieDescription("Labels", "Year");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Add a border to the picture */
$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, "Popularity Curve For '{$name}'", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));