Error al cargar mas de 1 vez: loader.js:146 Uncaught Error: google.charts.load() cannot be called more than once with version 45 or earlier.

29 views
Skip to first unread message

Danny FKB

unread,
Aug 4, 2016, 11:53:43 AM8/4/16
to Google Visualization API
Hola a todo mundo tengo un problema tengo un formulario donde mando variables por medio de ajax a una hoja donde hay un google chart. me imprime bien la primera ves que mando, pero cuando lo hago de nuevo me dice que no puede cargar de nuevo google.charts.load(), alguien me podría ayudar !!!!!


index.php

    <script type ="text/javascript">
$(document).ready(function(){
    $("#formulario").submit(function(){
        var bim=jQuery('#bim').val();
        var clone=jQuery('#clone').val();
        var matri=jQuery('#matri').val();
        $.ajax({
        type: "POST",
            url: "grafevalesc.php",
            data: {bim:bim, clone:clone, matri:matri} ,
            success: function(datos) {
            $("#datos").html(datos);
            }
        });
    });
});
    </script>
<h1>Evaluacion</h1>
<form id='formulario' action='javascript:void(0);' method='POST'>
    <div class="col-3">
        <label>Escuela
        <select name="bim" id="bim" tabindex="1">
            <option value="0">Elija Una Escuela...</option>
            <option value='1'>Español</option>
            <option value='2'>Matematicas</option>
            <option value='3'>Historia</option>
        </select></label>
    </div>
    <div class="col-3">
        <label>Ciclo escolar
        <select name="clone" id="clone" tabindex="2">
            <option value="">Ciclo Escolar</option>
            <?php 
            $prod=mysql_query("SELECT DISTINCT ciclo_escolar FROM inscripcion GROUP BY ciclo_escolar ORDER BY ciclo_escolar;");
            while($fila=mysql_fetch_array($prod)){
            $ciclo_escolar=$fila['ciclo_escolar']; ?>
            <option value="<?php echo $ciclo_escolar ?>"><?php echo $ciclo_escolar ?></option>
            <?php } ?>
        </select></label>
    </div>
    <div class="col-3">
        <label>Grado<input type="number" name="matri" id="matri" placeholder="Grado A Evaluar" tabindex="3" step="any"/>
        </label>
    </div>
    <div id="progress-button" class="progress-button">
    <button type='submit' id='enviar'><span>Mostrar</span></button>
    </div>
</form>
<div id='datos' style="width: 100%; height: 400px;"></div>

grafevalesc.php
    $bim = $_POST['bim'];
    $clone = $_POST['clone'];
    $matri = $_POST['matri'];

    $buscador = mysql_query("SELECT r.bime, r.matriren, r.ece, i.escuela, i.ciclo_escolar, i.gg,
    SUM(esp1) AS esp1, SUM(mat1) AS mat1, SUM(cien1) AS cien1, SUM(etica1) AS etica1, SUM(art1) AS art1, SUM(geo1) AS geo1, SUM(his1) AS his1, SUM(vivo1) AS vivo1, SUM(natu1) AS natu1, SUM(efis1) AS efis1,
    SUM(esp2) AS esp2, SUM(mat2) AS mat2,
            COUNT(*) as prime
                FROM rendimiento r , inscripcion i 
                    WHERE i.gg = '$matri' 
                        AND r.matriren = i.matricula 
                            AND i.escuela = '$bim'
                                AND r.ece = '$clone';") or die(mysql_error()); 
        while (($fila = mysql_fetch_array($buscador))){
//------  Datos
            $escuela = $fila['escuela'];
            $gg = $fila['gg'];
            $ciclo_escolar = $fila['ciclo_escolar'];
//-----  Califi
            $esp1 = $fila['esp1'];
            $esp2 = $fila['esp2'];
            $mat1 = $fila['mat1'];
            $mat2 = $fila['mat2'];
            $cien1 = $fila['cien1'];
            $etica1 = $fila['etica1'];
            $art1 = $fila['art1'];
            $geo1 = $fila['geo1'];
            $his1 = $fila['his1'];
            $vivo1 = $fila['vivo1'];
            $natu1 = $fila['natu1'];
            $efis1 = $fila['efis1'];

            $prime = $fila['prime'];
//-----  calculo de promedio
            $esces = $esp1/$prime;
            $aftes = $esp2/$prime;
            $escma = $mat1/$prime;
            $aftma = $mat2/$prime;
            $escci = $cien1/$prime;
            $escet = $etica1/$prime;
            $escar = $art1/$prime;
            $escge = $geo1/$prime;
            $eschi = $his1/$prime;
            $escvi = $vivo1/$prime;
            $escna = $natu1/$prime;
            $escefi = $efis1/$prime;
}   ?>

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

function datos() {
    var data = google.visualization.arrayToDataTable([
        ['Materias', 'Escuela',{ role: 'annotation' },'AfterSchool',{ role: 'annotation' }],
        ['Español', <?php echo number_format($esces+0,2,".",",");?>, '<?php echo number_format($esces+0,2,".",",");?>', <?php echo number_format($aftes+0,2,".",",");?>, '<?php echo number_format($aftes+0,2,".",",");?>'],
        ['Matematicas', <?php echo number_format($escma+0,2,".",",");?>, '<?php echo number_format($escma+0,2,".",",");?>', <?php echo number_format($aftma+0,2,".",",");?>, '<?php echo number_format($aftma+0,2,".",",");?>'],
        ['FCyE', <?php echo number_format($escet+0,2,".",",");?>, '<?php echo number_format($escet+0,2,".",",");?>', 0, '0'],
        ['Educacion Fisica', <?php echo number_format($escefi+0,2,".",",")?>, '<?php echo number_format($escefi+0,2,".",",")?>', 0, '0'],
        ['Artisticas', <?php echo number_format($escar+0,2,".",",");?>, '<?php echo number_format($escar+0,2,".",",");?>', 0, '0'],
        ['Naturaleza y Sociedad', <?php echo number_format($escna+0,2,".",",");?>, '<?php echo number_format($escna+0,2,".",",");?>', 0, '0']
    ]);

    var options = {
        title : 'Escuela <?php echo $escuela; ?> Del Ciclo Escolar <?php echo $ciclo_escolar;?> ',
        vAxis: {title: 'Calificacion'},
        hAxis: {title: 'Materias Grado: <?php echo "$gg"; ?>'},
        seriesType: 'bars',
        series: {5: {type: 'line'}},
        animation: {
            duration: 2000,
            easing: 'out',
            startup: true
      }
    };

    var chart = new google.visualization.ComboChart(document.getElementById('datos'));
        chart.draw(data, options);  };
    </script>

Lo que he pensado es poner un botom que limpie el <DIV> o una función .
Espero me puedan ayudar gracias y saludos a todo el grupo

Daniel LaLiberte

unread,
Aug 4, 2016, 12:05:19 PM8/4/16
to Google Visualization API
You will have to restructure your code so that in the web page, you only call google.charts.load() one time.   Perhaps move that call out of your script in the grafevalesc.php file because it is executed every time you load that file.  Move it to the first thing after the document has loaded:

  <script type ="text/javascript">
$(document).ready(function(){
    google.charts.load(...)
...


--
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-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@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/9eab5e76-1129-4a16-9593-827c239b99b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Danny FKB

unread,
Aug 4, 2016, 12:40:45 PM8/4/16
to Google Visualization API
Muchas gracias me sirvió mucho ya genera las tablas aun que me siga mandando el error !!!!!!!
Reply all
Reply to author
Forward
0 new messages