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

ExportToImage, border

2 Answers 68 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Richard Alvarez
Top achievements
Rank 1
Richard Alvarez asked on 27 Apr 2011, 11:02 PM
I'm exporting a chart to png using ExportToImage and the PngBitmapEncoder.  Is there any way of getting rid of the border around the resulting image?

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 03 May 2011, 08:33 AM
Hi Richard,

I made a local test in order to reproduce this issue, but I didn't get an unexpected border around the chart. If you mean the default RadChart border, you can remove it before exporting and restore it after that. For example:
private void ButtonExportChartToImage_Click(object sender, RoutedEventArgs e)
{
    //remove the default RadChart border before export
    radChart.BorderThickness = new Thickness(0);
 
    SaveFileDialog dialog = new SaveFileDialog();
    dialog.DefaultExt = "png";
    dialog.Filter = string.Format("{1} File (*.{0}) | *.{0}", "png", "PNG");
 
    if (!(bool)dialog.ShowDialog())
        return;
 
    Stream fileStream = dialog.OpenFile();
    radChart.ExportToImage(fileStream, new PngBitmapEncoder());
 
    fileStream.Close();
     
    //restore the default RadChart border after export
    radChart.BorderThickness = new Thickness(1);
}

I hope this helps.

Regards,
Polina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Alvarez
Top achievements
Rank 1
answered on 03 May 2011, 04:37 PM
That did help.  I did some more experimenting, and found that the problem only occurred when I set the width of the chart, which is strange because that is the constraining proportion for the area I'm putting the image of the chart in.  So instead, I calculate the height I think I need, set that, and let width go unassigned.
Tags
Chart
Asked by
Richard Alvarez
Top achievements
Rank 1
Answers by
Missing User
Richard Alvarez
Top achievements
Rank 1
Share this question
or