コード例 #1
0
ファイル: LightLine.php プロジェクト: carriercomm/jbs
 public function create()
 {
     $legend = $this->getArg('legend');
     $y = $this->getArg('y');
     if ($y === NULL) {
         awImage::drawError("Class LightLinePattern: Argument 'y' must not be NULL.");
     }
     $plot = new LinePlot($y);
     $plot->setSize(0.7, 1);
     $plot->setCenter(0.35, 0.5);
     $plot->setPadding(35, 15, 35, 30);
     $plot->setColor(new Orange());
     $plot->setFillColor(new LightOrange(80));
     $plot->grid->setType(Line::DASHED);
     $plot->mark->setType(Mark::CIRCLE);
     $plot->mark->setFill(new MidRed());
     $plot->mark->setSize(6);
     $plot->legend->setPosition(1, 0.5);
     $plot->legend->setAlign(Legend::LEFT);
     $plot->legend->shadow->smooth(TRUE);
     if ($legend !== NULL) {
         $plot->legend->add($plot, $legend, Legend::MARK);
     }
     return $plot;
 }
コード例 #2
0
ファイル: jpgraph.php プロジェクト: boriscy/upsys
 /**
  *Funcion que crea graficas tipo Linea
  *@param array() $data Array en el cual estan los datos para Y array(1, 2.3, 3, 4)
  *@param string $legend Título de los datos de la línea
  *@param string $color Color de la linea
  *@param int $weight Grueso de la Linea
  */
 function Line($data, $legend = null, $color = '#000000', $weight = 1)
 {
     vendor('jpgraph/jpgraph_line');
     $line = new LinePlot($data);
     $line->setLegend($legend);
     $line->setColor($color);
     $line->setWeight($weight);
     #Adicion de linea a la grafica
     $this->graph->Add($line);
     if (strlen($legend) > $this->maxLength) {
         $this->maxLength = strlen($legend);
     }
 }
コード例 #3
0
 function process()
 {
     parent::process();
     $this->setPmvTitle($this->graph);
     $this->setPmvBackgroundGradient($this->graph);
     /**
      * group (bar + line)
      */
     $group = new PlotGroup();
     $this->setPmvGroupProperties($group);
     $group->axis->right->setColor(new Red());
     $group->axis->right->label->setFont(new Font2());
     /**
      * line
      */
     $plot = new LinePlot($this->y2, LINEPLOT_MIDDLE);
     $plot->setColor(new Red());
     $plot->setThickness(1);
     $plot->setYAxis(PLOT_RIGHT);
     $group->legend->add($plot, $this->y2Legend, LEGEND_MARK);
     $group->add($plot);
     /**
      * vertical bar
      */
     $plot = new BarPlot($this->y1);
     $plot->grid->setType(LINE_DASHED);
     $this->setPmvPadding($plot);
     $this->setPmvBackgroundGradient($plot);
     $this->setPmvBarBorderProperties($plot);
     $this->setPmvBarShadowProperties($plot);
     $this->setPmvLabelProperties($plot, $this->y1);
     $this->setPmvBarGradient($plot);
     $this->setPmvBarSize($plot);
     //$plot->xAxis->setColor( new Color(  50, 97, 243) );
     //$plot->yAxis->setColor( new Color(  50, 97, 243) );
     //$plot->xAxis->label->setFont($this->font20);
     $group->axis->bottom->setLabelText($this->x);
     $group->axis->bottom->setPadding(0, 0, 100, 0);
     // display one axis label on two because too long for Mar 04 Apr 04 etc.
     if (isset($this->interval)) {
         $group->axis->bottom->label->setInterval(2);
     }
     $group->legend->add($plot, $this->y1Legend, LEGEND_BACKGROUND);
     $group->add($plot);
     /**
      * add group to graph
      */
     $this->graph->add($group);
 }
