} //=========== $graph = new Graph(750, 450); $graph->img->SetMargin(40, 40, 40, 80); $graph->img->SetAntiAliasing(); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set(strtoupper($pabrik) . " FFA " . $periode); $graph->title->SetFont(FF_DEFAULT, FS_NORMAL, 14); $graph->xaxis->SetFont(FF_DEFAULT, FS_NORMAL, 11); $graph->xaxis->SetTickLabels($labels); $graph->xaxis->SetLabelAngle(45); $p1 = new ScatterPlot($datay1); $p2 = new ScatterPlot($datay2); $p1->SetLegend('CPO'); $p2->SetLegend('Kernel'); $graph->legend->Pos(0.02, 0.03); $p1->mark->SetType(MARK_SQUARE); $p1->SetImpuls(); $p1->mark->SetFillColor("red"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p2->mark->SetType(MARK_FILLEDCIRCLE); $p2->SetImpuls(); $p2->mark->SetFillColor("orange"); $p2->mark->SetWidth(4); $p2->SetColor("black"); $p1->SetCenter(); $graph->Add(array($p1, $p2)); $graph->Stroke(); }
{ return sprintf("%02.2f", $l); } // Setup the basic parameters for the graph $graph = new Graph(400, 200); $graph->SetScale("intlin"); $graph->SetShadow(); $graph->SetBox(); $graph->title->Set("Impuls Example 3"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Set format callback for labels $graph->yaxis->SetLabelFormatCallback("mycallback"); // Set X-axis at the minimum value of Y-axis (default will be at 0) $graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis // Extend the margin for the labels on the Y-axis and reverse the direction // of the ticks on the Y-axis $graph->yaxis->SetLabelMargin(12); $graph->xaxis->SetLabelMargin(6); $graph->yaxis->SetTickSide(SIDE_LEFT); $graph->xaxis->SetTickSide(SIDE_DOWN); // Create a new impuls type scatter plot $sp1 = new ScatterPlot($datay); $sp1->mark->SetType(MARK_SQUARE); $sp1->mark->SetFillColor("red"); $sp1->SetImpuls(); $sp1->SetColor("blue"); $sp1->SetWeight(1); $sp1->mark->SetWidth(3); $graph->Add($sp1); $graph->Stroke();
/** * add plot to graph * @param string $pType plot types self::PT_* * @param array $pOptions plot options * @param boolean $pAdd if false, return plot instead of adding to graph * @return object plot, if not rendered directly */ public function addPlot($pType = self::PT_LINE, $pOptions = array(), $pAdd = true) { $file = self::$JPGRAPH_DIR . \DIRECTORY_SEPARATOR . self::$GRAPH_FILES[self::$GRAPH_TYPES[$pType]]; if (\file_exists($file)) { require_once $file; } if (!(count($this->dataX) > 0)) { $this->dataX = false; } switch ($pType) { case self::PT_LINE: $plot = new \LinePlot($this->dataY, $this->dataX); break; case self::PT_AREA: $plot = new \LinePlot($this->dataY, $this->dataX); if (\array_key_exists('color', $pOptions)) { $plot->SetFillColor($pOptions['color']); } break; case self::PT_BAR: $plot = new \BarPlot($this->dataY, $this->dataX); break; case self::PT_ERROR: $plot = new \ErrorPlot($this->dataY, $this->dataY); break; case self::PT_FIELD: $plot = new \FieldPlot($this->dataY, $this->dataX); break; case self::PT_STOCK: $plot = new \StockPlot($this->dataY, $this->dataX); break; case self::PT_SCATTER: $plot = new \ScatterPlot($this->dataY, $this->dataX); break; case self::PT_BALLOON: $plot = new \ScatterPlot($this->dataY, $this->dataX); break; case self::PT_IMPULS: $plot = new \ScatterPlot($this->dataY, $this->dataX); $plot->SetImpuls(); break; case self::PT_PIE: $this->graph = new \PieGraph(self::$WIDTH, self::$HEIGHT); $plot = new \PiePlot($this->data); break; } if ($pAdd) { $this->plots[] = $plot; $this->graph->Add($plot); } else { return $plot; } }