Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <div class="parent" >
  2. <img src="black.png" type="button" (click)="displayChild()"/>
  3. <my-child [displayDetail]="displayMe"></my-child>
  4. </div>
  5.  
  6. displayChild() {
  7. this.displayMe = !this.displayMe;
  8.  
  9. <div class="chart-pie">
  10. <chart [options]="options" (load)="saveInstance($event.context)"
  11. </chart>
  12. </div>
  13.  
  14. @Input() showMePartially: boolean;
  15. options: any;
  16. data: Object[];
  17. chart: any;
  18.  
  19. dataSubscription: Subscription;
  20.  
  21. constructor(private userService3: UserService3) {
  22.  
  23. this.options = {
  24. chart: { type: 'pie',
  25. series: [{
  26. name: 'Dispo',
  27. data: []
  28. }]
  29. };
  30.  
  31. saveInstance(chartInstance) {
  32. this.chart = chartInstance;
  33. console.log(chartInstance);
  34. }
  35.  
  36. public ngOnInit () {
  37. this.dataSubscription =
  38. this.userService3.getData().subscribe((data) => {
  39. this.options.series[0].data = data.data.operating_rate;
  40. // Code for the pie
  41.  
  42. let percentUp = data.data.operating_rate; // 88.14
  43. let percentDown = 100 - percentUp; // 11.86
  44. this.options.series[0].data = [
  45. {
  46. name: 'Up',
  47. y: percentUp,
  48. color: '#648e59'
  49. },
  50. {
  51. name: 'Down',
  52. y: percentDown,
  53. color: 'white'
  54. }
  55. ];
  56. console.log(data);
  57. });
  58. }
  59. public ngOnDestroy() {
  60. if (this.dataSubscription) {
  61. this.dataSubscription.unsubscribe();
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement