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);
 }
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph();
$graph->setTiming(TRUE);
$graph->setSize(400, 400);
$graph->setAntiAliasing(TRUE);
$x = array();
$k = array();
for ($i = 0; $i < 100; $i++) {
    $x[] = cos($i / 10);
    $k[] = sprintf("%.1f", $i / 10);
}
$plot = new LinePlot($x, $k);
$plot->setBackgroundColor(color(80));
$plot->setYAxis(PLOT_BOTH);
$plot->setColor(color());
$plot->grid->setInterval(mt_rand(1, 4), mt_rand(1, 4));
$plot->yAxis->setLabelNumber(20);
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->setTickInterval(5);
$plot->xAxis->setLabelInterval(2);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 1);
$plot->xAxis->setLabelText($k);
foreach ($x as $k => $v) {
    $x[$k] = sprintf("%.2f", $v);
}
$plot->label->set($x);
$plot->label->setColor(color(0));
$group->axis->bottom->title->setBackgroundColor(new Color(255, 255, 255, 25));
$group->axis->bottom->title->setPadding(1, 0, 0, 0);
$group->axis->top->title->set("Axis des X : Treize plus douze");
$group->axis->top->title->setBackgroundColor(new Color(240, 200, 197, 25));
$group->axis->top->title->setPadding(1, 0, 0, 0);
$count = mt_rand(2, 4);
for ($n = 0; $n < $count; $n++) {
    $x = array();
    for ($i = 0; $i < 10; $i++) {
        $x[] = round(cos($i * M_PI / 10) * mt_rand(-20, 100));
    }
    $plot = new LinePlot($x);
    $plot->setColor(color());
    $plot->setFillColor(color(90));
    $plot->setXAxis(mt_rand(0, 1) ? PLOT_BOTTOM : PLOT_TOP);
    $plot->setYAxis(mt_rand(0, 1) ? PLOT_LEFT : PLOT_RIGHT);
    $plot->label->set($x);
    $plot->label->setColor(color(0));
    if ($n % 2 === 0) {
        $plot->label->setBackgroundColor(new Color(mt_rand(220, 240), mt_rand(220, 240), mt_rand(220, 240), mt_rand(15, 35)));
    }
    $plot->label->setPadding(1, 0, 0, 0);
    $group->add($plot);
    $group->legend->add($plot, str_repeat("#" . ($n + 1), mt_rand(1, 2)), $n % 2 ? LEGEND_LINE : LEGEND_BACKGROUND);
}
$group->legend->setColumns(2);
$group->legend->border->hide();
$group->legend->setSpace(20);
$group->legend->setBackgroundColor(new Color(245, 255, 255));
$group->setPadding(NULL, 130, NULL, NULL);
$graph->add($group);
Exemplo n.º 4
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();
Exemplo n.º 5
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
    * const int TRIANGLE := 3
    $group->axis->{$axis}->setLabelNumber(mt_rand(0, 10));
    $group->axis->{$axis}->setLabelPrecision(1);
}
foreach (array('top', 'bottom') as $axis) {
    $group->axis->{$axis}->label->hideLast(TRUE);
    $group->axis->{$axis}->label->hideFirst(TRUE);
    $group->axis->{$axis}->setTickInterval(mt_rand(17, 23));
    $group->axis->{$axis}->setLabelInterval(2);
}
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 500; $i++) {
        $x[] = cos($i * M_PI / 500) / ($n + 1) * mt_rand(800, 1200) / 1000;
    }
    $plot = new LinePlot($x);
    $plot->setColor(color());
    $plot->setFillColor(color(40));
    $plot->setXAxis($n % 2 ? 'top' : 'bottom');
    $plot->setYAxis($n % 2 ? 'left' : 'right');
    $group->add($plot);
    $group->legend->add($plot, "Line #" . ($n + 1), $n ? LEGEND_LINE : LEGEND_BACKGROUND);
}
$group->legend->border->setColor(color(0));
$group->legend->setTextColor(color(0));
$group->legend->setTextFont(new PHPFont(mt_rand(1, 3)));
$group->legend->setPadding(3, 3, 3, 3);
$group->legend->setRows(1);
$group->legend->setAlign(LEGEND_LEFT, LEGEND_BOTTOM);
$group->legend->setPosition(0.16, 0.86);
$graph->add($group);
$graph->draw();
}
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 50; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0);
    }
    $plot = new LinePlot($x, mt_rand(0, 1) ? LINEPLOT_LINE : LINEPLOT_MIDDLE);
    $plot->setColor(color());
    $plot->setFillGradient(new LinearGradient(color(60), color(60), 90));
    $y = array();
    foreach ($x as $v) {
        $y[] = sprintf("%.2f", $v);
    }
    $plot->label->set($y);
    $plot->label->setColor(color(0));
    $plot->label->setBackgroundColor(new Color(mt_rand(220, 240), mt_rand(220, 240), mt_rand(220, 240), mt_rand(10, 20)));
    $plot->label->setPadding(1, 0, 0, 0);
    $plot->label->setInterval(12);
    $plot->label->setFont(new Tuffy(6));
    $plot->setXAxis(PLOT_BOTTOM);
    $plot->setYAxis(PLOT_LEFT);
    $group->add($plot);
    $group->legend->add($plot, "Line #" . ($n + 1));
}
$group->legend->setAlign(LEGEND_CENTER, LEGEND_TOP);
$group->legend->setPosition(0.87, 0.1);
$graph->shadow->setSize(mt_rand(10, 20));
$graph->shadow->setPosition(mt_rand(1, 4));
$graph->shadow->smooth(mt_rand(0, 1) ? TRUE : FALSE);
$graph->add($group);
$graph->draw();