Skip to content

Commit

Permalink
[Manual][Backport 2.x][Vis colors] Update legacy mapped colors in cha…
Browse files Browse the repository at this point in the history
…rts plugin to use ouiPaletteColorBlind() (#4451)

* [Vis colors] Update legacy mapped colors in charts plugin to use ouiPaletteColorBlind() (#4398)

Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
(cherry picked from commit 5e8a4fd)

* [Vis colors] Update legacy mapped colors in charts plugin to use ouiPaletteColorBlind() (#4398)

Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
(cherry picked from commit 5e8a4fd)
Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>

---------

Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
  • Loading branch information
manasvinibs and ashwin-pc authored Jul 26, 2023
1 parent d3163cf commit a85f798
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 168 deletions.
44 changes: 0 additions & 44 deletions src/plugins/charts/public/services/colors/color_palette.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/plugins/charts/public/services/colors/colors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { coreMock } from '../../../../../core/public/mocks';
import { COLOR_MAPPING_SETTING } from '../../../common';
import { euiPaletteColorBlind } from '@elastic/eui';

import { ColorsService } from './colors';

// Local state for config
Expand Down
117 changes: 0 additions & 117 deletions src/plugins/charts/public/services/colors/colors_palette.test.ts

This file was deleted.

8 changes: 6 additions & 2 deletions src/plugins/charts/public/services/colors/mapped_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import Color from 'color';

import { CoreSetup } from 'opensearch-dashboards/public';

import { euiPaletteColorBlind } from '@elastic/eui';
import { COLOR_MAPPING_SETTING } from '../../../common';
import { createColorPalette } from './color_palette';

const standardizeColor = (color: string) => new Color(color).hex().toLowerCase();

Expand Down Expand Up @@ -100,7 +100,11 @@ export class MappedColors {

// 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 numColors = allColors.length + keysToMap.length;
const colorPalette = euiPaletteColorBlind({
rotations: Math.ceil(numColors / 10),
direction: 'both',
}).slice(0, numColors);
let newColors = _.difference(colorPalette, allColors);

while (keysToMap.length > newColors.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/charts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ChartsServerPlugin implements Plugin<object, object> {
defaultMessage: 'Color mapping',
}),
value: JSON.stringify({
Count: '#00A69B',
Count: '#54B399',
}),
type: 'json',
description: i18n.translate('charts.advancedSettings.visualization.colorMappingText', {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ import { TagCloudVisualization } from './tag_cloud_visualization';
import { setFormatService } from '../services';
import { dataPluginMock } from '../../../data/public/mocks';
import { setHTMLElementOffset, setSVGElementGetBBox } from '../../../../test_utils/public';
import { euiPaletteColorBlind } from '@elastic/eui';

const seedColors = ['#00a69b', '#57c17b', '#6f87d8', '#663db8', '#bc52bc', '#9e3533', '#daa05d'];
const seedColors = euiPaletteColorBlind();

describe('TagCloudVisualizationTest', () => {
let domNode;
Expand Down

0 comments on commit a85f798

Please sign in to comment.