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

Export functionality of charts

3 Answers 28 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Sampada
Top achievements
Rank 1
Sampada asked on 24 Jun 2013, 07:50 AM

Telerik Team,

I have a Dashboard with Telerik Silverlight controls used. The Charts in the Dashboard are dynamically created as per user configuration. Now we have a requirement that when the Silverlight Content is loaded on the page followings things should happen:

  1. Create a word document at a particular location on server containing the images of all Charts on our Dashboard(Export to Word).
  2. Create a image in *.png format at a particular location on server of charts.

Please note that the word document should automatically be created on the silverlight content being loaded every time without requiring any user interaction.

Please let me know how I can achieve this task.

 

Thanks in advance.


3 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 27 Jun 2013, 08:13 AM
Hi Sampada,

Due to limitation of Silverlight framework, it is not possible to export a control if it is not attached to the visual tree. Additionally this needs to be done, after the chart is fully rendered. However the Silverlight framework does not provide a straight-forward way to know if a visual element is rendered. What you can do is to attach to the RadChart.Loaded event and then using a timer, execute the chart export logic after 1 second. In order to ensure that the chart is rendered, you need to disable the animations:
this.RadChart1.DefaultView.ChartArea.EnableAnimations = false;

RadChart provides 
built-in methods for exporting to several formats. For more advanced scenarios such as exporting to documents (Word, PDF, etc.), you can use the RadDocument control. Here you can find an example of that. After the chart is exported you can use the WebClient API to upload the image/document to the server (Silverlight code is executed on the client machine).

I hope this helps.

Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sampada
Top achievements
Rank 1
answered on 28 Jun 2013, 06:14 AM
Hi Petar,

Thanks for the reply

Could you please provide me a code sample or demo project of your given solution.

Thanks & regards
Sampada
0
Petar Kirov
Telerik team
answered on 03 Jul 2013, 06:57 AM
Hi Sampada,

I have attached a sample project. In it the chart is automatically exported to image on page load, and saved in a memory stream for later use. You can save the image on your computer, by clicking the Export button to verify that it is correct.

Please note that this is not a supported scenario, so be sure to test it extensively.

In your project, basically you need to replace the UploadImageToServer with your custom upload logic. In it you can use RadDocument, like it is demonstrated in this help topic to export Word, PDF, etc. Here you find an example of how to use WebClient to upload the file(s) to the server.
You can see for example how I have implemented the ExportButton_Click method, and it should be relatively simple to modify it as per your requirements.
 
Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
Sampada
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Sampada
Top achievements
Rank 1
Share this question
or