function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JN22JN22 

Visualforce Charts

Hello,

 

I am trying to create a few charts in a VF pageusing the controller below.  However, I am getting an error:

 

Error: theController Compile Error: Constructor already defined: <Constructor>() at line 24 column 10

 

I assume this means my structure is incorrect, but I don't know what I need to do to fix it.  Can someone advise?  Thanks.

 

 

public class theController {

//Empl Top 10 by Revenue
public list<Scorecard__c> Dashboard1 { get; set; }

public theController() {
Dashboard1 = [SELECT id,Name,Client_Name__c,Type_of_Client__c,Projected_Annual_Revenue__c,Overall_Percent__c,Overall_Score__c,Overall_Status_Icon__c,Renewal_Date__c
FROM Scorecard__c
WHERE Type_of_Client__c <> 'HP'
ORDER BY Projected_Annual_Revenue__c DESC limit 10];
}

public AggregateResult[] getChartData() {

return [SELECT Overall_Status__c Status, SUM(Projected_Annual_Revenue__c) Revenue
FROM Scorecard__c
GROUP BY Overall_Status__c];
}

 

//HP Top 10 by Revenue
public list<Scorecard__c> Dashboard2 { get; set; }

public theController() {
Dashboard2 = [SELECT id,Name,Client_Name__c,Type_of_Client__c,Projected_Annual_Revenue__c,Overall_Percent__c,Overall_Score__c,Overall_Status_Icon__c,Renewal_Date__c
FROM Scorecard__c
WHERE Type_of_Client__c = 'HP'
ORDER BY Projected_Annual_Revenue__c DESC limit 10];
}

public AggregateResult[] getChartData() {

return [SELECT Overall_Status__c Status, SUM(Projected_Annual_Revenue__c) Revenue
FROM Scorecard__c
GROUP BY Overall_Status__c];
}

}

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

you have defined 2 constructors in your class... "public theController()". You can have only one constructor per class. So move your logic to just one constructor

JN22JN22

Since I have different conditions for each dataset, how would you suggest I combine them under the single constructor?  Thanks.

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Even if you have different conditions it doesn't matter... put Dashboard1 and Dashbord2 queries in one constructor.

public class theController {

//Empl Top 10 by Revenue
public list<Scorecard__c> Dashboard1 { get; set; }

//HP Top 10 by Revenue
public list<Scorecard__c> Dashboard2 { get; set; }

public theController() {
Dashboard1 = [SELECT id,Name,Client_Name__c,Type_of_Client__c,Projected_Annual_Revenue__c,Overall_Percent__c,Overall_Score__c,Overall_Status_Icon__c,Renewal_Date__c
FROM Scorecard__c
WHERE Type_of_Client__c <> 'HP'
ORDER BY Projected_Annual_Revenue__c DESC limit 10];

Dashboard2 = [SELECT id,Name,Client_Name__c,Type_of_Client__c,Projected_Annual_Revenue__c,Overall_Percent__c,Overall_Score__c,Overall_Status_Icon__c,Renewal_Date__c
FROM Scorecard__c
WHERE Type_of_Client__c = 'HP'
ORDER BY Projected_Annual_Revenue__c DESC limit 10];

}

public AggregateResult[] getChartData() {
return [SELECT Overall_Status__c Status, SUM(Projected_Annual_Revenue__c) Revenue
FROM Scorecard__c
GROUP BY Overall_Status__c];
}
}

JN22JN22

Thanks, but how do I then get different aggregate results that I can use in a VF chart?  Sorry for all the questions, I'm new to this :-)  Thanks,

viv5586viv5586

Hi All

 

           I am trying to create a chart to know number of records to be inspected vs inspected and i am showing this on a visual force page and charting work completely fine the probelms is once i click on the x-axis or y-axis fields the colour is getting changed and the dashboard disappears.please findmy code below.

 

<apex:chart data="{!inspectionBarList}" width="600" height="250" animate="false" >
<apex:legend position="right"/>
<apex:axis type="Category" position="bottom" fields="jobName" title="Discipline" />
<apex:axis type="Numeric" position="left" fields="totalJobs" title="Inspections" minimum="0" maximum="10" />
<apex:barSeries orientation="vertical" axis="left" xField="jobName" yField="totalJobs" colorSet="0f0" tips="false" highlight="false" stAcked="true"/>
<apex:barSeries orientation="vertical" axis="bottom" xField="jobName" yField="completedJobs" tips="false" highlight="false" stacked="true"/>
</apex:chart>