Page code:
============
<apex:page controller="googlecha" showHeader="false" sidebar="false">
<script>
//alert('{!imgurl}');
</script>
<apex:image url="{!imgUrl}"/>
</apex:page>
Controller Code
==============
public class googlecha{
public googlecha(){
List<AggregateResult> aggres=[Select account.name,count(id) from Case WHERE CreatedDate = THIS_Month and status != 'Closed' and account.name!=null group by account.name];
System.debug(aggres);
imgurl='http://chart.apis.google.com/chart?chxt=x,y&chbh=a&chs=500x300&chdlp=b|l&cht=bvg&chxs=0,68228B,12|1,68228B&chdls=330033,12&chts=FF0000,20,t&chtt=Account+Status+Report';
//&chco=FFC6A5|FFFF42|DEF3BD|00A5C6|DEBDDE&chd=t:10,50,60,80,40,60,30';41A317,FDD017,F88017|&chxp=1,0,5,10|chm=t25.00,0000FF,0,0,10|t250.00,0000FF,0,1,10|
string chco='';
string chd='';
String chxr='';
String chxl='0:|';
String chm='';
String chdl='';
String chxs='';
Integer s;
for (integer i=0; i<aggres.size();i++){
s = Integer.valueOf(aggres[i].get('expr0'));
System.debug('----------->'+aggres);
if(i<aggres.size()-1){
if( s > 5){
chco+= 'ED1B0E|';
chd += aggres[i].get('expr0')+',';
chxl += string.valueof(i+1)+'|';
// chxl += aggres[i].get('Name')+'|';
chm +='t'+s+',0000FF,0,'+i+',10|';
//chdl+=aggres[i].get('Name')+'|';
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name')+'|';
}
else if(s == 5){
chco += 'FDD017|';
chd += aggres[i].get('expr0')+',';
chxl +=string.valueof(i+1)+'|';
//chxl += aggres[i].get('Name')+'|';
chm +='t'+s+',0000FF,0,'+i+',10|';
//chdl+=aggres[i].get('Name')+'|';
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name')+'|';
}
else{
chco+= '41A317|';
chd += aggres[i].get('expr0')+',';
chxl +=string.valueof(i+1)+'|';
//chxl += aggres[i].get('Name')+'|';
chm +='t'+s+',0000FF,0,'+i+',10|';
//chdl+=aggres[i].get('Name')+'|';
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name')+'|';
}
}
else{
System.debug('Else Part');
if( s > 5){
chco+= 'ED1B0E';
chd += aggres[i].get('expr0');
chxl +=string.valueof(i+1)+'|';
//chxl += aggres[i].get('Name');
chm +='t'+s+',0000FF,0,'+i+',10';
//chdl+=aggres[i].get('Name');
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name');
}
else if(s == 5){
chco += 'FDD017';
chd += aggres[i].get('expr0');
chxl +=string.valueof(i+1)+'|';
//chxl += aggres[i].get('Name');
chm +='t'+s+',0000FF,0,'+i+',10';
//chdl+=aggres[i].get('Name');
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name');
}
else{
chco+= '41A317';
chd+= aggres[i].get('expr0');
chxl +=string.valueof(i+1)+'|';
//chxl+= aggres[i].get('Name');
chm +='t'+s+',0000FF,0,'+i+',10';
chdl+=string.valueof(i+1)+'='+aggres[i].get('Name');
//chdl+=aggres[i].get('Name');
}
}
}
imgUrl+='&chco='+chco+'&chd=t:'+chd+'&chxl='+chxl+'&chm='+chm+'&chdl='+chdl;
//http://chart.apis.google.com/chart?chxt=x,y&chbh=a&chs=500x350&cht=bvg&chtt=Vertical+bar+chart&chco=41A317|FDD017&chd=t:1,5&chxl=0:|Account1|TestSkyRiver|
}
public string imgurl{get; set;}
}
=============================OutPut========================
No comments:
Post a Comment