WeekOfEntry(DateTime) and Weight (decimal). The chart appears, but the data points aren't there. I'm guessing my data is formatted improperly?<script type="text/javascript"> //Load the Visualization API library and the linechart library. google.load('visualization', '1.0', { 'packages': ['corechart'] });
//Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(drawLoseATonLineChart);
//Callback that creates and populates a data table, instantiates the line chart, //passes in the data, and draws it. function drawLoseATonLineChart() {
var url = "@Url.Action("GetChartStatistics")";
var jsonData = $.ajax({ method: 'GET', url: url, dataType: 'JSON', async: false }).responseText;
var data = new google.visualization.DataTable(); data.addColumn('string', 'WeekOfEntry'); data.addColumn('number', 'Weight');
for (var i = 0; i < data.length; i++) { data.addRow([jsonData[i].WeekOfEntry, jsonData[i].Weight]); }
var options = { title: 'Weight Progression', legend: { position: 'right', alignment: 'center' }, vAxis: { title: 'Weight' }, hAxis: { title: 'Week', slantedText: true, slantedTextAngle: 45
}, colors: ['E81A00'] };
var chart = new google.visualization.LineChart(document.getElementById('lose-a-ton-line-chart'));
chart.draw(data, options); } </script>var lineChartData = (from a in db.Associates join aw in db.AssociateWeights on a.RegistrationId equals aw.RegistrationId where a.EventId == eventId && a.Username == currentuser select new LineChartData { Weight = aw.Weight, WeekOfEntry = aw.WeekOfEntry });
return Json(lineChartData, JsonRequestBehavior.AllowGet);`"[{"Weight":190.0,"WeekOfEntry":"\/Date(1431921600000)\/"},{"Weight":121.0,"WeekOfEntry":"\/Date(1432526400000)\/"}]"`
var tableOptions={};
var dataTable = new google.visualization.LineChart(document.getElementById('test-table'));
dataTable.draw(data, tableOptions);--
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.