import { Component } from '@angular/core' ; import { ColorService , DashboardOptions } from '@ux-aspects/ux-aspects' ; import 'chance' ; import { BaseDocumentationSection } from '../../../../../components/base-documentation-section/base-documentation-section' ; import { DocumentationSectionComponent } from '../../../../../decorators/documentation-section-component' ; import { IPlayground } from '../../../../../interfaces/IPlayground' ; import { IPlaygroundProvider } from '../../../../../interfaces/IPlaygroundProvider' ; @ Component ( { selector : 'uxd-components-dashboard' , templateUrl : './dashboard.component.html' , styleUrls : [ './dashboard.component.less' ] } ) @ DocumentationSectionComponent ( 'ComponentsDashboardComponent' ) export class ComponentsDashboardComponent extends BaseDocumentationSection implements IPlaygroundProvider { lineChartData : Chart . ChartDataSets [ ] = [ { data : [ ] , borderWidth : 2 , fill : false } , { data : [ ] , borderWidth : 2 , fill : false } ] ; lineChartOptions : Chart . ChartOptions = { maintainAspectRatio : false , responsive : true , elements : { line : { tension : 0 } , point : { radius : 0 } } , scales : { xAxes : [ { gridLines : { color : 'transparent' } , ticks : { min : 0 , max : 49 , maxRotation : 0 } as Chart . LinearTickOptions } ] , yAxes : [ { gridLines : { color : '#ddd' } , ticks : { beginAtZero : true , stepSize : 100 } as Chart . LinearTickOptions , } ] } , } ; lineChartLabels : string [ ] = [ ] ; lineChartLegend : boolean = false ; lineChartColors = [ { borderColor : this . colorService . getColor ( 'vibrant1' ) . toHex ( ) , } , { borderColor : this . colorService . getColor ( 'vibrant2' ) . toHex ( ) , } ] ; options : DashboardOptions = { columns : 4 , padding : 10 , rowHeight : 220 , emptyRow : false , minWidth : 187 } ; playground : IPlayground = { files : { 'app.component.html' : this . snippets . raw . appHtml , 'app.component.ts' : this . snippets . raw . appTs , 'app.component.css' : this . snippets . raw . appCss } , modules : [ { imports : [ 'DashboardModule' , 'ColorServiceModule' , 'SparkModule' ] , library : '@ux-aspects/ux-aspects' } , { library : 'chance' } , { library : 'chart.js' } , { imports : [ 'ChartsModule' ] , library : 'ng2-charts' } ] } ; constructor ( public colorService ) { super ( require . context ( './snippets/' , false , /\.(html|css|js|ts)$/ ) ) ; for ( let idx = 0 ; idx < 50 ; idx ++ ) { let label = '' ; if ( idx === 0 ) { label = 'Jan 1, 2017' ; } if ( idx === 49 ) { label = 'Mar 30, 2017' ; } this . lineChartLabels . push ( label ) ; let dataset1 = this . lineChartData [ 0 ] . data as Chart . ChartPoint [ ] ; let dataset2 = this . lineChartData [ 1 ] . data as Chart . ChartPoint [ ] ; dataset1 . push ( { x : idx , y : chance . integer ( { min : 280 , max : 460 } ) } ) ; dataset2 . push ( { x : idx , y : chance . integer ( { min : 50 , max : 250 } ) } ) ; } } }