-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Set legend pixel width (#126018)
* [Lens] Set legend pixel width * Update tests to include legendSize * Fix typo in legend_settings_popover.test.tsx * Update text for tooltips * Fix row display for small screen * Update legend size setting interface * Fix label condition * Add disable for switch * Change condition for input disabling * Update translation key * Replace legend width setting input with select, make it disabled for horizontal legends and move number of columns setting outside of legend location settings component to place legend width setting above * Capitalize legend sizes select values names Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
affbed7
commit 50941eb
Showing
34 changed files
with
332 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
..._partition_vis/common/expression_functions/__snapshots__/mosaic_vis_function.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...ion_partition_vis/common/expression_functions/__snapshots__/pie_vis_function.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...partition_vis/common/expression_functions/__snapshots__/treemap_vis_function.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
..._partition_vis/common/expression_functions/__snapshots__/waffle_vis_function.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/lens/public/shared_components/columns_number_setting.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; | ||
import { ColumnsNumberSetting } from './columns_number_setting'; | ||
|
||
describe('Columns Number Setting', () => { | ||
it('should have default the columns input to 1 when no value is given', () => { | ||
const component = mount(<ColumnsNumberSetting isDisabled={false} isLegendOutside={false} />); | ||
expect( | ||
component.find('[data-test-subj="lens-legend-location-columns-input"]').at(0).prop('value') | ||
).toEqual(1); | ||
}); | ||
}); |
84 changes: 84 additions & 0 deletions
84
x-pack/plugins/lens/public/shared_components/columns_number_setting.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiFieldNumber, EuiFormRow } from '@elastic/eui'; | ||
import { useDebouncedValue } from './debounced_value'; | ||
import { TooltipWrapper } from './tooltip_wrapper'; | ||
|
||
export const DEFAULT_FLOATING_COLUMNS = 1; | ||
|
||
interface ColumnsNumberSettingProps { | ||
/** | ||
* Sets the number of columns for legend inside chart | ||
*/ | ||
floatingColumns?: number; | ||
/** | ||
* Callback on horizontal alignment option change | ||
*/ | ||
onFloatingColumnsChange?: (value: number) => void; | ||
/** | ||
* Flag to disable the location settings | ||
*/ | ||
isDisabled: boolean; | ||
/** | ||
* Indicates if legend is located outside | ||
*/ | ||
isLegendOutside: boolean; | ||
} | ||
|
||
export const ColumnsNumberSetting = ({ | ||
floatingColumns, | ||
onFloatingColumnsChange = () => {}, | ||
isDisabled, | ||
isLegendOutside, | ||
}: ColumnsNumberSettingProps) => { | ||
const { inputValue, handleInputChange } = useDebouncedValue({ | ||
value: floatingColumns ?? DEFAULT_FLOATING_COLUMNS, | ||
onChange: onFloatingColumnsChange, | ||
}); | ||
|
||
return ( | ||
<EuiFormRow | ||
label={i18n.translate('xpack.lens.shared.legendInsideColumnsLabel', { | ||
defaultMessage: 'Number of columns', | ||
})} | ||
fullWidth | ||
display="columnCompressed" | ||
> | ||
<TooltipWrapper | ||
tooltipContent={ | ||
isDisabled | ||
? i18n.translate('xpack.lens.shared.legendVisibleTooltip', { | ||
defaultMessage: 'Requires legend to be shown', | ||
}) | ||
: i18n.translate('xpack.lens.shared.legendInsideTooltip', { | ||
defaultMessage: 'Requires legend to be located inside visualization', | ||
}) | ||
} | ||
condition={isDisabled || isLegendOutside} | ||
position="top" | ||
delay="regular" | ||
display="block" | ||
> | ||
<EuiFieldNumber | ||
data-test-subj="lens-legend-location-columns-input" | ||
value={inputValue} | ||
min={1} | ||
max={5} | ||
compressed | ||
disabled={isDisabled || isLegendOutside} | ||
onChange={(e) => { | ||
handleInputChange(Number(e.target.value)); | ||
}} | ||
step={1} | ||
/> | ||
</TooltipWrapper> | ||
</EuiFormRow> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.