Guest User

Untitled

a guest
Jan 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Lightning Component:
  2. <aura:component controller="Test">
  3. <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4. <div class ="card">
  5. <div class="card-heading context-dashboard">
  6. Report View
  7. </div>
  8. <div class="card-detail">
  9. <div id="chart"></div>
  10. </div>
  11. </div>
  12.  
  13. ({
  14. doInit : function(component, event, helper) {
  15. var action = component.get("c.runReport");
  16.  
  17. action.setCallback(this,function(response){
  18. var state = response.getState();
  19. if(state === "SUCCESS"){
  20. var reportData = JSON.parse(response.getReturnValue());
  21. console.log ("Return value" + JSON.stringify(response.getReturnValue()));
  22. var returnData = [];
  23. for(var i=0, j= reportData.groupingsDown.groupings.lenght; i<j; i++){
  24. var label = reportData.groupingsDown.groupings[i].label;
  25. var Key = reportData.groupingsDown.groupings[i].Key;
  26. var value= reportData.factMap[Key + '!T'].aggregates[0].value;
  27. returnData.push([label,value]);
  28. }
  29. var chart = c3.generate ({
  30. bindto :'#chart',
  31. data:{
  32. coloumns: returnData,
  33. type: 'pie'
  34. }
  35. });
  36. }
  37. });
  38. $A.enqueueAction(action);
  39. }
  40.  
  41. @AuraEnabled
  42. public static String runReport(){
  43. Report rep = [SELECT Id, DeveloperName FROM Report where DeveloperName = 'Case' LIMIT 1];
  44. Reports.ReportResults results = Reports.ReportManager.runReport(rep.Id,true);
  45. return JSON.serialize(results);
  46. }
Add Comment
Please, Sign In to add comment