Embed Report Charts in Visualforce Pages

Embed Report Charts in Visualforce Pages

Last Updated on June 1, 2022 by Rakesh Gupta

👉 Check out this article if you want to learn how to Add Report Chart to Lightning Record Page

Reports and dashboards display how you performed in the past and what’s happening at the moment. They are important to driving success and implementation of any CRM project. The information provided by reports and dashboards is especially important in today’s arena, where it’s critical to be proactive, rather than reactive, in your approach. You want to be able to spot trends and act on them immediately.

Business Use case

Higher management in Universal Container wants to use Opportunity trends report chart on a Visualforce Page.

Automation Champion Approach (I-do):

You can use report Report Chart (That is created by using the report builder) in any Visualforce page, with only a single line of code. Report Chart can include dynamic filters, auto-refresh based on an expiration time, and many other options. With this enhancement, all of your most critical Chart and analytics is in the background, wherever you are working.

You no longer need workarounds such as iframes or Javascript to create a Visualforce page with dashboard-like functionality. You can just pull the chart into your Visualforce component by its report ID.  Follow the below instruction to complete this requirement

  • Create a Report with Chart. If you don’t to how to do that please go through my article Embedding Charts Anywhere
  • Copy the report ID, you can get a report’s ID from the report URL in Salesforce, or request it through the API.
  • Now create a Visualforce page and use Visualforce tag <analytics:reportChart> with attribute reportID


<apex:page >
<analytics:reportChart reportId="00Ox0000000i8gv" size="small"></analytics:reportChart>
  • It will look like below screenshot
Embed Report Charts in Visualforce Pages
Embed Report Charts in Visualforce Pages

You can find more details about <analytics:reportChart> tag by visiting the URL.

Points to Remember

  1. By default chart’s size is set to Medium. If you to change the size use size attribute and values you can use are Tiny, Small, Medium, Large, Huge.
  2. The length of time that an embedded chart can cache data is 24 hours.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

5 thoughts on “Embed Report Charts in Visualforce Pages

  1. Hi,
    I have used analytics:reportsChart on my vf page simply by using following code.

    where strCaseStatusChart contains the id of the report I need to display over my vf page.
    But it gives me the following error
    Error : Something has gone wrong. Assertion Failed!: Cannot call EnqueueAction() with a non Action parameter. : false. Please try again.

    I am not able to understand what and where went wrong can you please provide some solutions over this error.

  2. When i click on the chart, it takes me to the actual report. Can this be disabled, i don’t my users to see the underlying report.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.