Export to PDF the non visual chart.

5 posts, 1 answers
  1. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 02 Dec 2011 Link to this post

    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.


  2. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 03 Dec 2011 Link to this post

    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



    lobjRadChartDeomposed = new RadChart();



    lobjRadChartDeomposed.DefaultView.ChartLegend.Visibility =



    lobjRadChartDeomposed.DefaultView.ChartTitle.Visibility =



    lobjRadChartDeomposed.DefaultView.ChartArea.EnableAnimations =




    ChartArea lobjRadChartArea = new ChartArea();



    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:




    lobjRadChartDeomposed.DefaultView.ChartArea = lobjRadChartArea;




    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.


  3. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 05 Dec 2011 Link to this post

    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.
  4. Answer
    Giuseppe avatar
    2363 posts

    Posted 06 Dec 2011 Link to this post

    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,
    the Telerik team

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

  5. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 07 Dec 2011 Link to this post

    Hi Giuseppe,
    Thanks it worked.
    I was missing just one line of code.
Back to Top