Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VisLib] Replace legend color palette with OUI color palette #4365

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
- [Table Visualization] Remove custom styling for text-align:center in favor of OUI utility class. ([#4164](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4164))
- Replace the use of `bluebird` in `saved_objects` plugin ([#4026](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4026))
- [VisLib] Update legend colors to use OUI color palette ([#4365](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4365))

### 🔩 Tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ $visLegendLineHeight: $euiSize;
}

.visLegend__valueColorPicker {
width: ($euiSizeL * 8); // 8 columns
width: ($euiSizeL * 10); // 10 columns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 10 because that's the default size of oui palette?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

.visLegend__valueColorPickerDot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ import {
EuiPopoverProps,
EuiButtonGroup,
EuiButtonGroupOptionProps,
euiPaletteColorBlind,
} from '@elastic/eui';

import { legendColors, LegendItem } from './models';
import { LegendItem } from './models';

// starting from the default categorical colors, we generate 6 additional variants,
// 3 lighter and 3 darker
const legendColors = euiPaletteColorBlind({ rotations: 7, direction: 'both' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set direction here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, direction is 'lighter', which means that we wouldn't get the darker colors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see! So how does it gets divided to 3 lighter and 3 darker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

direction: 'both' basically generates a palette for each of the 10 base colors that goes from white to the color to black and chops off white and black. Setting direction to either 'lighter' or 'darker' basically chops off the lighter or darker end of the palette, so setting it to 'both' just keeps the whole palette.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!


interface Props {
item: LegendItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,62 +34,3 @@ export interface LegendItem {
}

export const CUSTOM_LEGEND_VIS_TYPES = ['heatmap', 'gauge'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want to add heatmap screenshot with updated legend palette?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add that - I think it renders the same.


export const legendColors: string[] = [
'#3F6833',
'#967302',
'#2F575E',
'#99440A',
'#58140C',
'#052B51',
'#511749',
'#3F2B5B', // 6
'#508642',
'#CCA300',
'#447EBC',
'#C15C17',
'#890F02',
'#0A437C',
'#6D1F62',
'#584477', // 2
'#629E51',
'#E5AC0E',
'#64B0C8',
'#E0752D',
'#BF1B00',
'#0A50A1',
'#962D82',
'#614D93', // 4
'#7EB26D',
'#EAB839',
'#6ED0E0',
'#EF843C',
'#E24D42',
'#1F78C1',
'#BA43A9',
'#705DA0', // Normal
'#9AC48A',
'#F2C96D',
'#65C5DB',
'#F9934E',
'#EA6460',
'#5195CE',
'#D683CE',
'#806EB7', // 5
'#B7DBAB',
'#F4D598',
'#70DBED',
'#F9BA8F',
'#F29191',
'#82B5D8',
'#E5A8E2',
'#AEA2E0', // 3
'#E0F9D7',
'#FCEACA',
'#CFFAFF',
'#F9E2D2',
'#FCE2DE',
'#BADFF4',
'#F9D9F9',
'#DEDAF7', // 7
];