I am trying to create an apex chart. While running i am getting the following error -
Invalid field Product__r.Family for AggregateResult
public list<wrapperclass> getPieData() {
List<wrapperclass> data = new List<wrapperclass>();
List<Work_Order_Item__c> memb = new List<Work_Order_Item__c>();
AggregateResult[] groupedResults = [SELECT count(Id),Product__r.Family FROM Work_Order_Item__c group by Product__r.Family];
for (AggregateResult ar : groupedResults) {
if(ar.get('Product__r.Family')!=null)
{
data.add(new wrapperclass(
String.ValueOf(ar.get('Product__r.Family')),
Double.ValueOf(ar.get('expr0'))
));
}
}
return data;
}
Vf Page -
<apex:chart height="350" width="450" data="{!pieData}">
<apex:pieSeries dataField="data" labelField="Name"/>
<apex:legend position="bottom"/>
</apex:chart>
Error Javascript -
SfdcCore.js:384 Visualforce Chart: Error loading configuration for chart 'jid0jid1pbjid3jid4': Unable to infer data model from result: result is not an Arrayb.resolve.b.provide.log @ SfdcCore.js:384
https://login.salesforce.com/17181/logo180.png Failed to load resource: the server responded with a status of 404 (Not Found)
Can anyone tell what i am doing wrong.
SELECT count(Id) cnt, Product__r.Family prodFam FROM Work_Order_Time....
) and then use that alias to get the values, soar.get('cnt');
andar.get('prodFam');