Working on an ASP.NET MVC4 system, I have a javascript code that displays a performance graph of students when the page loads.
Here is the code for the graph:
<script>
window.onload = function () {
var r = Raphael("holder"),
txtattr = { font: "20px sans-serif" };
var lines = r.linechart(30, 30, 600, 440,<%= Json.Encode(ViewBag.dates) %>,<%= Json.Encode(ViewBag.Grades)%>, {axisxstep : 6,nostroke: false, axis: "0 0 1 1", symbol: "circle", smooth: false }).hoverColumn(function () {
this.tags = r.set();
for (var i = 0, ii = this.y.length; i < ii; i++) {
this.tags.push(r.tag(this.x, this.y[i], Number(this.values[i]).toFixed(5), 160, 10).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }]));
}
});
</script>
The data for the graph is retrieved from the function DisplayGraph
in the controller. See the controller code below:
public ActionResult DisplayGraph(String InputStudent = "IP11")
{
// Controller logic to fetch data for the graph
}
When a new student joins the school, I want to display a message instead of the graph. How can I control the execution of javascript from the controller?
Any help would be greatly appreciated. Thank you