コード例 #4
0
 /**
  * Collects and renders visitor/week report data
  */
 public function visitor_week()
 {
     $myConfig = $this->getConfig();
     $oDb = oxDb::getDb();
     $aDataX = array();
     $aDataX2 = array();
     $aDataX3 = array();
     $aDataY = array();
     $sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to"))));
     $sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from"))));
     $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime";
     $aTemp = array();
     $rs = $oDb->execute($sSQL);
     if ($rs != false && $rs->recordCount() > 0) {
         while (!$rs->EOF) {
             //$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
             $aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++;
             $rs->moveNext();
         }
     }
     // initializing
     list($iFrom, $iTo) = $this->getWeekRange();
     for ($i = $iFrom; $i < $iTo; $i++) {
         $aDataX[$i] = 0;
         $aDataX2[$i] = 0;
         $aDataX3[$i] = 0;
         $aDataY[] = "KW " . $i;
     }
     foreach ($aTemp as $key => $value) {
         $aDataX[$key] = $value;
         $aDataX2[$key] = 0;
         $aDataX3[$key] = 0;
         $aDataY[] = "KW " . $key;
     }
     // buyer
     $sSQL = "select oxorderdate from oxorder where oxorderdate >= {$sTimeFrom} and oxorderdate <= {$sTimeTo} order by oxorderdate";
     $rs = $oDb->execute($sSQL);
     if ($rs != false && $rs->recordCount() > 0) {
         while (!$rs->EOF) {
             $sKey = oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]));
             if (isset($aDataX2[$sKey])) {
                 $aDataX2[$sKey]++;
             }
             $rs->moveNext();
         }
     }
     // newcustomer
     $sSQL = "select oxtime, oxsessid from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime";
     $rs = $oDb->execute($sSQL);
     if ($rs != false && $rs->recordCount() > 0) {
         while (!$rs->EOF) {
             $sKey = oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]));
             if (isset($aDataX3[$sKey])) {
                 $aDataX3[$sKey]++;
             }
             $rs->moveNext();
         }
     }
     header("Content-type: image/png");
     // New graph with a drop shadow
     $graph = new Graph(max(800, count($aDataX) * 80), 600);
     $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
     // Use a "text" X-scale
     $graph->setScale("textlin");
     $graph->setY2Scale("lin");
     $graph->y2axis->setColor("red");
     // Label align for X-axis
     $graph->xaxis->setLabelAlign('center', 'top', 'right');
     // Label align for Y-axis
     $graph->yaxis->setLabelAlign('right', 'bottom');
     $graph->setShadow();
     // Description
     $graph->xaxis->setTickLabels($aDataY);
     // Set title and subtitle
     $graph->title->set("Woche");
     // Use built in font
     $graph->title->setFont(FF_FONT1, FS_BOLD);
     $aDataFinalX = array();
     foreach ($aDataX as $dData) {
         $aDataFinalX[] = $dData;
     }
     // Create the bar plot
     $l2plot = new LinePlot($aDataFinalX);
     $l2plot->setColor("navy");
     $l2plot->setWeight(2);
     $l2plot->setLegend("Besucher");
     $l2plot->value->setColor("navy");
     $l2plot->value->setFormat('% d');
     $l2plot->value->hideZero();
     $l2plot->value->show();
     $aDataFinalX2 = array();
     foreach ($aDataX2 as $dData) {
         $aDataFinalX2[] = $dData;
     }
     // Create the bar plot
     $l3plot = new LinePlot($aDataFinalX2);
     $l3plot->setColor("orange");
     $l3plot->setWeight(2);
     $l3plot->setLegend("Bestellungen");
     //$l1plot->SetBarCenter();
     $l3plot->value->setColor("orange");
     $l3plot->value->setFormat('% d');
     $l3plot->value->hideZero();
     $l3plot->value->show();
     //conversion rate graph
     $l1datay = array();
     for ($iCtr = 0; $iCtr < count($aDataFinalX); $iCtr++) {
         if ($aDataFinalX[$iCtr] != 0 && $aDataFinalX2[$iCtr] != 0) {
             $l1datay[] = 100 / ($aDataFinalX[$iCtr] / $aDataFinalX2[$iCtr]);
         } else {
             $l1datay[] = 0;
         }
     }
     $l1plot = new LinePlot($l1datay);
     $l1plot->setColor("red");
     $l1plot->setWeight(2);
     $l1plot->setLegend("Conversion rate (%)");
     $l1plot->value->setColor('red');
     $l1plot->value->setFormat('% 0.4f%%');
     $l1plot->value->hideZero();
     $l1plot->value->show();
     // Create the grouped bar plot
     $graph->addY2($l1plot);
     $graph->add($l2plot);
     $graph->add($l3plot);
     // Finally output the  image
     $graph->stroke();
 }
