Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Esecuzione codice di esempio

    Ragazzi, devo fare un grafico all'interno di una pagina PHP e ho preso le API di google come esempio da modificare dopo in seguito;
    ho inserito questo codice di esempio in mypagina.php, ma se vado in esecuzione (da netbeans --> Esegui --> Run File , non vedo nulla;

    Scusate ma ho pochissima esperienza in PHP e volevo sapere come mai ?

    ecco il link :
    https://developers.google.com/chart/...hl=it#Examples

    ed ecco il codice impostato :

    codice:
    <?php
    
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     * 
     */
    
     
    ?>
    
    <script type="text/javascript" src="http://www.google.com/jsapi">
      function init() {
        var options = {
          width: 400,
          height: 240,
          animation:{
            duration: 1000,
            easing: 'out'
          },
          vAxis: {minValue:0, maxValue:1000}
        };
      
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'N');
        data.addColumn('number', 'Value');
        data.addRow(['V', 200]);
    
        var chart = new google.visualization.ColumnChart(
            document.getElementById('visualization'));
        var button = document.getElementById('b1');
    
        function drawChart() {
          // Disabling the button while the chart is drawing.
          button.disabled = true;
          google.visualization.events.addListener(chart, 'ready',
              function() {
                button.disabled = false;
              });
          chart.draw(data, options);
        }
    
        button.onclick = function() {
          var newValue = 1000 - data.getValue(0, 1);
          data.setValue(0, 1, newValue);
          drawChart();
        }
        drawChart();
      }   
        
        </script>

  2. #2
    Utente di HTML.it L'avatar di echoweb
    Registrato dal
    Sep 2008
    Messaggi
    419
    Ciao,

    l'esempio che devi usare è questo:

    codice:
    <html>
      <head>
        
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
    
          // Load the Visualization API and the piechart package.
          google.load('visualization', '1.0', {'packages':['corechart']});
    
          // Set a callback to run when the Google Visualization API is loaded.
          google.setOnLoadCallback(drawChart);
    
          // Callback that creates and populates a data table,
          // instantiates the pie chart, passes in the data and
          // draws it.
          function drawChart() {
    
            // Create the data table.
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Topping');
            data.addColumn('number', 'Slices');
            data.addRows([
              ['Mushrooms', 3],
              ['Onions', 1],
              ['Olives', 1],
              ['Zucchini', 1],
              ['Pepperoni', 2]
            ]);
    
            // Set chart options
            var options = {'title':'How Much Pizza I Ate Last Night',
                           '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>
      </head>
    
      <body>
        
        <div id="chart_div"></div>
      </body>
    </html>
    Quello che hai postato tu, è solo una parte di un esempio.


    "Non soffocare la tua ispirazione e la tua immaginazione,
    non diventare lo schiavo del tuo modello"

    Vincent van Gogh

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.