version that does not render

22 views
Skip to first unread message

Wilson Rogério Braun

unread,
Jun 8, 2016, 8:27:00 AM6/8/16
to Google Visualization API
Hello,
someone could give a hint, as I am trying to deploy my graphics and I can not render with the new versions google chart:
Down version that does not render:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">  
        var value;
        google.charts.load('current', { 'packages': ['corechart'] });
        google.setOnLoadCallback(function () { drawtable('') });
        $(document).ready(function () {
            value = $("#animal").val();
            if (value != undefined) {
                drawtable(value);
            }
            $("#animal").change(function () {
                value = $(this).val();
                drawtable(value);
            });
        });
function drawtable(codigo){
        google.charts.load('current', { 'packages': ['corechart'] });
        google.charts.setOnLoadCallback(function(){ drawchart('')});       
        var url = '/Programa_Nutricao/Principal/EvolucaoPeso/' + codigo;
        $.get(url, {},
              function (data) {
                  var tdata = new google.visualization.DataTable();
                  tdata.addColumn('date', 'data_atividade');
                  tdata.addColumn('number', 'peso_kg');
                  for (var i = 0; i < data.length; i++) {
                      if (data[i].data_atividade != null)
                          tdata.addRow([ToJavaScriptDate(data[i].data_atividade), parseFloat(data[i].peso_kg)]);
                  }
                  var options = {
                      width: 700,
                      height: 500,
                      vAxis: { title: "PESO (kg)", minValue: '0.5' },
                      hAxis: { title: "DATA", textStyle: { fontSize: 10 } },
                      legend: { position: "none" },
                      curveType: 'function'
                  };
                  var chart = new google.visualization.LineChart(document.getElementById('EvolucaoPeso'));
                  chart.draw(tdata, options);
              });
}
    </script>
<div id="EvolucaoPeso" style="width: 900px; height: 500px"></div>

Under the old version that renders:

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
    var value;
    google.load("visualization", "1", { packages: ["table", "corechart"] });
    google.setOnLoadCallback(function () { drawtable('') });
    $(document).ready(function () {
        value = $("#animal").val();
        if (value != undefined) {
            drawtable(value);
        }
        $("#animal").change(function () {
            value = $(this).val();
            drawtable(value);
        });
    });
  
    function drawtable(codigo) {  

google.setOnLoadCallback(function () { drawchart('') });
        var url = '/Programa_Nutricao/Principal/EvolucaoPeso/' + codigo;
        $.get(url, {},
              function (data) {
                  var tdata = new google.visualization.DataTable();
                  tdata.addColumn('date', 'data_atividade');
                  tdata.addColumn('number', 'peso_kg');
                  for (var i = 0; i < data.length; i++) {
                      if (data[i].data_atividade != null)
                          tdata.addRow([ToJavaScriptDate(data[i].data_atividade), parseFloat(data[i].peso_kg)]);
                  }
                  var options = {
                      width: 700,
                      height: 500,
                      vAxis: { title: "PESO (kg)", minValue: '0.5' },
                      hAxis: { title: "DATA", textStyle: { fontSize: 10 } },
                      legend: { position: "none" },
                      curveType: 'function'
                  };
                  var chart = new google.visualization.LineChart(document.getElementById('EvolucaoPeso'));
                  chart.draw(tdata, options);
              });
 }


    </script>

<div id="EvolucaoPeso" style="width: 900px; height: 500px"></div>

Daniel LaLiberte

unread,
Jun 8, 2016, 9:33:11 AM6/8/16
to Google Visualization API
You have extra calls of google.charts.load(), which is not supported yet in the 'current' version.
You call google.setOnLoadCallback() which doesn't exist.

I cleaned up your code here  https://jsfiddle.net/dlaliberte/r5eygwny/ but it still doesn't run because it requires your local data.

--
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/ac8e22bf-980a-474b-9c47-27bdd06879bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Wilson Rogério Braun

unread,
Jun 8, 2016, 10:21:01 AM6/8/16
to Google Visualization API
Ok giant, 100% rendered, thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.



--
Reply all
Reply to author
Forward
0 new messages