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

Export to PDF the non visual chart.

4 Answers 110 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 02 Dec 2011, 07:53 AM
Hi Team,

I was going through your documnet described in this blog post here. (Export to PDF in Help for Rad Chart)

Here when a chart we need to export is not in visual tree, we create a new RadChart and add the series mapping to it and export it.
But in my case I'm not using the DefaultView of RadChart, because I need to have a grid inside my chart area. So the modified RadChart I created in Xaml and using the same.
Now what I'm trying to do is I'm assigning the DataSeries to the chart I have in xaml (not creating a new one as in your example), and creating my chart. Now when I try to export it using ExportToImage, it throws an exception of null reference.

Is it not possible to export the chart which I have an updated view in xaml, when its not visible in the UI, by assigning the DataSeries as explained in your example (ex: not visible in visual tree)?

Please reply soon.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Manishkumar
Top achievements
Rank 1
answered on 03 Dec 2011, 01:35 PM
Hi Team,
I worked on this more, and able to generate the chart and grid from code behind, but the chart is not displayed in the PDF.
The chart does not have a SeriesMapping's but I'm having a ChartArea in which I am adding DataSeries for StackedBar / StackedArea (not at the same time), and finally adding this ChartArea to RadChart. Like this

RadChart

 

lobjRadChartDeomposed = new RadChart();

 

lobjRadChartDeomposed.BeginInit();

lobjRadChartDeomposed.DefaultView.ChartLegend.Visibility =

Visibility.Collapsed;

 

lobjRadChartDeomposed.DefaultView.ChartTitle.Visibility =

Visibility.Collapsed;

 

lobjRadChartDeomposed.DefaultView.ChartArea.EnableAnimations =

false;

 

 

ChartArea lobjRadChartArea = new ChartArea();

 

lobjRadChartArea.BeginInit();

lobjRadChartDeomposed.Height = 400;

lobjRadChartDeomposed.Width = 1115;

Adding DataSeries to ChartArea like this:
lobjRadChartArea.DataSeries.Add(lobjDataSeries); // near about 12 series.

Then assigning ChartArea to RadChart like this:

 

lobjRadChartArea.EndInit();

lobjRadChartArea.UpdateLayout();

lobjRadChartDeomposed.DefaultView.ChartArea = lobjRadChartArea;

lobjRadChartDeomposed.EndInit();

lobjRadChartDeomposed.UpdateLayout();

 

Finally generating the image as mentioned in the help for ExportToPDF for RadCharts.
Find the attachment for the output (copied from PDF)

Please let me know where I'm making mistake, as soon as possible.

Thanks.

0
Manishkumar
Top achievements
Rank 1
answered on 05 Dec 2011, 10:03 AM
Hi Team,
There were many post generated by me and awaiting your reply on that, it is really hampering my work, please reply to the post as soon as possible.

Related to this post, I'm able to generate the chart.
Bar chart export is working fine, but there are some problems with the Sand Chart.

In sand chart, the X and Y axis lines are not visible and also there are some Sand layers at the bottom are missing.

Is there any style I need to add for Sand Chart as we are doing for Bar Chart, because in bar chart there is no such problem exists.

Attaching the image for the PDF and UI comparision.

Please reply as soon as possible.
Thanks.
0
Accepted
Giuseppe
Telerik team
answered on 06 Dec 2011, 02:37 PM
Hi Manishkumar,

We are unsure why you are experiencing the erroneous behavior you are describing but generally if you do not want to use the default view of the control, you should set RadChart.UseDefaultLayout to false, and create the layout manually.

See the attached sample application that uses this approach and exports the chart to image correctly.


Best wishes,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Manishkumar
Top achievements
Rank 1
answered on 07 Dec 2011, 01:45 PM
Hi Giuseppe,
Thanks it worked.
I was missing just one line of code.
Tags
Chart
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Manishkumar
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or