コード例 #5
0
ファイル: Artichow.php プロジェクト: carriercomm/jbs
/**
* Формирование графика.
*
* Функция формирует, а затем записывает в файл ($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;
}
コード例 #6
0
ファイル: graphs.php プロジェクト: drognisep/Simple-Groupware
     $plot->yAxis->title->move(-4, 0);
     $plot->yAxis->setTitleAlignment(LABEL_TOP);
     $group->add($plot);
     $group->axis->bottom->setLabelText($keys_new);
     $group->axis->bottom->hideTicks(TRUE);
     if (count($data2) > 0) {
         if ($type == "linesteps") {
             list($data_new, $data_label, $keys_new) = build_line_steps($width, $data2, $keys);
         } else {
             $data_new = $data2;
             $data_label = $data2;
         }
         $plot = new LinePlot($data_new);
         $plot->label->set($data_label);
         $plot->label->move(5, -7);
         $plot->setColor(new Color(255, 165, 0));
         $plot->setFillColor(new LightOrange(80));
         $group->add($plot);
     }
     $graph->add($group);
 } else {
     if ($type == "scatter") {
         require INCLUDE_PATH . "/ScatterPlot.class.php";
         $graph = new Graph($width, $height);
         $graph->title->set($title);
         $graph->title->setFont(new Tuffy(11));
         $plot = new ScatterPlot($data, $keys);
         $plot->grid->setType(LINE_DASHED);
         $plot->grid->hideVertical(TRUE);
         $plot->setSpace(6, 6, 6, 0);
         $plot->setPadding(25, 15, 27, 20);
コード例 #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);
	}
コード例 #8
0
 * 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();
コード例 #9
0
$x = array(20, 25, 20, 18, 16, 25, 29, 12, 15, 18, 21, 26);
$plot = new BarPlot($x, 2, 2);
$plot->setBarColor(new Color(120, 175, 80, 10));
$plot->setBarPadding(0.15, 0.15);
$plot->barShadow->setSize(3);
$plot->barShadow->smooth(TRUE);
$plot->barShadow->setColor(new Color(200, 200, 200, 10));
$group->legend->add($plot, "Green bar", LEGEND_BACKGROUND);
$group->add($plot);
// Add a second bar plot
$x = array(12, 14, 10, 9, 10, 16, 12, 8, 8, 10, 12, 13);
$plot = new BarPlot($x, 2, 2);
$plot->setBarColor(new Orange());
$plot->setBarPadding(0.15, 0.15);
$group->legend->add($plot, "Orange bar", LEGEND_BACKGROUND);
$group->add($plot);
// Add a line plot
$x = array(6, 5, 6, 5.5, 4.5, 4, 4.5, 4, 5, 4, 5, 5.5);
$plot = new LinePlot($x, LINEPLOT_MIDDLE);
$plot->setColor(new DarkBlue());
$plot->setThickness(5);
$plot->setYAxis(PLOT_RIGHT);
$plot->setYMax(12);
$plot->mark->setType(MARK_CIRCLE);
$plot->mark->setSize(6);
$plot->mark->setFill(new LightBlue());
$plot->mark->border->show();
$group->legend->add($plot, "Blue line", LEGEND_MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();
コード例 #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";
// 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();
コード例 #11
0
	// point rouge sur le graphique
	$plot->mark->setFill($rouge);
	$plot->mark->setType(MARK_SQUARE);

   $group->add($plot);
	// pas de chiffre après la virgule
	   $group->axis->left->setLabelPrecision(1);
   $group->axis->left->setColor($rouge);
   $group->axis->left->title->move(-5, 0);
   $group->axis->left->title->set("Absences");

   // les retards
   $plot = new LinePlot($values_retards);
	$plot->xAxis->setLabelText($x);
   $plot->setColor($bleu);
   $plot->setYAxis(PLOT_RIGHT); //Plot::RIGHT
	// type de trait
	$plot->setStyle(LINE_DOTTED); //Line::DOTTED
		// Change le style de ligne (Line::SOLID, Line::DOTTED ou Line::DASHED).

	// point noir sur le graphique
	$plot->mark->setFill($bleu);
	$plot->mark->setType(MARK_CIRCLE);
	   $plot->mark->setSize(7);
	   $plot->mark->setFill(new White);
	   $plot->mark->border->show();

/*
    * const int CIRCLE := 1
    * const int SQUARE := 2
コード例 #12
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(450, 400);
$graph->setAntiAliasing(TRUE);
$blue = new Color(0, 0, 200);
$red = new Color(200, 0, 0);
$group = new PlotGroup();
$group->setBackgroundColor(new Color(240, 240, 240));
$group->setPadding(40, 40);
$values = array(12, 5, 20, 32, 15, 4, 16);
$plot = new LinePlot($values);
$plot->setColor($blue);
$plot->setYAxis(PLOT_LEFT);
$group->add($plot);
$group->axis->left->setColor($blue);
$group->axis->left->title->set("Blue line");
$values = array(6, 12, 14, 2, 11, 5, 21);
$plot = new LinePlot($values);
$plot->setColor($red);
$plot->setYAxis(PLOT_RIGHT);
$group->add($plot);
$group->axis->right->setColor($red);
$group->axis->right->title->set("Red line");
$graph->add($group);
$graph->draw();
コード例 #13
0
 * 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(375, 200);
// Set title
$graph->title->set('Star marks');
$graph->title->setFont(new Tuffy(12));
$graph->title->setColor(new DarkRed());
$plot = new LinePlot(array(5, 3, 4, 7, 6, 5, 8, 4, 7));
// Change plot size and position
$plot->setSize(0.76, 1);
$plot->setCenter(0.38, 0.5);
$plot->setPadding(30, 15, 38, 25);
$plot->setColor(new Orange());
$plot->setFillColor(new LightOrange(80));
// Change grid style
$plot->grid->setType(LINE_DASHED);
// Add customized  marks
$plot->mark->setType(MARK_STAR);
$plot->mark->setFill(new MidRed());
$plot->mark->setSize(6);
// Change legend
$plot->legend->setPosition(1, 0.5);
$plot->legend->setAlign(LEGEND_LEFT);
$plot->legend->shadow->smooth(TRUE);
$plot->legend->add($plot, 'My line', LEGEND_MARK);
$graph->add($plot);
$graph->draw();
コード例 #14
0
$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));
$plot->mark->setType(MARK_SQUARE);
$plot->mark->setFill(new DarkGreen());
$plot->mark->setSize(5);
$group->add($plot);
function setYear($value)
{
    return $value + 2000;
}
$group->axis->bottom->label->setCallbackFunction('setYear');
function setK($value)
{
    return round($value) . 'K';
}
$group->axis->left->label->setCallbackFunction('setK');
コード例 #15
0
ファイル: evolutions_courbes.php プロジェクト: rhertzog/lcs
$group = new PlotGroup;
$group->setPadding(40, 40);
$group->setBackgroundColor(
        new Color(240, 240, 240)
);

$nbre_courbes=count($data);

$i=0;
$values=Array();
foreach($data as $key=>$type) {
  foreach($type as $value) {
    $values[$i][]=$value;
  }
  $plot = new LinePlot($values[$i]);
  $color=new color(rand(0,200),rand(0,200),rand(0,200));
  $plot->setColor($color);
  $plot->setThickness(2);

  $group->legend->add($plot, $key, Legend::LINE);
  $group->legend->setPosition(1, 0.25);
  $group->add($plot);
  $i++;
}

$group->axis->bottom->setLabelText($months);

$graph->add($group);
$graph->draw();
?>
コード例 #16
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(300, 200);
$graph->setAntiAliasing(TRUE);
$x = array(-4, -5, -2, -8, -3, 1, 4, 9, 5, 6, 2);
$plot = new LinePlot($x);
$plot->setStyle(LINE_DASHED);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(25, 15, 10, 18);
$plot->setBackgroundGradient(new LinearGradient(new Color(230, 230, 230), new Color(255, 255, 255), 90));
$plot->setFilledArea(7, 9, new Red(25));
$plot->setFilledArea(1, 4, new Yellow(25));
$plot->setColor(new Color(0, 0, 150, 20));
$plot->grid->setColor(new VeryLightGray());
$plot->mark->setType(MARK_SQUARE);
$plot->mark->setSize(4);
$plot->mark->setFill(new VeryDarkGreen(30));
$plot->mark->border->show();
$plot->mark->border->setColor(new DarkBlue(60));
$plot->xAxis->label->hide(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 3);
$plot->yAxis->setLabelNumber(8);
$plot->legend->add($plot, "My line");
$plot->legend->setPosition(0.9, 0.77);
$graph->add($plot);
$graph->draw();
コード例 #17
0
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$x = array();
for ($i = 0; $i < 8; $i++) {
    $x[] = cos($i / 3 * M_PI) + mt_rand(-10, 10) / 40;
}
$plot = new LinePlot($x);
$plot->setPadding(22, 5, 25, 8);
// Hide grid
$plot->grid->setType(LINE_DASHED);
// Change background color
$plot->setBackgroundColor(new Color(240, 240, 240, 50));
// Set Y on both left and rights sides
$plot->setYAxis(PLOT_BOTH);
// Change line properties
$plot->setColor(new Color(0, 0, 0));
$plot->setFillColor(new Color(240, 190, 130, 50));
// Chenge ticks and labels interval
$plot->xAxis->setTickInterval(2);
$plot->xAxis->label->hide(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 1);
// Hide first and last values on X axis
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
// Add a title
$plot->title->set("Random values");
$plot->title->move(0, 2);
$plot->title->setFont(new Tuffy(8));
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->border->show();
$plot->title->setPadding(2, 2, 2, 2);
コード例 #18
0
ファイル: G_classement.php プロジェクト: lcapdecomme/monls
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);
}
コード例 #19
0
function color($a = NULL)
{
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function formatLabel($value)
{
    return sprintf("%.2f", $value);
}
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setXAxisZero(FALSE);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(25, 10, 10, 20);
$group->axis->left->setLabelNumber(2);
$group->axis->left->setLabelPrecision(1);
// Display two lines
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 10; $i++) {
        $x[] = cos($i * M_PI / 5) / ($n + 1);
    }
    $plot = new LinePlot($x);
    $plot->setColor(color(10));
    // Random line color
    $plot->setFillColor(color(90));
    // Random background color
    $group->add($plot);
}
$graph->add($group);
$graph->draw();
コード例 #20
0
ファイル: dolgraph.class.php プロジェクト: ADDAdev/Dolibarr
 /**
  * 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) . '">';
 }
コード例 #21
0
 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();
 }