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
BittusBittus 

Displaying a vf chart for fields of opportunity object

Hi all,

I am trying to display a line chart for Opportunity object fields- name,amount. I reffered an example. But am able to display only the data table and facing problem to display the line chart. Am even not getting any error.

Here is my code:-
--------------------------------

<apex:page controller="DynamicSalesChartController">
<apex:chart data="{!opportunities}" width="600" height="400">
     <apex:axis type="Category" position="left"   fields="Name"   title="Opportunities"/>
     <apex:axis type="Numeric"  position="bottom" fields="Amount" title="Amount"/>
     <apex:lineseries orientation="horizontal" axis="bottom" xField="Name" yField="Amount"/>
</apex:chart>
<apex:dataTable value="{!opportunities}" var="opportunity">
    <apex:column headerValue="Opportunity" value="{!opportunity.name}"/>
    <apex:column headerValue="Amount"      value="{!opportunity.amount}"/>
</apex:dataTable>    
</apex:page>


public class DynamicSalesChartController {
    
    // Get a set of Opportunities
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [SELECT name, type, amount, closedate FROM Opportunity]));
                setCon.setPageSize(20);
            }
            return setCon;
        }
        set;
    }
    
    public List<Opportunity> getOpportunities() {
         return (List<Opportunity>) setCon.getRecords();
    }
}
Karthik PKarthik P
Hi Bittus,

In the below line, please remove the orientation attribute and give a try. There is no attribute named "orientation" for the lineSeries component.
 
<apex:lineseries orientation="horizontal" axis="bottom" xField="Name" yField="Amount"/>

If it helps, please mark this as answer.

Thanks