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

fix(axis): style overrides not applied to axis dimensions #829

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions integration/tests/axis_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -47,6 +48,7 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector(
computeSeriesDomainsSelector,
countBarsInClusterSelector,
getSeriesSpecsSelector,
getAxesStylesSelector,
],
(
barsPadding,
Expand All @@ -57,21 +59,23 @@ export const computeAxisTicksDimensionsSelector = createCachedSelector(
seriesDomainsAndData,
totalBarsInCluster,
seriesSpecs,
axesStyles,
): Map<AxisId, AxisTicksDimensions> => {
const { xDomain, yDomain } = seriesDomainsAndData;
const fallBackTickFormatter = seriesSpecs.find(({ tickFormat }) => tickFormat)?.tickFormat ?? defaultTickFormatter;
const bboxCalculator = new CanvasTextBBoxCalculator();
const axesTicksDimensions: Map<AxisId, AxisTicksDimensions> = new Map();
axesSpecs.forEach((axisSpec) => {
const { id } = axisSpec;
const axisStyle = axesStyles.get(id) ?? chartTheme.axes;
const dimensions = computeAxisTicksDimensions(
axisSpec,
xDomain,
yDomain,
totalBarsInCluster,
bboxCalculator,
settingsSpec.rotation,
chartTheme.axes,
axisStyle,
fallBackTickFormatter,
barsPadding,
isHistogramMode,
Expand Down