From e2dce2e13535ea14183c3760ca5cd0a35c43127d Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Tue, 28 May 2024 16:07:43 +0200 Subject: [PATCH] fix the rtl test --- .../src/components/legend/legend_item.tsx | 25 ++++++++----------- .../legend/legend_table/legend_table_item.tsx | 8 ++---- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/packages/charts/src/components/legend/legend_item.tsx b/packages/charts/src/components/legend/legend_item.tsx index 62db2010a6..5590966829 100644 --- a/packages/charts/src/components/legend/legend_item.tsx +++ b/packages/charts/src/components/legend/legend_item.tsx @@ -15,7 +15,7 @@ import { SharedLegendItemProps } from './types'; import { getExtra } from './utils'; import { LegendItem, LegendItemExtraValues, LegendValue } from '../../common/legend'; import { SeriesIdentifier } from '../../common/series_id'; -import { LayoutDirection, isDefined } from '../../utils/common'; +import { LayoutDirection } from '../../utils/common'; /** @internal */ export const LEGEND_HIERARCHY_MARGIN = 10; @@ -32,14 +32,12 @@ export const prepareLegendValues = ( totalItems: number, extraValues: Map, ) => { - return legendValues - .map((legendValue) => { - if (legendValue === LegendValue.Value || legendValue === LegendValue.CurrentAndLastValue) { - return getExtra(extraValues, item, totalItems); - } - return item.values.find(({ type }) => type === legendValue); - }) - .filter(isDefined); + return legendValues.map((legendValue) => { + if (legendValue === LegendValue.Value || legendValue === LegendValue.CurrentAndLastValue) { + return getExtra(extraValues, item, totalItems); + } + return item.values.find(({ type }) => type === legendValue); + }); }; /** @internal */ @@ -116,12 +114,9 @@ export const LegendListItem: React.FC = (props) => { totalSeriesCount={totalItems} hiddenSeriesCount={hiddenItems} /> - {!isSeriesHidden && - legendValueItems.map((legendValueItem) => ( -
- {legendValueItem.label} -
- ))} + {!isSeriesHidden && legendValueItems[0] && legendValueItems[0].label !== '' && ( +
{legendValueItems[0].label}
+ )} {Action && (
diff --git a/packages/charts/src/components/legend/legend_table/legend_table_item.tsx b/packages/charts/src/components/legend/legend_table/legend_table_item.tsx index 4bf80aa1fe..fe3ea2684c 100644 --- a/packages/charts/src/components/legend/legend_table/legend_table_item.tsx +++ b/packages/charts/src/components/legend/legend_table/legend_table_item.tsx @@ -91,12 +91,8 @@ export const LegendListItem: React.FC = (props) => { /> - {legendValueItems?.map((l, i) => { - return ( - - - - ); + {legendValueItems.map((l, i) => { + return {l && }; })} {ActionComponent && (