I was with an event in select "onchange" as below, but in the select has 
only one item I not I the desired effect.

I need to render the chart being the select filled.

    <form action="">
      @Html.DropDownList("cod_animal", null, new { onchange = 
"drawchart(this.value)", Name = "cod_animal", id = "cod_animal", @class = 
"form-control" })                      
     </form>

<script type="text/javascript">      

    google.load('visualization', '1.1', { 'packages': ['corechart'] });
    google.setOnLoadCallback(function(){drawchart('')});
    function drawchart(cod_animal) {
        var url = '/Programa_Nutricao/Avaliacao/EvolucaoPeso/' + cod_animal;
        $.get(url, {},
              function (data) {
                  var tdata = new google.visualization.DataTable();
                  tdata.addColumn('date', 'data_semanal');
                  tdata.addColumn('number', 'peso_kg');
                  for (var i = 0; i < data.length; i++) {
                      if (data[i].data_semanal != null)
                          
tdata.addRow([ToJavaScriptDate(data[i].data_semanal), 
parseFloat(data[i].peso_kg)]);
                  }
                  var options = {
                      title: 'Evolução do peso corporal',
                      width: 700,
                      height: 500,
                      vAxis: { title: "PESO (kg)", minValue: 1, maxValue: 6 
},
                      hAxis: { title: "DATA", textStyle: { fontSize: 10 } },
                      legend: { position: "none" }
                  };
                  var chart = new 
google.visualization.LineChart(document.getElementById('EvolucaoPeso'));
                  chart.draw(tdata, options);
              });
    }  
</script>

Em quarta-feira, 8 de abril de 2015 10:25:31 UTC-3, Wilson Rogério Braun 
escreveu:
>
>
>
>    1. @using (Html.BeginForm())
>    2. {
>    3. @Html.AntiForgeryToken()
>    4. @Html.ValidationSummary(true)
>    5.  
>    6. <select id="animais" name="cod_animal" class="form-control"
>    ></select>
>    7.  
>    8.  
>    9. <script type="text/javascript"> 
>    10. //google.load('visualization', '1.1', { 'packages': ['corechart'] 
>    });
>    11. //google.setOnLoadCallback(drawChart);
>    12. function drawChart() { 
>    13. var frm = document.getElementById('#animais');
>    14. var animais = frm.options[frm.selectedIndex].value; 
>    15. var url = '/Programa_Nutricao/Avaliacao/EvolucaoPeso/' + animais;
>    16. $.get(url, {},
>    17. function (data) {
>    18. var tdata = new google.visualization.DataTable();
>    19. tdata.addColumn('date', 'data_semanal');
>    20. tdata.addColumn('number', 'peso_kg');
>    21. for (var i = 0; i < data.length; i++) {
>    22. if (data[i].data_semanal != null)
>    23. tdata.addRow([ToJavaScriptDate(data[i].data_semanal), parseFloat(
>    data[i].peso_kg)]);
>    24. }
>    25. var options = {
>    26. title: 'Evolução do peso corporal',
>    27. width: 700,
>    28. height: 500,
>    29. vAxis: { title: "PESO (kg)", minValue: 1, maxValue: 6 },
>    30. hAxis: { title: "DATA", textStyle: { fontSize: 10 } },
>    31. legend: { position: "none" }
>    32. };
>    33. var chart = new google.visualization.LineChart(document.
>    getElementById('EvolucaoPeso'));
>    34. chart.draw(tdata, options);
>    35. });
>    36. }
>    37. </script>
>    38.  
>    39. <div id="EvolucaoPeso" style="width: 900px; height: 500px;"></div>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to