@mui/x-charts
Version:
The community edition of MUI X Charts components.
41 lines (38 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSeriesHighlightedItem = getSeriesHighlightedItem;
exports.getSeriesUnfadedItem = getSeriesUnfadedItem;
exports.isSeriesFaded = isSeriesFaded;
exports.isSeriesHighlighted = isSeriesHighlighted;
function isSeriesHighlighted(scope, item, seriesId) {
return scope?.highlight === 'series' && item?.seriesId === seriesId;
}
function isSeriesFaded(scope, item, seriesId) {
if (isSeriesHighlighted(scope, item, seriesId)) {
return false;
}
return scope?.fade === 'global' && item != null || scope?.fade === 'series' && item?.seriesId === seriesId;
}
/**
* Returns the data index of the highlighted item for a specific series.
* If the item is not highlighted, it returns `null`.
*/
function getSeriesHighlightedItem(scope, item, seriesId) {
return scope?.highlight === 'item' && item?.seriesId === seriesId ? item.dataIndex : null;
}
/**
* Returns the data index of the "unfaded item" for a specific series.
* An "unfaded item" is the only item of a faded series that shouldn't be faded.
* If the series is not faded or if there is no highlighted item, it returns `null`.
*/
function getSeriesUnfadedItem(scope, item, seriesId) {
if (isSeriesHighlighted(scope, item, seriesId)) {
return null;
}
if (getSeriesHighlightedItem(scope, item, seriesId) === item?.dataIndex) {
return null;
}
return (scope?.fade === 'series' || scope?.fade === 'global') && item?.seriesId === seriesId ? item.dataIndex : null;
}