You need to sign in to do that
Don't have an account?
Merry S
Visualforce chart help
I have taken some code for a layered chart and adapting to my own. It is on a custom object called X3RE_Snapshot_Data__c. The controller seems to save fine, but the VF page gives me an error Unknown property 'threeREChartController.getData' Usually I can figure that out - but I am at a loss. I figure my controller is messed up somewhere. Below if the code for both.
public with sharing class threeREChartController{ public threeREChartController (){} public List<SnapshotData> getData() { AggregateResult[] result = [SELECT id,SUM(X3RE__c) daily3RE, AVG(X3RE__c) dailyavg3RE, CALENDAR_MONTH(CreatedDate) month, CALENDAR_YEAR(CreatedDate) year FROM X3RE_Snapshot_Data__c GROUP BY ID, CALENDAR_YEAR(CreatedDate),CALENDAR_MONTH(CreatedDate) HAVING CALENDAR_YEAR(CreatedDate) = 2013]; List<SnapshotData> threeREData = new List<SnapshotData>(); for (AggregateResult a : result) { Datetime d=Datetime.newInstance((Integer)a.get('year'),(Integer)a.get('month'), 1); SnapshotData snap = new SnapshotData(d.format('MMM'), (Double)a.get('dailyavg3RE'), (Double)a.get('daily3RE')); threeREData.add(snap); } return threeREData; } public class SnapshotData { public String month { get; set; } public Double dailyavg3RE { get; set; } public Double daily3RE { get; set; } public SnapshotData(String mon, Double davg, Double daily) { month = mon; dailyavg3RE = davg; daily3RE = daily; } } }
<apex:page controller="threeREChartController" showHeader="false" sidebar="false"> <apex:sectionHeader title="3RE"/> <apex:chart height="380" width="700" data="{!getData}"> <apex:legend position="right"/> <apex:axis type="Numeric" position="left" fields="dailyavg3RE" title="Average"/> <apex:axis type="Category" position="bottom" fields="month" title="Month of the Year"> <apex:chartLabel rotate="315"/> </apex:axis> <apex:barSeries title="3RE" orientation="vertical" axis="left" xField="daily" yField="daily3RE"> <apex:chartTips height="20" width="120"/> </apex:barSeries> <apex:axis type="Numeric" position="right" fields="daily3RE" title="3RE" grid="true"/> <apex:lineSeries title="3RE" axis="right" xField="month" yField="daily3RE" fill="true" markerType="cross" markerSize="4" markerFill="#FF0000"/> </apex:chart> </apex:page>
One other quick question - can you add filters to the vf charts?
<apex:chart height="380" width="700" data="{!threeREData}">
public with sharing class threeREChartController{
public List<SnapshotData> threeREData {get;set;}
public threeREChartController (){
threeREData = new List<SnapshotData>();
}
// your rest code
All Answers
<apex:chart height="380" width="700" data="{!threeREData}">
public with sharing class threeREChartController{
public List<SnapshotData> threeREData {get;set;}
public threeREChartController (){
threeREData = new List<SnapshotData>();
}
// your rest code
Thanks! Works great!