API Google Chart ne se lance pas avec un SUBMIT

Eléphant du PHP | 84 Messages

29 mai 2014, 16:02

Bonjour à tous.

J'utilise l'API google charts pour des graph sur mon site.
Ca fonctionne très bien lorsque tous les graph sont exécutés en même temps (line et pie).
Mais j'utilise en fait différents <SELECT><OPTION></OPTIONS></SELECT> qui lance chacun à leur tour le graph demandé.
Tant qu'il est demandé sous forme de "LineChart" ca fontionne, par contre les "PieChart" ne fonctionnent pas.

Voici mon script.
<FORM action="" method="post">
		<SELECT id="" name="annee">
			<OPTION value="0">-- Année --		</OPTION>
			<OPTION value="0">Toutes les années	</OPTION>
			<OPTION value="2013">2013	 	</OPTION>
			<OPTION value="2014">2014	 	</OPTION>
			<OPTION value="2015">2015	 	</OPTION>
		</SELECT>
					<INPUT type="submit" value="Ok">
	</FORM>

	<table id="lignes">
		<thead>
			<tr>
				<th>Année</th>
				<?php foreach ( $ventes as $annee ){ ?>
				<th><?php echo $annee['produit']; ?></th><?php } ?>
			</tr>
		</thead>
		<tbody>	
			<tr>
				<th><?php echo $annee['an1']; ?></th>
				<?php foreach ( $ventes as $annee ){ ?>
				<td><?php echo number_format($annee['Total'], 2, ',', '');?></td><?php } ?>
			</tr>  
		</tbody>
	</table>
	<?php  
				}
		}
	}
	?>





<FORM action="" method="post">
		<SELECT id="" name="mois">
			<OPTION value="0">-- Mois--		</OPTION>
			<OPTION value="janv">Janvier</OPTION>
			<OPTION value="fev">Fevrier</OPTION>
			<OPTION value="mars">Mars</OPTION>
                         .............
		</SELECT>
					<INPUT type="submit" value="Ok">
	</FORM>


	<table id="camembert">
		<thead>
			<tr>
				<th>Année</th>
				<?php foreach ( $ventes as $annee ){ ?>
				<th><?php echo $annee['produit']; ?></th><?php } ?>
			</tr>
		</thead>
		<tbody>	
			<tr>
				<th><?php echo $annee['an1']; ?></th>
				<?php foreach ( $ventes as $annee ){ ?>
				<td><?php echo number_format($annee['Total'], 2, ',', '');?></td><?php } ?>
			</tr>  
		</tbody>
	</table>
	<?php  
				}
		}
	}
	?>
Et le JS
[javascript]gvChartInit();
jQuery(document).ready(function(){
jQuery('#lignes').gvChart({
chartType: 'LineChart',
gvSettings: {
vAxis: {title: 'No of players'},
hAxis: {title: 'Month'},
'width':400,
'height':300
}
});


jQuery('#camembert').gvChart({
chartType: 'PieChart',
gvSettings: {
vAxis: {title: 'No of players'},
hAxis: {title: 'Month'},
colors: ['#9900A1', '#1796B0', '#A3CA1F', '#FFA200', '#D00000','#41C4FC','#FF00AE',],
'width':1000,
'height':600
}
});
});[/javascript]

Par contre, si je supprime dans le JS les lignes dédiées au LineChart, alors PieChart fonctionne.
En fait je crois que lorsque je valide avec le bouton submit pour le graph PieChart, le code JS ne saute pas pour aller chercher les bonnes lignes.
Je sais pas si j'ai été bien clair... Mais j’espère que vous allez pouvoir m'aider. :mrgreen: