I have one requirement. I have to create dynamic report on task object, dynamic in the sense i have to get users name in a drop down list and if i select any user and click on "get report" I should get his activities along with the chart.
Above part i have achieved, But the next part is once i get a chart x-axis is Status like "open, inprogress, Not Started" like this Now what I want is when i click on "open" I have to display all open activites under the chart, similarly for all status I have no idea how I gonna achieve please help me out Here is my code and screen shot of what i have done so far
VF Page
<apex:page standardController="Task" extensions="Task_Dynamic_Report_Controller" sidebar="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1" >
<apex:pageBlockSectionItem >
<apex:outputLabel >User</apex:outputLabel>
<apex:selectList multiselect="false" size="1" value="{!SelectedUser}">
<apex:selectOptions value="{!Names}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton value="Get Report" action="{!getTeamMembers}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Task By Status" >
<apex:pageBlockTable value="{!Summaries}" var="summary" style="width:50%" id="Chart">
<apex:column headerValue="Status" value="{!summary.Status}"/>
<apex:column headerValue="Count" value="{!summary.Quantity}"/>
<!-- <apex:column headerValue="Total" value="{!summary.total }"/> -->
</apex:pageBlockTable>
<apex:pageBlock title="Chart">
<apex:chart height="250" width="600" data="{!Summaries}">
<apex:axis type="Numeric" position="left" fields="Quantity" title="Count" minimum="0" margin="1" maximum="9"/>
<apex:axis type="Category" position="bottom" fields="Status" title="Stage" id="stg"/>
<apex:barSeries orientation="vertical" axis="left" xField="Status" yField="Quantity" colorsProgressWithinSeries="true" />
</apex:chart>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
![public with sharing class Task_Dynamic_Report_Controller {
public string SelectedUs = 'Sharath Chikkanna';
public string SelectedUser {get;set;}
public Summary\[\] Summaries { get; set; }
public string qry;
AggregateResult\[\] ag;
public Task_Dynamic_Report_Controller(ApexPages.StandardController controller) {
/* qry = 'SELECT Status, Count(id) Quantity FROM Task';
if(SelectedUser != ''){
qry += ' WHERE Owner.name =: SelectedUser';
}
qry += ' GROUP BY Status';
AggregateResult\[\] results = database.query(qry);
Summaries = new List<Summary>();
for (AggregateResult ar : results) {
Summaries.add(new Summary(ar));
} */
}
public pageReference getTeamMembers()
{
User();
return null;
}
public AggregateResult\[\] User(){
qry = 'SELECT Status, Count(id) Quantity FROM Task';
if(SelectedUser == 'Charu' || SelectedUser == 'Sharath Chikkanna'){
qry += ' WHERE Owner.name =: SelectedUser';
}
qry += ' GROUP BY Status';
AggregateResult\[\] results = database.query(qry);
Summaries = new List<Summary>();
for (AggregateResult ar : results) {
Summaries.add(new Summary(ar));
}
return results;
}
public class Summary {
public Integer Quantity { get; private set; }
public String Status { get; private set; }
// public decimal total {get;set;}
public Summary(AggregateResult ar) {
Quantity = (Integer) ar.get('Quantity');
Status = (String) ar.get('Status');
// Total = (decimal) ar.get('Total');
}
}
List<selectOption> options = new List<selectOption>();
public List<selectOption> getNames(){
options.add(new SelectOption('None', '--None--'));
for(User u : \[SELECT name FROM User \]){
options.add(new selectOption(u.name,u.name));
}
return options;
}
}][2]