how to run loop for php array in javascript( google graph api) i have x and y values in seprate php array and i am printing it like below.
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['x', 'y'],
<?php
for($i=1;$i<1000;$i++)
{
?>
[<?php echo $x[$i]; ?>,<?php echo $y[$i]; ?>],
<?php } ?>
]);
var options = {
title: 'CGR plot',
hAxis: {title: '(0,0)A (800,0) T', minValue: 0, maxValue: 800},
vAxis: {title: '(800,800)G ;(0,800)C', minValue: 0, maxValue: 800},
legend: 'none',
pointSize: 1,
};
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="width: 800px; height: 500px;"></div>
and it is working fine ...but here loop is runnning for 1000 times and try to run it according to array size using sizeof($x) or count($x). but it is not working. do u have any suggestion for this
for($i=1;$i<1000;$i++)makes loop running 1000 times, instead putfor($i=1;$i<count($x);$i++)