public ActionResult ChartDataOne() { var data = (from p in _context.LPlusScores where p.LPlusScoreID == "AE" orderby p.YTD select p).ToList();
return Json(data); }
public ActionResult ChartDataTwo() { var data = (from p in _context.LPlusScores where p.LPlusScoreID == "AE" orderby p.YTD select p).ToList();
return Json(data); }
[{"lPlusScoreID":"AE","lastYear":1.00,"jan":1.00,"feb":1.00,"mar":1.00,"apr":1.00,"may":1.00,"jun":1.00,"jul":1.00,"aug":1.00,"sep":1.00,"oct":1.00,"nov":1.00,"dec":1.00,"ytd":1.00}]
[{"lPlusScoreID":"GS","lastYear":3.00,"jan":3.00,"feb":3.00,"mar":3.00,"apr":3.00,"may":3.00,"jun":3.00,"jul":3.00,"aug":3.00,"sep":3.00,"oct":3.00,"nov":3.00,"dec":3.00,"ytd":3.00}]
<div id="chart_div"></div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript">
// Load the Visualization API package. google.charts.load('current', { 'packages': ['corechart', 'table', 'gauge'] });
// Set a callback to run when the Google Visualization API is loaded. google.charts.setOnLoadCallback(drawChart1); google.charts.setOnLoadCallback(drawChart2);
function drawChart1() { $.ajax({ type: 'GET', dataType: 'json', contentType: "application/json", url: '@Url.Action("ChartDataOne", "LPlusScore")', //See separate JSON Data Example success: function (result) {
// Create our data table out of JSON data loaded from server var data = new google.visualization.DataTable();
//Add Columns data.addColumn('string', 'lPlusScoreID'); data.addColumn('number', 'lastYear'); data.addColumn('number', 'ytd');
//Add Rows var dataArray = []; $.each(result, function (i, obj) { dataArray.push([ obj.lPlusScoreID, obj.lastYear, obj.ytd, ]); }); data.addRows(dataArray);
//Chart Options var options = { height: 200, };
//Draw Chart var chart = new google.visualization.Table(document.getElementById('chart_div')); chart.draw(data, options);
} //END success: function (result) { }); //END $.ajax({ }; //END function drawChart()
function drawChart2() { $.ajax({ type: 'GET', dataType: 'json', contentType: "application/json", url: '@Url.Action("ChartDataTwo", "LPlusScore")', //See separate JSON Data Example success: function (result) {
// Create our data table out of JSON data loaded from server var data = new google.visualization.DataTable();
//Add Columns data.addColumn('string', 'lPlusScoreID'); data.addColumn('number', 'lastYear'); data.addColumn('number', 'ytd');
//Add Rows var dataArray = []; $.each(result, function (i, obj) { dataArray.push([ obj.lPlusScoreID, obj.lastYear, obj.ytd, ]); }); data.addRows(dataArray);
//Chart Options var options = { height: 200, };
//Draw Chart var chart = new google.visualization.Table(document.getElementById('chart_div')); chart.draw(data, options);
} //END success: function (result) { }); //END $.ajax({ }; //END function drawChart() </script>
--
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/a963b11f-7295-409e-a7da-f3c923c9a800%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Oh wow...I missed the easiest part! Thank you for the hint.Another question, where is a good training resource on constructing the controller in MVC core? I've been having trouble determining the best way to make queries into my data context.
--
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/eddab32b-fde0-4d80-b180-cbef221d28d0%40googlegroups.com.