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

[Lens][Table] Add color by terms with color mappings #189895

Merged
merged 50 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6c9ff96
[Lens][Table] Add color by terms with color mappings
nickofthyme Aug 5, 2024
4dfb857
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 5, 2024
1737e6d
fix: cell style updates
nickofthyme Aug 5, 2024
160d3dd
fix initial palette when adding new dimension
nickofthyme Aug 5, 2024
b81bb4e
Add color mapping to row dimensions
nickofthyme Aug 5, 2024
5471c2a
Style & copy tweaks to align with mockups
nickofthyme Aug 5, 2024
1c0c53a
derive categories across all matching transposed columns
nickofthyme Aug 6, 2024
8dd3c34
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 6, 2024
5c2a577
fix i18n issues
nickofthyme Aug 7, 2024
3c555cf
Merge remote-tracking branch 'origin/color-mapping-tables' into color…
nickofthyme Aug 7, 2024
82bc97e
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 7, 2024
020dd91
fix type errors in datatable expression
nickofthyme Aug 8, 2024
3613870
fix types and test errors
nickofthyme Aug 13, 2024
ca97848
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 13, 2024
369e020
style: remove empty color when color is applied
nickofthyme Aug 13, 2024
fd5a754
fix legacy color sync on table palettes
nickofthyme Aug 14, 2024
eb2cf04
test: add and fix unit tests
nickofthyme Aug 16, 2024
f3814f9
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 16, 2024
f4c1ab5
cleanup cell value merged logic
nickofthyme Aug 16, 2024
a3ed882
fix i18n error
nickofthyme Aug 19, 2024
c27f325
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 19, 2024
01a70e3
chore: simplify `color_categories.ts` logic
nickofthyme Aug 21, 2024
8517989
chore: color all bucketed columns by terms
nickofthyme Aug 21, 2024
3401c34
chore: set default palette based on color type
nickofthyme Aug 21, 2024
d01d4c3
fix: color bucketed numerics by term
nickofthyme Aug 21, 2024
c9dcb25
chore: update tests for new by terms logic
nickofthyme Aug 21, 2024
75d583b
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 21, 2024
afda04d
test: fix flaky color sync tests
nickofthyme Aug 22, 2024
c4ad8ad
test: fix jest tests due to changes
nickofthyme Aug 22, 2024
46abc0a
test: move getColorStops to lens utils, fix color stops for custom pa…
nickofthyme Aug 22, 2024
70a1939
fix: jest test/type error
nickofthyme Aug 22, 2024
1a8b94d
fix: bad search predicate
nickofthyme Aug 22, 2024
ebdec6f
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 22, 2024
aead73b
chore: remove old nick
nickofthyme Aug 22, 2024
c059e28
fix: range column formatting
nickofthyme Aug 22, 2024
320f160
fix: setting switch font size
nickofthyme Aug 22, 2024
60d44bc
style: revert text style on EuiButtonEmpty
nickofthyme Aug 22, 2024
b6f4754
chore: remove unneeded flex group
nickofthyme Aug 22, 2024
0fb22f6
style: minor UI tweaks
nickofthyme Aug 23, 2024
a94a571
update limits due to increased size of `@kbn/coloring`
nickofthyme Aug 23, 2024
df48141
chore: add `colorMapping` telemetry
nickofthyme Aug 23, 2024
3be2d4f
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 23, 2024
5f0b622
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 23, 2024
dee8b55
Merge branch 'main' into color-mapping-tables
mbondyra Aug 26, 2024
034334a
chore: apply code review changes
nickofthyme Aug 26, 2024
f0f0f47
chore: fix linting errors
nickofthyme Aug 26, 2024
77cd409
fix: palette issue on datasource update
nickofthyme Aug 27, 2024
fed3089
fix: design styles for padding and icon coloring
nickofthyme Aug 27, 2024
5a873fa
Merge branch 'main' into color-mapping-tables
nickofthyme Aug 27, 2024
472dd0f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ import { Container } from './components/container/container';
import { ColorMapping } from './config';
Copy link
Contributor

