public static function lineChart($data1, $data2, $legends)
 {
     $graph = new Graph(600, 400);
     $graph->SetScale('intlin');
     $graph->SetShadow();
     $graph->SetMargin(40, 20, 20, 40);
     //        $graph->title->Set('Calls per operator (June,July)');
     //        $graph->subtitle->Set('(March 12, 2008)');
     //        $graph->xaxis->title->Set('Operator');
     //        $graph->yaxis->title->Set('# of calls');
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->SetTickLabels($legends);
     $lineplot = new LinePlot($data1);
     $lineplot->SetWeight(4);
     // Two pixel wide
     // Add the plot to the graph
     $graph->Add($lineplot);
     // Create the second data series
     $lineplot2 = new LinePlot($data2);
     $lineplot2->SetWeight(4);
     // Two pixel wide
     $graph->Add($lineplot2);
     $lineplot->SetLegend("This Year");
     $lineplot2->SetLegend("Last Year");
     $graph->legend->SetLayout(LEGEND_HOR);
     $graph->legend->Pos(0.4, 0.95, "center", "bottom");
     return $graph->Stroke('../graph/compareLineChart.png');
 }
Beispiel #2
0
 function monthchart($xdata, $ydata, $title = 'Line Chart')
 {
     // Create the graph. These two calls are always required
     $graph = new Graph(600, 250, "auto", 60);
     $graph->img->SetAntiAliasing(false);
     $graph->SetScale("textlin");
     $graph->xaxis->SetTickLabels($xdata);
     $graph->xgrid->SetColor('#E3E3E3');
     $graph->legend->SetFrameWeight(1);
     // Setup title
     $graph->title->Set($title);
     foreach ($ydata as $item) {
         // Create the linear plot
         if (count($item['values']) != count($xdata)) {
             continue;
         }
         $lineplot = new LinePlot($item['values'], $xdata);
         $lineplot->SetColor($item['color']);
         if (count($ydata) == 1) {
             $lineplot->SetFillColor($item['color']);
         }
         // Add the plot to the graph
         $graph->Add($lineplot);
         $lineplot->SetLegend($item['legend']);
     }
     return $graph;
 }
 public function graficofecha($gestion)
 {
     if (Conectar::con()) {
         //$gestion='2013';
         $objetoanalisis = new classAnalisis();
         $anio = $gestion;
         for ($i = 0; $i < 12; $i++) {
             $dat[] = $objetoanalisis->ventamensual($anio, $i);
         }
         $datos = $dat;
         //$datos =array('1','4','3','3','5');
         $grafico = new Graph(400, 300, "auto");
         $grafico->SetScale("textlin");
         $grafico->title->Set("Resumen de ventas por gestion");
         $grafico->xaxis->title->Set("");
         $grafico->yaxis->title->Set("");
         // Un gradiente Horizontal de rojo a azul
         // 25 pixeles de ancho para cada barra
         $lineplot = new LinePlot($datos);
         $lineplot->SetColor("green");
         $lineplot->SetWeight(2);
         $grafico->Add($lineplot);
         return $grafico->Stroke();
     }
 }
 /**
  * @return Chart
  */
 public function buildGraph()
 {
     require_once 'common/chart/Chart.class.php';
     if ($this->error == NULL) {
         if ($this->width == 0) {
             $this->width = count($this->data) * self::WIDTH_PER_POINT + self::MARGIN;
         }
         if ($this->scale == GraphOnTrackersV5_Chart_CumulativeFlow::SCALE_DAY) {
             foreach ($this->data as $date => $label) {
                 $dates[] = date('M-d', $date);
             }
         } else {
             foreach ($this->data as $date => $label) {
                 $dates[] = date('M-Y', $date);
             }
         }
         $this->graph = new Chart($this->width, $this->height);
         $colors = $this->getColors();
         $this->graph->SetScale("datlin");
         $this->graph->title->Set($this->title);
         $this->graph->xaxis->SetTickLabels($dates);
         $this->graph->yaxis->scale->SetAutoMin(0);
         if (is_null($this->description)) {
             $this->description = "";
         }
         $this->graph->subtitle->Set($this->description);
         $this->keys = array_keys($this->data[$this->start_date]);
         $this->nbOpt = count($this->keys);
         $this->stackDataCount();
         $this->graph->ygrid->SetFill(true, '#F3FFFF@0.5', '#FFFFFF@0.5');
         for ($i = $this->nbOpt - 1; $i >= 0; $i--) {
             $lineData = array();
             foreach ($this->data as $data => $row) {
                 $lineData[] = $row[$this->keys[$i]];
             }
             $line = new LinePlot($lineData);
             $line->SetFillColor($colors[$this->keys[$i]]);
             $line->SetColor('#000');
             $line->SetLegend($this->keys[$i]);
             $this->graph->Add($line);
         }
         try {
             $legend_line_height = 20;
             $graph_margin_bottom = 70;
             $margin_size = $this->nbOpt * $legend_line_height + $graph_margin_bottom;
             $this->graph->img->SetMargin(70, 30, 30, $margin_size);
         } catch (Exception $e) {
             // do nothing, JPGraph displays the error by itself
         }
         $this->graph->legend->SetAbsPos(0, $this->height, 'left', 'bottom');
     } else {
         $this->graph = $this->error;
     }
     return $this->graph;
 }
