mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Merge pull request #5805 from rashidkpc/fix/not-enough-colors
Use a random color if we run out
This commit is contained in:
commit
1b8bee1877
1 changed files with 6 additions and 1 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue