[SalesForce] Image Charts in Visualforce / PDF

Got a tricky one. I want to be able to create rich HTML emails to our clients which include graphs etc.

Problem is, Google Image Chart is being depreciated, Visualforce Charts can't be output to an image and Google Visualisation API needs JavaScript which is not good for emails.

I saw this post from August '13 How can I create a custom chart without JS besides Google Charts? and wondered if anyone has made any progress since then?

I've exhausted Google searching and there doesn't seem to be anything out there.

Please can you help?

Best Answer

You can get standard report charts, via a dashboard, into a pdf - I have this working for a client so I know this works.

What you need to do add the report +chart to a dashboard and then view the dashboard. Right click on a chart and open in new tab.

enter image description here

Copy the image url and paste into your pdf page into an img html component. This is an example I have working (ids changed to protect identity):-

<apex:page showheader="false" renderAs="pdf">
  <img src="https://cs8.salesforce.com/servlet/servlet.ChartServer?rsid=0FLL00000009XXX&ruid=00580000003BXXX&did=01ZC00000013SP0&s=8&fs=12&tfg=12&tfs=-16777216&explode=0&c=bar&cs=0&title=Top+10+Users+-+%23+of+Followers&eh=yes&compo=yes&fg=-16777216&bg1=-1&bg2=-1&bgdir=2&dl1=Full+Name&dl2=&l=2&sax=yes&Yman=no&nc=10&actUrl=%2F00OC0000004nUGU%3Fdbw%3D1&sd=4&scv=no&sct=no&spt=no&cu=USD&ab=X&u=0&vt=0&ab2=Y&u2=0&vt2=0&vl0=Record+Count&spoc=no&topn=no&gc0=-1&gc1=-1&gc2=-1&sona=0&refreshts=1389629381000"/>

  </apex:page> 

Whats really interesting is that when the dashboard is refreshed, the chart is also refreshed and so although this is a static url, the chart is 'dynamic'.

Related Topic