Merge pull request #5805 from rashidkpc/fix/not-enough-colors

Use a random color if we run out
This commit is contained in:
Court Ewing 2016-01-04 19:14:04 -05:00
commit 1b8bee1877

View file

@ -58,7 +58,12 @@ define((require) => (Private, config, $rootScope) => {
// Generate a color palette big enough that all new keys can have unique color values
const allColors = _(this.mapping).values().union(configColors).union(oldColors).value();
const colorPalette = createColorPalette(allColors.length + keysToMap.length);
const newColors = _.difference(colorPalette, allColors);
let newColors = _.difference(colorPalette, allColors);
while (keysToMap.length > newColors.length) {
newColors = newColors.concat(_.sample(allColors, keysToMap.length - newColors.length));
}
_.merge(this.mapping, _.zipObject(keysToMap, newColors));
}
}