You need to sign in to do that
Don't have an account?
mauricio.ramos@corpital
Issue with google chart in VF page
HEllo,
I havea visualforce page that I am trying to create a bar chart. I am using js remoting to call a method in the controller to get the result data BUT it is giving me a Null reference error when trying to access the account variable in the controller to use as a query parameter in the @RemoteACtion method.
CVF 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(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>
And this is the controller:
global class GoogleChartsController { global static Account acc; public GoogleChartsController(ApexPages.StandardController controller) { acc = (Account)controller.getRecord(); } @RemoteAction global static AggregateResult[] loadChildCases() { AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case WHERE AccountId = :acc.id Group By ParentId ]; return caseLst; } }
Please let me know where I am making an error in this.
Hi,
I think that can
VF Page
Controller
All Answers
Hi,
I think that can
VF Page
Controller
YESSS that did the job, I was actually trying to get the class variable value from inside the remote method when I could just have passed it as a parameter.
THANK YOU!! Accepting as solution.