Skip to content

Commit b25012d

Browse files
[8.x] [Lens] Use AxisLabelOrientationSelector in xy axis settings (elastic#208002) (elastic#210166)
# Backport This will backport the following commits from `main` to `8.x`: - [[Lens] Use AxisLabelOrientationSelector in xy axis settings (elastic#208002)](elastic#208002) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Maria Iriarte","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-07T11:35:44Z","message":"[Lens] Use AxisLabelOrientationSelector in xy axis settings (elastic#208002)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/206040\r\n\r\n- Uses the `AxisLabelOrientationSelector` component, which was\r\nintroduced in [202143](https://github.com/elastic/kibana/pull/202143),\r\nin the XY chart axis settings.\r\n- Adds `AxesSettingsConfig` and `AxesSettingsConfigKeys` declarations in\r\n`x-pack/platform/plugins/shared/lens/public/shared_components/axis/types.ts`\r\nfile\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra <[email protected]>","sha":"2657b86f94f9536e2265e23a9e9e2630f8a2884b","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[Lens] Use AxisLabelOrientationSelector in xy axis settings","number":208002,"url":"https://github.com/elastic/kibana/pull/208002","mergeCommit":{"message":"[Lens] Use AxisLabelOrientationSelector in xy axis settings (elastic#208002)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/206040\r\n\r\n- Uses the `AxisLabelOrientationSelector` component, which was\r\nintroduced in [202143](https://github.com/elastic/kibana/pull/202143),\r\nin the XY chart axis settings.\r\n- Adds `AxesSettingsConfig` and `AxesSettingsConfigKeys` declarations in\r\n`x-pack/platform/plugins/shared/lens/public/shared_components/axis/types.ts`\r\nfile\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra <[email protected]>","sha":"2657b86f94f9536e2265e23a9e9e2630f8a2884b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208002","number":208002,"mergeCommit":{"message":"[Lens] Use AxisLabelOrientationSelector in xy axis settings (elastic#208002)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/206040\r\n\r\n- Uses the `AxisLabelOrientationSelector` component, which was\r\nintroduced in [202143](https://github.com/elastic/kibana/pull/202143),\r\nin the XY chart axis settings.\r\n- Adds `AxesSettingsConfig` and `AxesSettingsConfigKeys` declarations in\r\n`x-pack/platform/plugins/shared/lens/public/shared_components/axis/types.ts`\r\nfile\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Marta Bondyra <[email protected]>","sha":"2657b86f94f9536e2265e23a9e9e2630f8a2884b"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Maria Iriarte <[email protected]>
1 parent 43efa5b commit b25012d

File tree

12 files changed

+47
-90
lines changed

12 files changed

+47
-90
lines changed

x-pack/platform/plugins/private/translations/translations/fr-FR.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27008,10 +27008,6 @@
2700827008
"xpack.lens.xyChart.annotations.saveAnnotationGroupToLibrary.successToastTitle": "\"{title}\" enregistré",
2700927009
"xpack.lens.xyChart.annotations.unlinkFromLibrary": "Dissocier de la bibliothèque",
2701027010
"xpack.lens.xyChart.annotations.unlinksFromLibrary": "Enregistre le groupe d’annotations en tant que partie de l’objet Lens enregistré",
27011-
"xpack.lens.xyChart.axisOrientation.angled": "En angle",
27012-
"xpack.lens.xyChart.axisOrientation.horizontal": "Horizontal",
27013-
"xpack.lens.xyChart.axisOrientation.label": "Orientation",
27014-
"xpack.lens.xyChart.axisOrientation.vertical": "Vertical",
2701527011
"xpack.lens.xyChart.axisSide.auto": "Auto",
2701627012
"xpack.lens.xyChart.axisSide.bottom": "Bas",
2701727013
"xpack.lens.xyChart.axisSide.label": "Côté de l'axe",

x-pack/platform/plugins/private/translations/translations/ja-JP.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26870,10 +26870,6 @@
2687026870
"xpack.lens.xyChart.annotations.saveAnnotationGroupToLibrary.successToastTitle": "\"{title}\"が保存されました",
2687126871
"xpack.lens.xyChart.annotations.unlinkFromLibrary": "ライブラリからのリンクを解除",
2687226872
"xpack.lens.xyChart.annotations.unlinksFromLibrary": "注釈グループをLens保存済みオブジェクトの一部として保存します",
26873-
"xpack.lens.xyChart.axisOrientation.angled": "傾斜",
26874-
"xpack.lens.xyChart.axisOrientation.horizontal": "横",
26875-
"xpack.lens.xyChart.axisOrientation.label": "向き",
26876-
"xpack.lens.xyChart.axisOrientation.vertical": "縦",
2687726873
"xpack.lens.xyChart.axisSide.auto": "自動",
2687826874
"xpack.lens.xyChart.axisSide.bottom": "一番下",
2687926875
"xpack.lens.xyChart.axisSide.label": "軸側",

x-pack/platform/plugins/private/translations/translations/zh-CN.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26955,10 +26955,6 @@
2695526955
"xpack.lens.xyChart.annotations.saveAnnotationGroupToLibrary.successToastTitle": "已保存“{title}”",
2695626956
"xpack.lens.xyChart.annotations.unlinkFromLibrary": "取消与库的链接",
2695726957
"xpack.lens.xyChart.annotations.unlinksFromLibrary": "将标注组另存为 Lens 已保存对象的一部分",
26958-
"xpack.lens.xyChart.axisOrientation.angled": "带角度",
26959-
"xpack.lens.xyChart.axisOrientation.horizontal": "水平",
26960-
"xpack.lens.xyChart.axisOrientation.label": "方向",
26961-
"xpack.lens.xyChart.axisOrientation.vertical": "垂直",
2696226958
"xpack.lens.xyChart.axisSide.auto": "自动",
2696326959
"xpack.lens.xyChart.axisSide.bottom": "底部",
2696426960
"xpack.lens.xyChart.axisSide.label": "轴侧",

x-pack/platform/plugins/shared/lens/public/shared_components/axis/orientation/axis_label_orientation_selector.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import React from 'react';
99
import { EuiFormRow, EuiButtonGroup } from '@elastic/eui';
1010
import { i18n } from '@kbn/i18n';
11-
12-
type AxesSettingsConfigKeys = 'x' | 'yRight' | 'yLeft';
11+
import type { AxesSettingsConfigKeys } from '../types';
1312

1413
export const allowedOrientations = [0, -45, -90] as const;
1514
export type Orientation = (typeof allowedOrientations)[number];

x-pack/platform/plugins/shared/lens/public/shared_components/axis/ticks/axis_ticks_settings.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import React, { useCallback } from 'react';
99
import { EuiSwitch, EuiFormRow } from '@elastic/eui';
1010
import { i18n } from '@kbn/i18n';
11-
import type { AxesSettingsConfig } from '../../../visualizations/xy/types';
12-
13-
type AxesSettingsConfigKeys = keyof AxesSettingsConfig;
11+
import type { AxesSettingsConfigKeys } from '../types';
1412

1513
export interface AxisTicksSettingsProps {
1614
/**

x-pack/platform/plugins/shared/lens/public/shared_components/axis/title/toolbar_title_settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, { useCallback, useMemo } from 'react';
99
import { EuiSpacer, EuiFormRow } from '@elastic/eui';
1010
import { i18n } from '@kbn/i18n';
1111
import { useDebouncedValue } from '@kbn/visualization-utils';
12-
import type { AxesSettingsConfig } from '../../../visualizations/xy/types';
12+
import type { AxesSettingsConfig } from '@kbn/visualizations-plugin/common';
1313
import { type LabelMode, VisLabel } from '../..';
1414

1515
type SettingsConfigKeys = keyof AxesSettingsConfig | 'legend';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { AxesSettingsConfig } from '@kbn/visualizations-plugin/common';
9+
10+
export type AxesSettingsConfigKeys = keyof AxesSettingsConfig;

x-pack/platform/plugins/shared/lens/public/shared_components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ export { AxisLabelOrientationSelector } from './axis/orientation/axis_label_orie
3030
export * from './static_header';
3131
export * from './vis_label';
3232
export { ExperimentalBadge } from './experimental_badge';
33+
export type { AxesSettingsConfigKeys } from './axis/types';

x-pack/platform/plugins/shared/lens/public/visualizations/xy/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
IconChartBarPercentage,
3535
IconChartBarHorizontal,
3636
} from '@kbn/chart-icons';
37+
import type { AxesSettingsConfig } from '@kbn/visualizations-plugin/common';
3738

3839
import { CollapseFunction } from '../../../common/expressions';
3940
import type { VisualizationType } from '../../types';
@@ -63,11 +64,6 @@ export const defaultSeriesType = SeriesTypes.BAR_STACKED;
6364

6465
export type YAxisMode = $Values<typeof YAxisModes>;
6566
export type SeriesType = $Values<typeof SeriesTypes>;
66-
export interface AxesSettingsConfig {
67-
x: boolean;
68-
yRight: boolean;
69-
yLeft: boolean;
70-
}
7167

7268
export interface AxisConfig extends Omit<YAxisConfig, 'extent'> {
7369
extent?: AxisExtentConfig;

x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.test.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ describe('AxesSettingsPopover', () => {
6262

6363
return {
6464
renderer: renderResult,
65-
orientation: new EuiButtonGroupTestHarness('lnsXY_axisOrientation_groups'),
6665
bounds: new EuiButtonGroupTestHarness('lnsXY_axisBounds_groups'),
6766
};
6867
};
@@ -86,28 +85,33 @@ describe('AxesSettingsPopover', () => {
8685
});
8786

8887
it('should have selected the horizontal option on the orientation group', async () => {
89-
const result = await renderAxisSettingsPopover({
88+
await renderAxisSettingsPopover({
9089
useMultilayerTimeAxis: false,
9190
areTickLabelsVisible: true,
9291
});
93-
expect(result.orientation.selected).not.toBeChecked();
92+
const orientationGroup = screen.getByRole('group', { name: /orientation/i });
93+
const pressedButton = within(orientationGroup).getByRole('button', { pressed: true });
94+
expect(pressedButton.title).toBe('Horizontal');
9495
});
9596

9697
it('should have called the setOrientation function on orientation button group change', async () => {
97-
const result = await renderAxisSettingsPopover({
98+
await renderAxisSettingsPopover({
9899
useMultilayerTimeAxis: false,
99100
areTickLabelsVisible: true,
100101
});
101-
result.orientation.select('Angled');
102-
expect(defaultProps.setOrientation).toHaveBeenCalled();
102+
const orientationGroup = screen.getByRole('group', { name: /orientation/i });
103+
fireEvent.click(within(orientationGroup).getByRole('button', { name: /angled/i }));
104+
expect(defaultProps.setOrientation).toBeCalledTimes(1);
105+
expect(defaultProps.setOrientation).toBeCalledWith(defaultProps.axis, -45);
103106
});
104107

105108
it('should hide the orientation group if the tickLabels are set to not visible', async () => {
106-
const result = await renderAxisSettingsPopover({
109+
await renderAxisSettingsPopover({
107110
useMultilayerTimeAxis: false,
108111
areTickLabelsVisible: false,
109112
});
110-
expect(result.orientation.self).not.toBeInTheDocument();
113+
const orientationGroup = screen.queryByRole('group', { name: /orientation/i });
114+
expect(orientationGroup).not.toBeInTheDocument();
111115
});
112116

113117
it('hides the endzone visibility switch if no setter is passed in', async () => {

0 commit comments

Comments
 (0)