Friday, October 1, 2010

Microsoft Chart Disappearing (not rendering)?

Sometimes my charts would show, sometimes they wouldn't. Sometimes when I refresh my page the chart disappears! I found if I set the ImageStorageMode of the chart to "UseImageLocation" it started working consistently.
<asp:Chart ID="chStats" runat="server" Palette="None" Height="500px" 
    Width="500px" ImageStorageMode="UseImageLocation" >

If you use this option, you have to make sure you define a location (that has write access) in your web.config.
<appSettings>
    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=C:\TempCharts;" />
</appSettings>

More Info: MSDN: Chart.ImageStorageMode Property