Eléphant du PHP |
333 Messages
31 oct. 2007, 07:38
Superbe résultat une fois qu'on comprend le fonctionnement,
Pour ceux que ca intéresse, voici l'exemple de mon code.
<?php
mysql_connect("mysql", "", "");
mysql_select_db("");
require_once "Artichow/BarPlot.class.php";
//************************************
$result = mysql_query("SELECT mois, COUNT(id) AS nb_total FROM logs WHERE annee = '2007' GROUP BY mois");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
$values[] = $row[1];
}
//***********************************
$graph = new Graph(800, 300);
// Set a title to the graph
$graph->title->set('Statistique de Visites');
// Change graph background color
$graph->setBackgroundColor(new Color(230, 230, 230));
// Declare a new BarPlot
$plot = new BarPlot($values);
// Reduce padding around the plot
$plot->setPadding(NULL, NULL, NULL, 20);
// Reduce plot size and move it to the bottom of the graph
$plot->setSize(1, 0.96);
$plot->setCenter(0.5, 0.52);
// Set a background color to the plot
$plot->grid->setBackgroundColor(new White);
// Set a dashed grid
$plot->grid->setType(LINE_DASHED);
$plot->label->set($values);
$plot->label->move(0, -10);
$plot->label->setColor(new DarkBlue);
// Set a shadow to the bars
$plot->barShadow->setSize(2);
// Bar size is at 60%
$plot->setBarSize(0.6);
// Change the color of the bars
$plot->setBarColor(
new Orange(15)
);
// On définit les jours de la semaine
$days = array(
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre'
);
// On ajoute les jours à l'axe des abscisses
$plot->xAxis->setLabelText($days);
$plot->xAxis->label->setColor(new Black);
$plot->xAxis->label->setFont(new Tuffy(8));
//$plot->xAxis->label->setSize(new 2);
// Add the plot to the graph
$graph->add($plot);
// Draw the graph
$graph->draw();
?>
Ce n'est pas toujours facile d'essayer, mais c'est toujours vallorisant lorsqu'on y arrive !!!
Apprenez, ne le faite pas faire par les autres.