Skip to content

Commit

Permalink
fix the rtl test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed May 28, 2024
1 parent ec3a272 commit e2dce2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
25 changes: 10 additions & 15 deletions packages/charts/src/components/legend/legend_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,14 +32,12 @@ export const prepareLegendValues = (
totalItems: number,
extraValues: Map<string, LegendItemExtraValues>,
) => {
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 */
Expand Down Expand Up @@ -116,12 +114,9 @@ export const LegendListItem: React.FC<LegendItemProps> = (props) => {
totalSeriesCount={totalItems}
hiddenSeriesCount={hiddenItems}
/>
{!isSeriesHidden &&
legendValueItems.map((legendValueItem) => (
<div key={legendValueItem.label} className="echLegendItem__legendValue">
{legendValueItem.label}
</div>
))}
{!isSeriesHidden && legendValueItems[0] && legendValueItems[0].label !== '' && (
<div className="echLegendItem__legendValue">{legendValueItems[0].label}</div>
)}
{Action && (
<div className="echLegendItem__action">
<Action series={seriesIdentifiers} color={color} label={label} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ export const LegendListItem: React.FC<LegendItemProps> = (props) => {
/>
</LegendTableCell>

{legendValueItems?.map((l, i) => {
return (
<LegendTableCell key={l?.type || i}>
<LegendValueComponent {...l} />
</LegendTableCell>
);
{legendValueItems.map((l, i) => {
return <LegendTableCell key={l?.type || i}>{l && <LegendValueComponent {...l} />}</LegendTableCell>;
})}
{ActionComponent && (
<LegendTableCell>
Expand Down

0 comments on commit e2dce2e

Please sign in to comment.