1

Report chart in Visualforce page

Hello All, I am facing a problem related to report chart in a Visual Force, Following is the objective: 1) For all the sales agents pull their top 10 Partners (who generated most leads) and display each partners last 12 months performance monthwise (showing bar chart how many leads are generated by each of those 10 partners) So, I wrote following VF Page:

<apex:page controller="Dashboard" sidebar="false" >
<script>
function closeWindow(){
window.parent.close();
}
</script>
<apex:form ID="Search" >
  <apex:pageBlock >  
    <apex:pageMessages ></apex:pageMessages>
  <apex:pageBlockButtons >
   <apex:commandButton value="Submit" action="{!Search}" reRender="showpartner" />

    </apex:pageBlockButtons>
  <apex:outputLabel value="Name:" />
  <apex:inputText value="{!Name}"/>

  <apex:pageBlockTable value="{!tenpartners }" var="partnervalue" id="showpartner" >

  <apex:column value="{!partnervalue.name}"/>
  <Apex:column value="{!partnervalue.id}"/>
  <apex:column value="{!partnervalue.NumberofLeads__c}"/>
  <apex:column value="{!partnervalue.CreatedDate}"/>

<apex:column >
<analytics:reportChart cacheAge="10" cacheResults="false" 
     reportid="00O240000027ckD" size="large" 
     filter="{column:'Partner__c.Name', operator:'equals',
              value:'{!JSENCODE(partnervalue.Name)}'}">
</analytics:reportChart>

</apex:column>

  </apex:pageblockTable>



  </apex:pageBlock>
  </apex:form>
</apex:page>

CONTROLLER:

public class Dashboard{


Public List<Partner__c> tenpartners{get;set;}
public String Name{get;set;}
public Boolean rend { get; set; }


public pagereference search(){
tenpartners = new List<Partner__c>();
tenpartners = database.query('SELECT ID,CreatedDate,NumberofLeads__c,Name FROM Partner__c where Owner.Name=:Name ORDER BY NumberofLeads__c desc LIMIT 10');

return null;


}}

But problem I am facing is for 1st partner its showing correct report chart but for rest of the 9 charts its displaying the chart which is of 1st partner, here is the screenshot, so if you see twelthpartner which has highest number of leads i.e. 6 is ranked first but same chart is displayed for rest of the nine partners.....

I have also created report and tried by creating passed filter and without any filter but no change... Anyone faced this problem or if they have any idea what happening here, will be a great favor..

  • 1
    I suggest you create a test page with a single entirely hard-coded analytics:reportChart including the filter expression and make sure that looks right. (Should column really be "Partner__c.Name" not just "Name"?) Then add a second hard-coded analytics:reportChart that references a different name and make sure they both look right. Then go back to the page you list in your question and use those patterns there; you can use your browsers "View Source" or "Inspect Element" to make sure the {! } expression evaluates to the correct string. – Keith C Jul 6 '15 at 17:46
  • <apex:column > <analytics:reportChart reportid="00OD0000006gE8i" size="medium" filter="{column:'Partner__c.Name', operator:'equals', value:'1stRankPartner'}"> </analytics:reportChart> <analytics:reportChart reportid="00OD0000006gE8i" size="medium" filter="{column:'Partner__c.Name', operator:'equals', value:'2ndRankPartner'}"> </analytics:reportChart> <analytics:reportChart reportid="00OD0000006gE8i" size="medium" filter="{column:'Partner__c.Name', operator:'equals', value:'3rdRankPartner'}"> </analytics:reportChart> </apex:column> – Mamnoon Hadi Jul 7 '15 at 14:25
  • I used above and indeed it is one step forward, when I hard coded as you suggested its showing values for hard coded values but problem is those three graphs are getting repeated for every partner and how can I filter 1st rank partner, 2nd partner etc etc,,,,,and regarding your suggestion of using name instead of partner__c.name its giving me error because report type is also partner with leads – Mamnoon Hadi Jul 7 '15 at 14:32
  • I've never used those filters so can't help. If you've narrowed the problem it might be worth posting a separate question appropriately titled and tagged and with just the relevant code. – Keith C Jul 7 '15 at 14:33
  • <apex:pageblockTable value="{!tenpartners }" var="partnervalue" id="showpartner" > <apex:column value="{!partnervalue.name}"/> <apex:column value="{!partnervalue.NumberofLeads__c}"/> <apex:column > <analytics:reportChart reportid="00OD0000006gE8i" size="medium" filter="{column:'Partner__c.Name', operator:'equals', value:'{!partnervalue.name}'}"> </analytics:reportChart> </apex:column> – Mamnoon Hadi Jul 7 '15 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.