5 order by `nb` desc;"; } else { $reqSelect="SELECT ville, count(ville) as `nb`, region, pays FROM `stats` WHERE substr(timestamp,1,4)=" .$year. " group by region HAVING `nb`>5 order by `nb` desc;"; } if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=monDebug(2, ['reqSelect' => $reqSelect],'graphPays');} $resConn=$idPdo->query($reqSelect); $l=-1; // --------------------------------------------------- // Formattage des nombres // --------------------------------------------------- function format_number_with_space($aVal) { return number_format($aVal, 0, ',', ' '); // Espace comme séparateur de milliers } // --------------------------------------------------- // Recup datas // --------------------------------------------------- while ($tbP=$resConn->fetch(PDO::FETCH_ASSOC)) { $l++; $data[$l]=$tbP['nb']; $lib[$l]=$tbP['ville']; // echo '$data[' .$l. ']=' .$data[$l]; } $largeur = 500; $hauteur = 800; if(count($lib)> 60) $hauteur = 18 * count($lib); $graph = new Graph($largeur, $hauteur, "auto"); $graph->setScale("textlin"); $graph->SetShadow(); $barPlot = new BarPlot($data); $graph->add($barPlot); $barPlot->SetFillgradient('darkgreen','#D5EAFF',GRAD_WIDE_MIDVER); $barPlot->value->Show(); $barPlot->value->SetFormat('%d'); $barPlot->SetValuePos('center'); $barPlot->SetValuePos('center'); $barPlot->SetValuePos('top'); $barPlot->value->SetColor("darkgreen","darkred"); $barPlot->value->SetFormatCallback('format_number_with_space'); // gauche-droit-haut-bas $graph->Set90AndMargin(130,40,30,30); // Axe des ordonées $graph->xaxis->SetPos('SIDE_LEFT'); $graph->xaxis->SetColor('black','blue'); $graph->xaxis->SetTickLabels($lib); $graph->xaxis->SetTextLabelInterval(1); // Axe des abscisses // $graph->yaxis->SetTextLabelInterval(520); $graph->yaxis->SetLabelMargin(-12); $graph->yaxis->scale->SetGrace(0); $graph->yaxis->SetPos('max'); $graph->title->SET("Villes avec + de 5 visites / Année : " .$year); $graph->stroke(); ?>