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

using Export in RadCartesianChart

1 Answer 184 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Shin
Top achievements
Rank 1
Shin asked on 10 Nov 2015, 01:19 AM

first forgive poor my english written

 

I Export to PNG before setting Zoom property is 5, 1 => 1, 1

but Export image is still 5, 1 Zoom setting

 

 in XAML Code

1.<!-- already Zoom property is 5,1 setting-->
2.<telerik:RadCartesianChart Grid.Column="0" Grid.Row="1" x:Name="trfChart1" Palette="Windows8" Zoom="5,1">

 

in cs Code

1.// this.myChart.Zoom = new Size(5, 1) already setting Zoom property     
2.string filename = "C:\\ExportedChart.png";
3.using (System.IO.Stream fileStream = System.IO.File.Open(filename, System.IO.FileMode.OpenOrCreate))
4.{
5.   this.trfChart1.Zoom = new Size(1, 1); // When before Export Zoom Property set Zoom 1, 1
6.   Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(this.trfChart1, fileStream, new System.Windows.Media.Imaging.PngBitmapEncoder());
7.
8.// But Export result is still Zoom 5, 1 setting

 

 please give advise 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 10 Nov 2015, 12:39 PM
Hello Shin,

The chart is not exported with the new zoom level because it is not yet measure and arranged with the e Measure() and Arrange() methods of the chart right before the Exnew zoom. In order to achieve the desired effect you can manually call thportToImage() call.
this.trfChart1.Zoom = new Size(1, 1);
 
var size = trfChart1.RenderSize;
this.trfChart1.Measure(Size.Empty);
this.trfChart1.Measure(size);
this.trfChart1.Arrange(new Rect(size));
this.trfChart1.UpdateLayout();
 
Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(this.trfChart1, fileStream, new System.Windows.Media.Imaging.PngBitmapEncoder());

I hope this helps.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ChartView
Asked by
Shin
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or