Beispiel #1
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) . '">';
 }
<?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(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array(1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4);
$plot = new LinePlot($x);
$plot->grid->setNobackground();
$plot->setPadding(20, 8, 8, 20);
$plot->setXAxisZero(FALSE);
// Set a background gradient
$plot->setBackgroundGradient(new LinearGradient(new Color(210, 210, 210), new Color(255, 255, 255), 0));
// Set semi-transparent background gradient
$plot->setFillGradient(new LinearGradient(new Color(230, 150, 150, 20), new Color(230, 230, 180, 50), 90));
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 2);
$graph->add($plot);
$graph->draw();
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = mt_rand(20, 80);
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400, "Abel", time() + 5);
$graph->setTiming(TRUE);
$graph->setAntiAliasing(TRUE);
$x = array();
for ($i = 0; $i < 10; $i++) {
    $x[] = mt_rand(0, 100);
}
$plot = new LinePlot($x);
$plot->setThickness(1);
$plot->setColor(color());
$plot->setFillGradient(new LinearGradient(color(), color(), 0));
$plot->grid->setType(LINE_DASHED);
$plot->setYMin(mt_rand(-20, 0));
$plot->yAxis->setLabelNumber(mt_rand(0, 10));
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 2);
$plot->setXAxisZero((bool) mt_rand(0, 1));
$graph->add($plot);
$graph->draw();
<?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(400, 300);
$graph->setAntiAliasing(TRUE);
$x = array(1, 2, 5, 0.5, 3, 8);
$plot = new LinePlot($x);
$plot->setSpace(6, 6, 10, 10);
$plot->setXAxisZero(FALSE);
// Set a background gradient
$plot->setBackgroundGradient(new LinearGradient(new Color(210, 210, 210), new Color(255, 255, 255), 0));
// Change line color
$plot->setColor(new Color(0, 0, 150, 20));
// Set line background gradient
$plot->setFillGradient(new LinearGradient(new Color(150, 150, 210), new Color(230, 230, 255), 90));
// Change mark type
$plot->mark->setType(MARK_CIRCLE);
$plot->mark->border->show();
$graph->add($plot);
$graph->draw();
Beispiel #5
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;
}
<?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";
// Use cache
$graph = new Graph(400, 400, "Example-006", time() + 5);
$graph->setTiming(TRUE);
$graph->setAntiAliasing(TRUE);
$x = array();
for ($i = 0; $i < 10; $i++) {
    $x[] = mt_rand(0, 100);
}
$plot = new LinePlot($x);
$plot->setColor(new Color(60, 60, 150));
$plot->setFillGradient(new LinearGradient(new Color(120, 175, 80, 47), new Color(231, 172, 113, 30), 0));
$plot->grid->setType(LINE_DASHED);
$plot->setYMin(-5);
$plot->yAxis->setLabelNumber(8);
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->setNumberByTick('minor', 'major', 3);
$plot->setXAxisZero(TRUE);
$graph->add($plot);
$graph->draw();
Beispiel #7
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);
	}
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400);
$graph->setTiming(TRUE);
$x = array();
for ($i = 0; $i < 10; $i++) {
    $x[] = mt_rand(-20, 100);
}
$plot = new LinePlot($x);
$plot->setPadding(NULL, 40, NULL, NULL);
$plot->setBackgroundColor(color(80));
$plot->setYAxis(PLOT_BOTH);
$plot->setColor(color());
if (mt_rand(0, 2) > 0) {
    $plot->setFillGradient(new LinearGradient(color(40), color(60), mt_rand(0, 1) * 90));
} else {
    $plot->setFillColor(color(64));
}
$plot->yAxis->setLabelNumber(mt_rand(0, 10));
$plot->yAxis->setLabelPrecision(1);
$plot->yAxis->title->set("Axis des Y : Quarante-deux");
$plot->xAxis->setTickInterval(2);
$plot->xAxis->setLabelInterval(2);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
$plot->label->set($x);
$plot->label->setInterval(mt_rand(1, 5));
$plot->label->setColor(color(0));
$plot->label->setBackgroundColor(new Color(mt_rand(180, 220), mt_rand(180, 220), mt_rand(180, 220), mt_rand(25, 35)));
$plot->label->border->setColor(color());
Beispiel #9
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(500, 100);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$x = array();
for ($i = 0; $i < 20; $i++) {
    $x[] = mt_rand(4, 12);
}
$plot = new LinePlot($x);
$plot->setSpace(0, 0, 50, 0);
$plot->setPadding(3, 3, 3, 3);
$plot->setBackgroundGradient(new LinearGradient(new Color(230, 230, 230), new Color(255, 255, 255), 0));
$plot->setColor(new Color(0, 0, 180, 20));
$plot->setFillGradient(new LinearGradient(new Color(220, 220, 230, 25), new Color(240, 240, 255, 25), 90));
$plot->xAxis->hide(TRUE);
$plot->yAxis->hide(TRUE);
$graph->add($plot);
$graph->draw();
<?php

