Criei um cursor em pl, agora estou tentando passar os registros para um array do javascript para criar gráficos, o newData
irá receber os dados do cursor.
Javascript criado é esse:
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var dataTable = new google.visualization.DataTable();
var newData = [['Ano', 'Vendas'],
['2004', 1000 ],
['2005', 1170],
['2006', 660],
['2007', 1030],
['2008', 1530]];
// determine the number of rows and columns.
var numRows = newData.length;
var numCols = newData[0].length;
// in this case the first column is of type 'string'.
dataTable.addColumn('string', newData[0][0]);
// all other columns are of type 'number'.
for (var i = 1; i < numCols; i++)
dataTable.addColumn('number', newData[0][i]);
// now add the rows.
for (var i = 1; i < numRows; i++)
dataTable.addRow(newData[i]);
var options = {
title: 'Vendas anual'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(dataTable, options);
}
</script>
json
e pega no javascript.