UNPKG

@mui/x-charts

Version:

The community edition of the Charts components (MUI X).

31 lines 1.13 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from 'react'; import { ChartsLoadingOverlay } from './ChartsLoadingOverlay'; import { useSeries } from '../hooks/useSeries'; import { ChartsNoDataOverlay } from './ChartsNoDataOverlay'; import { jsx as _jsx } from "react/jsx-runtime"; export function useNoData() { const seriesPerType = useSeries(); return Object.values(seriesPerType).every(seriesOfGivenType => { if (!seriesOfGivenType) { return true; } const { series, seriesOrder } = seriesOfGivenType; return seriesOrder.every(seriesId => series[seriesId].data.length === 0); }); } export function ChartsOverlay(props) { const noData = useNoData(); if (props.loading) { const LoadingOverlay = props.slots?.loadingOverlay ?? ChartsLoadingOverlay; return /*#__PURE__*/_jsx(LoadingOverlay, _extends({}, props.slotProps?.loadingOverlay)); } if (noData) { const NoDataOverlay = props.slots?.noDataOverlay ?? ChartsNoDataOverlay; return /*#__PURE__*/_jsx(NoDataOverlay, _extends({}, props.slotProps?.noDataOverlay)); } return null; }