ERRO:</script>Alguém tem alguma sugestão?
Controler:
public ActionResult Peso()
{
var dia = db.spPesoEvolucao().ToList();
var a = dia.Select(x => new { x.data_semanal, x.peso_kg });
return Json(a, JsonRequestBehavior.AllowGet);
}View:
<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--> <script type="text/javascript"> google.load('visualization', '1', { 'packages': ['corechart'] }); google.setOnLoadCallback(drawChart); function drawChart() { $.get('/Programa/Peso', {}, function (data) { var tdata = new google.visualization.DataTable(); tdata.addColumn('date', 'data_semanal'); tdata.addColumn('number', 'peso_kg'); //tdata.addColumn({ type: 'string', role: 'annotation' }); console.log(data); for (var i = 0; i < data.length; i++) { if (data[i].data_semanal != null) tdata.addRow([data[i].data_semanal, data[i].peso_kg]); } var options = { vAxis: { title: "PESO", minValue: 1 }, hAxis: { title: "DATA", textStyle: { fontSize: 10 } }, legend: { position: "none" } }; var chart = new google.visualization.LineChart(document.getElementById('EvolucaoPeso')); chart.draw(tdata, options); }); } </script> <body> <div id="EvolucaoPeso" style="width: 900px; height: 500px;"></div> </body>
No banco SQL Server 2008:
No design da tabela os campos peso_kg(nchar(10),null) e data_semanal(date,null)
--
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
...
--
...
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
Como retornar a data_semanal?
De:
Para:
data.addRows([To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
...
--
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
...
--
Okay, but the chart is not out yet. The return format below:
Tue Sep 02 2014 00:00:00 GMT-0300 (Hora oficial do Brasil) "1.340 "
Sat Sep 06 2014 00:00:00 GMT-0300 (Hora oficial do Brasil) "1.450 "
Mon Sep 08 2014 00:00:00 GMT-0300 (Hora oficial do Brasil) "1.540 "
...
--
...
--
...
--