Example #1
0
function _stats_build_graph($data, $labels, $filename, $stat, $width, $height, $vars)
{
    if (file_exists($filename)) {
        unlink($filename);
    }
    $data_orig = $data;
    foreach ($data as $key => $val) {
        if (!is_numeric($val)) {
            $data[$key] = 0;
        }
    }
    // $vars["color_tab_black"]
    $bg_grey = _stats_color($vars["bg_grey"], 0);
    $bg_light_blue = _stats_color($vars["bg_light_blue"], 25);
    $graph = new Graph($width, $height);
    $group = new PlotGroup();
    $group->setSpace(2, 2);
    $group->grid->setType(LINE_DASHED);
    $group->grid->hideVertical(TRUE);
    $group->setPadding(30, 10, 25, 20);
    $graph->setBackgroundColor($bg_grey);
    $graph->title->set($stat);
    $graph->title->setFont(new Tuffy(10));
    $plot = new BarPlot($data, 1, 1, 0);
    $plot->setBarColor($bg_light_blue);
    $plot->label->set($data_orig);
    $plot->label->move(0, -5);
    $group->add($plot);
    $group->axis->bottom->setLabelText($labels);
    $group->axis->bottom->hideTicks(TRUE);
    $graph->add($group);
    $graph->draw($filename);
}
 public function draw($format = false)
 {
     /* Make sure we have GD support. */
     if (!function_exists('imagecreatefromjpeg')) {
         die;
     }
     if ($format === false) {
         $format = IMG_PNG;
     }
     $group = new PlotGroup();
     $graph = new Graph($this->width, $this->height);
     $graph->setFormat($format);
     $graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4));
     $graph->shadow->setSize(3);
     $graph->title->set($this->title);
     $graph->title->setFont(new Tuffy(10));
     $graph->title->setColor(new Color(0x0, 0x0, 0x8b));
     $graph->border->setColor(new Color(187, 187, 187, 15));
     $plot = new BarPlot($this->xValues);
     $plot->setBarColor(new $this->color());
     $plot->barBorder->hide(true);
     $plot->setBarGradient(new LinearGradient(new $this->color(), new White(), 0));
     $plot->setBarPadding(0.2, 0.2);
     $group->axis->bottom->setLabelText($this->xLabels);
     $group->axis->bottom->label->setFont(new Tuffy(8));
     $plot2 = new LinePlot($this->xValues, LinePlot::MIDDLE);
     $plot2->setColor(new DarkBlue());
     $plot2->setThickness(1);
     if (GRAPH_TREND_LINES) {
         $group->add($plot2);
     }
     $group->add($plot);
     $graph->add($group);
     $graph->draw();
 }
Example #3
0
 public function create()
 {
     $group = new PlotGroup();
     $group->setSpace(2, 2, 2, 0);
     $group->setPadding(30, 10, NULL, NULL);
     $group->grid->hideVertical(TRUE);
     $group->grid->setType(Line::DASHED);
     $yForeground = $this->getArg('yForeground');
     $yBackground = $this->getArg('yBackground');
     $legendForeground = $this->getArg('legendForeground');
     $legendBackground = $this->getArg('legendBackground');
     $colorForeground = $this->getArg('colorForeground', new LightBlue(10));
     $colorBackground = $this->getArg('colorBackground', new Orange(25));
     if ($yForeground === NULL) {
         trigger_error("Argument 'yForeground' must not be NULL", E_USER_ERROR);
     }
     // Background
     if ($yBackground !== NULL) {
         $plot = $this->getPlot($yBackground, 6);
         $plot->setBarColor($colorBackground);
         $group->add($plot);
         if ($legendBackground !== NULL) {
             $group->legend->add($plot, $legendBackground, Legend::BACKGROUND);
         }
     }
     // Foreground
     $plot = $this->getPlot($yForeground, 0);
     $plot->setBarColor($colorForeground);
     $group->add($plot);
     if ($legendForeground !== NULL) {
         $group->legend->add($plot, $legendForeground, Legend::BACKGROUND);
     }
     $group->axis->bottom->hideTicks(TRUE);
     $group->legend->shadow->setSize(0);
     $group->legend->setAlign(Legend::CENTER);
     $group->legend->setSpace(6);
     $group->legend->setTextFont(new Tuffy(8));
     $group->legend->setPosition(0.5, 0.1);
     $group->legend->setBackgroundColor(new Color(255, 255, 255, 10));
     $group->legend->setColumns(2);
     return $group;
 }
Example #4
0
 function create()
 {
     $group = new PlotGroup();
     $group->setSpace(2, 2, 2, 0);
     $group->setPadding(30, 10, NULL, NULL);
     $group->grid->hideVertical(TRUE);
     $group->grid->setType(LINE_DASHED);
     $yForeground = $this->getArg('yForeground');
     $yBackground = $this->getArg('yBackground');
     $legendForeground = $this->getArg('legendForeground');
     $legendBackground = $this->getArg('legendBackground');
     $colorForeground = $this->getArg('colorForeground', new LightBlue(10));
     $colorBackground = $this->getArg('colorBackground', new Orange(25));
     if ($yForeground === NULL) {
         awImage::drawError("Class BarDepthPattern: Argument 'yForeground' must not be NULL.");
     }
     // Background
     if ($yBackground !== NULL) {
         $plot = $this->getPlot($yBackground, 6);
         $plot->setBarColor($colorBackground);
         $group->add($plot);
         if ($legendBackground !== NULL) {
             $group->legend->add($plot, $legendBackground, LEGEND_BACKGROUND);
         }
     }
     // Foreground
     $plot = $this->getPlot($yForeground, 0);
     $plot->setBarColor($colorForeground);
     $group->add($plot);
     if ($legendForeground !== NULL) {
         $group->legend->add($plot, $legendForeground, LEGEND_BACKGROUND);
     }
     $group->axis->bottom->hideTicks(TRUE);
     $group->legend->shadow->setSize(0);
     $group->legend->setAlign(LEGEND_CENTER);
     $group->legend->setSpace(6);
     $group->legend->setTextFont(new Tuffy(8));
     $group->legend->setPosition(0.5, 0.1);
     $group->legend->setBackgroundColor(new Color(255, 255, 255, 10));
     $group->legend->setColumns(2);
     return $group;
 }
