public function create() { $legend = $this->getArg('legend'); $y = $this->getArg('y'); if ($y === NULL) { awImage::drawError("Class LightLinePattern: Argument 'y' must not be NULL."); } $plot = new LinePlot($y); $plot->setSize(0.7, 1); $plot->setCenter(0.35, 0.5); $plot->setPadding(35, 15, 35, 30); $plot->setColor(new Orange()); $plot->setFillColor(new LightOrange(80)); $plot->grid->setType(Line::DASHED); $plot->mark->setType(Mark::CIRCLE); $plot->mark->setFill(new MidRed()); $plot->mark->setSize(6); $plot->legend->setPosition(1, 0.5); $plot->legend->setAlign(Legend::LEFT); $plot->legend->shadow->smooth(TRUE); if ($legend !== NULL) { $plot->legend->add($plot, $legend, Legend::MARK); } return $plot; }
function CreeGraphClassementZoom($fichier) { // Initialement, ces variables étaient passés dans la session // $G_listeJeux=$_SESSION['G_listeJeuxZoom']; // $G_listeJoueurs=$_SESSION['G_listeJoueursZoom']; // $G_listeResultats=$_SESSION['G_listeResultatsZoom']; // $G_MesCouleurs=$_SESSION['G_mesCouleurs']; global $G_ListeJeuxZoom; global $G_MesCouleurs; global $G_ListeResultatsMoyensZoom; global $G_ListeJoueurs; // Le niveau de transparence est définit à 95% // Ici, le graphique mesurera 620 x 700 pixels. $graph = new Graph(620, 700); // L'anti-aliasing permet d'afficher des courbes plus naturelles, // mais cette option consomme beaucoup de ressources sur le serveur. $graph->setAntiAliasing(TRUE); // Titre du graphe ! $graph->title->set("Zoom sur les quatre dernières moyennes"); // L'objet group permet de gérer plusieurs courbes sur un même grpahiques $group = new PlotGroup(); // Le style des lignes des courbes est dashed $group->grid->setType(LINE_DASHED); // La marge gauche est fixée à 40px du bord, droite à 20, haut à 40px et basse à 120px $group->setPadding(40, 20, 40, 120); // Le titre sur les absisses est : % Réussite $group->axis->left->title->set("% Reussite"); $group->setYAxisZero(false); // Les libellés sur les absisses sont inclinés de 45% $group->axis->bottom->label->setAngle(45); // Affiche 10 marques entre 2 marques majeures $group->axis->left->setNumberByTick('minor', 'major', 10); // Titre des ordonnées //$group->axis->bottom->title->set("Journées"); // La légende est affiché en bas du graphe $group->legend->setModel(LEGEND_MODEL_BOTTOM); // Position de la légénde par rapport au graphe $group->legend->setPosition(NULL, 0.9); // Nb de colonnes $group->legend->setRows(2); //$group->legend->shadow->hide(); // On créé autant de courbes qu'il y a de joueurs ! for ($j = 0; $j < sizeof($G_ListeJoueurs); $j++) { // Recherche des résultats du joueur $j $G_ResultatJoueur = array(); for ($k = 0; $k < sizeof($G_ListeJeuxZoom); $k++) { if (isset($G_ListeResultatsMoyensZoom[$k][$j])) { $G_ResultatJoueur[$k] = $G_ListeResultatsMoyensZoom[$k][$j]; } else { $G_ResultatJoueur[$k] = null; } } // Création d'une courbe pour ce joueur $plot = new LinePlot($G_ResultatJoueur); $plot->setColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2])); $plot->setFillColor(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2], NIVEAU_TRANSPARENCE)); $plot->mark->setType(MARK_CIRCLE); if ($j % 3 == 0) { $plot->mark->setType(MARK_TRIANGLE); } if ($j % 4 == 0) { $plot->mark->setType(MARK_CROSS); } $plot->mark->setFill(new Color($G_MesCouleurs[$j][0], $G_MesCouleurs[$j][1], $G_MesCouleurs[$j][2])); $plot->mark->setSize(7); $plot->yAxis->setLabelNumber(0.5); // $plot->xAxis->label->setAngle(45); $plot->setPadding(10, 10, 10, 10); // Ajoute d'une légende pour cette courbe et ce joueur $group->legend->add($plot, $G_ListeJoueurs[$j], LEGEND_MARK); // Ajoute cette courbe au group $group->add($plot); } // Fonction qui retourne les Abscisses function setAbscisseZoom($value) { global $G_ListeJeuxZoom; return $G_ListeJeuxZoom[$value]; } $group->axis->bottom->label->setCallbackFunction('setAbscisseZoom'); // Fonction qui retourne les Ordonnés function setOrdonneZoom($value) { return round($value); } $group->axis->left->label->setCallbackFunction('setOrdonneZoom'); // Ajout de ce groupe au graphique $graph->add($group); $graph->draw($fichier); }
$group->axis->left->setLabelNumber(8); $group->axis->left->setLabelPrecision(1); $group->axis->left->setTickStyle(TICK_OUT); $x = array(2, 4, 8, 16, 32, 48, 56, 60, 62); $plot = new LinePlot($x); $plot->setColor(new Orange()); $plot->setFillColor(new LightOrange(80)); $plot->mark->setType(MARK_CIRCLE); $plot->mark->setFill(new MidRed()); $plot->mark->setSize(6); $group->legend->add($plot, "John", LEGEND_MARK); $group->add($plot); $x = array(NULL, NULL, NULL, 10, 12, 14, 18, 26, 42); $plot = new LinePlot($x); $plot->setColor(new Color(120, 120, 30, 10)); $plot->setFillColor(new Color(120, 120, 60, 90)); $plot->mark->setType(MARK_SQUARE); $plot->mark->setFill(new DarkGreen()); $plot->mark->setSize(5); $group->add($plot); function setYear($value) { return $value + 2000; } $group->axis->bottom->label->setCallbackFunction('setYear'); function setK($value) { return round($value) . 'K'; } $group->axis->left->label->setCallbackFunction('setK'); $group->legend->add($plot, "George", LEGEND_MARK);
<?php include "../jpgraph.php"; include "../jpgraph_line.php"; // create the graph $graph = new Graph(400, 250, "auto"); $ydata = array(5, 10, 15, 20, 15, 10); $graph->SetScale("textlin"); $graph->SetShadow(true); $graph->SetMarginColor("antiquewhite"); $graph->img->SetMargin(60, 40, 40, 50); $graph->img->setTransparent("white"); $graph->xaxis->SetFont(FF_FONT1); $graph->xaxis->setTextTickInterval(1); $graph->xaxis->SetTextLabelInterval(1); $graph->legend->SetFillColor("antiquewhite"); $graph->legend->SetShadow(true); $graph->legend->SetLayout(LEGEND_VERT); $graph->legend->Pos(0.02, 0.01); $graph->title->Set("Step Styled Example"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $lineplot = new LinePlot($ydata); $lineplot->SetColor("black"); $lineplot->setFillColor("gray7"); $lineplot->SetStepStyle(); $lineplot->SetLegend(" 2002 "); // add plot to the graph $graph->Add($lineplot); $graph->ygrid->show(false, false); // display graph $graph->Stroke();
$plot->yAxis->setTitleAlignment(LABEL_TOP); $group->add($plot); $group->axis->bottom->setLabelText($keys_new); $group->axis->bottom->hideTicks(TRUE); if (count($data2) > 0) { if ($type == "linesteps") { list($data_new, $data_label, $keys_new) = build_line_steps($width, $data2, $keys); } else { $data_new = $data2; $data_label = $data2; } $plot = new LinePlot($data_new); $plot->label->set($data_label); $plot->label->move(5, -7); $plot->setColor(new Color(255, 165, 0)); $plot->setFillColor(new LightOrange(80)); $group->add($plot); } $graph->add($group); } else { if ($type == "scatter") { require INCLUDE_PATH . "/ScatterPlot.class.php"; $graph = new Graph($width, $height); $graph->title->set($title); $graph->title->setFont(new Tuffy(11)); $plot = new ScatterPlot($data, $keys); $plot->grid->setType(LINE_DASHED); $plot->grid->hideVertical(TRUE); $plot->setSpace(6, 6, 6, 0); $plot->setPadding(25, 15, 27, 20); $graph->add($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 "../../LinePlot.class.php"; $graph = new Graph(450, 400); $graph->setAntiAliasing(TRUE); $values = array(); for ($i = 0; $i < 15; $i++) { $values[] = mt_rand(4, 20); } $graph->title->set('Mon graphique'); $plot = new LinePlot($values, LINEPLOT_MIDDLE); $plot->setFillColor(new Color(0, 200, 0, 75)); $plot->mark->setType(MARK_CIRCLE); $plot->mark->setSize(8); $plot->mark->setFill(new Color(255, 255, 255)); $plot->mark->border->show(); $plot->setSpace(5, 5, 5, 5); $plot->setBackgroundColor(new Color(240, 240, 240)); $graph->add($plot); $graph->draw();
<?php require_once "../../LinePlot.class.php"; $graph = new Graph(400, 300); $graph->setAntiAliasing(TRUE); $values = array(1, 7, 3, 2.5, 5, -4.5, -5); $plot = new LinePlot($values); $plot->setBackgroundColor(new Color(245, 245, 245)); $plot->hideLine(TRUE); $plot->setFillColor(new Color(180, 180, 180, 75)); $plot->grid->setBackgroundColor(new Color(235, 235, 180, 60)); $plot->yAxis->setLabelPrecision(2); $plot->yAxis->setLabelNumber(6); $days = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'); $plot->xAxis->setLabelText($days); $plot->setSpace(6, 6, 10, 10); $plot->mark->setType(MARK_IMAGE); $plot->mark->setImage(new FileImage("smiley.png")); $plot->label->set($values); $plot->label->move(0, -23); $plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0)); $plot->label->border->setColor(new Color(20, 20, 20, 20)); $plot->label->setPadding(3, 1, 1, 0); $graph->add($plot); $graph->draw();
$group->axis->left->title->set("Axis des Y : Mille deux cent quarante-et-un"); $group->axis->bottom->title->set("Axis des X : Quarante-deux plus un"); $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));
/* * 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 "../../LinePlot.class.php"; function color() { return new Color(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 100)); } $graph = new Graph(450, 400); $graph->title->set('test of LINEPLOT_MIDDLE'); $graph->setAntiAliasing(TRUE); $values = array(); for ($i = 0; $i < 5; $i++) { $values[] = mt_rand(4, 20); } $group = new PlotGroup(); $group->setSpace(5, 5, 5, 5); $group->setBackgroundColor(new Color(240, 240, 240)); $plot = new LinePlot($values, LINEPLOT_MIDDLE); $plot->setFillColor(color()); $plot->mark->setType(MARK_CIRCLE); $plot->mark->setSize(mt_rand(1, 20)); $plot->mark->setFill(new Color(255, 255, 255)); $plot->mark->border->show(); $group->add($plot); $graph->add($group); $graph->draw();
$graph = new Graph(150, 100); $x = array(); for ($i = 0; $i < 8; $i++) { $x[] = cos($i / 3 * M_PI) + mt_rand(-10, 10) / 40; } $plot = new LinePlot($x); $plot->setPadding(22, 5, 25, 8); // Hide grid $plot->grid->setType(LINE_DASHED); // Change background color $plot->setBackgroundColor(new Color(240, 240, 240, 50)); // Set Y on both left and rights sides $plot->setYAxis(PLOT_BOTH); // Change line properties $plot->setColor(new Color(0, 0, 0)); $plot->setFillColor(new Color(240, 190, 130, 50)); // Chenge ticks and labels interval $plot->xAxis->setTickInterval(2); $plot->xAxis->label->hide(TRUE); $plot->xAxis->setNumberByTick('minor', 'major', 1); // Hide first and last values on X axis $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->label->hideLast(TRUE); // Add a title $plot->title->set("Random values"); $plot->title->move(0, 2); $plot->title->setFont(new Tuffy(8)); $plot->title->setBackgroundColor(new Color(255, 255, 255, 25)); $plot->title->border->show(); $plot->title->setPadding(2, 2, 2, 2); $graph->add($plot);
/* * 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 "../../BarPlot.class.php"; require_once "../../LinePlot.class.php"; $graph = new Graph(450, 400); $graph->setAntiAliasing(TRUE); $blue = new Color(150, 150, 230, 50); $red = new Color(240, 50, 50, 25); $group = new PlotGroup(); $group->setSpace(5, 5, 5, 0); $group->setBackgroundColor(new Color(240, 240, 240)); $values = array(18, 12, 14, 21, 11, 7, 9, 16, 7, 23); $plot = new BarPlot($values); $plot->setBarColor($red); $group->add($plot); $values = array(12, 8, 6, 12, 7, 5, 4, 9, 3, 12); $plot = new LinePlot($values, LINEPLOT_MIDDLE); $plot->setFillColor($blue); $plot->mark->setType(MARK_SQUARE); $plot->mark->setSize(7); $plot->mark->setFill(new Color(255, 255, 255)); $plot->mark->border->show(); $group->add($plot); $graph->add($group); $graph->draw();
} $graph = new Graph(400, 400); $graph->setTiming(TRUE); $x = array(); for ($i = 0; $i < 10; $i++) { $x[] = mt_rand(-20, 100); } $plot = new LinePlot($x); $plot->setPadding(NULL, 40, NULL, NULL); $plot->setBackgroundColor(color(80)); $plot->setYAxis(PLOT_BOTH); $plot->setColor(color()); if (mt_rand(0, 2) > 0) { $plot->setFillGradient(new LinearGradient(color(40), color(60), mt_rand(0, 1) * 90)); } else { $plot->setFillColor(color(64)); } $plot->yAxis->setLabelNumber(mt_rand(0, 10)); $plot->yAxis->setLabelPrecision(1); $plot->yAxis->title->set("Axis des Y : Quarante-deux"); $plot->xAxis->setTickInterval(2); $plot->xAxis->setLabelInterval(2); $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->label->hideLast(TRUE); $plot->label->set($x); $plot->label->setInterval(mt_rand(1, 5)); $plot->label->setColor(color(0)); $plot->label->setBackgroundColor(new Color(mt_rand(180, 220), mt_rand(180, 220), mt_rand(180, 220), mt_rand(25, 35))); $plot->label->border->setColor(color()); $plot->label->setPadding(1, 0, 0, 0); $plot->label->setAngle(mt_rand(0, 1) ? 0 : 90);
function grafic_queue(&$pDB_ast_cdr, &$pDB_ast, $queue, $dti, $dtf) { global $arrConf; $ancho = "700"; $margenDerecho = "100"; //============================================================================ $objPalo_AST_CDR = new paloSantoExtention($pDB_ast_cdr); /* * VALORES POR GET */ $arrData = array(); $numResults = 0; $arrValue = array(); $arrTimestamp = array(); //============================================================================ include_once "libs/paloSantoQueue.class.php"; $paloQueue = new paloQueue($pDB_ast); $arrResult = strlen($queue) != 0 ? $paloQueue->getQueue($queue) : $paloQueue->getQueue(); //$arrResult //Array ( [0] => Array ( [0] => 2000 [1] => 2000 Recepcion ) // [1] => Array ( [0] => 5000 [1] => 5000 Soporte ) // [2] => Array ( [0] => 7000 [1] => 7000 Ventas ) ) /* * SE CREA UN 2 ARREGLOS DE TAMAÑO 3*X+1 * $arrData PARA LOS DATOS DEL EJE Y * $arrayX PARA EL ARREGLO DE DATOS PARA EL EJE X */ $arrayX = array(); $num = sizeof($arrResult); $i = 0; for ($i = 1; $i <= $num; $i++) { $s = $arrResult[$i - 1]; $s_0 = array(0 => "", 1 => ""); if ($i == 1) { $arrData[0] = $s_0; $arrayX[0] = ""; } $arrData[3 * ($i - 1) + 1] = $s; $arrayX[3 * ($i - 1) + 1] = ""; $arrData[3 * ($i - 1) + 2] = $s; $arrayX[3 * ($i - 1) + 2] = $s[0]; $arrData[3 * ($i - 1) + 3] = $s_0; $arrayX[3 * ($i - 1) + 3] = ""; if ($i == $num) { $arrData[3 * ($i - 1) + 4] = $s_0; $arrayX[3 * ($i - 1) + 4] = ""; } } //====================================================== $graph = new Graph($ancho, 250); $graph->SetMargin(50, $margenDerecho, 30, 40); $graph->SetMarginColor('#fafafa'); $graph->SetFrame(true, '#999999'); $graph->legend->SetFillColor("#fafafa"); $graph->legend->Pos(0.012, 0.5, "right", "center"); $graph->legend->SetColor("#444444", "#999999"); $graph->legend->SetShadow('gray@0.6', 4); $graph->title->SetColor("#444444"); // Especifico la escala $graph->SetScale("intlin"); $graph->title->Set(utf8_decode(_tr("Number Calls vs Queues"))); $graph->xaxis->SetLabelFormatCallback('NameQueue'); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetColor("#666666", "#444444"); if (is_array($arrData) && count($arrData) > 0) { foreach ($arrData as $k => $arrMuestra) { $arrTimestamp[$k] = $k; /* X */ //$arr = $objPalo_AST_CDR->countQueue( $arrMuestra['id'], $dti, $dtf); $arr = $objPalo_AST_CDR->countQueue($arrMuestra[0], $dti, $dtf); $arrValue[$k] = $arr[0]; /* Y */ } if (count($arrTimestamp) > 0) { $numResults++; $line = new LinePlot($arrValue, $arrTimestamp); $line->SetStepStyle(); $line->SetColor("#00cc00"); $line->setFillColor("#00cc00"); $line->SetLegend("# " . _tr("Calls")); $graph->Add($line); $graph->yaxis->SetColor("#00cc00"); } } //====================================================================================== if ($numResults > 0) { $graph->Stroke(); } else { $graph = new CanvasGraph(500, 140, "auto"); $title = new Text(utf8_decode(_tr("No records found"))); $title->ParagraphAlign('center'); $title->SetFont(FF_FONT2, FS_BOLD); $title->SetMargin(3); $title->SetAlign('center'); $title->Center(0, 500, 70); $graph->AddText($title); $t1 = new Text(utf8_decode(_tr("There are no data to present"))); $t1->SetBox("white", "black", true); $t1->ParagraphAlign("center"); $t1->SetColor("black"); $graph->AddText($t1); $graph->img->SetColor('navy'); $graph->img->SetTextAlign('center', 'bottom'); $graph->img->Rectangle(0, 0, 499, 139); $graph->Stroke(); } }
$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();
*/ require_once "../../LinePlot.class.php"; $graph = new Graph(280, 200); $x = array(); for ($i = 115; $i < 115 + 180; $i++) { $x[] = cos($i / 25); } function format($value) { return sprintf("%.1f", $value) . ' %'; } $plot = new LinePlot($x); $plot->setBackgroundColor(new Color(240, 240, 240)); $plot->setPadding(40, 15, 15, 15); $plot->setColor(new Color(60, 60, 150)); $plot->setFillColor(new Color(120, 175, 80, 47)); $plot->grid->setType(LINE_DASHED); $plot->yAxis->setLabelNumber(6); $plot->yAxis->setLabelPrecision(1); $plot->yAxis->setNumberByTick('minor', 'major', 1); $plot->yAxis->label->setCallbackFunction('format'); $plot->yAxis->label->setFont(new Tuffy(7)); $plot->xAxis->setNumberByTick('minor', 'major', 3); $plot->xAxis->label->hideFirst(TRUE); $plot->xAxis->setLabelInterval(50); $plot->xAxis->label->setFont(new Tuffy(7)); $plot->grid->setInterval(1, 50); $graph->shadow->setSize(4); $graph->shadow->setPosition(SHADOW_RIGHT_BOTTOM); $graph->shadow->smooth(TRUE); $plot->label->set($x);