I am creating a chart using Chart.js and PHP, I would like the value to come from an array in PHP with the index of a JS variable. This is the code 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>