I'm developing an application where each user will receive different types of data through google charts, however I can not get the data to appear on the screen. Here is the javascript code snippet:
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Create the data table.
var data = new google.visualization.arrayToDataTable([
[{label: 'Status', type: 'string'},
{label: 'Quantidade', type: 'number'}
],
<?php
foreach ($_SESSION["data_grafico1"] as $dados){
echo "['$dados[0]', $dados[1]]";
}
?>
]);
// Set chart options
var options = {'title':'Quantidade de protocolos por Status',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
The information contained in the $ data variable is the indexes (string), represented by $ data [0] and the numeric values contained in $ data [1] respectively. Can anyone help me with this? The information in $ data [0] and $ data [1] is retrieved normally, however when adding in js it is not displayed. Thanks for the help in advance.