javascript - php variable to google charts api no JSON -
i'm trying pass few php variables google chart, , cannot seem syntax right. don't want invoke json (need i?).
stock example: works:
<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1.0', {'packages':['corechart']}); google.setonloadcallback(drawchart); function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('string', 'number'); data.addcolumn('number', 'frequency'); data.addrows([ ['mushrooms', 3], ['onions', 1], ['olives', 1], ['zucchini', 1], ['pepperoni', 2] ]); var options = { 'title':'title', 'width':400, 'height':300 }; var chart = new google.visualization.barchart(document.getelementbyid('chart_div')); chart.draw(data, options); } </script>
however, not (assume same surrounding code)
function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('string', 'number'); data.addcolumn('number', 'frequency'); data.addrows([ ['mushrooms', <?php echo $phpvariable ?>], ['onions', 1], ['olives', 1], ['zucchini', 1], ['pepperoni', 2] ]);
my thoughts: positioning of calculation of $phpvariable
wrong? or need use json somehow, , php variables cannot passed?
Comments
Post a Comment