function createPie($values, $title, $x, $y) { $plot = new Pie($values); $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.4, 0.4); $plot->setCenter($x, $y); $plot->setBorderColor(new Black()); return $plot; }
function createPie($values, $title, $x, $y) { $plot = new Pie($values, PIE_EARTH); $plot->title->set($title); $plot->title->setFont(new TuffyBold(9)); $plot->title->move(NULL, -12); $plot->label->setFont(new Tuffy(7)); $plot->legend->hide(TRUE); $plot->setLabelPosition(5); $plot->setSize(0.48, 0.35); $plot->setCenter($x, $y); $plot->set3D(8); $plot->setBorderColor(new White()); 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();
<?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 17)"); $graph->title->setFont(new Tuffy(14)); $values = array(12, 16, 13, 18, 10, 20, 11); $plot = new Pie($values, PIE_AQUA); $plot->setCenter(0.4, 0.55); $plot->setAbsSize(180, 180); $plot->setLegend(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')); $explode = array(); for ($i = 0; $i < count($values); $i++) { $explode[] = 15; } $plot->explode($explode); $plot->legend->setPosition(1.5); $plot->legend->shadow->setSize(0); $graph->add($plot); $graph->draw();
// police de caractère des étiquettes $pie->label->setFont(new Tuffy(8)); // fond de couleur des étiquettes $pie->label->setBackgroundColor(new White(50)); // padding des étiquettes $pie->label->setPadding(2, 2, 2, 2); // la légende // 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
/** * Формирование диаграммы. * * Функция формирует, а затем записывает в файл ($File) изображение диаграммы по * переданным пользователем данным($Lines). * * @param string <заголовок диаграммы> * @param string <полный путь с именем файла-результата> * @param array <исходные данные> * @param array <легенда диаграммы> */ function Artichow_Pie($Name, $File, $Lines, $Labels) { #----------------------------------------------------------------------------- $Graph = new Graph(500, 400); $Graph->setDriver('gd'); $Graph->setAntiAliasing(TRUE); $Graph->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240, 0), new White(), 0)); #----------------------------------------------------------------------------- $Graph->title->set($Name); $Graph->title->setFont(new Tuffy(15)); #----------------------------------------------------------------------------- $Pie = new Pie($Lines, array(new LightOrange(), new LightPurple(), new LightBlue(), new LightRed(), new LightPink(), new VeryDarkGreen(), new MidBlue(), new VeryDarkCyan(), new Cyan(), new DarkOrange(), new VeryLightOrange())); $Pie->setCenter(0.3, 0.5); $Pie->setAbsSize(300, 300); $Pie->setPadding(40, 40, 40, 40); $Pie->setLegend($Labels); #----------------------------------------------------------------------------- $Pie->legend->setTextFont(new Tuffy(7)); $Pie->legend->setPosition(1.6, 0.5); #----------------------------------------------------------------------------- $Pie->title->move(0, -40); $Pie->title->setFont(new Tuffy(14)); $Pie->title->setBackgroundColor(new White(50)); $Pie->title->setPadding(5, 5, 2, 2); $Pie->title->border->setColor(new Black()); #----------------------------------------------------------------------------- $Graph->add($Pie); #----------------------------------------------------------------------------- $Graph->draw($File); #----------------------------------------------------------------------------- return TRUE; }
<?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->setAntiAliasing(TRUE); $graph->title->set("Customized colors"); $graph->title->setFont(new Tuffy(12)); $graph->title->move(80, 10); $values = array(16, 9, 13, 23); $colors = array(new LightOrange(), new LightPurple(), new LightBlue(), new LightRed(), new LightPink()); $plot = new Pie($values, $colors); $plot->setCenter(0.3, 0.53); $plot->setAbsSize(200, 200); $plot->setBorderColor(new White()); $plot->setStartAngle(234); $plot->setLegend(array('Arthur', 'Abel', 'Pascal', 'Thamer')); $plot->setLabelPosition(-40); $plot->label->setPadding(2, 2, 2, 2); $plot->label->setFont(new Tuffy(7)); $plot->label->setBackgroundColor(new White(60)); $plot->legend->setPosition(1.38); $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(300, 175); $graph->setBackgroundGradient(new LinearGradient(new VeryLightGray(40), new White(), 90)); $graph->title->set("Arbitrary labels"); $graph->title->setAngle(90); $graph->title->move(120, NULL); $values = array(8, 4, 6, 2, 5, 3, 4); $plot = new Pie($values); $plot->setCenter(0.45, 0.5); $plot->setSize(0.55, 0.55 * 300 / 175); $plot->label->set(array('Arthur', 'Abel', 'Bernard', 'Thierry', 'Paul', 'Gaston', 'Joe')); $plot->label->setCallbackFunction(NULL); // We must disable the default callback function $plot->setLabelPosition(10); $plot->setLegend(array('ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQR', 'STU')); $plot->legend->hide(TRUE); $graph->add($plot); $graph->draw();
* 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();
* 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); $graph->title->set("It's raining again"); $graph->title->setBackgroundColor(new White(25)); $graph->title->border->show(); $graph->title->setPadding(3, 3, 3, 3); $x = array(); for ($i = 0; $i < 7; $i++) { $x[] = mt_rand(20, 100); } $y = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'); $plot = new Pie($x, PIE_AQUA); $plot->setCenter(0.5, 0.58); $plot->setSize(mt_rand(50, 100) / 100, mt_rand(50, 100) / 100); $plot->setLegend($y); $plot->setBorderColor(new Color(0, 0, 0)); $plot->label->hide(TRUE); //$plot->legend->add($plot, "Test", LEGEND_BACKGROUND); $plot->legend->setPadding(10, 10, 10, 10); $plot->legend->setTextMargin(8, 0); $plot->legend->shadow->setSize(4); $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); $graph->shadow->setSize(10); $graph->shadow->smooth(TRUE); $x = array(); for ($j = 0; $j < mt_rand(3, 6); $j++) { $x[] = mt_rand(35, 100); } $plot = new Pie($x, PIE_DARK); $plot->setSize(0.8, 0.8); $plot->setCenter(mt_rand(45, 55) / 100, mt_rand(45, 55) / 100); $plot->set3D(10); $plot->setBorderColor(new Color(230, 230, 230)); $plot->explode(array(1 => mt_rand(5, 50), 2 => mt_rand(5, 50), 3 => 12)); $plot->legend->setPadding(10, 10, 10, 10); $plot->legend->setTextMargin(8, 0); $plot->legend->hide(TRUE); $graph->add($plot); $graph->draw();
public function draw($format = false) { /* Make sure we have GD support. */ if (!function_exists('imagecreatefromjpeg')) { die; } if ($format === false) { $format = IMG_PNG; } $graph = new Graph($this->width, $this->height); $colors = array(new Green(), new Orange()); $graph->setFormat($format); $graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4)); $graph->shadow->setSize(3); $graph->title->set($this->title); $graph->title->setFont(new Tuffy(10)); $graph->title->setColor(new Color(0x0, 0x0, 0x8b)); $graph->border->setColor(new Color(187, 187, 187, 15)); $plot = new Pie($this->xValues, $colors); $plot->setCenter(0.5, 0.45); $plot->setAbsSize(160, 160); $plot->setLegend($this->xLabels); $plot->legend->setModel(Legend::MODEL_BOTTOM); $plot->legend->setPosition(NULL, 1.25); /*$this->legendOffset*/ $plot->legend->shadow->setSize(0); $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; }