nl_tokens: compute_scale_domain
pl_tokens: function compute_scale_domain ( scaleObj , data , opts ) { // Compute the domain (`[min, max]`) of a scale based on its data points. // `data` is a flat array of all values used in this scale, and is // created by `input-parsers/parse-<chart>.js` opts = opts || { } ; var scaleDomain = scaleObj . <mask> || [ ] ; var _domain ; var defaultMin ; var defaultMax ; if ( ! isArray ( data ) ) { throw new TypeError ( "data passed to compute_scale_domain must be an array" ) ; } var extent = d3 . extent ( data ) ; var niced = d3 . scale . linear ( ) . domain ( extent ) . nice ( ) . domain ( ) ; if ( ! scaleObj . domain || ! scaleObj . custom ) { if ( opts . nice ) { _domain = niced ; } else { _domain = extent ; } defaultMin = true ; defaultMax = true ; } else { _domain = ( opts . nice ) ? niced : extent ; defaultMin = ( _domain [ 0 ] === scaleDomain [ 0 ] || isUndefined ( scaleDomain [ 0 ] ) ) ; defaultMax = ( _domain [ 1 ] === scaleDomain [ 1 ] || isUndefined ( scaleDomain [ 1 ] ) ) ; _domain = scaleDomain ; } if ( opts . minZero ) { _domain [ 0 ] = Math . min ( _domain [ 0 ] , 0 ) ; } return { domain : _domain , custom : ( ! defaultMin || ! defaultMax ) } ; }