+ Start a Discussion
Marry SteinMarry Stein 

Radar Chart for Aggregate Results

Hey Guys, 

I have created a radar chart like
http://www.infallibletechie.com/2013/12/radar-chart-using-visualforce-and-apex.html

Now, i am looking for a way create one for my needs. I want to create a radar chart, which shows me the number of contacts related to the dimension (DISC__c)

1 Dimension = Steadiness
2 Dimesnion = Dominance
3 Dimension = Influence
4 Dimenson  = conscientious

So queried the contact object to get a result like this:

DISC__C | Number or Records
Steadiness | 20
Dominance | 30
Influence | 40
conscientious | 30

So i have changed the Conroller for my needs. But, if i use the field DISC__C in my Group By statement it 
does not recognize the variable.
public class RadarChart{   

    public List<RadarData> data {get;set;}
    
    public RadarChart() {        
    data = new List<RadarData>();
        List<AggregateResult> conList = new List<AggregateResult>();
        conList = [SELECT DISC__c, Count(id)numb  FROM Contact 
                  WHERE DISC__c != Null
                  GROUP BY DISC__c];
        		
        for(AggregateResult con : conList) {
            data.add(new RadarData(con.DISC__c, con.id )); // Problem with variable DISC__c
        }
    }
    public class RadarData {
        String discName {get;set;}
        Decimal numb {get;set;}
       
        
        public RadarData(String discName, Decimal numb) {
            this.discName = discName;
            this.numb = numb;
            
        }
    }
}

Here is the page. NumberOfContacts is just a placeholder.
<apex:page sidebar="false" Controller="RadarChart" showHeader="true" id="pg">
<apex:chart height="750" width="800" legend="true" data="{!data}">
    <apex:legend position="left"/>
    <apex:axis type="Radial" position="radial">
        <apex:chartLabel />
    </apex:axis>
    <apex:radarSeries xField="discName" yField="NumberOfContacts" tips="true" opacity="0.4"/>
</apex:chart>
</apex:page>

Thanks for your help guys. I am thankful for any help in this case. It would be amazing to get this radar chart work !

Cheers,

Marry
 
Best Answer chosen by Marry Stein
Steven NsubugaSteven Nsubuga
Use this 
public class RadarChart{   

    public List<RadarData> data {get;set;}
    
    public RadarChart() {        
    data = new List<RadarData>();
        List<AggregateResult> conList = new List<AggregateResult>();
        conList = [SELECT DISC__c, Count(id)numb  FROM Contact 
                  WHERE DISC__c != Null
                  GROUP BY DISC__c];
        		
        for(AggregateResult con : conList) {
            data.add(new RadarData(String.valueOf(con.get('DISC__c')), Integer.valueOf(con.get('expr0')))); // Problem with variable DISC__c
        }
    }
    public class RadarData {
        String discName {get;set;}
        Decimal numb {get;set;}
       
        
        public RadarData(String discName, Decimal numb) {
            this.discName = discName;
            this.numb = numb;
            
        }
    }
}

 

All Answers

Steven NsubugaSteven Nsubuga
Use this 
public class RadarChart{   

    public List<RadarData> data {get;set;}
    
    public RadarChart() {        
    data = new List<RadarData>();
        List<AggregateResult> conList = new List<AggregateResult>();
        conList = [SELECT DISC__c, Count(id)numb  FROM Contact 
                  WHERE DISC__c != Null
                  GROUP BY DISC__c];
        		
        for(AggregateResult con : conList) {
            data.add(new RadarData(String.valueOf(con.get('DISC__c')), Integer.valueOf(con.get('expr0')))); // Problem with variable DISC__c
        }
    }
    public class RadarData {
        String discName {get;set;}
        Decimal numb {get;set;}
       
        
        public RadarData(String discName, Decimal numb) {
            this.discName = discName;
            this.numb = numb;
            
        }
    }
}

 
This was selected as the best answer
Marry SteinMarry Stein
@Steven Nsubuga 
works like a charm ! your the man Steven ! Thanks a lot. 

Cheers Marry
Steven NsubugaSteven Nsubuga
My pleasure @Marry Stein !!