Re: [visualization-api] Cannot read property 'PieChart' of undefined

593 views
Skip to first unread message

Daniel LaLiberte

unread,
Jan 4, 2016, 9:05:15 AM1/4/16
to Google Visualization API
Your mistake is that your call of google.visualization.PieChart() is outside your drawChart function.   See a working example here: https://jsfiddle.net/dlaliberte/n1vytzhs/

On Mon, Jan 4, 2016 at 4:36 AM, Maël ATZORI MALTETE <atzorimal...@gmail.com> wrote:
Hi every one,
i have this error when i try the code for a PieChart : Uncaught TypeError: Cannot read property 'PieChart' of undefined
the function is actually not known...

my code :
<html>
<head>
    <meta charset="UTF-8">
    <title>Camembert</title>

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<?php
$tt= $_GET['num'];

include('model/config_path.php');

$req="SELECT abo_ville, SUM(abo_qte_place_reserv) AS totalresa , manif_intitule AS titremanif  FROM reservations INNER JOIN abonnes ON abonnes.abo_id  = reservations.abo_id_  INNER JOIN manifestations ON manifestations.manif_id = reservations.manif_id_ WHERE manif_id = 1 GROUP BY abo_ville";

$result = $bdd->query($req);
$chart = $result->fetchAll();

?>

<script type="text/javascript">
    google.charts.load('current', {packages: ['corechart']});
    google.charts.setOnLoadCallback(drawChart);
    function drawChart() {

       
var data = google.visualization.arrayToDataTable([
           
['Villes', 'Nombre de réservations'],
            <?php
                foreach($chart as $key => $value){
                echo '[\''.$value['abo_ville'].'\', '.$value['totalresa'].'],';
            }
            ?>
        ]);

        // Set chart options
        var options = {'title':'How Much Pizza I Ate Last Night',
            'width':400,
            'height':300};

    }

   
var chart = new google.visualization.PieChart(document.getElementById('piechart'));

    chart.draw(data, options);
</script>

<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>

i maybe did a mistake, tell me fast pls ! :)

Thanks for your help

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/e0240b84-c67e-42fa-9741-262046105754%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages