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 9e3ec3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
31 changes: 16 additions & 15 deletions packages/charts/src/components/legend/legend_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -67,7 +65,7 @@ export const LegendListItem: React.FC<LegendItemProps> = (props) => {
'echLegendItem--vertical': positionConfig.direction === LayoutDirection.Vertical,
});

const legendValueItems = prepareLegendValues(item, legendValues, totalItems, extraValues);
const legendValueItems = prepareLegendValues(item, legendValues, totalItems, extraValues).filter(isDefined);

const style: CSSProperties = flatLegend
? {}
Expand Down Expand Up @@ -116,12 +114,15 @@ 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.map((legendValueItem) =>
legendValueItem.label !== '' ? (
<div key={legendValueItem.label} className="echLegendItem__legendValue">
{legendValueItem.label}
</div>
) : null,
)
: null}
{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 9e3ec3f

Please sign in to comment.