diff --git a/integration/tests/__image_snapshots__/axis-stories-test-ts-axis-stories-should-render-correctly-rotated-ticks-1-snap.png b/integration/tests/__image_snapshots__/axis-stories-test-ts-axis-stories-should-render-correctly-rotated-ticks-1-snap.png new file mode 100644 index 0000000000..4ab4dd75c8 Binary files /dev/null and b/integration/tests/__image_snapshots__/axis-stories-test-ts-axis-stories-should-render-correctly-rotated-ticks-1-snap.png differ diff --git a/integration/tests/axis_stories.test.ts b/integration/tests/axis_stories.test.ts index bddc5c1504..f587283501 100644 --- a/integration/tests/axis_stories.test.ts +++ b/integration/tests/axis_stories.test.ts @@ -70,4 +70,10 @@ describe('Axis stories', () => { 'http://localhost:9001/?path=/story/axes--duplicate-ticks&knob-formatter=hourly&knob-Show duplicate ticks in x axis=true', ); }); + + it('should render correctly rotated ticks', async () => { + await common.expectChartAtUrlToMatchScreenshot( + 'http://localhost:9001/?path=/story/axes--tick-label-rotation&knob-debug_general=true&knob-disable%20axis%20overrides_general=false&knob-Tick%20label%20rotation_bottom=47&knob-Tick%20label%20rotation_left=-54&knob-Tick%20label%20rotation_top=69&knob-Tick%20label%20rotation_right=48&knob-Tick%20label%20rotation_shared=30', + ); + }); }); diff --git a/src/chart_types/xy_chart/state/selectors/compute_axis_ticks_dimensions.ts b/src/chart_types/xy_chart/state/selectors/compute_axis_ticks_dimensions.ts index 1a1b78302e..555adaf468 100644 --- a/src/chart_types/xy_chart/state/selectors/compute_axis_ticks_dimensions.ts +++ b/src/chart_types/xy_chart/state/selectors/compute_axis_ticks_dimensions.ts @@ -32,6 +32,7 @@ import { } from '../../utils/axis_utils'; import { computeSeriesDomainsSelector } from './compute_series_domains'; import { countBarsInClusterSelector } from './count_bars_in_cluster'; +import { getAxesStylesSelector } from './get_axis_styles'; import { getBarPaddingsSelector } from './get_bar_paddings'; import { getAxisSpecsSelector, getSeriesSpecsSelector } from './get_specs'; import { isHistogramModeEnabledSelector } from './is_histogram_mode_enabled'; @@ -47,6 +48,7 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector( computeSeriesDomainsSelector, countBarsInClusterSelector, getSeriesSpecsSelector, + getAxesStylesSelector, ], ( barsPadding, @@ -57,6 +59,7 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector( seriesDomainsAndData, totalBarsInCluster, seriesSpecs, + axesStyles, ): Map => { const { xDomain, yDomain } = seriesDomainsAndData; const fallBackTickFormatter = seriesSpecs.find(({ tickFormat }) => tickFormat)?.tickFormat ?? defaultTickFormatter; @@ -64,6 +67,7 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector( const axesTicksDimensions: Map = new Map(); axesSpecs.forEach((axisSpec) => { const { id } = axisSpec; + const axisStyle = axesStyles.get(id) ?? chartTheme.axes; const dimensions = computeAxisTicksDimensions( axisSpec, xDomain, @@ -71,7 +75,7 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector( totalBarsInCluster, bboxCalculator, settingsSpec.rotation, - chartTheme.axes, + axisStyle, fallBackTickFormatter, barsPadding, isHistogramMode,