You need to sign in to do that
Don't have an account?

motion chart for google chart help
I have created this controller with an aggregate query to use for the goolge motion chart. I keep getting the "error" when the chart tries to load that the first and second columns must be entity and time. I am not sure what to do from here. I have tried everything, except maybe putting the date in another format (javascript format), but I am not sure how to go about doing that, or even if that is the case.
This data comes from a customer object that is set up for a snapshot of data each week. Another issue I was getting was that there were too many rows, I have changed the VF page to
readonly="true"
, will that effect the chart?
Here is the controller - excuse the way it looks, I have been deleting and adding things all day and have not cleaned it up for this post.
public class Groupfor3RE{ // Data class public class Data { public String entity { get; set; } public Date time1 { get; set; } public Integer data2 { get; set; } public Integer data3 { get; set; } public Integer data4 { get; set; } public Integer data5 { get; set; } public String name6 { get; set; } public String name7 { get; set; } public String name8 { get; set; } public String name9 { get; set; } public String name10 { get; set; } public Data(String entity, Date time1, Integer data2, Integer data3, Integer data4, Integer data5, String name6, String name7, String name8, String name9, String name10) { this.entity = entity; this.time1 = time1; this.data2 = data2; this.data3 = data3; this.data4 = data4; this.data5 = data5; this.name6 = name6; this.name7 = name7; this.name8 = name8; this.name9 = name9; this.name10 = name10; } } public List<Data> getChartData1(){ List<AggregateResult> arList = [SELECT Account_Management_Type__c Type, Date_Conversion__c Day, AVG(X3RE__c) cThreeRE , AVG(Referenceable_Recurring_Revenue_R_RR__c) cRRR, AVG(Total_RR_Converted_to_USD__c)cRR, MAX(FTE__c) cFTE, Territory_Vertical__c Vertical, Territory_from_account__c Territory, Target_Industry_from_account__c Target, Sales_Channel__c Channel, Tier__c Tier from X3RE_Snapshot_Data__c group by Account_Management_Type__c, Date_Conversion__c, Territory_Vertical__c, Territory_from_account__c , Target_Industry_from_account__c , Sales_Channel__c, Tier__c]; List<Data> dataList = new List<Data>(); for (AggregateResult ar : arList){ String Type = String.valueOf(ar.get('Type')); Date Day = Date.valueOf(ar.get('day')); Integer cThree_RE = Integer.valueOf(ar.get('cThreeRE')); Integer cRRR = Integer.valueOf(ar.get('cRRR')); Integer cRR = Integer.valueOf(ar.get('cRR')); Integer cFTE = Integer.valueOf(ar.get('cFTE')); String Vertical = String.valueOf(ar.get('Vertical')); String Territory = String.valueOf(ar.get('Territory')); String Target = String.valueOf(ar.get('Target')); String Channel = String.valueOf(ar.get('Channel')); String Tier = String.valueOf(ar.get('Tier')); dataList.add(new Data( Type, day, cThree_RE, cRRR, cRR, cFTE, Vertical, Territory, Target, Channel, Tier)); } return dataList; } }
And the page:
<apex:page controller="Groupfor3RE" sidebar="false" showheader="false" readonly="true"> <title>Google Visualization API Sample</title> <script type="text/javascript" src="//www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['motionchart']}); function drawVisualization() { var data = new google.visualization.arrayToDataTable([ ['Type', 'Date', '3RE','RRR','RR','FTE','Vertical','Territory','Industry','Channel','Tier'], <apex:repeat value="{!ChartData1}" var="c"> ['{!c.entity}','{!c.time1}','{!c.data2}','{!c.data3}','{!c.data4}','{!c.data5}','{!c.name6}','{!c.name7}','{!c.name8}','{!c.name9}','{!c.name10}'], </apex:repeat> ]); var motionchart = new google.visualization.MotionChart( document.getElementById('chart_div')); motionchart.draw(data, {'width': 800, 'height': 400}); } google.setOnLoadCallback(drawVisualization); </script> <body style="font-family: Arial;border: 0 none;"> <div id="chart_div" ></div> </body> </apex:page>
If you can just point me the right direction, that would be awesome.