Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <aura:attribute name="chartType" type="string"/>
- <aura:attribute name="chartTitle" type="string" default="Opportunity by forecastcategoryname"/>
- <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by forecastcategoryname"/>
- <aura:attribute name="xAxisCategories" type="string[]" default="['PipeLine','Closed','Total','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
- <aura:attribute name="yAxisParameter" type="string" default="No. of PipeLine and Closed "/>
- <aura:attribute name="data" type="string" />
- <div class="slds-card">
- <br/>
- <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
- Graphical Representaion of Opportunity-> Pipeline and closed</h1></b></center>
- <br/>
- <div class="slds-grid slds-wrap slds-grid--pull-padded">
- <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
- <div aura:id="Bar" style="height: 300px "></div>
- </div>
- </div>
- <div class ="test" style=" padding-left: 250px;color: green;">
- <h4> GrandTotal:Pipeline and closed <ui:outputNumber value="{!v.TotalAmount}" /> </h4>
- </div>
- </div>
- grandTotal1: function(component, event, helper)
- {
- var action = component.get("c.getTotal");
- action.setCallback(this, function(response) {
- var state = response.getState();
- console.log('===='+state);
- component.set("v.TotalAmount",response.getReturnValue());
- });
- $A.enqueueAction(action);
- }
- ,
- var dataObj = JSON.parse(jsonData);
- new Highcharts.Chart({
- chart: {
- theme: "fusion",
- plotBackgroundColor: '#FCFFC5',
- plotBorderWidth: 2 ,
- plotShadow: false,
- renderTo: component.find("Bar").getElement(),
- type: 'bar',
- width :600
- },
- title: {
- text: component.get("v.chartTitle")+' (Line Chart)'
- },
- subtitle: {
- text: component.get("v.chartSubTitle")
- },
- xAxis: {
- lineColor: '#FF0000',
- categories: component.get("v.xAxisCategories"),
- style: {
- font: 'normal 9px Verdana, sans-serif, arial'
- },
- crosshair: true
- },
- yAxis: {
- min:0,
- borderRadius: 4,
- lineColor: '#FF0000',
- lineWidth: 1,
- title:
- {
- text: component.get("v.yAxisParameter")
- }
- },
- tooltip: {
- // pointFormat: '{series.name}: <b>{point.y}</b>'
- headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
- pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
- '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
- footerFormat: '</table>',
- shared: true,
- useHTML: true
- },
- plotOptions: {
- // pointPadding: 0.2,
- // borderWidth: 0,
- row: {
- colorByPoint: true
- },
- line: {
- dataLabels: {
- style: {
- color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'Black'
- },
- enabled: true,
- colors: '#000000',
- align: 'right',
- x: -10,
- y: 20,
- formatter: function () {
- return this.y;
- },
- style: {
- font: 'normal 13px Verdana, sans-serif'
- }
- },
- enableMouseTracking: false
- }
- },
- series: [{
- name:'Pipeline and Closed',
- data:dataObj,
- //data: [49.9, 71.5, 106.4, ]
- }]
- });
- }
- List<opportunity> lstopp = [select name, accountid, amount, closedate, forecastcategoryname, stagename from opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
- Map<String,Integer> mapLeadSource = new Map<String,Integer>();
- Map<Decimal,Decimal>newamount = new Map<Decimal,Decimal>();
- system.debug('newamount:'+newamount);
- for(opportunity l : lstopp)
- {
- if(mapLeadSource.containsKey(l.forecastcategoryname))
- {
- mapLeadSource.put(l.forecastcategoryname, mapLeadSource.get(l.forecastcategoryname)+1) ;
- newamount.put(l.Amount,newamount.get(l.Amount));
- }else{
- mapLeadSource.put(l.forecastcategoryname, 0) ;
- }
- }
- system.debug('map values--'+mapLeadSource);
- list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
- for(String key : mapLeadSource.keySet())
- {
- RadarDataWrapper rdw = new RadarDataWrapper();
- rdw.name=key;
- rdw.y= decimal.valueof(mapLeadSource.get(key));
- AggregateResult[] groupedResults = [SELECT SUM(Amount)renewals FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
- rdw.Total = (Decimal)groupedResults[0].get('renewals');
- // rdw.totalAmount = [select count() from Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
- radarData.add(rdw);
- }
- system.debug('rdw---'+radarData);
- return System.json.serialize(radarData);
- //return null;
- }
- @AuraEnabled
- public static Decimal getTotal(){
- /* list<opportunity> totalopp = [select Amount,forecastcategoryname FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
- double grandtotal = 0;
- for(opportunity opp : totalopp){
- if(opp.Amount!=null)
- grandtotal =grandtotal + opp.amount;
- system.debug('grandtotal:'+grandtotal);
- }
- return grandtotal;*/
- list<RadarDataWrapper> radarData2 = new list<RadarDataWrapper>();
- AggregateResult[] groupedResults = [SELECT SUM(Amount)renewals FROM Opportunity where accountid != null AND forecastcategoryname IN ('closed', 'Pipeline')];
- Decimal sum = (Decimal)groupedResults[0].get('renewals');
- return sum;
- }
- // Wrapper class to serialize as JSON as return Value//
- class RadarDataWrapper
- {
- @AuraEnabled
- public String name;
- @AuraEnabled
- public decimal y;
- @AuraEnabled
- public decimal Total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement