3

enter image description hereI 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 >
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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]

1 Answer 1

1

It seems that neither <apx:chart> nor <apex:axis> and <apex:barSeries> has build in onclick support you could use to define a handler.

But I found an approach, which looks very promising here:

https://gist.github.com/sohalloran/4694551

<apex:chart height="300" width="300" data="{!data}">
    <apex:axis type="Category" position="bottom" fields="ctype">
    <   apex:chartLabel rotate="270"/>
    </apex:axis>
    <apex:axis type="Numeric" position="left" fields="cval"/>
    <apex:barSeries axis="left" orientation="vertical" xField="ctype" yField="cval">
        <apex:chartTips rendererFn="renderer"/>
    </apex:barSeries>
</apex:chart>

<script type="text/javascript">
    function renderer(klass, item) {
        var type = item.storeItem.get('ctype');
        var val = item.storeItem.get('cval');
        var e = window.event;
        var t = e.target || e.srcElement;
        t.onclick=function(event){
            window.parent.location = "{!$Page.MyDrilldown}?type="+type;
        };
        this.setTitle(type + " : " + val);
    }
</script> 

Note that I have not tested this code myself yet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .