1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| $tab = array();
$base = mysqli_connect("127.0.0.1", "user", "pwd", "DB");
$i=0;
if($base)
{
$sql = "SELECT COUNT(DISTINCT(mac)) mac,date FROM `log` GROUP BY date ORDER BY date";
$resultat = mysqli_query($base, $sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while ($row = mysqli_fetch_row($resultat))
{
$buff = intval($row[0]);
$tab_nb[$i]=[$buff];
$tab_day[$i]=[$row[1]];
$i+=1;
}
//print_r($tab_nb);
echo gettype($tab_nb[2]);
/* CAT:Bar Chart */
/* pChart library inclusions */
include("./pChart/class/pData.class.php");
include("./pChart/class/pDraw.class.php");
include("./pChart/class/pImage.class.php");
/* Create and populate the pData object */
$MyData = new pData();
$MyData->loadPalette("./pChart/palettes/blind.color",TRUE);
$MyData->addPoints($tab_nb,"PCs");
$MyData->addPoints($tab_day,"Jours");
$MyData->setSerieDescription("Jours","Month");
$MyData->setAbscissa("Jours");
/* Create the floating 0 data serie */
$MyData->addPoints(array(60,80,20,40,40,50,90,30,100),"Floating 0");
$MyData->setSerieDrawable("Floating 0",FALSE);
/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>"./pChart/fonts/Forgotte.ttf","FontSize"=>10,"R"=>110,"G"=>110,"B"=>110));
/* Write the title */
$myPicture->drawText(10,13,"Production par jour");
/* Set the graphical area */
$myPicture->setGraphArea(50,30,680,180);
/* Draw the scale */
$AxisBoundaries = array(0=>array("Min"=>0,"Max"=>100));
$myPicture->drawScale(array("InnerTickWidth"=>0,"OuterTickWidth"=>0,"Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>$AxisBoundaries,"LabelRotation"=>45,"DrawXLines"=>FALSE,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridTicks"=>0,"GridAlpha"=>30,"AxisAlpha"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Draw the chart */
$settings = array("Floating0Serie"=>"Floating 0","Surrounding"=>10);
$myPicture->drawBarChart($settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBarChart.span.png");
}
else
{
echo "err de connexion à la DB";
} |
Partager