@mui/x-charts
Version:
The community edition of MUI X Charts components.
24 lines (23 loc) • 669 B
JavaScript
function alwaysFalse() {
return false;
}
/**
* The isHighlighted logic for main charts (those that are identified by an id and a dataIndex)
*/
export function createIsHighlighted(highlightScope, highlightedItem) {
if (!highlightScope || !highlightedItem) {
return alwaysFalse;
}
return function isHighlighted(item) {
if (!item) {
return false;
}
if (highlightScope.highlight === 'series') {
return item.seriesId === highlightedItem.seriesId;
}
if (highlightScope.highlight === 'item') {
return item.dataIndex === highlightedItem.dataIndex && item.seriesId === highlightedItem.seriesId;
}
return false;
};
}