Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. <aura:attribute name="chartType" type="string"/>
  2. <aura:attribute name="chartTitle" type="string" default="Opportunity by forecastcategoryname"/>
  3. <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by forecastcategoryname"/>
  4. <aura:attribute name="xAxisCategories" type="string[]" default="['PipeLine','Closed','Total','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
  5. <aura:attribute name="yAxisParameter" type="string" default="No. of PipeLine and Closed "/>
  6. <aura:attribute name="data" type="string" />
  7.  
  8. <div class="slds-card">
  9. <br/>
  10. <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
  11. Graphical Representaion of Opportunity-> Pipeline and closed</h1></b></center>
  12. <br/>
  13. <div class="slds-grid slds-wrap slds-grid--pull-padded">
  14.  
  15.  
  16.  
  17. <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
  18. <div aura:id="Bar" style="height: 300px "></div>
  19.  
  20.  
  21. </div>
  22. </div>
  23. <div class ="test" style=" padding-left: 250px;color: green;">
  24. <h4> GrandTotal:Pipeline and closed&nbsp;&nbsp;<ui:outputNumber value="{!v.TotalAmount}" /> </h4>
  25.  
  26. </div>
  27. </div>
  28.  
  29. grandTotal1: function(component, event, helper)
  30. {
  31. var action = component.get("c.getTotal");
  32. action.setCallback(this, function(response) {
  33. var state = response.getState();
  34.  
  35. console.log('===='+state);
  36. component.set("v.TotalAmount",response.getReturnValue());
  37.  
  38. });
  39. $A.enqueueAction(action);
  40. }
  41.  
  42.  
  43. ,
  44.  
  45. var dataObj = JSON.parse(jsonData);
  46.  
  47. new Highcharts.Chart({
  48. chart: {
  49. theme: "fusion",
  50. plotBackgroundColor: '#FCFFC5',
  51. plotBorderWidth: 2 ,
  52. plotShadow: false,
  53. renderTo: component.find("Bar").getElement(),
  54. type: 'bar',
  55.  
  56. width :600
  57. },
  58. title: {
  59. text: component.get("v.chartTitle")+' (Line Chart)'
  60. },
  61. subtitle: {
  62. text: component.get("v.chartSubTitle")
  63. },
  64. xAxis: {
  65. lineColor: '#FF0000',
  66. categories: component.get("v.xAxisCategories"),
  67. style: {
  68. font: 'normal 9px Verdana, sans-serif, arial'
  69. },
  70. crosshair: true
  71. },
  72. yAxis: {
  73. min:0,
  74. borderRadius: 4,
  75. lineColor: '#FF0000',
  76. lineWidth: 1,
  77.  
  78. title:
  79. {
  80. text: component.get("v.yAxisParameter")
  81. }
  82. },
  83. tooltip: {
  84. // pointFormat: '{series.name}: <b>{point.y}</b>'
  85.  
  86. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  87. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  88. '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
  89. footerFormat: '</table>',
  90. shared: true,
  91. useHTML: true
  92. },
  93.  
  94. plotOptions: {
  95. // pointPadding: 0.2,
  96. // borderWidth: 0,
  97.  
  98. row: {
  99. colorByPoint: true
  100.  
  101. },
  102. line: {
  103.  
  104. dataLabels: {
  105. style: {
  106. color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'Black'
  107. },
  108. enabled: true,
  109. colors: '#000000',
  110. align: 'right',
  111. x: -10,
  112. y: 20,
  113. formatter: function () {
  114. return this.y;
  115. },
  116. style: {
  117. font: 'normal 13px Verdana, sans-serif'
  118. }
  119. },
  120. enableMouseTracking: false
  121. }
  122. },
  123. series: [{
  124. name:'Pipeline and Closed',
  125. data:dataObj,
  126.  
  127. //data: [49.9, 71.5, 106.4, ]
  128.  
  129. }]
  130.  
  131. });
  132.  
  133. }
  134.  
  135. List<opportunity> lstopp = [select name, accountid, amount, closedate, forecastcategoryname, stagename from opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
  136.  
  137. Map<String,Integer> mapLeadSource = new Map<String,Integer>();
  138. Map<Decimal,Decimal>newamount = new Map<Decimal,Decimal>();
  139. system.debug('newamount:'+newamount);
  140.  
  141.  
  142. for(opportunity l : lstopp)
  143. {
  144. if(mapLeadSource.containsKey(l.forecastcategoryname))
  145. {
  146. mapLeadSource.put(l.forecastcategoryname, mapLeadSource.get(l.forecastcategoryname)+1) ;
  147.  
  148. newamount.put(l.Amount,newamount.get(l.Amount));
  149. }else{
  150. mapLeadSource.put(l.forecastcategoryname, 0) ;
  151.  
  152. }
  153. }
  154. system.debug('map values--'+mapLeadSource);
  155. list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
  156.  
  157. for(String key : mapLeadSource.keySet())
  158. {
  159. RadarDataWrapper rdw = new RadarDataWrapper();
  160. rdw.name=key;
  161. rdw.y= decimal.valueof(mapLeadSource.get(key));
  162. AggregateResult[] groupedResults = [SELECT SUM(Amount)renewals FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
  163. rdw.Total = (Decimal)groupedResults[0].get('renewals');
  164.  
  165.  
  166. // rdw.totalAmount = [select count() from Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
  167.  
  168. radarData.add(rdw);
  169. }
  170. system.debug('rdw---'+radarData);
  171. return System.json.serialize(radarData);
  172. //return null;
  173. }
  174.  
  175. @AuraEnabled
  176. public static Decimal getTotal(){
  177. /* list<opportunity> totalopp = [select Amount,forecastcategoryname FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
  178. double grandtotal = 0;
  179. for(opportunity opp : totalopp){
  180. if(opp.Amount!=null)
  181. grandtotal =grandtotal + opp.amount;
  182. system.debug('grandtotal:'+grandtotal);
  183. }
  184. return grandtotal;*/
  185. list<RadarDataWrapper> radarData2 = new list<RadarDataWrapper>();
  186.  
  187. AggregateResult[] groupedResults = [SELECT SUM(Amount)renewals FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
  188. Decimal sum = (Decimal)groupedResults[0].get('renewals');
  189. return sum;
  190.  
  191.  
  192. }
  193.  
  194.  
  195.  
  196. // Wrapper class to serialize as JSON as return Value//
  197.  
  198. class RadarDataWrapper
  199. {
  200. @AuraEnabled
  201. public String name;
  202. @AuraEnabled
  203. public decimal y;
  204. @AuraEnabled
  205. public decimal Total;
  206.  
  207.  
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement