VizLegend: Omit sectionRight when no right axis exists (#76923)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
co-authored by
Torkel Ödegaard
parent
b0eeeb9404
commit
344e99e069
@@ -56,26 +56,25 @@ export const VizLegendList = <T extends unknown>({
|
||||
}
|
||||
case 'bottom':
|
||||
default: {
|
||||
const leftItems = items.filter((item) => item.yAxis === 1);
|
||||
const rightItems = items.filter((item) => item.yAxis !== 1);
|
||||
|
||||
const renderItem = (item: VizLegendItem<T>, index: number) => {
|
||||
return <span className={styles.itemBottom}>{itemRenderer!(item, index)}</span>;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cx(styles.bottomWrapper, className)}>
|
||||
<div className={styles.section}>
|
||||
<InlineList
|
||||
items={items.filter((item) => item.yAxis === 1)}
|
||||
renderItem={renderItem}
|
||||
getItemKey={getItemKey}
|
||||
/>
|
||||
</div>
|
||||
<div className={cx(styles.section, styles.sectionRight)}>
|
||||
<InlineList
|
||||
items={items.filter((item) => item.yAxis !== 1)}
|
||||
renderItem={renderItem}
|
||||
getItemKey={getItemKey}
|
||||
/>
|
||||
</div>
|
||||
{leftItems.length > 0 && (
|
||||
<div className={styles.section}>
|
||||
<InlineList items={leftItems} renderItem={renderItem} getItemKey={getItemKey} />
|
||||
</div>
|
||||
)}
|
||||
{rightItems.length > 0 && (
|
||||
<div className={cx(styles.section, styles.sectionRight)}>
|
||||
<InlineList items={rightItems} renderItem={renderItem} getItemKey={getItemKey} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user