You need to sign in to do that
Don't have an account?

I am executing the code provided in visualforce page book, but i am not able to get the expected output
Apex Class:
-----------------
public class OppsController {
public ApexPages.StandardSetController setCon {
get {
if(setCon == null){
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}
public List<Opportunity> getOpportunities(){
return (List<Opportunity>) setCon.getRecords();
}
}
Visualforce Page:
-------------------------
<apex:page controller="OppsController" >
<apex:chart data="{!Opportunities}" height="400" width="600">
<apex:axis type="Category" position="left" fields="name" title="Opportunities" />
<apex:axis type="Numeric" position="bottom" fields="amount" title="Amount" />
<apex:barSeries orientation="horizontal" axis="bottom" xField="name" yField="amount" />
</apex:chart>
<apex:dataTable value="{!Opportunities}" var="opp" >
<apex:column headerValue="Opportunity" value="{!opp.name}" />
<apex:column headerValue="Amount" value="{!opp.amount}" />
</apex:dataTable>
</apex:page>
-----------------
public class OppsController {
public ApexPages.StandardSetController setCon {
get {
if(setCon == null){
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}
public List<Opportunity> getOpportunities(){
return (List<Opportunity>) setCon.getRecords();
}
}
Visualforce Page:
-------------------------
<apex:page controller="OppsController" >
<apex:chart data="{!Opportunities}" height="400" width="600">
<apex:axis type="Category" position="left" fields="name" title="Opportunities" />
<apex:axis type="Numeric" position="bottom" fields="amount" title="Amount" />
<apex:barSeries orientation="horizontal" axis="bottom" xField="name" yField="amount" />
</apex:chart>
<apex:dataTable value="{!Opportunities}" var="opp" >
<apex:column headerValue="Opportunity" value="{!opp.name}" />
<apex:column headerValue="Amount" value="{!opp.amount}" />
</apex:dataTable>
</apex:page>
i think you are trying to diplay a bar chart above the table... Change the code like below.
Class
VF page
Out put:
Hope this will help you,
Mark best ANSWER if its work for you..
Thanks
karthik
All Answers
On running the code provided by you I got the following output
Can you please let me know wht is your desired output so I can help you to achieve the same.
Controller Vf page :
i think you are trying to diplay a bar chart above the table... Change the code like below.
Class
VF page
Out put:
Hope this will help you,
Mark best ANSWER if its work for you..
Thanks
karthik