import { DataField } from './DataField' ; export class ChartDataItem { public name : string ; public data : { [ key ] : any ; } ; param name param data constructor ( name , data ) { this . name = name ; this . data = data ; } param field public hasValue ( field ) { return this . _getRawValue ( field ) !== null ; } param field public getValue ( field ) { const rawValue = this . _getRawValue ( field ) ; switch ( field . type ) { case 'percentage' : { if ( this . hasValue ( field ) ) { return Math . floor ( parseFloat ( rawValue ) * 100 ) ; } return 0 ; } case 'currency' : case 'number' : { if ( this . hasValue ( field ) ) { return parseInt ( rawValue , 10 ) ; } return 0 ; } case 'text' : { if ( this . hasValue ( field ) ) { if ( field . fieldName . indexOf ( 'OWSUSER' ) !== - 1 && typeof rawValue === 'string' && rawValue . indexOf ( ' | ' ) !== - 1 ) { return rawValue . split ( ' | ' ) [ 1 ] ; } return rawValue ; } return null ; } default : { return rawValue ; } } } param field protected _getRawValue ( field ) { const rawValue = this . data [ field . fieldName ] ; return rawValue ; } }