Choose a reason for hiding this comment

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

I observed this small bug when switching between categorical/numerical color palettes.

  1. Create a datatable with a last value dimension and categorical color palette set.
  2. switch to a numerical operation, like 'sum'
  3. Click on the color palette - the palette input is not filled properly. I'll pass you the video in a PM (github limits won't allow me to do so)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed this in 77cd409

import { uiReducer } from './state/ui';

export interface ColorMappingInputCategoricalData {
type: 'categories';
/** an ORDERED array of categories rendered in the visualization */
categories: Array<string | string[]>;
}

export interface ColorMappingInputContinuousData {
type: 'ranges';
min: number;
max: number;
bins: number;
}

/**
* A configuration object that is required to populate correctly the visible categories
* or the ranges in the CategoricalColorMapping component
*/
export type ColorMappingInputData =
| {
type: 'categories';
/** an ORDERED array of categories rendered in the visualization */
categories: Array<string | string[]>;
}
| {
type: 'ranges';
min: number;
max: number;
bins: number;
};
| ColorMappingInputCategoricalData
| ColorMappingInputContinuousData;

/**
* The props of the CategoricalColorMapping component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function getColorFactory(
})
: [];

// find all categories that doesn't match with an assignment
// find all categories that don't match with an assignment
const notAssignedCategories =
data.type === 'categories'
? data.categories.filter((category) => {
Expand Down
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function rangeMatch(rule: ColorMapping.RuleRange, value: number) {
}

// TODO: move in some data/table related package
export const SPECIAL_TOKENS_STRING_CONVERTION = new Map([
export const SPECIAL_TOKENS_STRING_CONVERSION = new Map([
[
'__other__',
i18n.translate('coloring.colorMapping.terms.otherBucketLabel', {
Expand All @@ -55,3 +55,9 @@ export const SPECIAL_TOKENS_STRING_CONVERTION = new Map([
}),
],
]);

/**
* Returns special string for sake of color mapping/syncing
*/
export const getSpecialString = (value: string) =>
SPECIAL_TOKENS_STRING_CONVERSION.get(value) ?? value;
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function Assignment({
css={
!disableDelete
? css`
color: ${euiThemeVars.euiTextSubduedColor};
color: ${euiThemeVars.euiTextColor};
transition: ${euiThemeVars.euiAnimSpeedFast} ease-in-out;
transition-property: color;
&:hover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const Match: React.FC<{
return (
<EuiFlexItem style={{ minWidth: 1, width: 1 }}>
<EuiComboBox
isClearable
data-test-subj={`lns-colorMapping-assignmentsItem${index}`}
fullWidth={true}
aria-label={i18n.translate('coloring.colorMapping.assignments.autoAssignedTermAriaLabel', {
Expand All @@ -82,7 +83,7 @@ export const Match: React.FC<{
placeholder={i18n.translate(
'coloring.colorMapping.assignments.autoAssignedTermPlaceholder',
{
defaultMessage: 'Auto assigned',
defaultMessage: 'Auto assigning term',
}
)}
options={convertedOptions}
Expand All @@ -103,7 +104,6 @@ export const Match: React.FC<{
}
}}
isCaseSensitive
isClearable={false}
compressed
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
*/

import React, { useState } from 'react';
import {
EuiButtonEmpty,
EuiPopoverTitle,
EuiTab,
EuiTabs,
EuiTitle,
EuiHorizontalRule,
} from '@elastic/eui';
import { EuiButtonEmpty, EuiPopoverTitle, EuiTab, EuiTabs, EuiHorizontalRule } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ColorMapping } from '../../config';
import { getPalette } from '../../palettes';
Expand Down Expand Up @@ -56,22 +49,14 @@ export function ColorPicker({
>
<EuiTabs size="m" expand>
<EuiTab onClick={() => setTab('palette')} isSelected={tab === 'palette'}>
<EuiTitle size="xxxs">
<span>
{i18n.translate('coloring.colorMapping.colorPicker.paletteTabLabel', {
defaultMessage: 'Colors',
})}
</span>
</EuiTitle>
{i18n.translate('coloring.colorMapping.colorPicker.paletteTabLabel', {
defaultMessage: 'Colors',
})}
</EuiTab>
<EuiTab onClick={() => setTab('custom')} isSelected={tab === 'custom'}>
<EuiTitle size="xxxs">
<span>
{i18n.translate('coloring.colorMapping.colorPicker.customTabLabel', {
defaultMessage: 'Custom',
})}
</span>
</EuiTitle>
{i18n.translate('coloring.colorMapping.colorPicker.customTabLabel', {
defaultMessage: 'Custom',
})}
</EuiTab>
</EuiTabs>
</EuiPopoverTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,14 @@ export const ColorSwatch = ({
css={css`
&::after {
content: '';
width: 0;
height: 0;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 4px solid ${colorIsDark ? 'white' : 'black'};
margin: 0;
bottom: 2px;
color: ${colorIsDark ? 'white' : 'black'};
// custom arrowDown svg
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3IiBoZWlnaHQ9IjQiIHZpZXdCb3g9IjAgMCA3IDQiPgogIDxwYXRoIGQ9Ik0uMTQ2LjE0N2EuNS41IDAgMCAxIC43MDggMEwzLjUgMi43OTQgNi4xNDYuMTQ3YS41LjUgMCAxIDEgLjcwOC43MDhsLTMgM2EuNS41IDAgMCAxLS43MDggMGwtMy0zYS41LjUgMCAwIDEgMC0uNzA4WiIvPgo8L3N2Zz4K');
height: 4px;
width: 7px;
bottom: 6px;
right: 4px;
position: absolute;
right: 2px;
}
`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiFlexItem,
EuiHorizontalRule,
EuiIcon,
EuiText,
EuiTitle,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -50,13 +50,13 @@ export function PaletteColors({
<>
<EuiFlexGroup direction="column" style={{ padding: 8 }}>
<EuiFlexItem>
<EuiText size="s">
<strong>
<EuiTitle size="xxxs">
<h6>
{i18n.translate('coloring.colorMapping.colorPicker.paletteColorsLabel', {
defaultMessage: 'Palette colors',
})}
</strong>
</EuiText>
</h6>
</EuiTitle>
<EuiFlexGroup
direction="row"
gutterSize="s"
Expand Down Expand Up @@ -84,22 +84,25 @@ export function PaletteColors({
<EuiHorizontalRule margin="xs" />
<EuiFlexGroup style={{ padding: 8, paddingTop: 0 }}>
<EuiFlexItem>
<EuiText size="s">
<strong>
<EuiTitle size="xxxs">
<h6>
{i18n.translate('coloring.colorMapping.colorPicker.themeAwareColorsLabel', {
defaultMessage: 'Neutral colors',
})}
</strong>
<EuiToolTip
position="bottom"
content={i18n.translate('coloring.colorMapping.colorPicker.themeAwareColorsTooltip', {
defaultMessage:
'The provided neutral colors are theme-aware and will change appropriately when switching between light and dark themes.',
})}
>
<EuiIcon tabIndex={0} type="questionInCircle" />
</EuiToolTip>
</EuiText>
<EuiToolTip
position="bottom"
content={i18n.translate(
'coloring.colorMapping.colorPicker.themeAwareColorsTooltip',
{
defaultMessage:
'The provided neutral colors are theme-aware and will change appropriately when switching between light and dark themes.',
}
)}
>
<EuiIcon tabIndex={0} type="questionInCircle" />
</EuiToolTip>
</h6>
</EuiTitle>
<EuiFlexGroup
direction="row"
gutterSize="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function AssignmentsConfig({
return (
<EuiPanel
color="subdued"
borderRadius="none"
borderRadius="m"
hasShadow={false}
paddingSize="none"
css={css`
Expand Down Expand Up @@ -195,7 +195,7 @@ export function AssignmentsConfig({
'coloring.colorMapping.container.mapValuesPromptDescription.mapValuesPromptDetail',
{
defaultMessage:
'Add new assignments to begin associating terms in your data with specified colors.',
'Add a new assignment to manually associate terms with specified colors.',
}
)}
</p>
Expand All @@ -214,7 +214,6 @@ export function AssignmentsConfig({
</EuiButton>,
<EuiButtonEmpty
data-test-subj="lns-colorMapping-assignmentsPromptAddAll"
color="primary"
size="xs"
onClick={onClickAddAllCurrentCategories}
>
Expand All @@ -228,13 +227,14 @@ export function AssignmentsConfig({
</EuiFlexGroup>
</div>
{assignments.length > 0 && <EuiHorizontalRule margin="none" />}
<div
css={css`
padding: ${euiThemeVars.euiPanelPaddingModifiers.paddingSmall};
overflow: hidden;
`}
>
{assignments.length > 0 && (

{assignments.length > 0 && (
<div
css={css`
padding: ${euiThemeVars.euiPanelPaddingModifiers.paddingSmall};
overflow: hidden;
`}
>
<EuiFlexGroup
direction="row"
alignItems="center"
Expand All @@ -251,6 +251,7 @@ export function AssignmentsConfig({
button={
<EuiButtonIcon
iconType="boxesVertical"
color="text"
aria-label={i18n.translate(
'coloring.colorMapping.container.OpenAdditionalActionsButtonLabel',
{
Expand Down Expand Up @@ -308,7 +309,9 @@ export function AssignmentsConfig({
setShowOtherActions(false);
dispatch(removeAllAssignments());
}}
color="danger"
css={css`
color: ${euiThemeVars.euiColorDanger};
`}
>
{i18n.translate(
'coloring.colorMapping.container.clearAllAssignmentsButtonLabel',
Expand All @@ -322,8 +325,8 @@ export function AssignmentsConfig({
</EuiPopover>
)}
</EuiFlexGroup>
)}
</div>
</div>
)}
</EuiPanel>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function Container({
>
<EuiButtonIcon
data-test-subj="lns-colorMapping-invertGradient"
color="text"
iconType="merge"
size="xs"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function ScaleMode({ getPaletteFn }: { getPaletteFn: ReturnType<typeof ge
>
<EuiButtonGroup
legend="Mode"
buttonSize="compressed"
data-test-subj="lns_colorMapping_scaleSwitch"
options={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
* Side Public License, v 1.
*/

export { CategoricalColorMapping, type ColorMappingProps } from './categorical_color_mapping';
export {
CategoricalColorMapping,
type ColorMappingProps,
type ColorMappingInputCategoricalData,
type ColorMappingInputContinuousData,
} from './categorical_color_mapping';
export type { ColorMappingInputData } from './categorical_color_mapping';
export type { ColorMapping } from './config';
export * from './palettes';
export * from './color/color_handling';
export { SPECIAL_TOKENS_STRING_CONVERTION } from './color/rule_matching';
export { SPECIAL_TOKENS_STRING_CONVERSION, getSpecialString } from './color/rule_matching';
export {
DEFAULT_COLOR_MAPPING_CONFIG,
DEFAULT_OTHER_ASSIGNMENT_INDEX,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pageLoadAssetSize:
expressionLegacyMetricVis: 23121
expressionMetric: 22238
expressionMetricVis: 23121
expressionPartitionVis: 29700
expressionPartitionVis: 44888
expressionRepeatImage: 22341
expressionRevealImage: 25675
expressions: 140958
Expand Down
Loading