Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5bda2dd
change default timeAxisLayerCount to 2, update matching default styles
walterra Jan 13, 2025
3024c20
update defaults for timeAxisLayerCount
walterra Jan 13, 2025
6de88e4
update examples
walterra Jan 13, 2025
bf6f13d
fix style application
walterra Jan 14, 2025
3ddc390
refactor getAxesStylesSelector
walterra Jan 14, 2025
f406321
update snapshots
walterra Jan 14, 2025
1eb76a5
fix jest tests for axis_utils
walterra Jan 14, 2025
6206090
update packages/charts/api/charts.api.md
walterra Jan 15, 2025
507a484
apply multilayer time axis style only to xy charts with time on the x…
walterra Jan 15, 2025
bdc89a2
update snapshots
walterra Jan 15, 2025
aa75d28
tweak getAxesStylesSelector to retain original default behavior
walterra Jan 15, 2025
53bb38d
pass around scaleType to identify if x axis is of type time
walterra Jan 16, 2025
699c962
fix jest tests for axis_utils
walterra Jan 16, 2025
326cb89
fix jest tests and update snapshots for utils/dimensions
walterra Jan 17, 2025
4a6f1cb
tweak var names
walterra Jan 17, 2025
f050825
revert isVertical to vertical
walterra Jan 17, 2025
e993704
update packages/charts/api/charts.api.md
walterra Jan 17, 2025
4be69ef
pass on settingsSpec.rotation
walterra Jan 17, 2025
c52a4c1
fix x axis time scale check
walterra Jan 20, 2025
9337433
update snapshots
walterra Jan 20, 2025
5d05ade
adds checks that isMultilayerTimeAxis needs to have chart rotation of 0.
walterra Jan 20, 2025
8ba9cd8
change story axis from ordinal to time to fix padding
walterra Jan 20, 2025
12f3d3b
isMultilayerTimeAxisSelector
walterra Jan 21, 2025
925c5ba
isMultilayerTimeAxisSelector is now just isMultilayerTimeAxis in axis…
walterra Jan 21, 2025
5ef3060
provide chart rotation via settingsSpec
walterra Jan 21, 2025
3bda648
fix jest tests
walterra Jan 23, 2025
35791a0
adds jest tests for isMultilayerTimeAxisFn
walterra Jan 24, 2025
316102b
delete leftover line
walterra Jan 24, 2025
93c761f
naming tweaks
walterra Feb 7, 2025
93e77c5
pass around less heavy args
walterra Feb 7, 2025
f2645cb
refactor to individual args instead of options arg
walterra Feb 7, 2025
c6fdc74
enable histogram mode for time scales to align with the multi-layer t…
walterra Feb 20, 2025
be42e14
fix storybook stories
markov00 Mar 4, 2025
59004d5
Merge branch 'main' into remove-legacy-time-axis-support
markov00 Mar 4, 2025
4337d98
fix import
walterra Mar 5, 2025
261324f
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Mar 5, 2025
bc499cb
use mock spec
walterra Mar 11, 2025
4f9927d
use MockGlobalSpec.settings
walterra Mar 11, 2025
f161d88
remove isXAxis
walterra Mar 11, 2025
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
2 changes: 1 addition & 1 deletion docs/docs/api/specs/xy/axis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Show duplicated ticks

### `timeAxisLayerCount`
- Type: <code>timeAxisLayerCount: number</code>
- Default: `0`
- Default: `2`
- tag: `@alpha`

Render a multi-layer time axis. Use 2 or 3 as valid number of layers. Use 0 to use the alternative, one row, time axis.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions packages/charts/src/chart_types/xy_chart/axes/axes_sizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Side Public License, v 1.
*/

import type { ScaleType } from '../../../scales/constants';
import type { SmallMultiplesSpec } from '../../../specs';
import type { Rotation } from '../../../utils/common';
import { Position } from '../../../utils/common';
import type { PerSideDistance } from '../../../utils/dimensions';
import { innerPad, outerPad } from '../../../utils/dimensions';
Expand All @@ -16,7 +18,7 @@ import type { AxesTicksDimensions } from '../state/selectors/compute_axis_ticks_
import { getSpecsById } from '../state/utils/spec';
import { isHorizontalAxis, isVerticalAxis } from '../utils/axis_type_utils';
import type { TickLabelBounds } from '../utils/axis_utils';
import { getAllAxisLayersGirth, getTitleDimension, shouldShowTicks } from '../utils/axis_utils';
import { getAllAxisLayersGirth, getTitleDimension, isMultilayerTimeAxis, shouldShowTicks } from '../utils/axis_utils';
import type { AxisSpec } from '../utils/specs';

