I use also Microsoft Chart control in my ASP.NET MVC application. The problem which you describe can not appears in my case. I can explain why. I have a MVC Controller with the method GetChart
which gives back pure PNG file as a stream. So I define on a HTML page (on a View to be exactly) a <img>
element with src
attribute like "<%= Url.Content ("~/Home/GetChart")%>"
. So web browser load and display a PNG graphic only. Such implementation works perfect in all browsers. It is also tested and works with IE6.
My GetChart
method looks like following:
public FileStreamResult GetChart (/*some additional parameters*/) {
MyChartModel model = new MyChartModel ();
System.Web.UI.DataVisualization.Charting.Chart chart =
model.CreateChart (/*some parameters*/);
// Save the chart in a MemoryStream
MemoryStream imageStream = new MemoryStream ();
chart.SaveImage (imageStream, ChartImageFormat.Png);
// Reset the stream’s pointer back to the start of the stream.
imageStream.Seek (0, SeekOrigin.Begin);
return new FileStreamResult (imageStream, "image/png");
}
The code of the model MyChartModel
is a little longer, but if you have already a implementation of Microsoft Chart you have already all needed.