@mui/x-charts
Version:
The community edition of MUI X Charts components.
23 lines (22 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getNextNonEmptySeries = getNextNonEmptySeries;
var _getNonEmptySeriesArray = require("./getNonEmptySeriesArray");
/**
* Returns the next series type and id that contains some data.
* Returns `null` if no other series have data.
* @param series - The processed series from the store.
* @param availableSeriesTypes - The set of series types that can be focused.
* @param type - The current series type.
* @param seriesId - The current series id.
*/
function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
const nonEmptySeries = (0, _getNonEmptySeriesArray.getNonEmptySeriesArray)(series, availableSeriesTypes);
if (nonEmptySeries.length === 0) {
return null;
}
const currentSeriesIndex = type !== undefined && seriesId !== undefined ? nonEmptySeries.findIndex(seriesItem => seriesItem.type === type && seriesItem.seriesId === seriesId) : -1;
return nonEmptySeries[(currentSeriesIndex + 1) % nonEmptySeries.length];
}