0

i am trying to recreate a visualforce bar chart example as documented in here http://www.salesforce.com/us/developer/docs/pages/Content/pages_charting_overview_providing_data_controller_method.htm

I have copy pasted the code.and it doesnt give an error.But my result graph doesnt actually have any bars at all.Although can see is coming through.What should i change ?

Apexcode:

public class oppcontro {
// 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(5);
            }
            return setCon;
        }
        set;
    }

    public List<Opportunity> getOpportunities() {
         return (List<Opportunity>) setCon.getRecords();
    }
}

APEXPAGE

    <apex:page controller="oppcontro">
        <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: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>

SCREENSHOT OF GRAPH enter image description here

JAVASCRIPT CONSOLE SCREENSHOTenter image description here

3
  • Do you see any javascript errors in the console? Commented May 13, 2014 at 11:30
  • I should have checked that first..It says 'Visualforce Chart: Error loading configuration for chart 'jid0jid1': Did not find required field 'amount' in data for chart 'jid0jid1'. Make sure field was queried and/or provided and has a value.' ..Still dont understand why that error is thrown as amount is being passed through as per datatable display
    – sfdc99999
    Commented May 13, 2014 at 11:37
  • Please ignore above..i was referring to an old log..i have attached a screenshot of log above..it looks no issues in it for me
    – sfdc99999
    Commented May 13, 2014 at 11:44

1 Answer 1

1

Make this change (or the equivalent change in the axes) and the example will work:

<apex:barSeries orientation="horizontal" axis="bottom" xField="Amount" yField="Name"/>

This change ensures the correct type of value is used with the correct type of axis.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .