function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hari azmeera 8hari azmeera 8 

embed reports and dashboards in visual force page and record detail page

Amit Chaudhary 8Amit Chaudhary 8
Hi hari azmeera 8,

There are to many example are available in google for same. please check below post. I hope that will help you
1) http://www.infallibletechie.com/2012/07/how-to-display-dashboard-using-visual.html
2) http://www.infallibletechie.com/2012/07/how-to-display-dashboard-using-visual.html
3) http://www.infallibletechie.com/2013/02/pie-chart-and-bar-chart-using-apex-in.html

Sample code
Visualforce page:

<apex:page controller="Graph" >
    <apex:pageblock title="Members and their Years of experience" >
        <apex:chart height="250" width="350" data="{!pieData}">
            <apex:pieSeries tips="true" dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
    </apex:pageblock>
                       
    <apex:pageblock title="Members and their Years of experience" >
        <apex:chart height="250" width="350" data="{!pieData}">
            <apex:axis type="Numeric" position="left" fields="data" title="Years of experience"/>   
            <apex:axis type="Category" position="bottom" fields="name" title="Member"/>           
            <apex:barSeries orientation="vertical" axis="left" xField="name" yField="data"/>
        </apex:chart>
    </apex:pageblock>           
</apex:page>

Apex Controller:

public with sharing class Graph
{ 
    public List<PieWedgeData> getPieData()
    { 
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<Member__c> memb = new List<Member__c>(); 
       
        String sql = 'SELECT Name, Year_s_Of_Experience__c FROM Member__c';
        memb = Database.Query(sql);
        for(Member__c temp:memb)
        {          
            data.add(new PieWedgeData(temp.Name,temp.Year_s_Of_Experience__c));
        }
        return data; 
    } 
   
    // Wrapper class 
    public class PieWedgeData
    { 
        public String name { get; set; } 
        public Decimal data { get; set; } 
       
        public PieWedgeData(String name, Decimal data)
        { 
            this.name = name; 
            this.data = data; 
        } 
    } 
}
Let us know if this will help you

Thanks
Amit Chaudhary

 
Sachin P Sam 1Sachin P Sam 1
Added code to add dashboard using iframe in visualforce page ,but dashboard is not displaying (Only white space appears)
Here is my code ,Please provide me the solution.
<apex:page standardController="Position__c" sidebar="false">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <apex:pageBlock >
  <apex:pageBlockSection >
  <apex:detail />
  
  </apex:pageBlockSection>
  
  </apex:pageBlock>
 <apex:iframe src="https://ensignllp-dev-ed.my.salesforce.com/01Z7F000000cS0q"  scrolling="true" id="theIframe"/>
</apex:page>