namespace Plot { export interface xyDatum { x : number ; y : number ; } export class xyData { data : xyDatum [ ] ; colour : string ; constructor ( values , colour ) { this . data = values ; this . colour = colour ; if ( colour == null ) { this . colour = "hsl(" + ~ ~ ( Math . random ( ) * 360 ) + ",99%,60%)" ; } } } export function toXYData ( items ) { if ( Object . prototype . toString . call ( items ) === "[object Array]" ) { if ( items . length = 0 ) { return [ ] ; } var isWorking = true ; for ( var i = 0 ; i < items . length ; i ++ ) { if ( items [ i ] . values == null || items [ i ] . colour == null ) { isWorking = false ; throw new Error ( "The xy data supplied is incorrect" ) ; } } if ( isWorking ) { var xyDataeaeaeae = [ ] ; for ( var i = 0 ; i < items . length ; i ++ ) { xyDataeaeaeae . push ( new xyData ( items [ i ] . values , items [ i ] . colour ) ) ; } return xyDataeaeaeae ; } } else { if ( items . values == null || items . colour == null ) { throw new Error ( "The xy data supplied is incorrect" ) ; } else { return [ new xyData ( items . values , items . colour ) ] ; } } } }