Skip to main content
removeu 4 caracteres do conteúdo
Fonte Link
Franchesco
  • 5,3mil
  • 3
  • 28
  • 48

Boa Tarde,

Criei um cursor em pl, agora estou tentando passar os registros para um arrayarray do javascript para criar gráficos

 , o newDatanewData irá receber os dados do cursor

Obrigado.

Java scriptJavascript criado é esse:

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]];
<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>

Boa Tarde,

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

Obrigado

Java script criado é esse

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>

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>
Fonte Link

recebendo array plsql em javascript

Boa Tarde,

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

Obrigado

Java script criado é esse

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>