You need to sign in to do that
Don't have an account?
Error in Apex class
Error Message:
Error: GoogleChartsController Compile Error: Incompatible types since an instance of ApexPages.StandardController is never an instance of Account at line 5 column 15
Controller:
global class GoogleChartsController {
global static Account acc;
public GoogleChartsController(ApexPages.StandardController controller) {
acc = (Account)controller.getRecord();
}
@RemoteAction
global static AggregateResult[] loadChildCases(Id prmAccountId) {
AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case WHERE AccountId = :prmAccountId Group By ParentId ];
return caseLst;
}
}
VF Page:
<apex:page extensions="GoogleChartsController" sidebar="false" standardController="Account" showHeader="false" pageStyle="Account" >
<apex:includeScript id="a" value="https://www.google.com/jsapi" />
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(initCharts);
//load all the charts..
function initCharts() {
GoogleChartsController.loadChildCases('{!acc.Id}', function(resultCase, event){
var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
var data1 = new google.visualization.DataTable();
data1.addColumn('string', 'Cases');
data1.addColumn('number', 'Cases');
//add rows from the remoting results
for(var i =0; i < resultCase.length; i++){
var r = resultCase[i];
data1.addRow([r.Id, r.expr0]);
}
// all done, lets draw the chart with some options to make it look nice.
visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
}, {escape:true});
}
</script>
<div id="caseChart" />
</apex:page>
I'm able to get the class to save. I had to modify the VF Page
FROM THIS
GoogleChartsController.loadChildCases('{!Acc.id}', function(resultCase, event){
TO THIS
GoogleChartsController.loadChildCases('{!Account.id}', function(resultCase, event){
and now it works. Your URL should point to something like this:
https://c.na9.visual.force.com/apex/VisualForcePageName?id=SomeAccountID