import { Component , OnDestroy } from '@angular/core' ; import { NbThemeService } from '@nebular/theme' ; @ Component ( { selector : 'ngx-chartjs-pie' , template : `
    <chart type="pie" [data]="data" [options]="options"></chart>
  ` , } ) export class ChartjsPieComponent implements OnDestroy { data : any ; options : any ; themeSubscription : any ; constructor ( private theme ) { this . themeSubscription = this . theme . getJsTheme ( ) . subscribe ( config => { const colors = config . variables ; const chartjs = config . variables . chartjs ; this . data = { labels : [ 'Download Sales' , 'In-Store Sales' , 'Mail Sales' ] , datasets : [ { data : [ 300 , 500 , 100 ] , backgroundColor : [ colors . primaryLight , colors . infoLight , colors . successLight ] , } ] , } ; this . options = { maintainAspectRatio : false , responsive : true , scales : { xAxes : [ { display : false , } , ] , yAxes : [ { display : false , } , ] , } , legend : { labels : { fontColor : chartjs . textColor , } , } , } ; } ) ; } ngOnDestroy ( ) { this . themeSubscription . unsubscribe ( ) ; } }