Chart: Disabling animations for rendering to a bitmap

Feb 9, 2010 at 12:42 PM



I try to use the chart component in a console application and want to render it to a file.

The problem that I encounter is that the rendered bitmap is empty - due to the fact that it is propably animated and the data is not yet shown.


Is there a way to disable these "show" animations?


Thank you.

Dec 15, 2010 at 1:17 PM

Hi I have exactly the same problem. The code goes like this:


Chart chart = new Chart { Width = 300, Height = 230 };
// I do not add series yet, because I thought that maybe that caused problems...
chart.Background = Brushes.Blue;
chart.BorderBrush = Brushes.Red;
chart.BorderThickness = new Thickness(10);
chart.Title = "Test chart";
chart.Measure(new Size(chart.Width, chart.Height));
chart.Arrange(new Rect(new Size(chart.Width, chart.Height)));

RenderTargetBitmap rtb = new RenderTargetBitmap((int)chart.Width, (int)chart.Height, 96, 96, PixelFormats.Pbgra32);
PngBitmapEncoder png = new PngBitmapEncoder();


using (System.IO.Stream stream = System.IO.File.Create("C:\\chart.png"))

// END

If I use it in WPF application where I have a chart control on a form, I get a nice image with entire chart. However if I try to do that in my console application without showing it to the user (I only want to generate images), then I get an empty image of the specified size...

Any advice? Thanks in advance.