Beispiel #5
0
 public function renderGraph()
 {
     require_once 'libs/jpgraph/jpgraph.php';
     require_once 'libs/jpgraph/jpgraph_bar.php';
     require_once 'libs/jpgraph/jpgraph_line.php';
     $graph = new Graph(300, 200, 'auto');
     $graph->SetMarginColor('white');
     $graph->SetFrame(false);
     $graph->SetScale("textlin");
     $graph->SetY2Scale("lin");
     $graph->img->SetMargin(0, 30, 20, 65);
     $graph->yaxis->HideLabels();
     $graph->yaxis->HideTicks();
     $graph->yaxis->scale->SetGrace(20);
     $graph->y2axis->SetColor("black", "red");
     $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
     $labelsy = array();
     $datay = array();
     $datay2 = array();
     switch ($this->_controllerAction->getRequest()->getParam('type')) {
         case 'year':
             $this->_populateYearData($labelsy, $datay, $datay2);
             break;
         default:
             $this->_populateWeekData($labelsy, $datay, $datay2);
     }
     $graph->xaxis->SetTickLabels($labelsy);
     $locale = Zend_Registry::get('Zend_Locale');
     if ($locale == 'ja') {
         // the ttf file for FF_MINCHO is already encoded in utf-8
         $legend1 = $this->view->translate('Trusted sites');
         $legend2 = $this->view->translate('Sites per user');
     } else {
         // default ttf files are latin-1 encoded
         $legend1 = utf8_decode($this->view->translate('Trusted sites'));
         $legend2 = utf8_decode($this->view->translate('Sites per user'));
     }
     $bplot = new BarPlot($datay);
     $bplot->setLegend($legend1);
     $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
     $bplot->value->Show();
     $bplot->value->SetFormat('%d');
     $p1 = new LinePlot($datay2);
     $p1->SetColor("red");
     $p1->SetLegend($legend2);
     $graph->Add($bplot);
     $graph->AddY2($p1);
     $graph->legend->SetLayout(LEGEND_HOR);
     if ($locale == 'ja') {
         $graph->legend->setFont(FF_MINCHO, FS_NORMAL);
     }
     $graph->legend->Pos(0.5, 0.99, "center", "bottom");
     $graph->Stroke();
 }
