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

printing chart to png - background

1 Answer 112 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 16 Jul 2016, 03:42 PM

Hi,

 

print i chart with this code:

string filename = "ExportedChart.png";
using (Stream fileStream = File.Open(filename, FileMode.OpenOrCreate))
{
    Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(this.chart, fileStream, new PngBitmapEncoder());
}

 

the problem ist, that the background of the png-file ist black! how can i change this to white?

thanks a lot

Rene

1 Answer, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 18 Jul 2016, 08:58 AM
Hello Rene,

Thank you for the code-snippet provided.

When you export the ChartView to png, the background of the image should be the same as the background of the ChartView. If you are using e.g. Expression_Dark theme or you have set Background property of the chart to black, then the image should have the same color.  However, you can change the Background of the chart only by export: 
string filename = "ExportedChart.png";
var initialColor = this.chart.Background;
this.chart.Background = new SolidColorBrush(Colors.White);
using (Stream fileStream = File.Open(filename, FileMode.OpenOrCreate))
{
     Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(this.chart, fileStream, new PngBitmapEncoder());
}
this.chart.Background = initialColor;

I hope this information helps.

Regards,
Milena
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ChartView
Asked by
ITA
Top achievements
Rank 1
Answers by
Milena
Telerik team
Share this question
or