I am very new to reporting and mvc. Im trying to get my database data to populate my reports. The reports i have so far are hard coded but i have tried to use a raw query function which got from Return count using raw query, using Entity Framework and MVC to assist me. However i am still struggling to get the chart to display the database data.
report view:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawChart);
var sql = "SELECT COUNT(*) FROM dbo.School WHERE (SchoolName = Accountancy)";
var total = _context.Database.SqlQuery < int > (sql).single();
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Accountancy', total],
['Economics and Business', 2],
['Law', 2],
['Governance', 2],
['Business', 7]
]);
var options = {
title: 'Sample (Until we figure out how to get database data)'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
<div id="piechart" style="width:800px; height: 600px;"></div>
</div>
I tried to get the "Accounting" field to display but the chart didn't display the accounting total, it only displays the totals for the others (which are hard-coded)
Is there anything specific that needs to be coded to get this data ie like in the controller?.. just to remind I am very new to this