function createPie($values, $title, $x, $y) { $plot = new Pie($values, PIE_EARTH); $plot->title->set($title); $plot->title->setFont(new TuffyBold(8)); $plot->title->move(NULL, -12); $plot->label->setFont(new Tuffy(7)); $plot->legend->hide(TRUE); $plot->setLabelPosition(5); $plot->setSize(0.45, 0.45); $plot->setCenter($x, $y); $plot->set3D(10); $plot->setBorderColor(new Color(230, 230, 230)); return $plot; }
<?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 "../../Pie.class.php"; $graph = new Graph(300, 175); $graph->setBackgroundGradient(new LinearGradient(new White(), new VeryLightGray(40), 0)); $graph->title->set("Horses"); $graph->shadow->setSize(5); $graph->shadow->smooth(TRUE); $graph->shadow->setPosition(SHADOW_LEFT_BOTTOM); $graph->shadow->setColor(new DarkGray()); $values = array(8, 4, 6, 2, 5); $plot = new Pie($values); $plot->setCenter(0.35, 0.55); $plot->setSize(0.7, 0.6); $plot->set3D(10); $plot->setLabelPosition(10); $plot->setLegend(array('France', 'Spain', 'Italy', 'Germany', 'England')); $plot->legend->setPosition(1.4); $plot->legend->shadow->setSize(0); $plot->legend->setBackgroundColor(new VeryLightGray(30)); $graph->add($plot); $graph->draw();
// tableau des noms dans la légende $pie->setLegend($x); // positionement de la légende $pie->legend->setPosition(1.45, .45); // le camember // positionement du camembert $pie->setCenter(.35, .50); // taille du camembert $pie->setSize(.60, .70); // encadrement des différentes partie du camembert // remplacer 1.0.9 par setBorderColor // $pie->setBorder(new Black()); $pie->setBorderColor(new Black()); // mode 3D du camembert $pie->set3D(15); // couleur de fond du camembert //$pie->setBackgroundColor(new White(0)); // part à séparer ? //$pie->explode(); // le titre // le texte du titre $pie->title->set($donnee_titre[0]); // emplacement du titre $pie->title->move(10, -20); // police de caractère du titre $pie->title->setFont(new TuffyBold(10)); // le fond de couleur du titre $pie->title->setBackgroundColor(new White(50)); // les espacement dans le cadre du titre
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../Pie.class.php"; $graph = new Graph(400, 300); $graph->setTiming(TRUE); $graph->setAntiAliasing(TRUE); for ($i = 0; $i < 4; $i++) { $x = array(); for ($j = 0; $j < 6; $j++) { $x[] = mt_rand(35, 100); } $plot = new Pie($x, PIE_DARK); $plot->setStartAngle(mt_rand(0, 360)); $plot->title->set('Pie #' . $i); $plot->setSize(0.45, 0.45); $plot->setCenter($i % 2 / 2 + 0.2, $i > 1 ? 0.2 : 0.7); if (mt_rand(0, 1) === 1) { $plot->set3D(15); } $plot->setBorderColor(new Color(230, 230, 230)); $plot->explode(array(mt_rand(5, 35), 3 => 8)); if ($i === 3) { $plot->legend->setPosition(1.1, 1.0); } else { $plot->legend->setTextMargin(8, 0); $plot->legend->hide(TRUE); } $graph->add($plot); } $graph->draw();
<?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 "../../Pie.class.php"; $graph = new Graph(400, 300); $graph->setTiming(TRUE); $graph->setAntiAliasing(TRUE); $x = array(); for ($i = 0; $i < 7; $i++) { $x[] = mt_rand(20, 100); } $plot = new Pie($x, PIE_EARTH); $plot->setBorderColor(new Color(50, 50, 50)); $plot->set3D(20); $plot->setLabelPosition(-60); $plot->label->setPadding(2, 2, 2, 2); $plot->label->border->setColor(new Red(20)); $plot->label->setFont(new Tuffy(7)); $plot->label->setBackgroundGradient(new LinearGradient(new LightRed(30), new White(30), 0)); $plot->legend->setPadding(10, 10, 10, 10); $plot->legend->setTextMargin(8, 0); $graph->add($plot); $graph->draw();
<?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 "../Pie.class.php"; $graph = new Graph(400, 250); $graph->setAntiAliasing(TRUE); $graph->title->set("Pie (example 7)"); $values = array(8, 4, 6, 2, 5, 3, 4); $plot = new Pie($values, PIE_DARK); $plot->setCenter(0.4, 0.55); $plot->setSize(0.7, 0.6); $plot->set3D(5); $plot->setBorderColor(new White()); $plot->setLegend(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')); $plot->legend->setPosition(1.3); $plot->legend->setBackgroundColor(new VeryLightGray(30)); $plot->legend->shadow->setPosition(SHADOW_RIGHT_TOP); $plot->label->setPadding(2, 2, 2, 2); $plot->label->border->setColor(new Red(60)); $plot->label->setFont(new Tuffy(7)); $plot->label->setBackgroundGradient(new LinearGradient(new Red(80), new White(80), 0)); $plot->setLabelPrecision(1); $graph->add($plot); $graph->draw();
protected function getImage_p($id) { require_once "./protected/pages/components/velopark/artichow/Pie.class.php"; $sql = "SELECT id, area,filling, name FROM hr_vp_parking "; $cmd = $this->db->createCommand($sql); $data = $cmd->query(); $data = $data->read(); $graph = new Graph(500, 300); $graph->setBackgroundGradient(new LinearGradient(new White(), new VeryLightGray(40), 0)); $graph->title->set(Prado::localize("Service {name}", array("name" => utf8_decode($data['name'])))); $graph->shadow->setSize(3); $graph->shadow->smooth(TRUE); $graph->shadow->setPosition(Shadow::RIGHT_BOTTOM); $graph->shadow->setColor(new DarkGray()); $values = array($data['filling'], $data['area'] - $data['filling'] + 1.0E-9); //$values = array(22.0,0.000000001); $colors = array(new LightRed(), new LightGreen()); $plot = new Pie($values, $colors); $plot->setCenter(0.42, 0.55); $plot->setSize(0.7, 0.7); $plot->set3D(20); /*if($data['filling']>0) $plot->explode(array(1 => 10));*/ $plot->setLegend(array(utf8_decode(Prado::localize('Used')), utf8_decode(Prado::localize('Free')))); $plot->legend->setPosition(1.3); $plot->legend->shadow->setSize(0); $plot->legend->setBackgroundColor(new VeryLightGray(30)); $graph->add($plot); $graph->draw(); exit; }