Beispiel #6
0
 /**
  *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);
     }
 }
 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);
 }
function LineGraph($w, $h, $title, $data1, $data2, $datax, $output)
{
    // Create the graph. These two calls are always required
    $graph = new Graph($w, $h, "auto");
    $graph->SetScale("textlin");
    $graph->SetMarginColor('white');
    $graph->SetFrame(true);
    // Adjust the margin
    $graph->img->SetMargin(40, 100, 20, 40);
    $graph->SetShadow(false);
    // Create the linear plot
    $lineplot = new LinePlot($data1);
    $lineplot->SetWeight(2);
    $lineplot->SetColor("blue");
    $lineplot->mark->SetType(MARK_DIAMOND);
    $lineplot->mark->SetWidth(5);
    $lineplot->mark->SetFillColor('blue');
    $lineplot->value->SetMargin(-20);
    $lineplot->value->show();
    $lineplot->value->SetColor('blue');
    $lineplot->value->SetFormat('%0.0f');
    $lineplot->SetLegend($_SESSION[Tahun1]);
    $lineplot2 = new LinePlot($data2);
    $lineplot2->SetColor("green");
    $lineplot2->SetWeight(2);
    $lineplot2->mark->SetType(MARK_FILLEDCIRCLE);
    $lineplot2->mark->SetWidth(3);
    $lineplot2->mark->SetFillColor('green');
    $lineplot2->value->show();
    $lineplot2->value->SetColor('darkgreen');
    $lineplot2->value->SetFormat('%0.0f');
    $lineplot2->SetLegend($_SESSION[Tahun2]);
    // Add the plot to the graph
    $graph->Add($lineplot);
    $graph->xaxis->SetTickLabels($datax);
    $graph->title->Set($title);
    $graph->xaxis->title->Set("");
    $graph->yaxis->title->Set("");
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->Add($lineplot2);
    $graph->legend->SetShadow(false);
    $graph->legend->SetFillColor('white');
    $graph->legend->SetPos(0.01, 0.88, 'right', 'center');
    // Display the graph
    $graph->Stroke($output);
}
Beispiel #9
0
 function linechart($ydata, $title = 'Line Chart')
 {
     require_once APPPATH . 'third_party/jpgraph-3.5.0b1/src/jpgraph.php';
     require_once APPPATH . 'third_party/jpgraph-3.5.0b1/src/jpgraph_line.php';
     // Create the graph. These two calls are always required
     $graph = new Graph(350, 250, "auto", 60);
     $graph->SetScale("textlin");
     // Setup title
     $graph->title->Set($title);
     // Create the linear plot
     $lineplot = new LinePlot($ydata);
     $lineplot->SetColor("blue");
     // Add the plot to the graph
     $graph->Add($lineplot);
     return $graph;
     // does PHP5 return a reference automatically?
 }
 function AudiogrammeTonal($with_legend = true)
 {
     $frequences = CExamAudio::$frequences;
     $delta = $with_legend ? 75 : 0;
     // Setup the graph.
     $this->Graph(300 + $delta, 250, "auto");
     $this->SetScale("textlin", -120, 10);
     $this->SetMarginColor("lightblue");
     // Image setup
     //$this->img->SetAntiAliasing();
     $this->img->SetMargin(45, 20 + $delta, 30, 15);
     // Legend setup
     if ($with_legend) {
         $this->legend->Pos(0.02, 0.5, "right", "center");
         $this->legend->SetShadow("darkgray@0.5", 3);
         $this->legend->SetFont(FF_ARIAL, FS_NORMAL, 7);
         $this->legend->SetFillColor('white@0.3');
     } else {
         $this->legend->Hide();
     }
     // Title setup
     $this->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
     $this->title->SetColor("darkred");
     //Setup X-axis labels
     $this->xgrid->Show(true);
     $this->xgrid->SetColor("lightgray", "lightgray:1.8");
     $this->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
     $this->xaxis->SetTickLabels($frequences);
     $this->xaxis->SetLabelSide(1);
     $this->xaxis->SetLabelMargin(22);
     // Setup Y-axis labels
     $this->ygrid->Show(true, true);
     $this->ygrid->SetColor("lightgray", "lightgray:1.8");
     $this->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
     $this->yaxis->SetLabelFormatString("%ddB");
     $this->yaxis->scale->ticks->Set(20, 10);
     $this->yaxis->scale->ticks->SupressZeroLabel(false);
     $this->yaxis->scale->ticks->SupressMinorTickMarks(false);
     // Empty plots for scale window
     foreach ($frequences as $value) {
         $datay[] = 100;
     }
     $p1 = new LinePlot($datay);
     $p1->SetCenter();
     $this->Add($p1);
 }
Beispiel #11
0
 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;
 }
function createSpline($ydata = "")
{
    $xdata = array(2, 4, 6, 8, 10, 12, 14, 16);
    if (!$ydata) {
        $ydata = array(5, 1, 9, 6, 4, 3, 4, 2);
    }
    // Get the interpolated values by creating
    // a new Spline object.
    $spline = new Spline($xdata, $ydata);
    // For the new data set we want 40 points to
    // get a smooth curve.
    list($newx, $newy) = $spline->Get(50);
    // Create the graph
    $g = new Graph(380, 300);
    $g->SetMargin(30, 20, 40, 30);
    //$g->title->Set("Natural cubic splines");
    //$g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
    //$g->subtitle->Set('(Control points shown in red)');
    //$g->subtitle->SetColor('darkred');
    $g->SetMarginColor('lightblue');
    //$g->img->SetAntiAliasing();
    // We need a linlin scale since we provide both
    // x and y coordinates for the data points.
    $g->SetScale('linlin');
    $xlable = array('', 'AA', 'AA', 'AB', 'AB', 'BB', 'BB', 'BC', 'BC', 'CC', 'CC', 'CD', 'CD', 'DD', 'DD', 'FF', 'FF', '');
    // We want 1 decimal for the X-label
    //$g -> xaxis -> SetLabelFormat('%d');
    $g->xaxis->SetTickLabels($xlable);
    // We use a scatterplot to illustrate the original
    // contro points.
    $splot = new ScatterPlot($ydata, $xdata);
    //
    $splot->mark->SetFillColor('red@0.3');
    $splot->mark->SetColor('red@0.5');
    // And a line plot to stroke the smooth curve we got
    // from the original control points
    $lplot = new LinePlot($newy, $newx);
    $lplot->SetColor('navy');
    // Add the plots to the graph and stroke
    $g->Add($lplot);
    $g->Add($splot);
    $g->Stroke();
}
Beispiel #13
0
function draw_graph($datay, $data2y, $label_x)
{
    include_once "src/jpgraph.php";
    include_once "src/jpgraph_line.php";
    // A nice graph with anti-aliasing
    $graph = new Graph(800, 600, "auto");
    $graph->img->SetMargin(40, 180, 40, 40);
    $graph->img->SetAntiAliasing("white");
    $graph->SetScale("textlin");
    $graph->SetShadow();
    $graph->title->Set("Nodes and Comment Count By Duration");
    $graph->xaxis->SetTickLabels($label_x);
    // Use built in font
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    // Slightly adjust the legend from it's default position in the
    // top right corner.
    $graph->legend->Pos(0.05, 0.5, "right", "center");
    // Create the first line
    if ($datay) {
        $p1 = new LinePlot($datay);
        $p1->mark->SetType(MARK_FILLEDCIRCLE);
        $p1->mark->SetFillColor("blue");
        $p1->mark->SetWidth(4);
        $p1->SetColor("blue");
        $p1->SetCenter();
        $p1->SetLegend("Nodes Count");
        $graph->Add($p1);
    }
    // ... and the second
    if ($data2y) {
        $p2 = new LinePlot($data2y);
        $p2->mark->SetType(MARK_STAR);
        $p2->mark->SetFillColor("red");
        $p2->mark->SetWidth(4);
        $p2->SetColor("red");
        $p2->SetCenter();
        $p2->SetLegend("Comments Count");
        $graph->Add($p2);
    }
    // Output line
    $graph->Stroke();
}
Beispiel #14
0
 function plot()
 {
     $this->_setValues();
     $graph = new Graph(380, 250);
     $graph->img->SetMargin(50, 30, 40, 40);
     $graph->SetShadow();
     $graph->SetColor("lightyellow");
     $graph->SetScale("textlin");
     $graph->title->Set($this->_graphTitle);
     $graph->yaxis->SetColor("blue");
     $graph->xaxis->SetColor("blue");
     $graph->title->SetFont(FONT1_BOLD);
     $graph->xaxis->SetTickLabels($this->_xaxisValues);
     $lineplot = new LinePlot($this->_yaxisValues);
     $lineplot->SetColor("red");
     // Add the plot to the graph
     $graph->Add($lineplot);
     // Display the graph
     $graph->Stroke();
 }
 /**
  * @return Chart
  */
 public function buildGraph()
 {
     $graph = new Chart($this->width, $this->height);
     $graph->SetScale("datlin");
     $graph->title->Set($this->title);
     $graph->subtitle->Set($this->description);
     $colors = $graph->getThemedColors();
     $graph->xaxis->SetTickLabels($this->burndown_data->getHumanReadableDates());
     $remaining_effort = new LinePlot($this->burndown_data->getRemainingEffort());
     $remaining_effort->SetColor($colors[1] . ':0.7');
     $remaining_effort->SetWeight(2);
     $remaining_effort->SetLegend('Remaining effort');
     $remaining_effort->mark->SetType(MARK_FILLEDCIRCLE);
     $remaining_effort->mark->SetColor($colors[1] . ':0.7');
     $remaining_effort->mark->SetFillColor($colors[1]);
     $remaining_effort->mark->SetSize(3);
     $graph->Add($remaining_effort);
     $ideal_burndown = new LinePlot($this->burndown_data->getIdealEffort());
     $ideal_burndown->SetColor($colors[0] . ':1.25');
     $ideal_burndown->SetLegend('Ideal Burndown');
     $graph->Add($ideal_burndown);
     return $graph;
 }
