Hello,
I did that by adding function in the model.
The function constructs what google chart needs and get all the google chart code in one variable. Then i use the variable (here $thisGraph) in the view and hop hop hop magic is there.
First part of the Google Graph Code :
$thisGraph = "
<script type=\"text/javascript\">
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Jour', 'Tonne par heure','Cible (250 T/H)'],
";
Then a double loop that creates the data texts
foreach ($resultats as $resultat) {
bla bla bla
$thisGraph .= $preparedArray[$numeroDeLigne] . ",";
}
Then the rest of the Google Graph Code :
$thisGraph .=
"
]);
var options = {
title : 'Tonnes par heure hors arrêt',
vAxis: {title: \"Quantité\"},
hAxis: {title: \"Jour\"},
seriesType: \"bars\",
isStacked: \"true\",
colors: ['#99cc00', '#003366'],
series: {1: {type: \"line\"}}
};
var chart = new google.visualization.ComboChart(document.getElementById('tonneHeure_div'));
chart.draw(data, options);
}
google.setOnLoadCallback(drawVisualization);
</script>
<div id=\"tonneHeure_div\" style=\"text-align:center; width:900px; height:400px;\"></div>
";
}
I can understand it is not the most beautiful way to do it, but it works