* 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(); $graph->setTiming(TRUE); function color($a = NULL) { if ($a === NULL) { $a = mt_rand(0, 100); } return new Color(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), $a); } $graph->setSize(400, 400); $graph->setFormat(IMAGE_PNG); $graph->setBackgroundColor(new Color(150, 150, 150)); for ($i = 0; $i <= 1; $i++) { $x = array(); for ($j = 0, $count = mt_rand(1, 8); $j <= $count; $j++) { $x[] = mt_rand(-100, 100) / 10; } $plot = new LinePlot($x); $plot->title->set("Component #" . $i); if (mt_rand(0, 1) === 0) { $plot->setBackgroundGradient(new LinearGradient(color(), color(), mt_rand(0, 1) * 90)); } else { $plot->setBackgroundColor(color()); } $mark = mt_rand(1, 2); $plot->mark->setType($mark);
public function draw($format = false) { /* Make sure we have GD support. */ if (!function_exists('imagecreatefromjpeg')) { die; } if ($format === false) { $format = IMG_JPEG; } $graph = new Graph($this->width, $this->height); $graph->setFormat($format); $graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4)); $graph->shadow->setSize(6); $graph->title->set($this->title); $graph->title->setFont(new Tuffy(48)); $graph->title->setColor(new Color(0x0, 0x0, 0x8b)); $graph->border->setColor(new Color(187, 187, 187, 15)); $plot = new BarPlotPipeline($this->xValues, 1, 1, 0, $this->totalValue, false); $plot->setPadding(40, 40, 15, 45); $plot->setBarColor(new DarkGreen()); $plot->barBorder->hide(true); $plot->arrayBarBackground = $this->colorArray; $plot->xAxis->setLabelText($this->xLabels); $plot->xAxis->label->setFont(new Tuffy(24)); $plot->yAxis->label->setFont(new Tuffy(18)); $graph->add($plot); $graph->draw(); die; }