Using the answer Generating the Image from a Controller from this post, I created a controller action to return a chart image as seen below (the X and Y values are just there as test data):
public FileContentResult HistoryChart()
{
Chart chart = new Chart();
string[] currencies = { "ZAR", "USD", "GBP", "JPY" };
foreach (string currency in currencies)
{
Series series = new Series(currency);
series.ChartType = SeriesChartType.FastLine;
for (int x = 0; x <= 30; x++)
series.Points.AddXY(x, (x * 5));
chart.Series.Add(series);
}
using (MemoryStream ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
}
The problem is, the image that the controller returns is blank (although it DOES return an image)
Im hoping its something simple that I have left out! Any input would be appreciated, thanks.