Completed
Last Updated: 04 Apr 2014 13:29 by Telerik Admin
ADMIN
Petar Marchev
Created on: 12 Nov 2013 08:28
Category: ChartView
Type: Bug Report
1
Chart is not exported properly when Margin is present
Chart is not exported properly when Margin is present.
1 comment
Imported User
Posted on: 10 Jan 2014 14:50
The workaround I found for this was to export the entire UserControl that hosts the charts, then render only the control(Grid in my case) that hosts the charts.  You will then have to trim/crop the image you end up with in the event other controls on the same UserControl didn't get rendered.

My Code (notice I capture "this" and only render the grid that my charts are hosted in, chartsGrid):
            RenderTargetBitmap rtb = new RenderTargetBitmap((int)this.ActualWidth, (int)this.ActualHeight, 96, 96, PixelFormats.Pbgra32);
            rtb.Render(this.chartsGrid);

            var bitmapImage = new BitmapImage();
            var bitmapEncoder = new BmpBitmapEncoder();
            bitmapEncoder.Frames.Add(BitmapFrame.Create(rtb));

            PngBitmapEncoder png = new PngBitmapEncoder();
            png.Frames.Add(BitmapFrame.Create(rtb));

            ImageInline img = null;

            using (MemoryStream stream = new MemoryStream())
            {
                png.Save(stream);

                //Scale down to 3/4th size of original
                img = new ImageInline(stream, new Size(this.ActualWidth * .75, this.ActualHeight * .75), "png");
            }