Skip to content

Commit

Permalink
Fixed types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Apr 27, 2022
1 parent d04a78b commit 867d3da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export interface LegendLocationSettingsProps {
/**
* Sets the vertical alignment for legend inside chart
*/
verticalAlignment?: VerticalAlignment;
verticalAlignment?: typeof VerticalAlignment.Top | typeof VerticalAlignment.Bottom;
/**
* Sets the vertical alignment for legend inside chart
*/
horizontalAlignment?: HorizontalAlignment;
horizontalAlignment?: typeof HorizontalAlignment.Left | typeof HorizontalAlignment.Right;
/**
* Callback on horizontal alignment option change
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export interface LegendSettingsPopoverProps {
/**
* Sets the vertical alignment for legend inside chart
*/
verticalAlignment?: VerticalAlignment;
verticalAlignment?: typeof VerticalAlignment.Top | typeof VerticalAlignment.Bottom;
/**
* Sets the vertical alignment for legend inside chart
*/
horizontalAlignment?: HorizontalAlignment;
horizontalAlignment?: typeof HorizontalAlignment.Left | typeof HorizontalAlignment.Right;
/**
* Callback on horizontal alignment option change
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React, { memo, useCallback } from 'react';
import { i18n } from '@kbn/i18n';
import { Position, ScaleType, VerticalAlignment, HorizontalAlignment } from '@elastic/charts';
import { Position, ScaleType } from '@elastic/charts';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { AxesSettingsConfig, AxisExtentConfig } from '@kbn/expression-xy-plugin/common';
import type { VisualizationToolbarProps, FramePublicAPI } from '../../types';
Expand All @@ -21,6 +21,7 @@ import { getScaleType } from '../to_expression';
import { TooltipWrapper } from '../../shared_components';
import { getDefaultVisualValuesForLayer } from '../../shared_components/datasource_default_values';
import { getDataLayers } from '../visualization_helpers';
import { LegendSettingsPopoverProps } from '../../shared_components/legend_settings_popover';

type UnwrapArray<T> = T extends Array<infer P> ? P : T;
type AxesSettingsConfigKeys = keyof AxesSettingsConfig;
Expand Down Expand Up @@ -380,8 +381,10 @@ export const XyToolbar = memo(function XyToolbar(
}}
onAlignmentChange={(value) => {
const [vertical, horizontal] = value.split('_');
const verticalAlignment = vertical as VerticalAlignment;
const horizontalAlignment = horizontal as HorizontalAlignment;
const verticalAlignment = vertical as LegendSettingsPopoverProps['verticalAlignment'];
const horizontalAlignment =
horizontal as LegendSettingsPopoverProps['horizontalAlignment'];

setState({
...state,
legend: { ...state.legend, verticalAlignment, horizontalAlignment },
Expand Down

0 comments on commit 867d3da

Please sign in to comment.