SHARE
TWEET

Untitled

a guest Jun 19th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div style="height: 100%; width: 100%; float:left;" *ngIf="AllocationDetails && AllocationDetails.ChartData"
  2.   class="col-md-7">
  3.   <app-pie-chart [series]="allocation_series"></app-pie-chart>
  4. </div>
  5.      
  6. public getAllocationsDetails(evalDate: string) {
  7.         if (this.ManagerStrategyId != null) {
  8.             this.initGrid();
  9.  
  10.              //  this.spinner.show();
  11.             this.allocationsService.getAllocationsDetails(this.ManagerStrategyId, evalDate)
  12.                 .subscribe(data => {
  13.                     this.AllocationDetails = data;
  14.                     this.GridOptions.rowData = this.AllocationDetails;
  15.                     this.allocation_series = this.AllocationDetails.ChartData;
  16.  
  17.  
  18.                   if(!this.AllocationDetails.ManagerAllocations || !this.AllocationDetails.ManagerAllocations.length) {
  19.  
  20.                     this.GridOptions.suppressNoRowsOverlay = true;
  21.                     //this.GridOptions.api.showNoRowsOverlay();
  22.                   } else {
  23.                     this.FirmName = this.AllocationDetails.ManagerAllocations[0].FirmName;
  24.                   }
  25.  
  26.                     this.ColumnDefs = this.getColumns();
  27.                   //  this.spinner.hide();
  28.  
  29.                     setTimeout(() => {  
  30.                         this.GridOptions.api.sizeColumnsToFit();
  31.                     }, 100, true);
  32.                 },
  33.                     err => {
  34.                         this.Error = 'An error has occurred. Please contact BSG';
  35.                     },
  36.                     () => {
  37.                     });
  38.         }
  39.     }
  40.      
  41. import { Component, NgZone, Input } from '@angular/core';
  42. import * as am4core from '@amcharts/amcharts4/core';
  43. import * as am4charts from '@amcharts/amcharts4/charts';
  44. import am4themes_animated from '@amcharts/amcharts4/themes/animated';
  45.  
  46. import { OnInit, AfterViewInit, OnDestroy } from '@angular/core';
  47. am4core.useTheme(am4themes_animated);
  48.  
  49.  
  50.  
  51.  
  52. @Component({
  53.   template: ` <div id="chartdiv"  [style.width.%]="100"  [style.height.px]="500" > "hideCredits" : true</div>`,
  54.   selector: 'app-pie-chart'
  55. })
  56. export class PieChartComponent implements AfterViewInit, OnDestroy {
  57.   private chart: am4charts.PieChart;
  58.  // @Input() series: any;
  59.  
  60.   _series: any;
  61.   get series(): any {
  62.     return this._series;
  63. }
  64.  
  65. @Input('series')
  66. set series(value: any) {
  67.     this._series = value;
  68.  
  69. }
  70.  
  71.   constructor(private zone: NgZone) { }
  72.  
  73.   ngAfterViewInit() {
  74.     this.zone.runOutsideAngular(() => {
  75.       const chart = am4core.create('chartdiv', am4charts.PieChart);
  76.       chart.responsive.enabled = true;
  77.  
  78.  
  79.     if (this.series) {
  80.         chart.data = this.series;
  81.         const pieSeries = chart.series.push(new am4charts.PieSeries());
  82.         pieSeries.dataFields.value = 'Percent';
  83.         pieSeries.dataFields.category = 'ProductName';
  84.  
  85.  
  86.         pieSeries.colors.list = [
  87.           am4core.color('#717171'),
  88.           am4core.color('#62B1D0'),
  89.           am4core.color('#3AA6D0'),
  90.           am4core.color('#024C68'),
  91.           am4core.color('#226078'),
  92.           am4core.color('#717171'),
  93.           am4core.color('#62B1D0'),
  94.           am4core.color('#3AA6D0'),
  95.           am4core.color('#024C68'),
  96.           am4core.color('#226078'),
  97.           am4core.color('#717171'),
  98.           am4core.color('#62B1D0'),
  99.           am4core.color('#3AA6D0'),
  100.           am4core.color('#024C68'),
  101.           am4core.color('#226078'),
  102.  
  103.      ];
  104.  
  105.  
  106.  
  107.        this.chart = chart;
  108.       }
  109.     });
  110.   }
  111.  
  112.   ngOnDestroy() {
  113.     this.zone.runOutsideAngular(() => {
  114.       if (this.chart) {
  115.         this.chart.dispose();
  116.       }
  117.     });
  118.   }
  119. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top