Example #5
0
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
require_once "../../BarPlot.class.php";
$graph = new Graph(600, 250);
$graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4));
$graph->shadow->setSize(3);
$graph->title->set("Evolution");
$graph->title->setFont(new Tuffy(15));
$graph->title->setColor(new Color(0x0, 0x0, 0x8b));
$group = new PlotGroup();
$group->setSize(0.82, 1);
$group->setCenter(0.41, 0.5);
$group->setPadding(35, 26, 40, 27);
$group->setSpace(2, 2);
$group->grid->setColor(new Color(0xc4, 0xc4, 0xc4));
$group->grid->setType(LINE_DASHED);
$group->grid->hideVertical(TRUE);
$group->grid->setBackgroundColor(new White());
$group->axis->left->setColor(new DarkGreen());
$group->axis->left->label->setFont(new Font2());
$group->axis->right->setColor(new DarkBlue());
$group->axis->right->label->setFont(new Font2());
$group->axis->bottom->label->setFont(new Font2());
$group->legend->setPosition(1.18);
$group->legend->setTextFont(new Tuffy(8));
<?php

require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$group = new PlotGroup();
$group->setBackgroundColor(new VeryLightGray());
$group->setPadding(30, 30, 30, 30);
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.5, 0.62);
$group->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
function getCircle($size)
{
    $center = 0;
    $x = array();
    $y = array();
    for ($i = 0; $i <= 30; $i++) {
        $rad = $i / 30 * 2 * M_PI;
        $x[] = $center + cos($rad) * $size;
        $y[] = $center + sin($rad) * $size;
    }
    return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue());
$plot->mark->setFill(new DarkPink());
$plot->mark->setType(MARK_CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', LEGEND_MARK);
$group->add($plot);
list($x, $y) = getCircle(5);
$plot = new ScatterPlot($y, $x);
Example #7
0
function CreeGraphClassementZoom($fichier)
{
    // Initialement, ces variables étaient passés dans la session
    // $G_listeJeux=$_SESSION['G_listeJeuxZoom'];
    // $G_listeJoueurs=$_SESSION['G_listeJoueursZoom'];
    // $G_listeResultats=$_SESSION['G_listeResultatsZoom'];
    // $G_MesCouleurs=$_SESSION['G_mesCouleurs'];
    global $G_ListeJeuxZoom;
    global $G_MesCouleurs;
    global $G_ListeResultatsMoyensZoom;
    global $G_ListeJoueurs;
    // Le niveau de transparence est définit à 95%
    // Ici, le graphique mesurera 620 x 700 pixels.
    $graph = new Graph(620, 700);
    // L'anti-aliasing permet d'afficher des courbes plus naturelles,
    // mais cette option consomme beaucoup de ressources sur le serveur.
    $graph->setAntiAliasing(TRUE);
    // Titre du graphe !
    $graph->title->set("Zoom sur les quatre dernières moyennes");
    // L'objet group permet de gérer plusieurs courbes sur un même grpahiques
    $group = new PlotGroup();
    // Le style des lignes des courbes est dashed
    $group->grid->setType(LINE_DASHED);
    // La marge gauche est fixée à 40px du bord, droite à 20, haut à 40px et basse à 120px
    $group->setPadding(40, 20, 40, 120);
    // Le titre sur les absisses est : % Réussite
    $group->axis->left->title->set("% Reussite");
    $group->setYAxisZero(false);
    // Les libellés sur les absisses sont inclinés de 45%
    $group->axis->bottom->label->setAngle(45);
    // Affiche 10 marques entre 2 marques majeures
    $group->axis->left->setNumberByTick('minor', 'major', 10);
    // Titre des ordonnées
    //$group->axis->bottom->title->set("Journées");
    // La légende est affiché en bas du graphe
    $group->legend->setModel(LEGEND_MODEL_BOTTOM);
    // Position de la légénde par rapport au graphe
    $group->legend->setPosition(NULL, 0.9);
    // Nb de colonnes
    $group->legend->setRows(2);
    //$group->legend->shadow->hide();
    // On créé autant de courbes qu'il y a de joueurs !
    for ($j = 0; $j < sizeof($G_ListeJoueurs); $j++) {
        // Recherche des résultats du joueur $j
        $G_ResultatJoueur = array();
        for ($k = 0; $k < sizeof($G_ListeJeuxZoom); $k++) {
            if (isset($G_ListeResultatsMoyensZoom[$k][$j])) {
                $G_ResultatJoueur[$k] = $G_ListeResultatsMoyensZoom[$k][$j];
            } else {
                $G_ResultatJoueur[$k] = null;
            }
        }
        // Création d'une courbe pour ce joueur
        $plot = new LinePlot($G_ResultatJoueur);
        $plot->setColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2]));
        $plot->setFillColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2], NIVEAU_TRANSPARENCE));
        $plot->mark->setType(MARK_CIRCLE);
        if ($j % 3 == 0) {
            $plot->mark->setType(MARK_TRIANGLE);
        }
        if ($j % 4 == 0) {
            $plot->mark->setType(MARK_CROSS);
        }
        $plot->mark->setFill(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2]));
        $plot->mark->setSize(7);
        $plot->yAxis->setLabelNumber(0.5);
        // $plot->xAxis->label->setAngle(45);
        $plot->setPadding(10, 10, 10, 10);
        // Ajoute d'une légende pour cette courbe et ce joueur
        $group->legend->add($plot, $G_ListeJoueurs[$j], LEGEND_MARK);
        // Ajoute cette courbe au group
        $group->add($plot);
    }
    // Fonction qui retourne les Abscisses
    function setAbscisseZoom($value)
    {
        global $G_ListeJeuxZoom;
        return $G_ListeJeuxZoom[$value];
    }
    $group->axis->bottom->label->setCallbackFunction('setAbscisseZoom');
    // Fonction qui retourne les Ordonnés
    function setOrdonneZoom($value)
    {
        return round($value);
    }
    $group->axis->left->label->setCallbackFunction('setOrdonneZoom');
    // Ajout de ce groupe au graphique
    $graph->add($group);
    $graph->draw($fichier);
}
Example #8
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$group = new PlotGroup();
$group->grid->hide(TRUE);
$group->setSpace(2, 2, 20, 0);
$group->setPadding(30, 10, NULL, NULL);
$colors = array(new Orange(25), new LightBlue(10));
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 3 - $n * 3; $i++) {
        $x[] = NULL;
    }
    for ($i = 3 - $n * 3; $i < 12 - $n * 3; $i++) {
        $x[] = cos($i * M_PI / 100) * mt_rand(800, 1200) / 1000 * (((1 - $n) * 5 + 10) / 10);
    }
    for ($i = 0; $i < $n * 3; $i++) {
        $x[] = NULL;
    }
    $plot = new BarPlot($x, 1, 1, (1 - $n) * 6);
    //	$plot->setBarPadding(2, 2);
Example #9
0
/**
* Формирование графика.
*
* Функция формирует, а затем записывает в файл ($File) изображение графика по
* переданным пользователем данным($Lines). Данная функция может рисовать как одиночные,
* так и многолинейные графики.Исходными данными является массив, элементы которого также
* является массивами исходных данных для соответствующих графиков (данная структура
* сохраняется и для одиночных графиков!). Цвет каждой линии передается в массиве
* $Colors, ключи которого совпадают с ключами массива исходных данных. Цвет задается
* шестнадцатиричным кодом цвета (например, 0x000000 для черного цвета).
*
* @param string  <заголовок диаграммы>
* @param string  <полный путь с именем файла-результата>
* @param array   <исходные данные>
* @param array   <подписи к оси Ox>
* @param array   <цвета линий>
*/
function Artichow_Line($Name, $File, $Lines, $Labels, $Colors)
{
    #-----------------------------------------------------------------------------
    $Graph = new Graph(1000, 300);
    $Graph->setDriver('gd');
    $Graph->setAntiAliasing(TRUE);
    #-----------------------------------------------------------------------------
    $Graph->title->set($Name);
    $Graph->title->setFont(new Tuffy(15));
    $Graph->title->move(0, -5);
    #-----------------------------------------------------------------------------
    if (Count($Lines) > 1) {
        #---------------------------------------------------------------------------
        $Group = new PlotGroup();
        $Group->setPadding(40, 40);
        $Group->setBackgroundColor(new Color(240, 240, 240));
    }
    #-----------------------------------------------------------------------------
    $IsSetLabel = FALSE;
    #-----------------------------------------------------------------------------
    foreach ($Lines as $LineID => $Line) {
        #---------------------------------------------------------------------------
        $Plot = new LinePlot($Line);
        $Color = Color_RGB_Explode($Colors[$LineID]);
        $Plot->setColor(new Color($Color['R'], $Color['G'], $Color['B']));
        $Plot->setThickness(1);
        $Plot->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240), new Color(255, 255, 255), 0));
        $Plot->setFillGradient(new LinearGradient(new LightOrange(10), new VeryLightOrange(90), 90));
        $Plot->setPadding(50, 50, 50, 50);
        #---------------------------------------------------------------------------
        $Plot->mark->setType(Mark::CIRCLE);
        $Plot->mark->setSize(5);
        #---------------------------------------------------------------------------
        $Plot->label->set($Line);
        $Plot->label->move(0, -15);
        $Plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0));
        $Plot->label->border->setColor(new Color(20, 20, 20, 20));
        $Plot->label->setPadding(2, 2, 2, 2);
        #---------------------------------------------------------------------------
        if (Count($Lines) < 2) {
            #-------------------------------------------------------------------------
            $Plot->xAxis->setLabelText($Labels);
            $Plot->yAxis->setLabelPrecision(1);
        } else {
            #-------------------------------------------------------------------------
            if (!$IsSetLabel) {
                #-----------------------------------------------------------------------
                $Plot->setXAxis(Plot::BOTTOM);
                $IsSetLabel = TRUE;
            }
        }
        #---------------------------------------------------------------------------
        if (Count($Lines) > 1) {
            $Group->add($Plot);
        }
        #---------------------------------------------------------------------------
        if (Count($Lines) > 1) {
            #-------------------------------------------------------------------------
            $Graph->add($Group);
            #-------------------------------------------------------------------------
            $Group->axis->bottom->setTickStyle(0);
            $Group->axis->bottom->setLabelText($Labels);
        } else {
            $Graph->add($Plot);
        }
    }
    #-----------------------------------------------------------------------------
    $Graph->draw($File);
    #-----------------------------------------------------------------------------
    return TRUE;
}
Example #10
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->grid->setType(LINE_DASHED);
$group->setPadding(40, NULL, 20, NULL);
$group->axis->left->setLabelNumber(8);
$group->axis->left->setLabelPrecision(1);
$group->axis->left->setTickStyle(TICK_OUT);
$x = array(2, 4, 8, 16, 32, 48, 56, 60, 62);
$plot = new LinePlot($x);
$plot->setColor(new Orange());
$plot->setFillColor(new LightOrange(80));
$plot->mark->setType(MARK_CIRCLE);
$plot->mark->setFill(new MidRed());
$plot->mark->setSize(6);
$group->legend->add($plot, "John", LEGEND_MARK);
$group->add($plot);
$x = array(NULL, NULL, NULL, 10, 12, 14, 18, 26, 42);
$plot = new LinePlot($x);
$plot->setColor(new Color(120, 120, 30, 10));
$plot->setFillColor(new Color(120, 120, 60, 90));
Example #11
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
$graph = new Graph(280, 280);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(6, 6, 5, 5);
$group->setBackgroundGradient(new LinearGradient(new Color(235, 235, 235), new White(), 0));
$group->setPadding(40, 10, 10, 50);
$group->axis->left->setLabelPrecision(2);
$group->axis->bottom->label->hide(TRUE);
$group->axis->bottom->hideTicks(TRUE);
$group->grid->setType(LINE_DASHED);
$group->grid->hideHorizontal(TRUE);
$gradients = array(new LinearGradient(new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0), new LinearGradient(new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0), new LinearGradient(new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0));
for ($n = 0; $n < 3; $n++) {
    $x = array();
    for ($i = 0; $i < 6; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0);
    }
    $plot = new BarPlot($x, $n + 1, 3);
    $plot->setXAxis(PLOT_BOTTOM);
    $plot->barShadow->setSize(1);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
