[英]adding dynamic rows to google chart
I'm using google Line chart for my college project, here i want to add rows dynamically based on the user selection from database, addRow() function is used to add a row but i want it to be add by looping. 我正在为我的大学项目使用google折线图,在这里我想根据数据库中的用户选择动态添加行,addRow()函数用于添加行,但我希望通过循环添加行。 someone can help me?
有人可以帮助我吗?
Here is my code: 这是我的代码:
var rowArray1 = [];
var rowArray2 = [];
<?php
for($i=1;$i<=$count;$i++)
{
$row=mysql_fetch_array($rows);
echo "rowArray1.push('". $row['a'] ."')";
echo "rowArray2.push(". $row['b'].")";
array_push($rowArray,"'".$row['a']."',".$row['b']);
}
?>
for(i=0;i<count;i++)
{
data.addRow( [rowArray1[i], rowArray2[i]] );
}
it's not working properly... :-( 它不能正常工作... :-(
Finally I got the solution. 终于我找到了解决方案。 it's very simple way.
这是非常简单的方法。 when i asked this question, i was just a beginner so i dont know how to do it.
当我问这个问题时,我只是一个初学者,所以我不知道该怎么做。 now i got the answer.
现在我得到了答案。
I just included the PHP scripts inside the javascript code like this, 我只是将PHP脚本包含在这样的javascript代码中,
<script>
// Google chart codes....
<?php
$row=mysql_fetch_array($rows);
foreach($row as $data) {
echo "data.addRow( $data['a'] , $data['b'] );";
}
?>
// Google chart codes....
</script>
It's worked fine... :) 工作正常... :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.