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

Suggestion on how to create vector image/pdf for chart on server side

2 Answers 183 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Raghu
Top achievements
Rank 1
Raghu asked on 07 Jul 2014, 05:54 PM
Hi,

Can you please provide some suggestion on creating a chart on server side and export SVG out of it to create vector graphics/pdf.

We have an application which runs as a scheduler on the server, generates charts and emails them to customers in PDF/Images. All this without any manual interaction.

I looked at RadChart and RadHTMLChart. RadChart is a server side compontent but can't export vercor graphics, and RadHtmlChart renders SVG strictly the on browser.

The problem with using RadHtmlChart is we have to run a browser object from server side code to execute JS which can be a 'not so' reliable solution.

Please suggest. Thanks!

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 08 Jul 2014, 07:12 AM

Hello Raghu,

RadHtmlChart renders with JavaScript in the browser, so you need to run it in a browser context in order for it to render. At this point you can access the SVG string that it generates and use it.

On RadChart export - it has never been intended to work with vector graphics and produces only raster images, so you may need to go with the RadHtmlChart.

You can find example of exporting it here: http://www.telerik.com/support/code-library/exporting-radhtmlchart-to-png-and-pdf. It uses a third party tool (in this case Inkscape) to generate a PDF or PNG from the SVG string. Depending on your needs, you may need to tweak it.

On avoiding user interaction - you would, indeed, need to run the browser on the server in order to get the rendered HtmlChart. You can consider using other tools to run the browser and get the needed data, like PhantomJS: http://phantomjs.org/.

Whether this is a reliable solution - I do not see reasons why it would break, especially if the code that runs the browser instance cleans up after itself (i.e., closes the browser). All export operations put load on the server, yet running a browser with one or a couple of charts should not slow it down significantly, generating a large PDF is likely to require more memory and resources. If this is still not an option, you could consider requiring user interaction so that the charts render on the client's browsers and they only send you back the SVG string.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Raghu
Top achievements
Rank 1
answered on 08 Jul 2014, 05:08 PM
Thanks Marin!

Yes, I did review the forums and some examples already. I'm currently using Gecko engine to make the browser request from server.
I was basically looking to see if I missed any existing feature on server side to get SVG, or any newly planned feature coming up.
Thanks!

Also, on a side note the search feature seems to be broken in forums. The search is not yielding any results.
http://www.telerik.com/forums/aspnet-ajax/chart

Just fyi...




Tags
Chart (Obsolete)
Asked by
Raghu
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Raghu
Top achievements
Rank 1
Share this question
or