src/color/util.js
function sn_color_map(fillColors, keys) {
	var colorRange = d3.scale.ordinal().range(fillColors);
	var colorData = keys.map(function(el, i) { return {source:el, color:colorRange(i)}; });
	
	// also provide a mapping of sources to corresponding colors
	var i, len, sourceName;
	for ( i = 0, len = colorData.length; i < len; i += 1 ) {
		// a source value might actually be a number string, which JavaScript will treat 
		// as an array index so only set non-numbers here
		sourceName = colorData[i].source;
		if ( sourceName === '' ) {
			// default to Main if source not provided
			sourceName = 'Main';
		}
		if ( isNaN(Number(sourceName)) ) {
			colorData[sourceName] = colorData[i].color;
		}
	}
	
	return colorData;
}
function sn_color_map(fillColors, keys) {
	var colorRange = d3.scale.ordinal().range(fillColors);
	var colorData = keys.map(function(el, i) { return {source:el, color:colorRange(i)}; });
	
	// also provide a mapping of sources to corresponding colors
	var i, len, sourceName;
	for ( i = 0, len = colorData.length; i < len; i += 1 ) {
		// a source value might actually be a number string, which JavaScript will treat 
		// as an array index so only set non-numbers here
		sourceName = colorData[i].source;
		if ( sourceName === '' ) {
			// default to Main if source not provided
			sourceName = 'Main';
		}
		if ( isNaN(Number(sourceName)) ) {
			colorData[sourceName] = colorData[i].color;
		}
	}
	
	return colorData;
}
function sn_color_map ( fillColors , keys ) { var colorRange = d3 . scale . ordinal ( ) . range ( fillColors ) ; var colorData = keys . map ( function ( el , i ) { return { source : el , color : colorRange ( i ) } ; } ) ; // also provide a mapping of sources to corresponding colors var i , len , sourceName ; for ( i = 0 , len = colorData . length ; i < len ; i += 1 ) { // a source value might actually be a number string, which JavaScript will treat  // as an array index so only set non-numbers here sourceName = colorData [ i ] . source ; if ( sourceName === '' ) { // default to Main if source not provided sourceName = 'Main' ; } if ( isNaN ( Number ( sourceName ) ) ) { colorData [ sourceName ] = colorData [ i ] . color ; } } return colorData ; }
Return an array of colors for a set of unique keys, where the returned
array also contains associative properties for all key values to thier
corresponding color value.

<p>This is designed so the set of keys always map to the same color,
even across charts where not all sources may be present.</p>

@preserve
Return an array of colors for a set of unique keys where the returned array also contains associative properties for all key values to thier corresponding color value .