I wanted to use the ASP.NET Chart Controls, but since all of the available examples used a code-behind page reminiscent of Web Forms, I shied away from this. Then I found an example returning the Chart Control as a FileResult, and tried it out. It worked, I was happy and all was good in the world. Except that occasionally I'll get a broken link showing instead of the image it should resolve to. Here's how I have it set up:
In the View, the code is very simple. It's just an image tag that has its src attribute set to the Controller method. I didn't realize this was possible, and thought it pretty cool:<img src="<%: Url.Action("DeveloperLoadCountsChartData")%>"
id="DeveloperLoadCountsChart" alt="Chart" />
In the Controller, I instantiate and build the Chart Control in its entirety, and then output it as a FileResult:public DSC.Web.Controllers.FileResult CompletedProjectsChartData()
// Current user information gathered from method in base Controller.
CurrentUser currentUser = GetCurrentUser();
// Get completed project information.
View Complete Post