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] update default legend size to medium #130336

Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1bd3e8a
update lens legend default to medium
drewdaemon Apr 13, 2022
348b793
Remove auto option when not currently selected
drewdaemon Apr 13, 2022
a6449c6
update legend size settings
drewdaemon Apr 14, 2022
43011c6
Add lens legend migration
drewdaemon Apr 14, 2022
a43e87a
Default legend size at expression level
drewdaemon Apr 15, 2022
f50405c
hide auto option and update default legend size for agg-based visuali…
drewdaemon Apr 15, 2022
bacdef6
update default legend sizes for aggs-based visualizations
drewdaemon Apr 15, 2022
07b6ba4
fn name update
drewdaemon Apr 15, 2022
75e5770
add migration for aggs-based visualizations
drewdaemon Apr 15, 2022
cbd7483
Add visualizations as required bundle for editor
drewdaemon Apr 18, 2022
f7079d2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 18, 2022
9e97779
add test for visualize SO migration
drewdaemon Apr 19, 2022
6e87e68
Merge branch '129474/default-legend-size-to-fixed-migrations-strategy…
drewdaemon Apr 19, 2022
e252436
test lens saved object migrations
drewdaemon Apr 19, 2022
c018293
update unit test
drewdaemon Apr 19, 2022
ce369ec
Merge branch 'main' into 129474/default-legend-size-to-fixed-migratio…
kibanamachine Apr 19, 2022
1be5bbf
update baseline screenshot for area chart
drewdaemon Apr 19, 2022
538742a
Merge branch '129474/default-legend-size-to-fixed-migrations-strategy…
drewdaemon Apr 19, 2022
7f879f1
Merge branch 'main' into 129474/default-legend-size-to-fixed-migratio…
kibanamachine Apr 20, 2022
0efec68
wait to hide auto option - lens
drewdaemon Apr 21, 2022
17140fc
Merge branch '129474/default-legend-size-to-fixed-migrations-strategy…
drewdaemon Apr 21, 2022
b876e1a
wait to hide auto option - visualize
drewdaemon Apr 21, 2022
8d47281
Merge branch 'main' of github.com:elastic/kibana into 129474/default-…
drewdaemon May 2, 2022
0089aa4
remove unused setters
drewdaemon May 2, 2022
44ea016
fix some checks
drewdaemon May 2, 2022
180c5e7
adjust visual test error margin
drewdaemon May 2, 2022
ecb8604
Merge branch 'main' into 129474/default-legend-size-to-fixed-migratio…
kibanamachine May 3, 2022
ea1218e
import default legend size and LegendSizes from visualizations plugin
drewdaemon May 3, 2022
0c019bf
Merge branch '129474/default-legend-size-to-fixed-migrations-strategy…
drewdaemon May 3, 2022
cfbed11
Merge branch 'main' of github.com:elastic/kibana into 129474/default-…
drewdaemon May 3, 2022
70d8605
Merge branch 'main' of github.com:elastic/kibana into 129474/default-…
drewdaemon May 3, 2022
01ba9b7
fix test
drewdaemon May 3, 2022
7c8d259
fix test
drewdaemon May 3, 2022
befa54f
allow for undefined params in visualization migration function
drewdaemon May 3, 2022
127fbd4
fix migration types
drewdaemon May 3, 2022
7b44734
more typing fixes
drewdaemon May 3, 2022
0e3a30d
Interpret auto as auto instead of 0
drewdaemon May 4, 2022
922b5a9
update baseline snapshot
drewdaemon May 4, 2022
3a3cf3a
Using strings for legend sizes
drewdaemon May 5, 2022
43a69e9
Merge branch 'main' of github.com:elastic/kibana into 129474/default-…
drewdaemon May 5, 2022
bf828cb
move legendSize default and pixel translation to expression layer
drewdaemon May 5, 2022
8c28bbc
update aggs-based
drewdaemon May 6, 2022
c4f118d
update some unit tests
drewdaemon May 6, 2022
58b4dcd
remove unused import
drewdaemon May 6, 2022
eb4588f
Merge branch 'main' of github.com:elastic/kibana into 129474/default-…
drewdaemon May 6, 2022
3332ce1
remove unused imports
drewdaemon May 6, 2022
701a66c
update snaps
drewdaemon May 6, 2022
cd85c83
update translation path
drewdaemon May 7, 2022
cee8d53
restore i18n string
drewdaemon May 9, 2022
9ee0704
remove unnecessary optional chaining operators
drewdaemon May 9, 2022
bc69ec8
Merge branch 'main' into 129474/default-legend-size-to-fixed-migratio…
kibanamachine May 9, 2022
d612e4d
Merge branch 'main' into 129474/default-legend-size-to-fixed-migratio…
kibanamachine May 10, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { Position } from '@elastic/charts';
import { i18n } from '@kbn/i18n';
import type { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { DEFAULT_LEGEND_SIZE, LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { EXPRESSION_HEATMAP_LEGEND_NAME } from '../constants';
import { HeatmapLegendConfig, HeatmapLegendConfigResult } from '../types';

Expand Down Expand Up @@ -52,10 +53,19 @@ export const heatmapLegendConfig: ExpressionFunctionDefinition<
}),
},
legendSize: {
types: ['number'],
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: i18n.translate('expressionHeatmap.function.args.legendSize.help', {
defaultMessage: 'Specifies the legend size in pixels.',
defaultMessage: 'Specifies the legend size.',
}),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
},
fn(input, args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common';

import { CustomPaletteState } from '@kbn/charts-plugin/common';
import { LegendSize } from '@kbn/visualizations-plugin/public';
import {
EXPRESSION_HEATMAP_NAME,
EXPRESSION_HEATMAP_LEGEND_NAME,
Expand Down Expand Up @@ -43,7 +44,7 @@ export interface HeatmapLegendConfig {
* Exact legend width (vertical) or height (horizontal)
* Limited to max of 70% of the chart container dimension Vertical legends limited to min of 30% of computed width
*/
legendSize?: number;
legendSize?: LegendSize;
}

export type HeatmapLegendConfigResult = HeatmapLegendConfig & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { act } from 'react-dom/test-utils';
import { HeatmapRenderProps, HeatmapArguments } from '../../common';
import HeatmapComponent from './heatmap_component';
import { LegendSize } from '@kbn/visualizations-plugin/common';

jest.mock('@elastic/charts', () => {
const original = jest.requireActual('@elastic/charts');
Expand Down Expand Up @@ -47,6 +48,7 @@ const args: HeatmapArguments = {
isVisible: true,
position: 'top',
type: 'heatmap_legend',
legendSize: LegendSize.SMALL,
},
gridConfig: {
isCellLabelVisible: true,
Expand Down Expand Up @@ -119,6 +121,33 @@ describe('HeatmapComponent', function () {
expect(component.find(Settings).prop('legendPosition')).toEqual('top');
});

it('sets correct legend sizes', () => {
const component = shallowWithIntl(<HeatmapComponent {...wrapperProps} />);
expect(component.find(Settings).prop('legendSize')).toEqual(80);

component.setProps({
args: {
...args,
legend: {
...args.legend,
legendSize: LegendSize.AUTO,
},
},
});
expect(component.find(Settings).prop('legendSize')).toBeUndefined();

component.setProps({
args: {
...args,
legend: {
...args.legend,
legendSize: undefined,
},
},
});
expect(component.find(Settings).prop('legendSize')).toEqual(130);
});

it('renders the legend toggle component if uiState is set', async () => {
const component = mountWithIntl(<HeatmapComponent {...wrapperProps} />);
await actWithTimeout(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import {
getAccessorByDimension,
getFormatByAccessor,
} from '@kbn/visualizations-plugin/common/utils';
import {
DEFAULT_LEGEND_SIZE,
LegendSizeToPixels,
} from '@kbn/visualizations-plugin/common/constants';
import type { HeatmapRenderProps, FilterEvent, BrushEvent } from '../../common';
import { applyPaletteParams, findMinMaxByColumnId, getSortPredicate } from './helpers';
import {
Expand Down Expand Up @@ -485,7 +489,7 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = memo(
onElementClick={interactive ? (onElementClick as ElementClickListener) : undefined}
showLegend={showLegend ?? args.legend.isVisible}
legendPosition={args.legend.position}
legendSize={args.legend.legendSize}
legendSize={LegendSizeToPixels[args.legend.legendSize ?? DEFAULT_LEGEND_SIZE]}
legendColorPicker={uiState ? LegendColorPickerWrapper : undefined}
debugState={window._echDebugStateFlag ?? false}
tooltip={tooltip}
Expand Down

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

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

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

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 @@ -47,7 +47,7 @@ export const strings = {
}),
getLegendSizeArgHelp: () =>
i18n.translate('expressionPartitionVis.reusable.function.args.legendSizeHelpText', {
defaultMessage: 'Specifies the legend size in pixels',
defaultMessage: 'Specifies the legend size',
}),
getNestedLegendArgHelp: () =>
i18n.translate('expressionPartitionVis.reusable.function.args.nestedLegendHelpText', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Position } from '@elastic/charts';
import { prepareLogTable, validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { DEFAULT_LEGEND_SIZE, LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { LegendDisplay, PartitionVisParams } from '../types/expression_renderers';
import { ChartTypes, MosaicVisExpressionFunctionDefinition } from '../types';
import {
Expand Down Expand Up @@ -64,8 +65,17 @@ export const mosaicVisFunction = (): MosaicVisExpressionFunctionDefinition => ({
strict: true,
},
legendSize: {
types: ['number'],
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: strings.getLegendSizeArgHelp(),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
nestedLegend: {
types: ['boolean'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ValueFormats,
LegendDisplay,
} from '../types/expression_renderers';
import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common';
import { ExpressionValueVisDimension, LegendSize } from '@kbn/visualizations-plugin/common';
import { Datatable } from '@kbn/expressions-plugin/common/expression_types/specs';
import { pieVisFunction } from './pie_vis_function';
import { PARTITION_LABELS_VALUE } from '../constants';
Expand All @@ -31,6 +31,7 @@ describe('interpreter/functions#pieVis', () => {
addTooltip: true,
legendDisplay: LegendDisplay.SHOW,
legendPosition: 'right',
legendSize: LegendSize.SMALL,
isDonut: true,
emptySizeRatio: EmptySizeRatios.SMALL,
nestedLegend: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Position } from '@elastic/charts';
import { prepareLogTable, validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { DEFAULT_LEGEND_SIZE, LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { EmptySizeRatios, LegendDisplay, PartitionVisParams } from '../types/expression_renderers';
import { ChartTypes, PieVisExpressionFunctionDefinition } from '../types';
import {
Expand Down Expand Up @@ -64,8 +65,17 @@ export const pieVisFunction = (): PieVisExpressionFunctionDefinition => ({
strict: true,
},
legendSize: {
types: ['number'],
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: strings.getLegendSizeArgHelp(),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
nestedLegend: {
types: ['boolean'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Position } from '@elastic/charts';
import { prepareLogTable, validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { DEFAULT_LEGEND_SIZE, LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { LegendDisplay, PartitionVisParams } from '../types/expression_renderers';
import { ChartTypes, TreemapVisExpressionFunctionDefinition } from '../types';
import {
Expand Down Expand Up @@ -64,8 +65,17 @@ export const treemapVisFunction = (): TreemapVisExpressionFunctionDefinition =>
strict: true,
},
legendSize: {
types: ['number'],
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: strings.getLegendSizeArgHelp(),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
nestedLegend: {
types: ['boolean'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Position } from '@elastic/charts';
import { prepareLogTable, validateAccessor } from '@kbn/visualizations-plugin/common/utils';
import { DEFAULT_LEGEND_SIZE, LegendSize } from '@kbn/visualizations-plugin/common/constants';
import { LegendDisplay, PartitionVisParams } from '../types/expression_renderers';
import { ChartTypes, WaffleVisExpressionFunctionDefinition } from '../types';
import {
Expand Down Expand Up @@ -63,8 +64,17 @@ export const waffleVisFunction = (): WaffleVisExpressionFunctionDefinition => ({
strict: true,
},
legendSize: {
types: ['number'],
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: strings.getLegendSizeArgHelp(),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
truncateLegend: {
types: ['boolean'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { PaletteOutput } from '@kbn/coloring';
import { Datatable, DatatableColumn } from '@kbn/expressions-plugin/common';
import { SerializedFieldFormat } from '@kbn/field-formats-plugin/common';
import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common';
import { LegendSize } from '@kbn/visualizations-plugin/public';
import { ChartTypes, ExpressionValuePartitionLabels } from './expression_functions';

export enum EmptySizeRatios {
Expand Down Expand Up @@ -52,7 +53,7 @@ interface VisCommonParams {
legendPosition: Position;
truncateLegend: boolean;
maxLegendLines: number;
legendSize?: number;
legendSize?: LegendSize;
ariaLabel?: string;
}

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 @@ -25,6 +25,7 @@ import {
createMockWaffleParams,
} from '../mocks';
import { ChartTypes } from '../../common/types';
import { LegendSize } from '@kbn/visualizations-plugin/common';

jest.mock('@elastic/charts', () => {
const original = jest.requireActual('@elastic/charts');
Expand Down Expand Up @@ -177,6 +178,35 @@ describe('PartitionVisComponent', function () {
expect(component.find(Settings).prop('legendMaxDepth')).toBeUndefined();
});

it('sets correct legend sizes', () => {
const component = shallow(
<PartitionVisComponent
{...wrapperProps}
visParams={{
...visParams,
legendSize: LegendSize.SMALL,
}}
/>
);
expect(component.find(Settings).prop('legendSize')).toEqual(80);

component.setProps({
visParams: {
...visParams,
legendSize: LegendSize.AUTO,
},
});
expect(component.find(Settings).prop('legendSize')).toBeUndefined();

component.setProps({
visParams: {
...visParams,
legendSize: undefined,
},
});
expect(component.find(Settings).prop('legendSize')).toEqual(130);
});

it('defaults on displaying the tooltip', () => {
const component = shallow(<PartitionVisComponent {...wrapperProps} />);
expect(component.find(Settings).prop('tooltip')).toStrictEqual({ type: TooltipType.Follow });
Expand Down
Loading