using the d3.js graphs, I added the graph in the View cshtml page. now i want that the values in the graph will withdraw from my DB. so I wrote the following function in the Controller:
protected int GetReadinessAvg()
{
var avgReadiness = 0;
var countItems = 0;
foreach (var item in db.Reviews)
{
avgReadiness = avgReadiness + item.LecturerReadine;
countItems++;
}
avgReadiness = avgReadiness / countItems;
return avgReadiness;
}
This function works great and really return the relevant value. Now, in the graph (the Js code), i want to use this value. Here is what I trying to do..
var freqData = [
{ State: '2013', freq: { LecturerReadine: '<%=GetReadinessAvg()%>', LecturerTransferRate: 412, LecturerAttitude: 674, LecturerKnowledge: 2001 } }
, { State: '2014', freq: { LecturerReadine: 932, LecturerTransferRate: 2149, LecturerAttitude: 418, LecturerKnowledge: 4726 } }
, { State: '2015', freq: { LecturerReadine: 832, LecturerTransferRate: 1152, LecturerAttitude: 1862, LecturerKnowledge: 2135 } }
];
But call to the function: LecturerReadine: '<%=GetReadinessAvg()%>' isn't working. Any suggestions?