const getAxisSizeForLabel = (
Expand All @@ -25,11 +27,12 @@ const getAxisSizeForLabel = (
axesStyles: Map<AxisId, AxisStyle | null>,
{ maxLabelBboxWidth = 0, maxLabelBboxHeight = 0 }: TickLabelBounds,
smSpec: SmallMultiplesSpec | null,
multilayerTimeAxis: boolean,
) => {
const { tickLine, axisTitle, axisPanelTitle, tickLabel } = axesStyles.get(axisSpec.id) ?? sharedAxesStyles;
const horizontal = isHorizontalAxis(axisSpec.position);
const maxLabelBoxGirth = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth;
const allLayersGirth = getAllAxisLayersGirth(axisSpec.timeAxisLayerCount, maxLabelBoxGirth, horizontal);
const allLayersGirth = getAllAxisLayersGirth(axisSpec.timeAxisLayerCount, maxLabelBoxGirth, multilayerTimeAxis);
const hasPanelTitle = isVerticalAxis(axisSpec.position) ? smSpec?.splitVertically : smSpec?.splitHorizontally;
const panelTitleDimension = hasPanelTitle ? getTitleDimension(axisPanelTitle) : 0;
const titleDimension = axisSpec.title ? getTitleDimension(axisTitle) : 0;
Expand All @@ -41,7 +44,7 @@ const getAxisSizeForLabel = (
// don't overflow when the multiTimeAxis layer is used.
const maxLabelBoxHalfLength = isVerticalAxis(axisSpec.position)
? maxLabelBboxHeight / 2
: axisSpec.timeAxisLayerCount > 0
: multilayerTimeAxis
? 0
: maxLabelBboxWidth / 2;
return horizontal
Expand All @@ -66,13 +69,23 @@ export function getAxesDimensions(
axesStyles: Map<AxisId, AxisStyle | null>,
axisSpecs: AxisSpec[],
smSpec: SmallMultiplesSpec | null,
xScaleType: ScaleType,
rotation: Rotation,
): PerSideDistance & { margin: { left: number } } {
const sizes = [...axisDimensions].reduce(
(acc, [id, tickLabelBounds]) => {
const axisSpec = getSpecsById<AxisSpec>(axisSpecs, id);
if (tickLabelBounds.isHidden || !axisSpec) return acc;
const multilayerTimeAxis = isMultilayerTimeAxis(axisSpec, xScaleType, rotation);
// TODO use first and last labels
const { top, bottom, left, right } = getAxisSizeForLabel(axisSpec, theme, axesStyles, tickLabelBounds, smSpec);
const { top, bottom, left, right } = getAxisSizeForLabel(
axisSpec,
theme,
axesStyles,
tickLabelBounds,
smSpec,
multilayerTimeAxis,
);
if (isVerticalAxis(axisSpec.position)) {
acc.axisLabelOverflow.top = Math.max(acc.axisLabelOverflow.top, top);
acc.axisLabelOverflow.bottom = Math.max(acc.axisLabelOverflow.bottom, bottom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const axisSpec: AxisSpec = {
position: Position.Left,
style,
tickFormat: (value: any) => `${value}`,
timeAxisLayerCount: 0,
timeAxisLayerCount: 2,
};
axesSpecs.push(axisSpec);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface AxisProps {
debug: boolean;
renderingArea: Dimensions;
layerGirth: number;
multilayerTimeAxis: boolean;
}

/** @internal */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ export function renderTicks(ctx: CanvasRenderingContext2D, ticks: AxisTick[], ax
}

function getTickLineCoordinates(
{ position, domainClampedPosition: tickPosition, layer, detailedLayer }: AxisTick,
{
axisSpec: { position: axisPosition, timeAxisLayerCount },
size: { width, height },
axisStyle: { tickLine },
layerGirth,
}: AxisProps,
{ position, domainClampedPosition: tickPosition, layer, detailedLayer, multilayerTimeAxis }: AxisTick,
{ axisSpec, size: { width, height }, axisStyle: { tickLine }, layerGirth }: AxisProps,
): Line | undefined {
if (Math.abs(tickPosition - position) > OUTSIDE_RANGE_TOLERANCE) return;
const tickOnTheSide = timeAxisLayerCount > 0 && typeof layer === 'number';
const { position: axisPosition } = axisSpec;
const tickOnTheSide = multilayerTimeAxis && typeof layer === 'number';
const extensionLayer = tickOnTheSide ? layer + 1 : 0;
const tickSize =
tickLine.size +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export function renderTickLabel(
ctx: CanvasRenderingContext2D,
tick: AxisTick,
showTicks: boolean,
{ axisSpec: { position, timeAxisLayerCount }, dimension, size, debug, axisStyle }: AxisProps,
{ axisSpec, dimension, size, debug, axisStyle }: AxisProps,
layerGirth: number,
) {
const { position } = axisSpec;
const labelStyle = axisStyle.tickLabel;
const tickLabelProps = getTickLabelPosition(
axisStyle,
Expand All @@ -48,7 +49,7 @@ export function renderTickLabel(
}
}

const tickOnTheSide = timeAxisLayerCount > 0 && Number.isFinite(tick.layer);
const tickOnTheSide = tick.multilayerTimeAxis && Number.isFinite(tick.layer);

renderText(
ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function renderGridPanels(ctx: CanvasRenderingContext2D, { x: chartX, y:
}

function renderPanel(ctx: CanvasRenderingContext2D, props: AxisProps, locale: string) {
const { size, anchorPoint, debug, axisStyle, axisSpec, panelAnchor, secondary } = props;
const { size, anchorPoint, debug, axisStyle, axisSpec, panelAnchor, secondary, multilayerTimeAxis } = props;
const { position } = axisSpec;
const x = anchorPoint.x + (position === Position.Right ? -1 : 1) * panelAnchor.x;
const y = anchorPoint.y + (position === Position.Bottom ? -1 : 1) * panelAnchor.y;
Expand All @@ -49,7 +49,16 @@ function renderPanel(ctx: CanvasRenderingContext2D, props: AxisProps, locale: st
renderTitle(
ctx,
true,
{ panelTitle, axisSpec, axisStyle, size, dimension, debug, anchorPoint: { x: 0, y: 0 } },
{
panelTitle,
axisSpec,
axisStyle,
size,
multilayerTimeAxis,
dimension,
debug,
anchorPoint: { x: 0, y: 0 },
},
locale,
); // TODO: should we use the axisSpec/Style for the title of small multiple or use their own style?
}
Expand All @@ -64,7 +73,7 @@ export function renderPanelSubstrates(ctx: CanvasRenderingContext2D, props: Axes
perPanelAxisGeoms.forEach(({ axesGeoms, panelAnchor }) => {
axesGeoms.forEach((geometry) => {
const {
axis: { panelTitle, id, position, secondary },
axis: { panelTitle, id, position, secondary, multilayerTimeAxis },
anchorPoint,
size,
dimension,
Expand All @@ -84,7 +93,16 @@ export function renderPanelSubstrates(ctx: CanvasRenderingContext2D, props: Axes
renderTitle(
ctx,
false,
{ size: parentSize, debug, panelTitle, anchorPoint, dimension, axisStyle, axisSpec },
{
size: parentSize,
debug,
panelTitle,
anchorPoint,
dimension,
axisStyle,
axisSpec,
multilayerTimeAxis,
},
locale,
);
}
Expand All @@ -106,6 +124,7 @@ export function renderPanelSubstrates(ctx: CanvasRenderingContext2D, props: Axes
debug,
renderingArea,
layerGirth,
multilayerTimeAxis,
},
locale,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { isHorizontalAxis } from '../../../utils/axis_type_utils';
import { getAllAxisLayersGirth, getTitleDimension, shouldShowTicks } from '../../../utils/axis_utils';
import type { AxisProps } from '../axes/axis_props';

type PanelTitleProps = Pick<AxisProps, 'panelTitle' | 'axisSpec' | 'axisStyle' | 'size' | 'dimension' | 'debug'>;
type PanelTitleProps = Pick<
AxisProps,
'panelTitle' | 'axisSpec' | 'axisStyle' | 'size' | 'dimension' | 'debug' | 'multilayerTimeAxis'
>;
type TitleProps = PanelTitleProps & { anchorPoint: Point };

const titleFontDefaults: Omit<TextFont, 'fontFamily' | 'textColor' | 'fontSize'> = {
Expand All @@ -36,14 +39,16 @@ export function renderTitle(
{
size: { width, height },
dimension: { maxLabelBboxWidth, maxLabelBboxHeight },
axisSpec: { position, hide: hideAxis, title, timeAxisLayerCount },
axisSpec,
axisStyle: { axisPanelTitle, axisTitle, tickLabel, tickLine },
panelTitle,
debug,
anchorPoint,
multilayerTimeAxis,
}: TitleProps,
locale: string,
) {
const { position, hide: hideAxis, title, timeAxisLayerCount } = axisSpec;
const titleToRender = panel ? panelTitle : title;
const axisTitleToUse = panel ? axisPanelTitle : axisTitle;
if (!titleToRender || !axisTitleToUse.visible) {
Expand All @@ -55,7 +60,7 @@ export function renderTitle(
const font: TextFont = { ...titleFontDefaults, ...axisTitleToUse, textColor: axisTitleToUse.fill };
const tickDimension = shouldShowTicks(tickLine, hideAxis) ? tickLine.size + tickLine.padding : 0;
const maxLabelBoxGirth = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth;
const allLayersGirth = getAllAxisLayersGirth(timeAxisLayerCount, maxLabelBoxGirth, horizontal);
const allLayersGirth = getAllAxisLayersGirth(timeAxisLayerCount, maxLabelBoxGirth, multilayerTimeAxis);
const labelPaddingSum = innerPad(tickLabel.padding) + outerPad(tickLabel.padding);
const labelSize = tickLabel.visible ? allLayersGirth + labelPaddingSum : 0;
const otherTitleDimension = otherTitle ? getTitleDimension(otherAxisTitleToUse) : 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/src/chart_types/xy_chart/specs/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const Axis = specComponentFactory<AxisSpec>()(
showOverlappingTicks: false,
showOverlappingLabels: false,
position: Position.Left,
timeAxisLayerCount: 0,
timeAxisLayerCount: 2,
},
);

Expand Down
9 changes: 8 additions & 1 deletion packages/charts/src/chart_types/xy_chart/specs/bar_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export const BarSeries = function <D extends BaseDatum = Datum>(
>,
) {
const { defaults, overrides } = buildProps;
useSpecFactory<BarSeriesSpec<D>>({ ...defaults, ...stripUndefined(props), ...overrides });
const constraints: Pick<typeof props, 'enableHistogramMode'> = {};

// enable histogram mode for time scales to align with the multi-layer time axis.
if (props.xScaleType === ScaleType.Time) {
constraints.enableHistogramMode = true;
}

useSpecFactory<BarSeriesSpec<D>>({ ...defaults, ...stripUndefined(props), ...overrides, ...constraints });
return null;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ describe('Chart state pointer interactions', () => {
showOverlappingLabels: false,
showOverlappingTicks: false,
style,
timeAxisLayerCount: 0,
timeAxisLayerCount: 2,
};
bottomAxis = {
chartType: ChartType.XYAxis,
Expand All @@ -780,7 +780,7 @@ describe('Chart state pointer interactions', () => {
showOverlappingLabels: false,
showOverlappingTicks: false,
style,
timeAxisLayerCount: 0,
timeAxisLayerCount: 2,
};
currentSettingSpec = getSettingsSpecSelector(store.getState());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/

import { computeChartDimensionsSelector } from './compute_chart_dimensions';
import { getScaleConfigsFromSpecsSelector } from './get_api_scale_configs';
import { getAxesStylesSelector } from './get_axis_styles';
import { axisSpecsLookupSelector } from './get_specs';
import { getVisibleTickSetsSelector } from './visible_ticks';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { computeSmallMultipleScalesSelector } from '../../../../state/selectors/compute_small_multiple_scales';
import { getChartThemeSelector } from '../../../../state/selectors/get_chart_theme';
import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_spec';
import { getAxesGeometries } from '../../utils/axis_utils';

/** @internal */
Expand All @@ -24,6 +26,8 @@ export const computeAxesGeometriesSelector = createCustomCachedSelector(
getAxesStylesSelector,
computeSmallMultipleScalesSelector,
getVisibleTickSetsSelector,
getScaleConfigsFromSpecsSelector,
getSettingsSpecSelector,
],
getAxesGeometries,
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*/

import { computeAxisTicksDimensionsSelector } from './compute_axis_ticks_dimensions';
import { getScaleConfigsFromSpecsSelector } from './get_api_scale_configs';
import { getAxesStylesSelector } from './get_axis_styles';
import { getAxisSpecsSelector } from './get_specs';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { getChartContainerDimensionsSelector } from '../../../../state/selectors/get_chart_container_dimensions';
import { getChartThemeSelector } from '../../../../state/selectors/get_chart_theme';
import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_spec';
import { getSmallMultiplesSpec } from '../../../../state/selectors/get_small_multiples_spec';
import { computeChartDimensions } from '../../utils/dimensions';

Expand All @@ -24,6 +26,8 @@ export const computeChartDimensionsSelector = createCustomCachedSelector(
getAxesStylesSelector,
getAxisSpecsSelector,
getSmallMultiplesSpec,
getScaleConfigsFromSpecsSelector,
getSettingsSpecSelector,
],
computeChartDimensions,
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,55 @@
* Side Public License, v 1.
*/

import { getScaleConfigsFromSpecsSelector } from './get_api_scale_configs';
import { getAxisSpecsSelector } from './get_specs';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { getChartThemeSelector } from '../../../../state/selectors/get_chart_theme';
import { mergePartial } from '../../../../utils/common';
import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_spec';
import type { RecursivePartial } from '../../../../utils/common';
import { mergePartial, Position } from '../../../../utils/common';
import type { AxisId } from '../../../../utils/ids';
import type { AxisStyle } from '../../../../utils/themes/theme';
import { isVerticalAxis } from '../../utils/axis_type_utils';
import { isMultilayerTimeAxis } from '../../utils/axis_utils';

const MULTILAYER_TIME_AXIS_STYLE: RecursivePartial<AxisStyle> = {
tickLabel: {
visible: true,
padding: 0,
rotation: 0,
alignment: {
vertical: Position.Bottom,
horizontal: Position.Left,
},
},
tickLine: {
visible: true,
size: 0,
padding: 4,
},
};

/** @internal */
export const getAxesStylesSelector = createCustomCachedSelector(
[getAxisSpecsSelector, getChartThemeSelector],
(axesSpecs, { axes: sharedAxesStyle }): Map<AxisId, AxisStyle | null> =>
axesSpecs.reduce((axesStyles, { id, style, gridLine, position }) => {
const gridStyle = gridLine && { gridLine: { [isVerticalAxis(position) ? 'vertical' : 'horizontal']: gridLine } };
return axesStyles.set(id, style ? mergePartial(sharedAxesStyle, { ...style, ...gridStyle }) : null);
[getAxisSpecsSelector, getChartThemeSelector, getScaleConfigsFromSpecsSelector, getSettingsSpecSelector],
(axesSpecs, { axes: sharedAxesStyle }, scaleConfigs, settingsSpec): Map<AxisId, AxisStyle | null> =>
axesSpecs.reduce((axesStyles, axisSpec) => {
const { id, position, style, gridLine } = axisSpec;
let mergedStyle: AxisStyle | null = null;

// apply multilayer time axis style to xy charts with time on the x axis.
if (isMultilayerTimeAxis(axisSpec, scaleConfigs.x.type, settingsSpec.rotation)) {
mergedStyle = mergePartial(sharedAxesStyle, MULTILAYER_TIME_AXIS_STYLE);
}

if (style) {
const gridStyle = gridLine && {
gridLine: { [isVerticalAxis(position) ? 'vertical' : 'horizontal']: gridLine },
};
mergedStyle = mergePartial(mergedStyle ?? sharedAxesStyle, { ...style, ...gridStyle });
}

return axesStyles.set(id, mergedStyle);
}, new Map()),
);
Loading