Beispiel #16
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) . '">';
 }
Beispiel #17
0
<?php

include "../jpgraph.php";
include "../jpgraph_line.php";
$ydata = array(12, 17, 22, 19, 5, 15);
$graph = new Graph(270, 170);
$graph->SetMargin(30, 90, 30, 30);
$graph->SetScale("textlin");
$graph->img->SetAngle(90);
$graph->img->SetCenter(floor(270 / 2), floor(170 / 2));
$line = new LinePlot($ydata);
$line->SetLegend('2002');
$line->SetColor('darkred');
$line->SetWeight(2);
$graph->Add($line);
// Output graph
$graph->Stroke();
?>


Beispiel #18
0
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 50, 30, 30);
$graph->title->Set('Filled Y-grid');
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Create the first line
$p1 = new LinePlot($datay1);
$p1->SetColor("navy");
$p1->SetLegend('Line 1');
$graph->Add($p1);
// Create the second line
$p2 = new LinePlot($datay2);
$p2->SetColor("red");
$p2->SetLegend('Line 2');
$graph->Add($p2);
// Create the third line
$p3 = new LinePlot($datay3);
$p3->SetColor("orange");
$p3->SetLegend('Line 3');
$graph->Add($p3);
$graph->legend->SetShadow('gray@0.4', 5);
$graph->legend->SetPos(0.1, 0.1, 'right', 'top');
// Output line
$graph->Stroke();
?>


Beispiel #19
0
 /**
  * Draw the XY type plot
  *
  * @param array $data plot data array reference
  * @param array $xmlArr xml array reference
  * @return object refernce XY plot object reference
  */
 public function renderXYPlot(&$data, &$xmlArr)
 {
     $id = $xmlArr['ATTRIBUTES']['ID'];
     $field = $xmlArr['ATTRIBUTES']['FIELD'];
     $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
     $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
     $weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
     $color = $xmlArr['ATTRIBUTES']['COLOR'];
     $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
     $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
     $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
     $visible = $xmlArr['ATTRIBUTES']['VISIBLE'];
     if ($chartType == 'Line' or $chartType == 'Bar') {
         if ($chartType == 'Line') {
             include_once JPGRAPH_DIR . '/jpgraph_line.php';
             $plot = new LinePlot($data);
             $this->_drawMark($plot->mark, $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
             $plot->SetBarCenter();
             $plot->SetCenter();
         } else {
             if ($chartType == 'Bar') {
                 include_once JPGRAPH_DIR . '/jpgraph_bar.php';
                 $plot = new BarPlot($data);
                 $plot->SetAlign('center');
             }
         }
         if ($color) {
             $plot->SetColor($color);
         }
         if ($fillColor) {
             $plot->SetFillColor($fillColor);
         }
         if ($weight) {
             $plot->SetWeight($weight);
         }
         if ($showVal == 1) {
             $plot->value->Show();
         }
         if ($legend) {
             $plot->SetLegend($legend);
         }
         $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
     }
     if ($chartType == 'GroupBar' or $chartType == 'AccBar') {
         $children = $xmlArr['ATTRIBUTES']['CHILDREN'];
         $childList = explode(",", $children);
         foreach ($childList as $child) {
             $childPlotList[] = $this->m_PlotList[$child];
         }
         if ($chartType == 'GroupBar') {
             $plot = new GroupBarPlot($childPlotList);
         } else {
             if ($chartType == 'AccBar') {
                 $plot = new AccBarPlot($childPlotList);
             }
         }
     }
     $this->m_PlotList[$id] = $plot;
     if ($visible == 1) {
         return $plot;
     }
     return null;
 }
Beispiel #20
0
pg_close($coop);
include "../../../include/jpgraph/jpgraph.php";
include "../../../include/jpgraph/jpgraph_bar.php";
include "../../../include/jpgraph/jpgraph_line.php";
include "../../../include/network.php";
$nt = new NetworkTable("IACLIMATE");
$cities = $nt->table;
$graph = new Graph(600, 400, "example1");
$graph->SetScale("textlin", 0, 100);
$graph->img->SetMargin(40, 5, 35, 60);
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetTextTickInterval(100);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetTitle("Precip [inches]");
$graph->xaxis->SetTitleMargin(30);
$graph->yaxis->SetTitle("Cumulative Distribution (percent)");
$graph->title->Set($cities[$station]['name'] . " Precip Accumulation Probabilities");
$graph->subtitle->Set($subtitle);
$l1 = new LinePlot($ydata);
$l1->SetColor("blue");
$l1->SetWeight(2);
$l1->AddArea($hm, $hm, LP_AREA_FILLED, "lightred");
$l1->AddArea($h95, $h95, LP_AREA_FILLED, "lightred");
$l1->AddArea($h5, $h5, LP_AREA_FILLED, "lightred");
$txt = new Text("Diagnostics\n  Min: {$lowVal} ({$lowYear})\n  95%: " . ($lowVal + $h95 * 0.01) . "\n~Mean: " . ($lowVal + $hm * 0.01) . "\n   SD: {$stddev}\n   5%: " . ($lowVal + $h5 * 0.01) . "\n  Max: {$hiVal} ({$hiYear})\n");
$txt->SetPos(0.71, 0.128);
$txt->SetFont(FF_FONT1, FS_NORMAL);
$txt->SetColor("blue");
$graph->Add($l1);
$graph->Add($txt);
$graph->Stroke();
Beispiel #21
0
$graph->subtitle->Set("100 data points, X-Scale: 'text'");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(2);
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetAbsWidth(6);
$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
?>

Beispiel #22
0
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(50, 90, 40, 50);
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set("Examples for graph");
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetLegend("Test 1");
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Beispiel #23
0
        $labelinterval = 1;
    }
    // Graphing
    $graph = new Graph(850, 350, 0, false);
    $graph->SetShadow();
    $graph->SetScale("textlin");
    $graph->yaxis->SetTitleMargin(40);
    $graph->img->SetMargin(60, 60, 30, 70);
    $graph->title->Set("MCP Score Distribution");
    $graph->xaxis->title->Set("Score (rounded)");
    $graph->xaxis->SetTextLabelInterval($labelinterval);
    $graph->xaxis->SetTickLabels($data_labels);
    $graph->yaxis->title->Set("No. of messages");
    $graph->legend->SetLayout(LEGEND_HOR);
    $graph->legend->Pos(0.52, 0.87, 'center');
    $bar1 = new LinePlot($data_count);
    $bar1->SetFillColor('blue');
    $graph->Add($bar1);
    $graph->Stroke($filename);
}
// Creating the page
echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
echo " <TR><TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . MS_LOGO . "\" ALT=\"MailScanner Logo\"></TD></TR>";
echo " <TR>\n";
//  Check Permissions to see if the file has been written and that apache to read it.
if (is_readable($filename)) {
    echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>";
} else {
    echo "<TD ALIGN=\"CENTER\"> File isn't readable. Please make sure that " . CACHE_DIR . " is readable and writable by MailWatch.";
}
// Create the table
Beispiel #24
0
//
$graph = new Graph(400, 200);
//
// We use an integer scale on the X-axis since the positions on the X axis
// are assumed to be UNI timestamps
$graph->SetScale('intlin', 0, 0, $xmin, $xmax);
$graph->title->Set('Basic example with manual ticks');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
//
// Make sure that the X-axis is always at the bottom of the scale
// (By default the X-axis is alwys positioned at Y=0 so if the scale
// doesn't happen to include 0 the axis will not be shown)
$graph->xaxis->SetPos('min');
// Now set the tic positions
$graph->xaxis->SetTickPositions($tickPositions, $minTickPositions);
// The labels should be formatted at dates with "Year-month"
$graph->xaxis->SetLabelFormatString('My', true);
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
// Add a X-grid
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($datay, $datax);
$p1->SetColor('teal');
$graph->Add($p1);
// Output graph
$graph->Stroke();
?>


