Skip to content

Commit

Permalink
[Visualizations] Fix bad color mapping with multiple split series (#8…
Browse files Browse the repository at this point in the history
…0801) (#80829)

* [Vislib] Fix bad color mapping with multiple split series

* Add unit test to cover the new colors generation
  • Loading branch information
stratoula authored Oct 16, 2020
1 parent 5925f59 commit 4248f10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/charts/public/services/colors/color_palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createColorPalette(num: number): string[] {
const seedLength = seedColors.length;

_.times(num - seedLength, function (i) {
colors.push(hsl((fraction(i + seedLength + 1) * 360 + offset) % 360, 0.5, 0.5).hex());
colors.push(hsl((fraction(i + seedLength + 1) * 360 + offset) % 360, 50, 50).hex());
});

return colors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@ describe('Color Palette', () => {
it('should create new darker colors when input is greater than 72', () => {
expect(createColorPalette(num3)[72]).not.toEqual(seedColors[0]);
});

it('should create new colors and convert them correctly', () => {
expect(createColorPalette(num3)[72]).toEqual('#404ABF');
});
});

0 comments on commit 4248f10

Please sign in to comment.