Example #12
0
    $k++;
}
/*
$call_matiere = mysql_query("SELECT nom_complet FROM matieres WHERE matiere = '".$temp3[$i]."'");
$etiquettex[$i] = old_mysql_result($call_matiere, "0", "nom_complet");
*/
$etiquettex[$i]=$temp3[$i];
$i++;
}


        $graph = new Graph(600, 400);
        $graph->setAntiAliasing(TRUE);
        $blue = new Color(0, 0, 200);
        $red = new Color(200, 0, 0);
        $group = new PlotGroup();
        $group->setPadding(40, 40,60,100);
        $group->setBackgroundColor(
            new Color(240, 240, 240)
        );

        $k = 1;
        while ($k < $nb_data) {

            $plot = new BarPlot($datay1[$k], $k, $nb_data-1);

            $plot->barBorder->setColor(new Color(0, 0, 0, 30));

            $plot->setBarPadding(0.1, 0.1);
            $plot->setBarSpace(0);
Example #13
0
	/**
	 * 		Build a graph onto disk using Artichow library
	 *    	@param      file    Image file name on disk
	 */
	function draw_artichow($file)
	{
		dol_syslog("DolGraph.class::draw_artichow this->type=".$this->type);

		if (! defined('SHADOW_RIGHT_TOP'))  define('SHADOW_RIGHT_TOP',3);
		if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
		if (! defined('LEGEND_LINE'))       define('LEGEND_LINE',1);

		// Create graph
		$classname='';
		if ($this->type == 'bars')  $classname='BarPlot';
		if ($this->type == 'lines') $classname='LinePlot';
		include_once DOL_DOCUMENT_ROOT."/includes/artichow/".$classname.".class.php";

		// Definition de couleurs
		$bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
		$bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
		$colortrans=new Color(0,0,0,100);
		$colorsemitrans=new Color(255,255,255,60);
		$colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
		$colorwhite=new Color(255,255,255);

		// Graph
		$graph = new Graph($this->width, $this->height);
		$graph->border->hide();
		$graph->setAntiAliasing(true);
		if (isset($this->title))
		{
			$graph->title->set($this->title);
			$graph->title->setFont(new Tuffy(10));
		}

		if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor);
		else $graph->setBackgroundGradient($colorgradient);

		$group = new PlotGroup;
		//$group->setSpace(5, 5, 0, 0);

		$paddleft=50;
		$paddright=10;
		$strl=dol_strlen(max(abs($this->MaxValue),abs($this->MinValue)));
		if ($strl > 6) $paddleft += ($strln * 4);
		$group->setPadding($paddleft, $paddright);		// Width on left and right for Y axis values
		$group->legend->setSpace(0);
		$group->legend->setPadding(2,2,2,2);
		$group->legend->setPosition(NULL,0.1);
		$group->legend->setBackgroundColor($colorsemitrans);

		if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid);
		else $group->grid->setBackgroundColor($colortrans);

		if ($this->hideXGrid)	$group->grid->hideVertical(true);
		if ($this->hideYGrid)	$group->grid->hideHorizontal(true);

		// On boucle sur chaque lot de donnees
		$legends=array();
		$i=0;
		$nblot=sizeof($this->data[0])-1;

		while ($i < $nblot)
		{
			$j=0;
			$values=array();
			foreach($this->data as $key => $valarray)
			{
				$legends[$j] = $valarray[0];
				$values[$j]  = $valarray[$i+1];
				$j++;
			}

			// Artichow ne gere pas les valeurs inconnues
			// Donc si inconnu, on la fixe a null
			$newvalues=array();
			foreach($values as $val)
			{
				$newvalues[]=(is_numeric($val) ? $val : null);
			}


			if ($this->type == 'bars')
			{
				//print "Lot de donnees $i<br>";
				//print_r($values);
				//print '<br>';

				$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
				$colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50);

				$colorgrey=new Color(100,100,100);
				$colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);

				if ($this->mode == 'side')  $plot = new BarPlot($newvalues, $i+1, $nblot);
				if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);

				$plot->barBorder->setColor($colorgrey);
				//$plot->setBarColor($color);
				$plot->setBarGradient( new LinearGradient($colorbis, $color, 90) );

				if ($this->mode == 'side')  $plot->setBarPadding(0.1, 0.1);
				if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4);
				if ($this->mode == 'side')  $plot->setBarSpace(5);
				if ($this->mode == 'depth') $plot->setBarSpace(2);

				$plot->barShadow->setSize($this->SetShading);
				$plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
				$plot->barShadow->setColor(new Color(160, 160, 160, 50));
				$plot->barShadow->smooth(TRUE);
				//$plot->setSize(1, 0.96);
				//$plot->setCenter(0.5, 0.52);

				// Le mode automatique est plus efficace
				$plot->SetYMax($this->MaxValue);
				$plot->SetYMin($this->MinValue);
			}

			if ($this->type == 'lines')
			{
				$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
				$colorbis=new Color(min($this->datacolor[$i][0]+20,255),min($this->datacolor[$i][1]+20,255),min($this->datacolor[$i][2]+20,255),60);
				$colorter=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),90);

				$plot = new LinePlot($newvalues);
				//$plot->setSize(1, 0.96);
				//$plot->setCenter(0.5, 0.52);

				$plot->setColor($color);
				$plot->setThickness(1);

				// Set line background gradient
				$plot->setFillGradient( new LinearGradient($colorter, $colorbis, 90) );

				$plot->xAxis->setLabelText($legends);

				// Le mode automatique est plus efficace
				$plot->SetYMax($this->MaxValue);
				$plot->SetYMin($this->MinValue);
				//$plot->setYAxis(0);
				//$plot->hideLine(true);
			}

			//$plot->reduce(80);		// Evite temps d'affichage trop long et nombre de ticks absisce satures

			$group->legend->setTextFont(new Tuffy(10)); // This is to force Artichow to use awFileFontDriver to
														// solve a bug in Artichow with UTF8
			if (sizeof($this->Legend))
			{
				if ($this->type == 'bars')  $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND);
				if ($this->type == 'lines') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
			}
			$group->add($plot);

			$i++;
		}

		$group->axis->bottom->setLabelText($legends);
		$group->axis->bottom->label->setFont(new Tuffy(7));

		//print $group->axis->bottom->getLabelNumber();
		if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval);

		$graph->add($group);

		// Generate file
		$graph->draw($file);
	}
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function labelFormat($value)
{
    return round($value, 2);
}
$graph = new Graph(500, 400);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(5, 5, 15, 15);
$group->setPadding(40, 40, 25, 25);
$group->axis->left->setLabelPrecision(2);
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 6; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0) + 0.3;
    }
    $plot = new BarPlot($x, floor($n / 2) + 1, 2, ($n % 2 === 0) * 6);
    $plot->barBorder->setColor(color());
    $plot->setBarSpace(12);
    $plot->barShadow->setSize(4);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
    $plot->barShadow->setColor(new Color(180, 180, 180, 10));
    $plot->barShadow->smooth(TRUE);
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setBackgroundGradient(new LinearGradient(new Color(200, 200, 200), new Color(240, 240, 240), 0));
$group->setPadding(40, 40, 25, 25);
$group->setXAxisZero((bool) mt_rand(0, 1));
if (mt_rand(0, 1)) {
    $group->setYMax(0);
}
$group->axis->left->setLabelPrecision(2);
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 5; $i++) {
        $x[] = cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5 - 1;
    }
    $plot = new BarPlot($x, $n + 1, 4);
    $plot->barBorder->hide();
    $plot->setBarPadding(0.2, 0.2);
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(3, 3, 5, 5);
$group->setBackgroundGradient(new LinearGradient(new Color(200, 200, 200), new Color(240, 240, 240), 0));
$group->setPadding(NULL, NULL, 25, 25);
$group->axis->left->setLabelPrecision(2);
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 5; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0);
    }
    $plot = new BarPlot($x, $n + 1, 4);
    $plot->barBorder->hide();
    $plot->setXAxis(PLOT_TOP);
    $plot->barShadow->setSize(4);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
    $plot->barShadow->setColor(new Color(255, 255, 255, 20));
