2019-07-09 14:22:19 +01:00
import { Component , OnInit , AfterViewInit , Input , Output , EventEmitter , ViewChild , TemplateRef } from '@angular/core' ;
import { ApiService } from '../providers/api-service' ;
2019-07-10 12:49:36 +01:00
import { ChartOptions , ChartType , ChartDataSets } from 'chart.js' ;
import { Color } from 'ng2-charts' ;
2019-07-10 13:04:07 +01:00
import { CurrencyPipe } from '@angular/common' ;
import { DataType } from '../shared/data-types.enum' ;
import * as moment from 'moment' ;
2019-07-10 12:49:36 +01:00
import { BubbleChartComponent } from '../panels/bubble-panel' ;
2019-07-09 14:22:19 +01:00
import { AgmCoreModule } from '@agm/core' ;
import { BsModalService , ModalDirective } from 'ngx-bootstrap/modal' ;
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service' ;
2019-07-10 12:22:26 +01:00
// interface RecurSupplierData {
// name : string;
// }
2019-07-09 14:22:19 +01:00
@Component ( {
templateUrl : 'more-graphs-and-tables.component.html' ,
} )
2019-07-11 15:18:33 +01:00
export class MoreStuffComponent implements OnInit {
// @Input() public recurList: Array<RecurSupplierData>;
2019-07-09 14:22:19 +01:00
@Output ( ) public onClick = new EventEmitter ( ) ;
@Input ( ) public categories : any ;
2019-07-10 13:04:07 +01:00
public recurClick ( event : any ) : void {
this . onClick . emit ( event ) ;
}
constructor (
private api : ApiService ,
private currencyPipe : CurrencyPipe ,
) { }
ngOnInit ( ) : void {
}
// main vars
public bootstrapColours : string [ ] = [ 'bg-primary' , 'bg-secondary' , 'bg-success' ,
'bg-danger' , 'bg-warning' , 'bg-info' ] ;
// REAL chart data
public chartType = 'bubble' ;
public chartLegend = true ;
2019-07-11 15:18:33 +01:00
public bubbleChartDataCategory : any [ ] = [
{
data : [
{ x : 10 , y : 10 , r : 10 } ,
{ x : 15 , y : 5 , r : 15 } ,
{ x : 26 , y : 12 , r : 23 } ,
{ x : 7 , y : 8 , r : 8 } ,
] ,
label : [ "Series A" ] ,
backgroundColor : 'green' ,
borderColor : 'blue' ,
hoverBackgroundColor : 'purple' ,
hoverBorderColor : 'red' ,
} ,
{
data : [
{ x : 10 , y : 2 , r : 10 } ,
{ x : 15 , y : 1 , r : 15 } ,
{ x : 26 , y : 7 , r : 23 } ,
{ x : 5 , y : 8 , r : 8 } ,
] ,
label : [ "Series B" ] ,
backgroundColor : 'green' ,
borderColor : 'blue' ,
hoverBackgroundColor : 'purple' ,
hoverBorderColor : 'red' ,
} ,
] ;
2019-07-10 13:04:07 +01:00
public bubbleChartLabelsCategory : string [ ] = [ ] ;
public bubbleChartOptionsCategory :any = {
2019-07-11 15:18:33 +01:00
responsive : true ,
scales : {
xAxes : [
{
ticks : {
min : 0 ,
}
}
] ,
yAxes : [
{
ticks : {
min : 0 ,
}
}
]
} ,
2019-07-10 13:04:07 +01:00
tooltips : {
callbacks : {
label : ( tooltip , data ) = > {
return this . tooltipLabelCallback ( tooltip , data ) ;
} ,
} ,
} ,
}
private setChartData ( dataCat : any ) {
// now we just need some data and it will display!
}
2019-07-11 15:18:33 +01:00
public chartClicked ( { event , active } : { event : MouseEvent , active : { } [ ] } ) : void {
console . log ( event , active ) ;
}
2019-07-10 13:04:07 +01:00
2019-07-11 15:18:33 +01:00
public chartHovered ( { event , active } : { event : MouseEvent , active : { } [ ] } ) : void {
console . log ( event , active ) ;
}
2019-07-10 13:04:07 +01:00
// functions
private tooltipLabelCallback ( tooltipItem : any , data : any ) {
var dataset = data . datasets [ tooltipItem . datasetIndex ] ;
var value = dataset . data [ tooltipItem . index ] ;
return this . currencyPipe . transform ( value , 'GBP' , 'symbol' , '1.2-2' ) ;
}
// SAMPLE chart data
2019-07-10 12:49:36 +01:00
2019-07-10 13:04:07 +01:00
public sampleBubbleChartColors : Color [ ] = [
2019-07-10 12:49:36 +01:00
{
backgroundColor : [
'red' ,
'green' ,
'blue' ,
'purple' ,
'yellow' ,
'brown' ,
'magenta' ,
'cyan' ,
'orange' ,
'pink'
]
}
] ;
2019-07-09 14:22:19 +01:00
}