1
I am creating a chart using Chart.js and PHP, I would like the value to come from a PHP array with the input of a JS variable. This is the code of what I tried to do.
<script type="text/javascript">
var ctx = document.getElementById("piechart").getContext("2d");
var data = [];
var i = 0;
while(i <= <?print $ind;?>)
{
data.push({
<?$variavelphp = "<script>document.write(i)</script>";?>
value: <?print $array[$variavelphp];?>,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
});
i++;
}
}
var options = {
animateScale: false
};
var myNewChart = new Chart(ctx).Pie(data,options);
</script>
what problem are you encountering? be clearer with your doubt please.
– RFL