本文整理汇总了PHP中Graph::draw方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::draw方法的具体用法?PHP Graph::draw怎么用?PHP Graph::draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: draw_artichow
/**
* Build a graph onto disk using Artichow library
*
* @param string $file Image file name to use if we save onto disk
* @param string $fileurl Url path to show image if saved onto disk
* @return void
*/
private function draw_artichow($file, $fileurl)
{
global $artichow_defaultfont;
dol_syslog(get_class($this) . "::draw_artichow this->type=" . join(',', $this->type));
if (!defined('SHADOW_RIGHT_TOP')) {
define('SHADOW_RIGHT_TOP', 3);
}
if (!defined('LEGEND_BACKGROUND')) {
define('LEGEND_BACKGROUND', 2);
}
if (!defined('LEGEND_LINE')) {
define('LEGEND_LINE', 1);
}
// Create graph
$classname = '';
if (!isset($this->type[0]) || $this->type[0] == 'bars') {
$classname = 'BarPlot';
} else {
if ($this->type[0] == 'lines') {
$classname = 'LinePlot';
} else {
$classname = 'TypeUnknown';
}
}
include_once ARTICHOW_PATH . $classname . '.class.php';
// Definition de couleurs
$bgcolor = new Color($this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]);
$bgcolorgrid = new Color($this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
$colortrans = new Color(0, 0, 0, 100);
$colorsemitrans = new Color(255, 255, 255, 60);
$colorgradient = new LinearGradient(new Color(235, 235, 235), new Color(255, 255, 255), 0);
$colorwhite = new Color(255, 255, 255);
// Graph
$graph = new Graph($this->width, $this->height);
$graph->border->hide();
$graph->setAntiAliasing(true);
if (isset($this->title)) {
$graph->title->set($this->title);
//print $artichow_defaultfont;exit;
$graph->title->setFont(new $artichow_defaultfont(10));
}
if (is_array($this->bgcolor)) {
$graph->setBackgroundColor($bgcolor);
} else {
$graph->setBackgroundGradient($colorgradient);
}
$group = new PlotGroup();
//$group->setSpace(5, 5, 0, 0);
$paddleft = 50;
$paddright = 10;
$strl = dol_strlen(max(abs($this->MaxValue), abs($this->MinValue)));
if ($strl > 6) {
$paddleft += $strl * 4;
}
$group->setPadding($paddleft, $paddright);
// Width on left and right for Y axis values
$group->legend->setSpace(0);
$group->legend->setPadding(2, 2, 2, 2);
$group->legend->setPosition(NULL, 0.1);
$group->legend->setBackgroundColor($colorsemitrans);
if (is_array($this->bgcolorgrid)) {
$group->grid->setBackgroundColor($bgcolorgrid);
} else {
$group->grid->setBackgroundColor($colortrans);
}
if ($this->hideXGrid) {
$group->grid->hideVertical(true);
}
if ($this->hideYGrid) {
$group->grid->hideHorizontal(true);
}
// On boucle sur chaque lot de donnees
$legends = array();
$i = 0;
$nblot = count($this->data[0]) - 1;
while ($i < $nblot) {
$x = 0;
$values = array();
foreach ($this->data as $key => $valarray) {
$legends[$x] = $valarray[0];
$values[$x] = $valarray[$i + 1];
$x++;
}
// We fix unknown values to null
$newvalues = array();
foreach ($values as $val) {
$newvalues[] = is_numeric($val) ? $val : null;
}
if ($this->type[0] == 'bars') {
//print "Lot de donnees $i<br>";
//print_r($values);
//print '<br>';
$color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20);
//.........这里部分代码省略.........
示例2: CreeGraphClassementZoom
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);
}
示例3: color
*
*/
require_once "../../LinePlot.class.php";
function color($a = NULL)
{
if ($a === NULL) {
$a = mt_rand(20, 80);
}
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400, "Abel", time() + 5);
$graph->setTiming(TRUE);
$graph->setAntiAliasing(TRUE);
$x = array();
for ($i = 0; $i < 10; $i++) {
$x[] = mt_rand(0, 100);
}
$plot = new LinePlot($x);
$plot->setThickness(1);
$plot->setColor(color());
$plot->setFillGradient(new LinearGradient(color(), color(), 0));
$plot->grid->setType(LINE_DASHED);
$plot->setYMin(mt_rand(-20, 0));
$plot->yAxis->setLabelNumber(mt_rand(0, 10));
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 2);
$plot->setXAxisZero((bool) mt_rand(0, 1));
$graph->add($plot);
$graph->draw();
示例4: Artichow_Line
/**
* Формирование графика.
*
* Функция формирует, а затем записывает в файл ($File) изображение графика по
* переданным пользователем данным($Lines). Данная функция может рисовать как одиночные,
* так и многолинейные графики.Исходными данными является массив, элементы которого также
* является массивами исходных данных для соответствующих графиков (данная структура
* сохраняется и для одиночных графиков!). Цвет каждой линии передается в массиве
* $Colors, ключи которого совпадают с ключами массива исходных данных. Цвет задается
* шестнадцатиричным кодом цвета (например, 0x000000 для черного цвета).
*
* @param string <заголовок диаграммы>
* @param string <полный путь с именем файла-результата>
* @param array <исходные данные>
* @param array <подписи к оси Ox>
* @param array <цвета линий>
*/
function Artichow_Line($Name, $File, $Lines, $Labels, $Colors)
{
#-----------------------------------------------------------------------------
$Graph = new Graph(1000, 300);
$Graph->setDriver('gd');
$Graph->setAntiAliasing(TRUE);
#-----------------------------------------------------------------------------
$Graph->title->set($Name);
$Graph->title->setFont(new Tuffy(15));
$Graph->title->move(0, -5);
#-----------------------------------------------------------------------------
if (Count($Lines) > 1) {
#---------------------------------------------------------------------------
$Group = new PlotGroup();
$Group->setPadding(40, 40);
$Group->setBackgroundColor(new Color(240, 240, 240));
}
#-----------------------------------------------------------------------------
$IsSetLabel = FALSE;
#-----------------------------------------------------------------------------
foreach ($Lines as $LineID => $Line) {
#---------------------------------------------------------------------------
$Plot = new LinePlot($Line);
$Color = Color_RGB_Explode($Colors[$LineID]);
$Plot->setColor(new Color($Color['R'], $Color['G'], $Color['B']));
$Plot->setThickness(1);
$Plot->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240), new Color(255, 255, 255), 0));
$Plot->setFillGradient(new LinearGradient(new LightOrange(10), new VeryLightOrange(90), 90));
$Plot->setPadding(50, 50, 50, 50);
#---------------------------------------------------------------------------
$Plot->mark->setType(Mark::CIRCLE);
$Plot->mark->setSize(5);
#---------------------------------------------------------------------------
$Plot->label->set($Line);
$Plot->label->move(0, -15);
$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(2, 2, 2, 2);
#---------------------------------------------------------------------------
if (Count($Lines) < 2) {
#-------------------------------------------------------------------------
$Plot->xAxis->setLabelText($Labels);
$Plot->yAxis->setLabelPrecision(1);
} else {
#-------------------------------------------------------------------------
if (!$IsSetLabel) {
#-----------------------------------------------------------------------
$Plot->setXAxis(Plot::BOTTOM);
$IsSetLabel = TRUE;
}
}
#---------------------------------------------------------------------------
if (Count($Lines) > 1) {
$Group->add($Plot);
}
#---------------------------------------------------------------------------
if (Count($Lines) > 1) {
#-------------------------------------------------------------------------
$Graph->add($Group);
#-------------------------------------------------------------------------
$Group->axis->bottom->setTickStyle(0);
$Group->axis->bottom->setLabelText($Labels);
} else {
$Graph->add($Plot);
}
}
#-----------------------------------------------------------------------------
$Graph->draw($File);
#-----------------------------------------------------------------------------
return TRUE;
}
示例5: Black
// 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
$pie->title->setPadding(5, 5, 2, 2);
// encadrement du titre
$pie->title->border->setColor(new Black());
$graph->add($pie);
if ( $export_pdf === 'oui' ) { $graph->draw('../../documents/aa.png'); }
else { $graph->draw(); }
?>
示例6: foreach
$seenVertices[$currentVertex->guid] = $currentVertex;
if (isset($edges[$currentVertex->guid])) {
foreach ($edges[$currentVertex->guid] as $destinationVertexGuid => $weight) {
if (!isset($distances[$destinationVertexGuid]) || $distances[$currentVertex->guid] + $weight < $distances[$destinationVertexGuid]) {
$distances[$destinationVertexGuid] = $distances[$currentVertex->guid] + $weight;
$previousVertex[$destinationVertexGuid] = $currentVertex->guid;
}
}
}
}
return $previousVertex;
}
$graph = new Graph();
$graph->random_point_generation_disk(500, 150, 200);
$graph->random_noncrossing_edge_generation(3, null, true);
$image = $graph->draw(500, 500, true);
ob_start();
imagepng($image);
$imagevariable = ob_get_clean();
echo '<img src="data:image/png;base64,' . base64_encode($imagevariable) . '"/><pre>';
reset($graph->vertices);
$sourceVertex = next($graph->vertices);
$return = shortestPath($graph->vertices, $graph->edges, $sourceVertex);
echo "</pre>";
foreach (array_keys($return) as $vertexGuid) {
$currentVertexGuid = $vertexGuid;
$string = $vertexGuid;
do {
$previousVertexGuid = $return[$currentVertexGuid];
$string = $previousVertexGuid . ' -> ' . $string;
$currentVertexGuid = $previousVertexGuid;
示例7: build_line_steps
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);
}
}
}
}
$graph->draw(str_replace("\\", "/", realpath($cache_dir)) . "/" . $cid);
if ($cache_dir == "cache/") {
header("Location: " . $cache_dir . $cid);
} else {
header("Content-Type: image/png; charset=utf-8");
readfile($cache_dir . $cid);
}
function build_line_steps($width, $data, $keys)
{
$width /= 2;
$data_new = $data;
$data_label = $data;
$keys_new = $keys;
$last = -1;
for ($i = 0; $i < $width; $i++) {
$curr = floor((count($data) - 1) * (($i + 1) / $width));
示例8: dis_chart_bar_multiple
function dis_chart_bar_multiple($chart) {
global $chart_colors;
$title = $chart["title"];
$xlabels = $chart["xlabels"];
$values = $chart["plots"]["values"];
$labels = $chart["plots"]["labels"];
$legends = $chart["plots"]["legends"];
$new_bar = $chart["plots"]["new_bar"];
$graph = new Graph(600, 250);
$graph->setAntiAliasing(TRUE);
$graph->setBackgroundColor(new Color(240, 240, 240));
$group = new PlotGroup;
$group->grid->hideVertical();
$group->setPadding(45, 22 ,30, 40);
$group->setSpace(3, 3, NULL, NULL);
$group->legend->setAlign(NULL, LEGEND_TOP);
$group->legend->setPosition(1,0);
// X axis Labels infos
$xlabel = new Label($xlabels);
$group->axis->bottom->setlabelText($xlabels);
// Title infos
if ($title != "") {
$graph->title->set("$title");
}
$num = 0;
$nb_bars = array_sum($new_bar);
$num_bar = 0;
// $num_plot is the plot number
// $num_bar is the bar number (1 bar can cumul more than one plot)
foreach ($values as $num_plot => $plot_values) {
// Chart infos : colors, size, shadow
if ($new_bar[$num_plot] == 1) {
$num_bar++;
}
$plot = new BarPlot($plot_values, $num_bar, $nb_bars);
$plot->setBarColor(new Color($chart_colors[$num_plot][0], $chart_colors[$num_plot][1], $chart_colors[$num_plot][2]));
$plot->setBarSize(0.6);
if ($new_bar[$num_plot] == 1) {
$plot->barShadow->setSize(2);
$plot->barShadow->smooth(TRUE);
// Labels infos
$label = new Label($labels[$num_plot]);
$label->setFont(new Tuffy(8));
$label->setAlign(NULL, LABEL_TOP);
$plot->label = $label;
}
$group->add($plot);
$group->legend->add($plot, utf8_decode($legends[$num_plot]), LEGEND_BACKGROUND);
}
$graph->add($group);
$graph->draw();
}
示例9: Color
/**
* Build a graph onto disk using Artichow library
* @param file Image file name on disk
*/
function draw_artichow($file)
{
dol_syslog("DolGraph.class::draw_artichow this->type=".$this->type);
if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
if (! defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND',2);
if (! defined('LEGEND_LINE')) define('LEGEND_LINE',1);
// Create graph
$classname='';
if ($this->type == 'bars') $classname='BarPlot';
if ($this->type == 'lines') $classname='LinePlot';
include_once DOL_DOCUMENT_ROOT."/includes/artichow/".$classname.".class.php";
// Definition de couleurs
$bgcolor=new Color($this->bgcolor[0],$this->bgcolor[1],$this->bgcolor[2]);
$bgcolorgrid=new Color($this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]);
$colortrans=new Color(0,0,0,100);
$colorsemitrans=new Color(255,255,255,60);
$colorgradient= new LinearGradient(new Color(235, 235, 235),new Color(255, 255, 255),0);
$colorwhite=new Color(255,255,255);
// Graph
$graph = new Graph($this->width, $this->height);
$graph->border->hide();
$graph->setAntiAliasing(true);
if (isset($this->title))
{
$graph->title->set($this->title);
$graph->title->setFont(new Tuffy(10));
}
if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor);
else $graph->setBackgroundGradient($colorgradient);
$group = new PlotGroup;
//$group->setSpace(5, 5, 0, 0);
$paddleft=50;
$paddright=10;
$strl=dol_strlen(max(abs($this->MaxValue),abs($this->MinValue)));
if ($strl > 6) $paddleft += ($strln * 4);
$group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values
$group->legend->setSpace(0);
$group->legend->setPadding(2,2,2,2);
$group->legend->setPosition(NULL,0.1);
$group->legend->setBackgroundColor($colorsemitrans);
if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid);
else $group->grid->setBackgroundColor($colortrans);
if ($this->hideXGrid) $group->grid->hideVertical(true);
if ($this->hideYGrid) $group->grid->hideHorizontal(true);
// On boucle sur chaque lot de donnees
$legends=array();
$i=0;
$nblot=sizeof($this->data[0])-1;
while ($i < $nblot)
{
$j=0;
$values=array();
foreach($this->data as $key => $valarray)
{
$legends[$j] = $valarray[0];
$values[$j] = $valarray[$i+1];
$j++;
}
// Artichow ne gere pas les valeurs inconnues
// Donc si inconnu, on la fixe a null
$newvalues=array();
foreach($values as $val)
{
$newvalues[]=(is_numeric($val) ? $val : null);
}
if ($this->type == 'bars')
{
//print "Lot de donnees $i<br>";
//print_r($values);
//print '<br>';
$color=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2],20);
$colorbis=new Color(min($this->datacolor[$i][0]+50,255),min($this->datacolor[$i][1]+50,255),min($this->datacolor[$i][2]+50,255),50);
$colorgrey=new Color(100,100,100);
$colorborder=new Color($this->datacolor[$i][0],$this->datacolor[$i][1],$this->datacolor[$i][2]);
if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i+1, $nblot);
if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot-$i-1)*5);
$plot->barBorder->setColor($colorgrey);
//$plot->setBarColor($color);
//.........这里部分代码省略.........
示例10: Black
// $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
$pie->title->setPadding(5, 5, 2, 2);
// encadrement du titre
$pie->title->border->setColor(new Black());
$graph->add($pie);
$graph->draw('../../documents/graph_temp.png');
$graph->deleteAllCache();
?>
示例11: _stats_build_graph
function _stats_build_graph($data, $labels, $filename, $stat, $width, $height, $vars)
{
if (file_exists($filename)) {
unlink($filename);
}
$data_orig = $data;
foreach ($data as $key => $val) {
if (!is_numeric($val)) {
$data[$key] = 0;
}
}
// $vars["color_tab_black"]
$bg_grey = _stats_color($vars["bg_grey"], 0);
$bg_light_blue = _stats_color($vars["bg_light_blue"], 25);
$graph = new Graph($width, $height);
$group = new PlotGroup();
$group->setSpace(2, 2);
$group->grid->setType(LINE_DASHED);
$group->grid->hideVertical(TRUE);
$group->setPadding(30, 10, 25, 20);
$graph->setBackgroundColor($bg_grey);
$graph->title->set($stat);
$graph->title->setFont(new Tuffy(10));
$plot = new BarPlot($data, 1, 1, 0);
$plot->setBarColor($bg_light_blue);
$plot->label->set($data_orig);
$plot->label->move(0, -5);
$group->add($plot);
$group->axis->bottom->setLabelText($labels);
$group->axis->bottom->hideTicks(TRUE);
$graph->add($group);
$graph->draw($filename);
}
示例12: Tuffy
// pas de chiffre après la virgule
$group->axis->right->setLabelPrecision(1);
$group->axis->right->setColor($bleu);
$group->axis->right->title->set("Retard");
// AXE X
// donnée de l'axe X
$group->axis->bottom->setLabelText($x);
// police de caractère de l'axe X
$group->axis->bottom->label->setFont(new Tuffy(8));
// rotation du texte de l'axe X en degré
$group->axis->bottom->label->setAngle("30");
// positionement du texte de l'axe X
$group->axis->bottom->label->move(10, 0);
// alignement du texte de l'axe X
$group->axis->bottom->label->setAlign(LABEL_RIGHT, LABEL_BOTTOM);
// padding de l'axe X
$group->axis->bottom->label->setPadding(0, 0, 0, 0);
$graph->add($group);
$nom_fichier = $_SESSION['nom_fichier_png'];
$graph->draw('../../documents/'.$nom_fichier.'.png');
$graph->deleteAllCache();
?>
示例13: array
<?php
require "../../includes.php";
$result = array(&$count, &$date, &$product_id);
$stmt = $db->prepare_full("\n\tSELECT\n\t\tSUM(`transaction_contents`.`count`),\n\t\tDATE(`transactions`.`timestamp`) as d,\n\t\tproduct_id\n\tFROM\n\t\t`transaction_contents` JOIN\n\t\t`transactions` ON (`transaction_contents`.`transaction_id` = `transactions`.`transaction_id`)\n\tWHERE\n\t\t`transactions`.`timestamp` > ? AND\n\t\t`transaction_contents`.`product_id` in (?)\n\tGROUP BY\n\t\tDATE(`transactions`.`timestamp`), product_id\n\tORDER BY\n\t\tproduct_id,\n\t\td", $result, 'si', date('Y') - 1 . date('-m-d'), ClientData::request('id'));
$image = new Graph();
$image->slide = 7;
$image->period = 365;
$image->height = 200;
$image->width = 730;
$image->vertical_lable = 5;
$start = gregoriantojd(date('m'), date('d'), date('Y') - 1);
$old_product_id = null;
while ($stmt->fetch()) {
if ($old_product_id != $product_id) {
$product = Product::from_id($product_id);
}
$s_date = explode('-', $date);
$image->add($count, gregoriantojd($s_date[1], $s_date[2], $s_date[0]) - $start, $product->name);
}
$image->draw();
示例14: draw
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;
}
示例15: getImage_p
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;
}