Example #17
0
' A B C+C-D E'
);

while ($i < $nb_data) {
    $values[$i]=array();
    $values[$i][0]=$_GET['temp'.$i];
    array_push($all_values,$values[$i][0]);
    $colors[$i] = new Color(180, 180, 180, 10);
    $i++;
}
$max=max($all_values);
if ($place_eleve != "") $colors[$place_eleve]= new Color(0, 0, 0, 0);
$graph = new Graph(150, 150);
//$graph->SetSize();
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$k = 1;
while ($k < $nb_data) {
    $plot = new BarPlot($values[$k], $k, $nb_data-1);
    $plot->setBarColor($colors[$k]);
    $plot->setBarSize(1);
    $plot->setYMax($max);
    $group->add($plot);
    $k++;
}

$group->axis->left->hide(TRUE);
$group->axis->bottom->hide(TRUE);
//$group->axis->bottom->setNumberByTick('minor','major', 0);
//$group->axis->bottom->setLabelNumber(count($etiquettex));
//$group->axis->bottom->setLabelText($etiquettex);
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setXAxisZero(FALSE);
$group->grid->setType(LINE_DASHED);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(40, NULL, 20, NULL);
$group->axis->left->setLabelNumber(8);
$group->axis->left->setLabelPrecision(1);
$group->axis->left->setTickStyle(TICK_OUT);
$x = array(NULL);
for ($i = 1; $i < 10; $i++) {
    $x[] = cos($i * M_PI / 8) - 1;
}
$plot = new LinePlot($x);
$plot->setXAxis(PLOT_TOP);
$plot->setColor(new Color(40, 40, 150, 10));
$plot->setFillColor(new Color(40, 40, 150, 90));
$plot->mark->setType(MARK_BOOK);
$plot->mark->move(mt_rand(0, 10), mt_rand(0, 10));
$group->add($plot);
Example #19
0
function dis_chart_bar_multiple($chart) {
  global $chart_colors;

  $title = $chart["title"];
  $xlabels = $chart["xlabels"];
  $values = $chart["plots"]["values"];
  $labels = $chart["plots"]["labels"];
  $legends = $chart["plots"]["legends"];
  $new_bar = $chart["plots"]["new_bar"];

  $graph = new Graph(600, 250);
  $graph->setAntiAliasing(TRUE);
  $graph->setBackgroundColor(new Color(240, 240, 240));
  $group = new PlotGroup;
  $group->grid->hideVertical();
  $group->setPadding(45, 22 ,30, 40);
  $group->setSpace(3, 3, NULL, NULL);
  $group->legend->setAlign(NULL, LEGEND_TOP);
  $group->legend->setPosition(1,0);

  // X axis Labels infos
  $xlabel = new Label($xlabels);
  $group->axis->bottom->setlabelText($xlabels);

  // Title infos
  if ($title != "") {
    $graph->title->set("$title");
  }

  $num = 0;
  $nb_bars = array_sum($new_bar);
  $num_bar = 0;

  // $num_plot is the plot number
  // $num_bar is the bar number (1 bar can cumul more than one plot)
  foreach ($values as $num_plot => $plot_values) {
    // Chart infos : colors, size, shadow
    if ($new_bar[$num_plot] == 1) {
      $num_bar++;
    }
    $plot = new BarPlot($plot_values, $num_bar, $nb_bars);
    $plot->setBarColor(new Color($chart_colors[$num_plot][0], $chart_colors[$num_plot][1], $chart_colors[$num_plot][2]));
    $plot->setBarSize(0.6);
    if ($new_bar[$num_plot] == 1) {
      $plot->barShadow->setSize(2);
      $plot->barShadow->smooth(TRUE);
      // Labels infos
      $label = new Label($labels[$num_plot]);
      $label->setFont(new Tuffy(8));
      $label->setAlign(NULL, LABEL_TOP);
      $plot->label = $label;
    }
    $group->add($plot);
    $group->legend->add($plot, utf8_decode($legends[$num_plot]), LEGEND_BACKGROUND);
  }

  $graph->add($group);
  $graph->draw();
}
require_once "../../LinePlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function getPerCent($value)
{
    return sprintf('%.1f', $value) . ' %';
}
$graph = new Graph(450, 400);
$graph->setTiming(TRUE);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setBackgroundColor(color(80));
$group->setXAxisZero(FALSE);
$group->title->set("Some lines");
$group->title->setBackgroundColor(new Color(255, 255, 255, 25));
$group->title->border->show();
$group->title->setPadding(3, 3, 3, 3);
$group->title->move(0, -15);
$group->setPadding(45, NULL, 45, NULL);
$group->axis->left->setLabelNumber(mt_rand(0, 10));
$group->axis->left->label->setCallbackFunction('getPerCent');
foreach (array('left', 'right') as $axis) {
    $group->axis->{$axis}->setTickStyle(TICK_OUT);
}
foreach (array('top', 'bottom') as $axis) {
    $group->axis->{$axis}->setTickStyle(TICK_OUT);
Example #21
0
    $val_biz[0] = ($val_ytd[0] + $val_prv[0]) / 2 + wdiff($val_ytd[0], mdays(1), $val_prv[11], 30);
} else {
    $val_biz[0] = 0;
}
for ($i = 1; $i < 12; $i++) {
    if (isset($val_ytd[$i]) && isset($val_prv[$i]) && isset($val_ytd[$i - 1]) && isset($val_prv[$i - 1])) {
        $val_biz[$i] = ($val_ytd[$i] + $val_prv[$i]) / 2 + wdiff($val_ytd[$i], mdays($i + 1), $val_ytd[$i - 1], mdays($i)) - wdiff($val_prv[$i], 30, $val_prv[$i - 1], 30) / 2;
    } else {
        $val_biz[$i] = 0;
    }
}
function FmtAmount($val)
{
    return abs($val) >= 1000000 ? '$' . round($val / 1000000, 1) . 'M' : abs($val) >= 1000 ? '$' . round($val / 1000, 1) . 'K' : '$' . round($val, 1);
}
$grp = new PlotGroup();
$grp->setPadding(make_num('pad_left', 50), make_num('pad_right', 50), make_num('pad_top', NULL), make_num('pad_bottom', NULL));
$max_val_ytd = $val_ytd ? max($val_ytd) : 0;
$max_val_prv = $val_prv ? max($val_prv) : 0;
$max = max(1.05 * $max_val_ytd, 1.05 * $max_val_prv);
$min_val_ytd = $val_ytd ? min($val_ytd) : 0;
$min = min(0, $min_val_ytd);
$pwr_qty = 1;
while ($qty_max > 99) {
    $qty_max /= 10;
    $pwr_qty *= 10;
}
$qty_max = $pwr_qty * ceil($qty_max / 5) * 5;
$qty_step = $qty_max / 5;
$qty_min = -ceil(-$qty_min / $qty_step) * $qty_step;
$qty_min = 0;
Example #22
0
     $plot->setCenter(0.4, 0.55);
     $plot->setSize(0.65, 0.7);
     $plot->set3D(10);
     $plot->setLabelPosition(10);
     $plot->setLegend($keys);
     $plot->legend->setPosition(1.37);
     $plot->legend->shadow->setSize(0);
     $plot->legend->setBackgroundColor(new Color(235, 235, 235));
     $graph->add($plot);
 } else {
     if ($type == "line" or $type == "linesteps") {
         require INCLUDE_PATH . "/LinePlot.class.php";
         $graph = new Graph($width, $height);
         $graph->title->set($title);
         $graph->title->setFont(new Tuffy(11));
         $group = new PlotGroup();
         $group->setSpace(1, 0);
         $group->setPadding(25, 15, 27, 20);
         $group->grid->setType(LINE_DASHED);
         $group->grid->hideVertical(TRUE);
         if ($type == "linesteps") {
             list($data_new, $data_label, $keys_new) = build_line_steps($width, $data, $keys);
         } else {
             $data_new = $data;
             $data_label = $data;
             $keys_new = $keys;
         }
         $plot = new LinePlot($data_new);
         $plot->setColor(new Color(0, 0, 255));
         $plot->setFillColor(new LightBlue(40));
         $plot->label->set($data_label);
Example #23
0
      'Mardi',
      'Mercredi',
      'Jeudi',
      'Vendredi',
      'Samedi',
      'Dimanche'
   );

//$graph = new Graph(388, 200);
$graph = new Graph(370, 200);

   // définition des couleur bleu et rouge
   $bleu = new Color(0, 0, 200);
   $rouge = new Color(200, 0, 0);

   $group = new PlotGroup;
   // padding du graphique
   $group->setPadding(40, 40);
   // décalement du 0 et de la fin
//   $group->setSpace(4, 4, 10, 0);
   // couleur de fond du graphique
   $group->setBackgroundColor(
      new Color(255, 255, 255)
   );

//   $values_absences = array(12, 5, 20, 32, 15, 4, 12, 5, 20, 32, 15, 4);
	$values_absences = $_SESSION['axe_y_abs'];
//   $values_retards = array(1, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0);
	$values_retards = $_SESSION['axe_y_ret'];
//   $x = array('jan.', 'fev.', 'mar.', 'avr.', 'mai', 'jui.', 'juil.', 'aou.', 'sep.', 'oct.', 'nov.', 'dec.');
	$x = $_SESSION['axe_x'];
<?php

require_once "../../ScatterPlot.class.php";
$graph = new Graph(280, 280);
$graph->title->move(-40, 0);
$graph->title->set('Two circles');
$group = new PlotGroup();
$group->setBackgroundGradient(new LinearGradient(new VeryLightGray(), new Color(245, 245, 245), 0));
$group->setPadding(25, 20, 40, 15);
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.82, 0.1);
$group->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
function getCircle($size)
{
    $center = 0;
    $x = array();
    $y = array();
    for ($i = 0; $i <= 20; $i++) {
        $rad = $i / 20 * 2 * M_PI;
        $x[] = $center + cos($rad) * $size;
        $y[] = $center + sin($rad) * $size;
    }
    return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue());
