Page 1 sur 1

créer un graphique d'après mes donnée Bdd

Posté : 06 juin 2007, 23:30
par auclairp
Bonjour. j'ai créer une Bdd avec les stat de visite de mon site web, il est très simple, il compte les visite par mois seulemetn pas d'autres données compliqué sur les types de visiteurs.

J'aimerais pouvoir le visualiser avec des bande de graphique, cela est-il possible.

Merci.

Posté : 07 juin 2007, 09:25
par orgerix
C'est possible.

Je te conseille d'aller voir la librairie Artichow qui te permettera de faire des graphique simplement.

Posté : 07 juin 2007, 18:28
par Invité
Merci je regarde et redonne des news.

Posté : 31 oct. 2007, 07:38
par auclairp
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();

?>