Jpgraph n'actualise pas les données...
Ffx_Win
-
Ffx_Win -
Ffx_Win -
Bonjour,
J'utilise JPGraph pour générer des statistiques dans une page php. Les classes que j'utilise sont incompatibles avec certaines classes de JPGraph(même nom).
J'ai donc décidé d'appeler le graphe (jpg.php) dans une iframe sur la page de base(à coté de la liste des liens qui appellent le graphe).
Lorsque je clique sur un lien, le graphe s'affiche impeccablement, puis si je clique sur un autre lien, le nom, l'année etc change mais pas les données. Le graphe est une image générée et il ne 'recompile' pas les données alors qu'il change bien le nom selon ce que je sélectionne.
N'ayez pas peur j'ai des classes persos.
Code :
INDEX.php
CODE:
JPG.PHP :
Merci de votre intêret / réponses.
J'utilise JPGraph pour générer des statistiques dans une page php. Les classes que j'utilise sont incompatibles avec certaines classes de JPGraph(même nom).
J'ai donc décidé d'appeler le graphe (jpg.php) dans une iframe sur la page de base(à coté de la liste des liens qui appellent le graphe).
Lorsque je clique sur un lien, le graphe s'affiche impeccablement, puis si je clique sur un autre lien, le nom, l'année etc change mais pas les données. Le graphe est une image générée et il ne 'recompile' pas les données alors qu'il change bien le nom selon ce que je sélectionne.
N'ayez pas peur j'ai des classes persos.
Code :
INDEX.php
<?php
require('../../jessy.inc.php');
$jessy->include_class('html_tabs');
$jessy->include_file('html.inc.php');
$jessy->include_file('html2.inc.php');
$jessy->include_file('form3.inc.php');
$html = new html_doc();
$html->begin('Statistiques');
$html->header();
$html->begin_menu();
echo $html->get_page_header();
//onglets
$tb = new html_tabs('stats_tab');
$tb->add_tab('Total Absences');
echo $tb->get_start();
//switch ($tb->get_current_tab()) { // si plusieurs onglets
// case 'Total Absences':
$jessy->include_class('db_select');
$form1 = &new form(1);
$result = db_query('SELECT DISTINCT(YEAR(date)) AS year FROM checkin_tbl order by year');
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$years[$row['year']] = $row['year'];
}
mysql_free_result($result);
$year = &$form1->add_element('year', 'select');
$year->set_default(date('Y'));
$year->set_label($i18n->get_message('year'));
$year->set_submit_on_change(true);
$year->set_options($years);
}
$holiday = &$form1->add_element('holiday', 'select');
$holiday->set_submit_on_change(true);
$holiday->set_options($db->get_options('id', 'name', 'holidays_tbl'));
$holiday_row = db_get_row('*', 'holidays_tbl', $holiday->get_value());
echo $form1->get('h');
$resultx = db_query("SELECT SUM(C.hours) as hours, SUM(C.days) as days, C.user, U.real_name as name, U.id as uid"
." FROM checkin_tbl C
LEFT JOIN users_tbl U ON C.user=U.id
WHERE C.link_type='Absence' AND "
."C.link_id='".$holiday->get_Value()."' AND DATE_FORMAT(date,'%Y')='".$year->get_Value()."' GROUP BY name ORDER BY name");
echo "<table width=\"100%\"><tr><td valign=\"top\">";
echo "\t\t<table width=\"100%\" class=\"grid\">\n";
echo "\t\t<tr><td style=\"font-weight:bold\">Nom</td><td style=\"font-weight:bold\" align=\"right\">";
if ($holiday_row['units'] == 'Jours') {
echo "Jours";
}else{
echo "Heures";
}
echo"</td></tr>\n";
if ($resultx) {
$total =0;
while ($rowx = mysql_fetch_assoc($resultx)) {
if($rowx[days]!=0 OR $rowx[hours]!=0){
if ($holiday_row['units'] == 'Jours') {
echo "<tr onmouseover=\"this.style.backgroundColor = '#E1EAFE';\" onmouseout=\"this.style.backgroundColor = '#fff';\"><td>
<a href=\"#\" onclick=\"window.bdc.location.href='jpg.php?&uid=".$rowx[uid].">ype=individuel&name=".$rowx[name]."&units=".$holiday_row['units']."&link_id=".$holiday->get_Value()."&year=".$year->get_Value()."\">".$rowx[name]."</a></td><td align=\"right\">".$rowx[days]."</td></tr>";
$total += $rowx[days];
} else {
echo "<tr onmouseover=\"this.style.backgroundColor = '#E1EAFE';\" onmouseout=\"this.style.backgroundColor = '#fff';\"><td>
<a href=\"#\" onclick=\"window.bdc.location.href='jpg.php?&uid=".$rowx[uid].">ype=individuel&name=".$rowx[name]."&units=".$holiday_row['units']."&link_id=".$holiday->get_Value()."&year=".$year->get_Value()."'\">".$rowx[name]."</a></td><td align=\"right\">".$rowx[hours]."</td></tr>";
$total += $rowx[hours];
}
}
}
}
echo "\t\t<tr style=\"font-weight:bold\"><td>
<a href=\"#\" onclick=\"window.bdc.location.href='jpg.php?&uid=".$rowx[uid].">ype=global&name=Total&units=".$holiday_row['units']."&link_id=".$holiday->get_Value()."&year=".$year->get_Value()."'\">Total</a></td><td align=\"right\">".$total."</td></tr>";
echo "</table>";
echo "<pre>";
print_r($_GET);
echo "</pre>";
mysql_free_result($resultx);
echo"</td><td>"; ?>
<iframe name="bdc" src="jpg.php" width="750" height="530" style="border: 0px;"></iframe>
<?php echo"</td></tr></table>";
//break;
echo $tb->get_end();
$html->end_menu();
$html->footer();
$html->end();
?>
CODE:
JPG.PHP :
<?php
require('../../jessy.inc.php');
include ("../../../lib/jpgraph/src/jpgraph.php");
include ("../../../lib/jpgraph/src/jpgraph_bar.php");
$months = array('Jan','Fév','Mar','Avr','Mai','Ju','Jui','Ao','Sep','Oct','Nov','Dec');
//vars
$jessy->include_class('db_select');
if(isset($_GET['link_id'])){
$abs_name = db_get_one('name','holidays_tbl','id='.$_GET['link_id']);
$graph_title = $_GET['name']." - ".$abs_name." (".$_GET['year'].")";
}else{
$graph_title = "Veuillez sélectionner un nom ou le total.";
}
$graph_units = $_GET['units'];
$h_abs_month = array();
for($i=1;$i<=12;$i++){
if($i<10) $i = "0".$i;
if($graph_type == 'individuel'){//individuel
$result = db_query("SELECT C.hours as hours, C.days as days"
." FROM checkin_tbl C
WHERE C.user='".$_GET['uid']."' AND C.link_type='Absence' AND "
."C.link_id='".$_GET['link_id']."' AND
DATE_FORMAT(date,'%Y-%m')='".$_GET['year']."-".$i."'");
}else{ //rqt global
$result = db_query("SELECT C.hours as hours, C.days as days"
." FROM checkin_tbl C
WHERE C.link_type='Absence' AND "
."C.link_id='".$_GET['link_id']."' AND
DATE_FORMAT(date,'%Y-%m')='".$_GET['year']."-".$i."'");
}
if($result){
$total_month =0;
while ($row = mysql_fetch_assoc($result)) {
if($row[days]!=0 OR $row[hours]!=0){
if ($_GET['units'] == 'Jours') {
$total_month += $row[days];
}else{
$total_month += $row[hours];
}
}else{
$total_month += 0;
}
}
if($total_month != 0){
array_push($h_abs_month,$total_month);
}else{
array_push($h_abs_month,0);
}
}
mysql_free_result($result);
}
// Creation du graphique
$graph = new Graph(12*60,500);
$graph->SetScale("textlin");
$graph->title->Set($graph_title); //récupéré
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTitle("Mois");
$graph->yaxis->SetTitle($graph_units); //récupéré
$graph->SetColor('white');
$graph->SetMarginColor('white');
$graph->img->SetMargin(40,20,40,40);
// Création du système de points
$barplot = new BarPlot($h_abs_month);
$barplot->SetFillGradient('cornflowerblue','lightblue',GRAD_HOR);
$barplot->SetColor('black');
$barplot->value->Show();
// On rajoute les points au graphique
$graph->Add($barplot);
// Affichage
$graph->Stroke();
?>
Merci de votre intêret / réponses.
A voir également:
- Jpgraph n'actualise pas les données...
- Fuite données maif - Guide
- Effacer les données de navigation sur android - Guide
- Trier des données excel - Guide
- Données personnelles - Accueil - Windows
- Sauvegarde des données - Guide