// http://colorbrewer2.org/ function ColorMap() { // public methods this.byConference = function(conference) // no restrictions { if (bigFive.indexOf(conference) >= 0) { return colors0[0]; } if (groupOfFive.indexOf(conference) >= 0) { return colors0[1]; } return colors0[2]; } this.getConferenceColors = function() { return [ { category: 'Big Five', color: colors0[0] }, { category: 'Group Of Five', color: colors0[1] }, { category: 'Independent', color: colors0[2] } ]; } this.byConferenceBlindSafe = function(conference) { if (bigFive.indexOf(conference) >= 0) { return colors1[0]; } if (groupOfFive.indexOf(conference) >= 0) { return colors1[1]; } return colors1[2]; } this.getConferenceBlindSafeColors = function() { return [ { category: 'Big Five', color: colors1[0] }, { category: 'Group Of Five', color: colors1[1] }, { category: 'Independent', color: colors1[2] } ]; } this.byConferencePhotocopySafe = function(conference) { if (bigFive.indexOf(conference) >= 0) { return colors2[0]; } if (groupOfFive.indexOf(conference) >= 0) { return colors2[1]; } return colors2[2]; } this.getConferencePhotocopySafeColors = function() { return [ { category: 'Big Five', color: colors2[0] }, { category: 'Group Of Five', color: colors2[1] }, { category: 'Independent', color: colors2[2] } ]; } this.byBigFive = function(conference) // no restrictions { var i = bigFive.indexOf(conference); if (i >= 0) { return bigFiveColors[i]; } } this.inBigFive = function(conference) { return bigFive.indexOf(conference) >= 0; } this.getBigFiveColors = function() { var categories = []; bigFive.forEach(function(v, i) { categories.push( { category: v, color: bigFiveColors[i] } ); }); return categories; } // expect rank, one of { 0, 1, 2, 3, 4 } this.fiveByMultiHue = function(rank) { if (rank < fiveMultiHue.length) { return fiveMultiHue[rank]; } } this.getMultiHueColors = function() { var categories = []; fiveMultiHue.forEach(function(v, i) { categories.push( { category: 'Rank ' + (i + 1), color: v } ); }); return categories; } // see above for rank this.fiveBySingleHue = function(rank) { if (rank < fiveSingleHue.length) { return fiveSingleHue[rank]; } } this.getSingleHueColors = function() { var categories = []; fiveSingleHue.forEach(function(v, i) { categories.push( { category: 'Rank ' + (i + 1), color: v } ); }); return categories; } // private variables var bigFive = [ 'SEC', 'ACC', 'Big 12', 'Pac-12', 'Big Ten' ]; var groupOfFive = [ 'American', 'Sun Belt', 'MWC', 'MAC', 'CUSA' ]; var fiveMultiHue = [ '#253494', '#2c7fb8', '#41b6c4', '#a1dab4', '#ffffcc' ]; var fiveSingleHue = [ '#a50f15', '#de2d26', '#fb6a4a', '#fcae91', '#fee5d9' ]; var colors0 = [ '#e41a1c', '#377eb8', '#4daf4a' ]; var colors1 = [ '#1b9e77', '#d95f02', '#7570b3' ]; var colors2 = [ '#f0f0f0', '#bdbdbd', '#636363' ]; var bigFiveColors = [ '#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00']; }