Beispiel #25
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_date.php';
// Create a data set in range (50,70) and X-positions
DEFINE('NDATAPOINTS', 360);
DEFINE('SAMPLERATE', 240);
$start = time();
$end = $start + NDATAPOINTS * SAMPLERATE;
$data = array();
$xdata = array();
for ($i = 0; $i < NDATAPOINTS; ++$i) {
    $data[$i] = rand(50, 70);
    $xdata[$i] = $start + $i * SAMPLERATE;
}
// Create the new graph
$graph = new Graph(540, 300);
// Slightly larger than normal margins at the bottom to have room for
// the x-axis labels
$graph->SetMargin(40, 40, 30, 130);
// Fix the Y-scale to go between [0,100] and use date for the x-axis
$graph->SetScale('datlin', 0, 100);
$graph->title->Set("Example on Date scale");
// Set the angle for the labels to 90 degrees
$graph->xaxis->SetLabelAngle(90);
$line = new LinePlot($data, $xdata);
$line->SetLegend('Year 2005');
$line->SetFillColor('lightblue@0.5');
$graph->Add($line);
$graph->Stroke();
Beispiel #26
0
    foreach ($lines as $line => $datarow) {
        $split = preg_split('/[\\s]+/', $datarow);
        $aYears[] = substr(trim($split[0]), 0, 4);
        $aSunspots[] = trim($split[1]);
    }
}
$year = array();
$ydata = array();
readsunspotdata('yearssn.txt', $year, $ydata);
// Width and height of the graph
$width = 600;
$height = 200;
// Create a graph instance
$graph = new Graph($width, $height);
// Specify what scale we want to use,
// int = integer scale for the X-axis
// int = integer scale for the Y-axis
$graph->SetScale('intint');
// Setup a title for the graph
$graph->title->Set('Sunspot example');
// Setup titles and X-axis labels
$graph->xaxis->title->Set('(year from 1701)');
// Setup Y-axis title
$graph->yaxis->title->Set('(# sunspots)');
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetFillColor('orange@0.5');
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Beispiel #27
0
 public function bytes_s()
 {
     require_once 'jpgraph/jpgraph.php';
     require_once 'jpgraph/jpgraph_line.php';
     require_once 'jpgraph/jpgraph_date.php';
     $size = $this->uri->segment(3);
     $server_id = $this->uri->segment(4);
     $time = $this->uri->segment(5);
     $server = $this->server->get_record_by_id($server_id);
     $start = time() - $time;
     $mcount = $time / 60;
     $data = array();
     $xdata = array();
     for ($i = 0; $i < $mcount; ++$i) {
         $time = $start + $i * 60;
         $xdata[$i] = $time;
         $date_min = date('YmdHi', $time);
         $query = $this->db->query("select Bytes_sent from mysql_status_ext_history where server_id='{$server_id}' and YmdHi = '" . $date_min . "'; ");
         if ($query->num_rows() > 0) {
             $row = $query->row();
             $yresult = $row->Bytes_sent;
         } else {
             $yresult = '0';
         }
         $ydata[$i] = $yresult;
     }
     // Create the graph. These two calls are always required
     if ($size == 'small') {
         $width = 400;
         $height = 260;
     } else {
         if ($size = 'large') {
             $width = 1280;
             $height = 400;
         }
     }
     $graph = new Graph($width, $height);
     //$graph->SetScale("textlin");
     $graph->SetScale('datelin');
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->scale->SetDateFormat('H:i');
     $graph->SetShadow();
     $graph->img->SetMargin(40, 20, 20, 40);
     $dplot = new LinePlot($ydata, $xdata);
     $dplot->SetFillColor("orange@0.3");
     // Add the plot to the graph
     $graph->Add($dplot);
     $graph->xaxis->SetTextTickInterval(2);
     $grapha_title = $server['host'] . ":" . $server['port'] . " " . $server['application'] . " Sent Flow(KB)";
     $graph->title->Set($grapha_title);
     $graph->xaxis->title->Set("");
     $graph->yaxis->title->Set("");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->Stroke();
 }