require_once "../../LinePlot.class.php";
$graph = new Graph();
$graph->setSize(400, 400);
$x = array(1, 4, 3, -1, 1);
$plot = new LinePlot($x);
$plot->setXAxisZero(FALSE);
$plot->setFillGradient(new LinearGradient(new Color(255, 20, 20, 30), new Color(20, 255, 20, 30), 0));
$graph->shadow->setSize(50);
$graph->shadow->smooth(mt_rand(0, 1) ? TRUE : FALSE);
$graph->add($plot);
$graph->draw();
Beispiel #11
0
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 175);
$graph->setAntiAliasing(TRUE);
$x = array(4, 3, 1, 0, -2, 1, 3, 2, 3, 5, 4, 1);
$plot = new LinePlot($x);
$plot->setXAxisZero(FALSE);
$plot->grid->hide(TRUE);
$plot->title->set("Using dashed line and legend");
$plot->title->setFont(new TuffyItalic(9));
$plot->title->setBackgroundColor(new Color(255, 255, 255, 50));
$plot->title->setPadding(3, 3, 3, 3);
$plot->title->move(0, 20);
$plot->setSpace(6, 6, 10, 10);
$plot->setPadding(30, 10, 15, 25);
$plot->setBackgroundColor(new Color(245, 245, 245));
$plot->setStyle(LINE_DASHED);
$plot->setColor(new Color(0, 150, 0, 20));
$plot->setFillGradient(new LinearGradient(new Color(220, 220, 150, 40), new Color(255, 255, 210, 30), 0));
$graph->shadow->setSize(4);
$graph->shadow->setPosition(SHADOW_LEFT_BOTTOM);
$graph->shadow->smooth(TRUE);
$plot->legend->add($plot, "Apples");
$plot->legend->shadow->setSize(0);
$plot->legend->setAlign(LEGEND_CENTER, LEGEND_TOP);
$plot->legend->setPosition(0.75, 0.6);
$plot->legend->setTextFont(new Tuffy(8));
$graph->add($plot);
$graph->draw();
$plot->setPadding(20, 15, 10, 40);

$plot->setBackgroundGradient(
    new LinearGradient(
        new Color(210, 210, 210),
        new Color(255, 255, 255),
        0
    )
);

$plot->setColor(new Color(0, 0, 150, 20));

$plot->setFillGradient(
    new LinearGradient(
        new Color(150, 150, 210),
        new Color(245, 245, 245),
        0
    )
);

$plot->mark->setType(MARK_CIRCLE);
$plot->mark->border->show();

//$plot->yAxis->title->set("Nombre d'absences");
//$plot->yAxis->title->setFont(new Tuffy(10));

$plot->xAxis->setLabelText($x);
//$plot->xAxis->SetAngle(50);
$plot->xAxis->label->setFont(new Tuffy(8));
$plot->xAxis->label->setAngle("30");
$plot->xAxis->label->move(10, 0);
Beispiel #13
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";
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array(1, 2, 5, 4, 2, 3);
$plot = new LinePlot($x);
// Change component padding
$plot->setPadding(10, 12, 12, 7);
// Set a background gradient
$plot->setBackgroundGradient(new LinearGradient(new Color(230, 230, 230), new Color(255, 255, 255), 0));
// Change line background color
$plot->setFillGradient(new LinearGradient(new Color(200, 240, 215, 30), new Color(150, 190, 165, 30), 0));
// Hide grid
$plot->grid->hide(TRUE);
$plot->grid->setNobackground();
$plot->yAxis->label->hide(TRUE);
$plot->xAxis->label->hide(TRUE);
$plot->label->set($x);
$plot->label->setBackgroundColor(new Color(240, 240, 240, 10));
$plot->label->border->setColor(new Color(255, 0, 0, 15));
$plot->label->setPadding(3, 2, 0, 0);
$plot->label->setFont(new Font1());
$graph->add($plot);
$graph->draw();
    return $value . ' %';
}
foreach (array('top', 'bottom') as $axis) {
    $group->axis->{$axis}->label->hideLast(TRUE);
    $group->axis->{$axis}->label->hideFirst(TRUE);
    $group->axis->{$axis}->setLabelInterval(5);
    $group->axis->{$axis}->setTickStyle(TICK_OUT);
}
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 50; $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 LinePlot($x, mt_rand(0, 1) ? LINEPLOT_LINE : LINEPLOT_MIDDLE);
    $plot->setColor(color());
    $plot->setFillGradient(new LinearGradient(color(60), color(60), 90));
    $y = array();
    foreach ($x as $v) {
        $y[] = sprintf("%.2f", $v);
    }
    $plot->label->set($y);
    $plot->label->setColor(color(0));
    $plot->label->setBackgroundColor(new Color(mt_rand(220, 240), mt_rand(220, 240), mt_rand(220, 240), mt_rand(10, 20)));
    $plot->label->setPadding(1, 0, 0, 0);
    $plot->label->setInterval(12);
    $plot->label->setFont(new Tuffy(6));
    $plot->setXAxis(PLOT_BOTTOM);
    $plot->setYAxis(PLOT_LEFT);
    $group->add($plot);
    $group->legend->add($plot, "Line #" . ($n + 1));
}