This is a migrated thread and some comments may be shown as answers.

Problem Exporting RadChart with RadControls for WPF Q2 2009

3 Answers 106 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alvaro
Top achievements
Rank 1
Alvaro asked on 07 Dec 2010, 09:49 AM

Hello everybody, my name is Alvaro and I am having the following problem:

I am making a Radchart showing in Stacked Bar100 some information about some forms. Well, the problem comes in the instruction below.

            try
            {
                Stream imagen = RadChart1.Save(120, 120);
            }
            catch (Exception e) { throw e; }

++throws this error:

[System.ArgumentOutOfRangeException] = {"The parameter value must be greater than zero.\r\nParameter name: pixelWidth"}

And if I try directly to do the following:

            try
            {
                Stream imagen = RadChart1.Save();
            }
            catch (Exception e) { throw e; }

++throw this error:

[System.Security.SecurityException] = {"Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

Any idea of why is this happening?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Alvaro
Top achievements
Rank 1
answered on 07 Dec 2010, 09:54 AM
It is a must continue using this version so I need the possible solutions made on this version of Telerik and not any other newer

Regards,

Alvaro
0
Evgenia
Telerik team
answered on 10 Dec 2010, 09:57 AM
Hello Alvaro,

Currently it is not possible to Save RadChart to Stream directly from code. What I can suggest you is to export it to a file using SaveFileDialog and get the stream from there. You can find a sample of Exporting with source code in our demos - http://demos.telerik.com/wpf/#Chart/Exporting.

Best wishes,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Alvaro
Top achievements
Rank 1
answered on 14 Dec 2010, 11:53 AM
Hello Evgenia,

Finally, I solved this problem with the following code:

try
            {
                Stream imagen = RadChart1.Save();

                System.Drawing.Image img = System.Drawing.Image.FromStream(imagen);
                img.Save("C:\\newpic.bmp");

            }
            catch (Exception x)
            {
                throw x;
            }

This way you get the stream from the chart and you keep it as an image. Then, just using .Save() method from the image you can keep it.

Hope this will help anyone.

Greets,
Alvaro Rincón
Deloitte Technological Department
Tags
Chart
Asked by
Alvaro
Top achievements
Rank 1
Answers by
Alvaro
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or