Skip to content

Commit 78ffbf5

Browse files
authored
[VisLib] Replace legend color palette with OUI color palette (#4365)
* [VisLib] Replace legend color palette with OUI color palette Replace hard-coded palette (of 8 colors with 7 variations each) with rotations from euiPaletteColorBlind (of 10 colors with 7 variations each) Fixes #4321 Signed-off-by: Josh Romero <rmerqg@amazon.com> * update changelog Signed-off-by: Josh Romero <rmerqg@amazon.com> * Update legend unit test Signed-off-by: Josh Romero <rmerqg@amazon.com> * Update hard-coded legend color values in functional tests Signed-off-by: Josh Romero <rmerqg@amazon.com> --------- Signed-off-by: Josh Romero <rmerqg@amazon.com>
1 parent e451d13 commit 78ffbf5

File tree

7 files changed

+14
-67
lines changed

7 files changed

+14
-67
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8282
- Replace the use of `bluebird` in `saved_objects` plugin ([#4026](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4026))
8383
- Relocate tutorials imagery into `src/plugins/home/public/assets/tutorials/logos` ([#4382](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4382))
8484
- [VisBuilder] Use OUI icon ([#4446](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4446))
85+
- [Vis Colors] [VisLib] Update legend colors to use OUI color palette ([#4365](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4365))
8586
- [Vis Colors] [Region Maps] Replace hardcode color to OUI color in `region_map` plugin ([#4299](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4299))
8687
- [Vis Colors] Replace color maps with OUI color palettes ([#4293](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4293))
8788
- [Vis Colors] [Maps] Replace hardcoded color to OUI color in `maps_legacy` plugin ([#4294](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4294))

src/plugins/vis_type_vislib/public/vislib/components/legend/_legend.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $visLegendLineHeight: $euiSize;
8484
}
8585

8686
.visLegend__valueColorPicker {
87-
width: ($euiSizeL * 8); // 8 columns
87+
width: ($euiSizeL * 10); // 10 columns
8888
}
8989

9090
.visLegend__valueColorPickerDot {

src/plugins/vis_type_vislib/public/vislib/components/legend/legend.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { I18nProvider } from '@osd/i18n/react';
3535
import { EuiButtonGroup } from '@elastic/eui';
3636

3737
import { VisLegend, VisLegendProps } from './legend';
38-
import { legendColors } from './models';
38+
import { legendColors } from './legend_item';
3939

4040
jest.mock('@elastic/eui', () => {
4141
const original = jest.requireActual('@elastic/eui');

src/plugins/vis_type_vislib/public/vislib/components/legend/legend_item.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ import {
4242
EuiPopoverProps,
4343
EuiButtonGroup,
4444
EuiButtonGroupOptionProps,
45+
euiPaletteColorBlind,
4546
} from '@elastic/eui';
4647

47-
import { legendColors, LegendItem } from './models';
48+
import { LegendItem } from './models';
49+
50+
// starting from the default categorical colors, we generate 6 additional variants,
51+
// 3 lighter and 3 darker
52+
export const legendColors = euiPaletteColorBlind({ rotations: 7, direction: 'both' });
4853

4954
interface Props {
5055
item: LegendItem;

src/plugins/vis_type_vislib/public/vislib/components/legend/models.ts

-59
Original file line numberDiff line numberDiff line change
@@ -34,62 +34,3 @@ export interface LegendItem {
3434
}
3535

3636
export const CUSTOM_LEGEND_VIS_TYPES = ['heatmap', 'gauge'];
37-
38-
export const legendColors: string[] = [
39-
'#3F6833',
40-
'#967302',
41-
'#2F575E',
42-
'#99440A',
43-
'#58140C',
44-
'#052B51',
45-
'#511749',
46-
'#3F2B5B', // 6
47-
'#508642',
48-
'#CCA300',
49-
'#447EBC',
50-
'#C15C17',
51-
'#890F02',
52-
'#0A437C',
53-
'#6D1F62',
54-
'#584477', // 2
55-
'#629E51',
56-
'#E5AC0E',
57-
'#64B0C8',
58-
'#E0752D',
59-
'#BF1B00',
60-
'#0A50A1',
61-
'#962D82',
62-
'#614D93', // 4
63-
'#7EB26D',
64-
'#EAB839',
65-
'#6ED0E0',
66-
'#EF843C',
67-
'#E24D42',
68-
'#1F78C1',
69-
'#BA43A9',
70-
'#705DA0', // Normal
71-
'#9AC48A',
72-
'#F2C96D',
73-
'#65C5DB',
74-
'#F9934E',
75-
'#EA6460',
76-
'#5195CE',
77-
'#D683CE',
78-
'#806EB7', // 5
79-
'#B7DBAB',
80-
'#F4D598',
81-
'#70DBED',
82-
'#F9BA8F',
83-
'#F29191',
84-
'#82B5D8',
85-
'#E5A8E2',
86-
'#AEA2E0', // 3
87-
'#E0F9D7',
88-
'#FCEACA',
89-
'#CFFAFF',
90-
'#F9E2D2',
91-
'#FCE2DE',
92-
'#BADFF4',
93-
'#F9D9F9',
94-
'#DEDAF7', // 7
95-
];

test/functional/apps/dashboard/dashboard_state.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ export default function ({ getService, getPageObjects }) {
7575
await PageObjects.dashboard.switchToEditMode();
7676

7777
await PageObjects.visChart.openLegendOptionColors('Count');
78-
await PageObjects.visChart.selectNewLegendColorChoice('#EA6460');
78+
await PageObjects.visChart.selectNewLegendColorChoice('#8d4059');
7979

8080
await PageObjects.dashboard.saveDashboard('Overridden colors');
8181

8282
await PageObjects.dashboard.gotoDashboardLandingPage();
8383
await PageObjects.dashboard.loadSavedDashboard('Overridden colors');
8484
const colorChoiceRetained = await PageObjects.visChart.doesSelectedLegendColorExist(
85-
'#EA6460'
85+
'#8d4059'
8686
);
8787

8888
expect(colorChoiceRetained).to.be(true);
@@ -245,9 +245,9 @@ export default function ({ getService, getPageObjects }) {
245245
it('updates a pie slice color on a soft refresh', async function () {
246246
await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME);
247247
await PageObjects.visChart.openLegendOptionColors('80,000');
248-
await PageObjects.visChart.selectNewLegendColorChoice('#F9D9F9');
248+
await PageObjects.visChart.selectNewLegendColorChoice('#e9b0c3');
249249
const currentUrl = await browser.getCurrentUrl();
250-
const newUrl = currentUrl.replace('F9D9F9', 'FFFFFF');
250+
const newUrl = currentUrl.replace('e9b0c3', 'FFFFFF');
251251
await browser.get(newUrl.toString(), false);
252252
await PageObjects.header.waitUntilLoadingHasFinished();
253253

test/functional/page_objects/visualize_chart_page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export function VisualizeChartPageProvider({ getService, getPageObjects }: FtrPr
286286
await testSubjects.click(`legend-${name}`);
287287
await this.waitForVisualizationRenderingStabilized();
288288
// arbitrary color chosen, any available would do
289-
const isOpen = await this.doesLegendColorChoiceExist('#EF843C');
289+
const isOpen = await this.doesLegendColorChoiceExist('#e09e64');
290290
if (!isOpen) {
291291
throw new Error('legend color selector not open');
292292
}

0 commit comments

Comments
 (0)