$plot->mark->setFill(new DarkPink());
$plot->mark->setType(MARK_CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', LEGEND_MARK);
$group->add($plot);
Example #25
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Two bars');
$values = array(12, 8, 13, 2, 4);
$group = new PlotGroup();
$group->setPadding(NULL, NULL, 35, NULL);
$plot = new BarPlot($values, 1, 2);
$plot->setBarColor(new LightBlue(25));
$plot->setBarSpace(5);
$group->add($plot);
$values = array(1, 7, 2, 10, 6);
$plot = new BarPlot($values, 2, 2);
$plot->setBarColor(new LightOrange(25));
$plot->setBarSpace(5);
$group->add($plot);
$graph->add($group);
$graph->draw();
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
function color()
{
    return new Color(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 100));
}
$graph = new Graph(450, 400);
$graph->title->set('test of LINEPLOT_MIDDLE');
$graph->setAntiAliasing(TRUE);
$values = array();
for ($i = 0; $i < 5; $i++) {
    $values[] = mt_rand(4, 20);
}
$group = new PlotGroup();
$group->setSpace(5, 5, 5, 5);
$group->setBackgroundColor(new Color(240, 240, 240));
$plot = new LinePlot($values, LINEPLOT_MIDDLE);
$plot->setFillColor(color());
$plot->mark->setType(MARK_CIRCLE);
$plot->mark->setSize(mt_rand(1, 20));
$plot->mark->setFill(new Color(255, 255, 255));
$plot->mark->border->show();
$group->add($plot);
$graph->add($group);
$graph->draw();
Example #27
0
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function labelFormat($value)
{
    return round($value, 2);
}
$graph = new Graph(280, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(5, 5, 15, 0);
$group->setPadding(40, 40);
$group->axis->left->setLabelPrecision(2);
$group->axis->right->setLabelPrecision(2);
$colors = array(new Color(80, 105, 190, 10), new Color(105, 190, 80, 10));
$darkColor = array(new Color(40, 55, 120, 10), new Color(55, 120, 40, 10));
$axis = array(PLOT_LEFT, PLOT_RIGHT);
$group->axis->left->setColor($darkColor[0]);
$group->axis->left->label->setColor($darkColor[0]);
$group->axis->right->setColor($darkColor[1]);
$group->axis->right->label->setColor($darkColor[1]);
$group->setBackgroundGradient(new LinearGradient(new Color(225, 225, 225), new Color(255, 255, 255), 0));
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 4; $i++) {
Example #28
0
 /**
  * Build a graph onto disk using Artichow library
  *
  * @param	string	$file    	Image file name to use if we save onto disk
  * @param	string	$fileurl	Url path to show image if saved onto disk
  * @return	void
  */
 private function draw_artichow($file, $fileurl)
 {
     global $artichow_defaultfont;
     dol_syslog(get_class($this) . "::draw_artichow this->type=" . join(',', $this->type));
     if (!defined('SHADOW_RIGHT_TOP')) {
         define('SHADOW_RIGHT_TOP', 3);
     }
     if (!defined('LEGEND_BACKGROUND')) {
         define('LEGEND_BACKGROUND', 2);
     }
     if (!defined('LEGEND_LINE')) {
         define('LEGEND_LINE', 1);
     }
     // Create graph
     $classname = '';
     if (!isset($this->type[0]) || $this->type[0] == 'bars') {
         $classname = 'BarPlot';
     } else {
         if ($this->type[0] == 'lines') {
             $classname = 'LinePlot';
         } else {
             $classname = 'TypeUnknown';
         }
     }
     include_once ARTICHOW_PATH . $classname . '.class.php';
     // Definition de couleurs
     $bgcolor = new Color($this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]);
     $bgcolorgrid = new Color($this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
     $colortrans = new Color(0, 0, 0, 100);
     $colorsemitrans = new Color(255, 255, 255, 60);
     $colorgradient = new LinearGradient(new Color(235, 235, 235), new Color(255, 255, 255), 0);
     $colorwhite = new Color(255, 255, 255);
     // Graph
     $graph = new Graph($this->width, $this->height);
     $graph->border->hide();
     $graph->setAntiAliasing(true);
     if (isset($this->title)) {
         $graph->title->set($this->title);
         //print $artichow_defaultfont;exit;
         $graph->title->setFont(new $artichow_defaultfont(10));
     }
     if (is_array($this->bgcolor)) {
         $graph->setBackgroundColor($bgcolor);
     } else {
         $graph->setBackgroundGradient($colorgradient);
     }
     $group = new PlotGroup();
     //$group->setSpace(5, 5, 0, 0);
     $paddleft = 50;
     $paddright = 10;
     $strl = dol_strlen(max(abs($this->MaxValue), abs($this->MinValue)));
     if ($strl > 6) {
         $paddleft += $strl * 4;
     }
     $group->setPadding($paddleft, $paddright);
     // Width on left and right for Y axis values
     $group->legend->setSpace(0);
     $group->legend->setPadding(2, 2, 2, 2);
     $group->legend->setPosition(NULL, 0.1);
     $group->legend->setBackgroundColor($colorsemitrans);
     if (is_array($this->bgcolorgrid)) {
         $group->grid->setBackgroundColor($bgcolorgrid);
     } else {
         $group->grid->setBackgroundColor($colortrans);
     }
     if ($this->hideXGrid) {
         $group->grid->hideVertical(true);
     }
     if ($this->hideYGrid) {
         $group->grid->hideHorizontal(true);
     }
     // On boucle sur chaque lot de donnees
     $legends = array();
     $i = 0;
     $nblot = count($this->data[0]) - 1;
     while ($i < $nblot) {
         $x = 0;
         $values = array();
         foreach ($this->data as $key => $valarray) {
             $legends[$x] = $valarray[0];
             $values[$x] = $valarray[$i + 1];
             $x++;
         }
         // We fix unknown values to null
         $newvalues = array();
         foreach ($values as $val) {
             $newvalues[] = is_numeric($val) ? $val : null;
         }
         if ($this->type[0] == 'bars') {
             //print "Lot de donnees $i<br>";
             //print_r($values);
             //print '<br>';
             $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20);
             $colorbis = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 50);
             $colorgrey = new Color(100, 100, 100);
             $colorborder = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
             if ($this->mode == 'side') {
                 $plot = new BarPlot($newvalues, $i + 1, $nblot);
             }
             if ($this->mode == 'depth') {
                 $plot = new BarPlot($newvalues, 1, 1, ($nblot - $i - 1) * 5);
             }
             $plot->barBorder->setColor($colorgrey);
             //$plot->setBarColor($color);
             $plot->setBarGradient(new LinearGradient($colorbis, $color, 90));
             if ($this->mode == 'side') {
                 $plot->setBarPadding(0.1, 0.1);
             }
             if ($this->mode == 'depth') {
                 $plot->setBarPadding(0.1, 0.4);
             }
             if ($this->mode == 'side') {
                 $plot->setBarSpace(5);
             }
             if ($this->mode == 'depth') {
                 $plot->setBarSpace(2);
             }
             $plot->barShadow->setSize($this->SetShading);
             $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
             $plot->barShadow->setColor(new Color(160, 160, 160, 50));
             $plot->barShadow->smooth(TRUE);
             //$plot->setSize(1, 0.96);
             //$plot->setCenter(0.5, 0.52);
             // Le mode automatique est plus efficace
             $plot->SetYMax($this->MaxValue);
             $plot->SetYMin($this->MinValue);
         }
         if ($this->type[0] == 'lines') {
             $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20);
             $colorbis = new Color(min($this->datacolor[$i][0] + 20, 255), min($this->datacolor[$i][1] + 20, 255), min($this->datacolor[$i][2] + 20, 255), 60);
             $colorter = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 90);
             $plot = new LinePlot($newvalues);
             //$plot->setSize(1, 0.96);
             //$plot->setCenter(0.5, 0.52);
             $plot->setColor($color);
             $plot->setThickness(1);
             // Set line background gradient
             $plot->setFillGradient(new LinearGradient($colorter, $colorbis, 90));
             $plot->xAxis->setLabelText($legends);
             // Le mode automatique est plus efficace
             $plot->SetYMax($this->MaxValue);
             $plot->SetYMin($this->MinValue);
             //$plot->setYAxis(0);
             //$plot->hideLine(true);
         }
         //$plot->reduce(80);		// Evite temps d'affichage trop long et nombre de ticks absisce satures
         $group->legend->setTextFont(new $artichow_defaultfont(10));
         // This is to force Artichow to use awFileFontDriver to
         // solve a bug in Artichow with UTF8
         if (count($this->Legend)) {
             if ($this->type[0] == 'bars') {
                 $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND);
             }
             if ($this->type[0] == 'lines') {
                 $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE);
             }
         }
         $group->add($plot);
         $i++;
     }
     $group->axis->bottom->setLabelText($legends);
     $group->axis->bottom->label->setFont(new $artichow_defaultfont(7));
     //print $group->axis->bottom->getLabelNumber();
     if ($this->labelInterval > 0) {
         $group->axis->bottom->setLabelInterval($this->labelInterval);
     }
     $graph->add($group);
     // Generate file
     $graph->draw($file);
     $this->_stringtoshow = '<!-- Build using ' . $this->_library . ' --><img src="' . $fileurl . '" title="' . dol_escape_htmltag($this->title ? $this->title : $this->YLabel) . '" alt="' . dol_escape_htmltag($this->title ? $this->title : $this->YLabel) . '">';
 }
Example #29
0
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$group = new PlotGroup();
$group->setSpace(5, 10, 20, 15);
$group->setPadding(40, 10, NULL, 20);
$group->setXAxisZero(FALSE);
$group->axis->left->setLabelPrecision(2);
$colors = array(new Color(100, 180, 154, 12), new Color(100, 154, 180, 12), new Color(154, 100, 180, 12), new Color(180, 100, 154, 12));
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 6; $i++) {
        $x[] = cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 1400) / 1000 - 0.5;
    }
    $plot = new BarPlot($x, 1, 1, (3 - $n) * 7);
    $plot->barBorder->setColor(new Color(0, 0, 0));
    $plot->setBarSize(0.54);
    $plot->barShadow->setSize(3);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);