Beispiel #28
0
 function Create(MASK $mask = NULL, INTERVAL $iv = NULL)
 {
     global $GRAPH_MARGINS;
     global $GRAPH_DENSITY_PLOT_VALID_SIZE;
     global $GRAPH_DENSITY_PLOT_VALID_COLOR;
     global $GRAPH_DENSITY_PLOT_INVALID_SIZE;
     global $GRAPH_DENSITY_PLOT_INVALID_COLOR;
     global $GRAPH_DENSITY_POINTS_TYPE;
     global $GRAPH_DENSITY_POINTS_SIZE;
     global $GRAPH_DENSITY_POINTS_COLOR;
     global $GRAPH_DENSITY_POINTS_OUTLINE;
     global $JPGRAPH_VERSION;
     if ($this->ready) {
         return;
     }
     list($axes, $data, $spec) = $this->PrepareData($this->reader, $mask, $iv);
     $draw_modes = array();
     foreach ($data as $info) {
         $items = $info['items'];
         foreach ($items as $item) {
             array_push($draw_modes, $item['draw_mode']);
         }
     }
     $this->plot_mode = $this->FindPlotMode($this->req->props['plot_mode']);
     $this->AnalyzeGapsRequirements($axes, $data, $spec);
     $this->AnalyzeMarksRequirements($axes, $data, $spec);
     list($xaxis, $yaxis) = $this->ConfigureAxis($axes, $iv, $data, $spec);
     $this->spec =& $spec;
     $this->graph = new Graph($this->width, $this->height, "auto");
     $this->graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE);
     if ($xaxis['date_format']) {
         $this->graph->SetScale("datlin", 0, 1, $xaxis['from'], $xaxis['to']);
         //$this->graph->xaxis->scale->Update($this->graph, $xaxis['from'], $xaxis['to']);
         $this->graph->xaxis->scale->SetDateFormat($xaxis['date_format']);
     } else {
         $this->graph->SetScale("linlin", 0, 1, $xaxis['from'], $xaxis['to']);
         if ($xaxis['ticks']) {
             $this->graph->xscale->ticks->Set($xaxis['ticks'][0], $xaxis['ticks'][1]);
         }
     }
     if ($xaxis['label_interval']) {
         $this->graph->xaxis->SetTextLabelInterval($xaxis['label_interval']);
     }
     if ($this->hide_axes) {
         if (strcasecmp($this->hide_axes, 'Y')) {
             $hide_x = true;
         } else {
             $hide_x = false;
         }
         $hide_y = true;
     } else {
         $hide_x = false;
         $hide_y = false;
     }
     $this->graph_margin = array();
     if ($hide_y) {
         $this->graph_yaxis_size = 0;
         if ($hide_x) {
             $this->graph_margin[0] = 0;
             $this->graph_margin[2] = 0;
         } else {
             $this->graph_margin[0] = $GRAPH_MARGINS['right'] + $GRAPH_MARGINS['axis'];
             $this->graph_margin[2] = $GRAPH_MARGINS['right'];
         }
         $this->graph->yaxis->HideLabels();
     } else {
         $this->graph_yaxis_size = $GRAPH_MARGINS['axis'];
         $this->graph_margin[0] = $GRAPH_MARGINS['left'] + $this->graph_yaxis_size * $axes->GetAxesNumber();
         $this->graph_margin[2] = $GRAPH_MARGINS['right'];
     }
     if ($hide_x) {
         $this->graph_margin[1] = 0;
         $this->graph_margin[3] = 1;
         $this->graph->xaxis->HideLabels();
     } else {
         $this->graph_margin[1] = $GRAPH_MARGINS['top'];
         $this->graph_margin[3] = $GRAPH_MARGINS['bottom'];
         $title = $this->GenerateTitle($data, $spec);
         $this->graph->title->Set($title);
         $this->graph->xaxis->SetPos("min");
         //$this->graph->xaxis->SetLabelAngle(0);
         $this->graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
         //$this->graph->xaxis->scale->SetTimeAlign(MINADJ_15);
         // We can use SetLabelFormatCallback for higher control
         //$this->graph->yaxis->SetLabelFormat('%0.5g');
         //$this->graph->SetYDeltaDist($this->graph_yaxis_size);
     }
     $this->graph->img->SetMargin($this->graph_margin[0], $this->graph_margin[2], $this->graph_margin[1], $this->graph_margin[3]);
     $this->graph->xaxis->SetLabelMargin(13);
     foreach ($axes as $axis_i => $axis) {
         $empty_axis = true;
         if (intval($this->plot_mode) === DRAW::PLOT_STANDARD) {
             foreach ($axis as $i => $plot_data) {
                 $plot = new LinePlot($plot_data[1], $plot_data[0]);
                 $color = $axis->GetChannelColor($i);
                 if ($color) {
                     $plot->SetColor($color);
                 }
                 $weight = $axis->GetChannelProperty($i, "weight");
                 if ($weight) {
                     $plot->SetWeight($weight);
                 }
                 if ($spec['marks']) {
                     $prop = $axis->GetChannelProperty($i, "mark_type");
                     if ($prop) {
                         $plot->mark->SetType($prop);
                     }
                     $prop = $axis->GetChannelProperty($i, "mark_size");
                     if ($prop) {
                         $plot->mark->SetSize($prop);
                     }
                     $prop = $axis->GetChannelProperty($i, "mark_fill");
                     if ($prop) {
                         $plot->mark->SetFillColor($prop);
                     }
                 }
                 $this->graph->AddY($axis_i, $plot);
                 $empty_axis = false;
             }
         } else {
             if (intval($this->plot_mode) === DRAW::PLOT_CUSTOM) {
                 foreach ($data as $info) {
                     $acc_lineplot_array = array();
                     $lineplot_array = array();
                     $items = $info['items'];
                     $time = $info['time'];
                     $values = $info['values'];
                     foreach ($axis as $i => $plot_data) {
                         $plot = new LinePlot($plot_data[1], $plot_data[0]);
                         $color = $axis->GetChannelColor($i);
                         if ($color) {
                             $plot->SetColor($color);
                         }
                         $weight = $axis->GetChannelProperty($i, "weight");
                         if ($weight) {
                             $plot->SetWeight($weight);
                         }
                         if ($spec['marks']) {
                             $prop = $axis->GetChannelProperty($i, "mark_type");
                             if ($prop) {
                                 $plot->mark->SetType($prop);
                             }
                             $prop = $axis->GetChannelProperty($i, "mark_size");
                             if ($prop) {
                                 $plot->mark->SetSize($prop);
                             }
                             $prop = $axis->GetChannelProperty($i, "mark_fill");
                             if ($prop) {
                                 $plot->mark->SetFillColor($prop);
                             }
                         }
                         if ($items[$i]['draw_mode'] !== "LINE") {
                             $plot->SetFillColor($color);
                             array_push($acc_lineplot_array, $plot);
                         } else {
                             array_push($lineplot_array, $plot);
                         }
                         $empty_axis = false;
                     }
                     if (!empty($acc_lineplot_array)) {
                         $accplot = new AccLinePlot($acc_lineplot_array);
                         $this->graph->AddY($axis_i, $accplot);
                     }
                     if (!empty($lineplot_array)) {
                         foreach ($lineplot_array as $plot) {
                             $this->graph->AddY($axis_i, $plot);
                         }
                     }
                 }
             }
         }
         if ($empty_axis) {
             $plot = new LinePlot(array(0), array($spec['from']));
             $this->graph->AddY($axis_i, $plot);
         }
         $range = $axis->GetRange();
         $scale = $axis->IsLogarithmic() ? "log" : "lin";
         if ($range) {
             if ($axis->IsLogarithmic()) {
                 if ($range[0] <= 0) {
                     $range[0] = DRAW::MIN_LOG;
                 }
                 if ($range[1] <= 0) {
                     $range[1] = 1;
                 }
                 $this->graph->SetYScale($axis_i, $scale, log10($range[0]), log10($range[1]));
                 //	        $this->graph->SetYScale($axis_i, $scale, (log10(max(DRAW::MIN_LOG, $range[0]))), (log10(max(DRAW::MIN_LOG, $range[1]))));
             } else {
                 $this->graph->SetYScale($axis_i, $scale, $range[0], $range[1]);
             }
         } else {
             if ($empty_axis) {
                 $this->graph->SetYScale($axis_i, $scale, 0, 1);
             } else {
                 $this->graph->SetYScale($axis_i, $scale);
             }
         }
         $color = $axis->GetColor();
         $this->graph->ynaxis[$axis_i]->SetColor($color);
         if ($hide_y) {
             $this->graph->ynaxis[$axis_i]->HideLabels();
         } else {
             $this->graph->ynaxis[$axis_i]->SetPos("min");
             $this->graph->ynaxis[$axis_i]->SetTickSide(SIDE_RIGHT);
             $this->graph->ynaxis[$axis_i]->SetLabelSide(SIDE_LEFT);
             $this->graph->ynaxis[$axis_i]->SetPosAbsDelta(-$axis_i * $this->graph_yaxis_size - 2);
             if (!$range) {
                 $this->graph->ynaxis[$axis_i]->scale->SetGrace(0.1, 0.1);
             }
             $title = $axis->GetTitle();
             if ($title) {
                 $this->graph->ynaxis[$axis_i]->SetTitle($title, "high");
                 $this->graph->ynaxis[$axis_i]->SetTitleSide(SIDE_LEFT);
                 if ($JPGRAPH_VERSION > 2) {
                     $this->graph->ynaxis[$axis_i]->SetTitleMargin(15 - $this->graph_yaxis_size);
                 } else {
                     $this->graph->ynaxis[$axis_i]->SetTitleMargin($this->graph_yaxis_size - 20);
                 }
                 $this->graph->ynaxis[$axis_i]->title->SetColor($color);
                 $this->graph->ynaxis[$axis_i]->HideLastTickLabel();
             }
         }
         // We can use SetLabelFormatCallback for higher control
         //$this->graph->ynaxis[$axis_i]->SetLabelFormat('%0.5g');
         $this->graph->ynaxis[$axis_i]->SetLabelFormatCallback(array(new DRAW_JPGraphAxisHolder($this, $axis, $this->graph->ynaxis[$axis_i]), "YLabelFormat"));
     }
     /*
         $plot = new LinePlot(array(0), array($spec['from']));
         $this->graph->AddY(1, $plot);
         $this->graph->SetYScale(1, 'lin', $range[0], $range[1]);
             $this->graph->ynaxis[1]->SetPos("min");
             $this->graph->ynaxis[1]->SetTitleSide(SIDE_LEFT);
             $this->graph->ynaxis[1]->SetTickSide(SIDE_RIGHT);
             $this->graph->ynaxis[1]->SetLabelSide(SIDE_LEFT);
     	$this->graph->ynaxis[1]->SetPosAbsDelta(-1 * 60 - 2);
     */
     $something_shown = false;
     if ($spec['gaps']) {
         //$px = ($max - $min) / $this->height; $realmax = $max + 2*$px;
         $realmax = 1 + 3 / $this->height;
         switch ($spec['gaps']) {
             case DRAW::SHOW_GAPS:
                 $gtime = array();
                 $gvalue = array();
                 foreach ($data as &$info) {
                     $flag = 0;
                     foreach ($info['gaps'] as $idx => &$val) {
                         if ($val) {
                             if ($flag) {
                                 $flag++;
                             } else {
                                 array_push($gtime, $info['time'][$idx]);
                                 array_push($gvalue, $realmax);
                                 $flag = 1;
                             }
                         } else {
                             if ($flag) {
                                 array_push($gtime, $info['time'][$idx]);
                                 array_push($gvalue, $realmax);
                                 array_push($gtime, $info['time'][$idx]);
                                 array_push($gvalue, false);
                                 $flag = 0;
                             }
                         }
                     }
                     if (sizeof($gtime) > 0) {
                         $something_shown = true;
                         $plot = new LinePlot($gvalue, $gtime);
                         $plot->SetColor($GRAPH_DENSITY_PLOT_INVALID_COLOR);
                         $plot->SetWeight($GRAPH_DENSITY_PLOT_INVALID_SIZE);
                         $this->graph->Add($plot);
                     }
                 }
                 break;
             case DRAW::SHOW_POINTS:
                 $something_shown = true;
                 foreach ($data as &$info) {
                     foreach ($info['gaps'] as $idx => &$val) {
                         if ($val > 1) {
                             $val = false;
                         } else {
                             $val = $realmax;
                         }
                     }
                     //		print_r($info['gaps']);
                     $plot = new LinePlot($info['gaps'], $info['time']);
                     $plot->SetColor($GRAPH_DENSITY_PLOT_VALID_COLOR);
                     $plot->SetWeight($GRAPH_DENSITY_PLOT_VALID_SIZE);
                     if ($GRAPH_DENSITY_POINTS_TYPE) {
                         eval("\$mtype={$GRAPH_DENSITY_POINTS_TYPE};");
                     }
                     $plot->mark->SetType($mtype);
                     $plot->mark->SetColor($GRAPH_DENSITY_POINTS_OUTLINE);
                     $plot->mark->SetFillColor($GRAPH_DENSITY_POINTS_COLOR);
                     $plot->mark->SetSize($GRAPH_DENSITY_POINTS_SIZE);
                     $this->graph->Add($plot);
                 }
         }
     }
     if (!$something_shown) {
         $plot = new LinePlot(array(0), array($spec['from']));
         $this->graph->Add($plot);
     }
     $this->graph->yaxis->Hide();
     $this->graph_interval = $iv;
     $this->graph_axes = $axes;
     $this->precision = $spec['precision'];
 }
Beispiel #29
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.php";
$l1datay = array(11, 9, 2, 4, 3, 13, 17);
$l2datay = array(23, 12, 5, 19, 17, 10, 15);
$datax = array('Jan', 'Feb', 'Mar', 'Apr', 'May');
// Create the graph.
$graph = new Graph(400, 200);
$graph->SetScale('textlin');
$graph->img->SetMargin(40, 130, 20, 40);
$graph->SetShadow();
// Create the linear error plot
$l1plot = new LinePlot($l1datay);
$l1plot->SetColor('red');
$l1plot->SetWeight(2);
$l1plot->SetLegend('Prediction');
// Create the bar plot
$l2plot = new LinePlot($l2datay);
$l2plot->SetFillColor('orange');
$l2plot->SetLegend('Result');
// Add the plots to the graph
$graph->Add($l2plot);
$graph->Add($l1plot);
$graph->title->Set('Mixing line and filled line');
$graph->xaxis->title->Set('X-title');
$graph->yaxis->title->Set('Y-title');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new BarPlot($data_freq);
// Create targets and alt texts for the image maps. One for each bar
// (In this example this is just "dummy" targets)
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$bplot->SetCSIMTargets($targ, $alts);
// Create accumulative graph
$lplot = new LinePlot($data_accfreq);
// We want the line plot data point in the middle of the bars
$lplot->SetBarCenter();
// Use transperancy
$lplot->SetFillColor('lightblue@0.6');
$lplot->SetColor('blue@0.6');
//$lplot->SetColor('blue');
$graph->AddY2($lplot);
// Setup the bars
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$bplot->value->Show();
// Add it to the graph
$graph->Add($bplot);