@mui/x-charts
Version:
The community edition of MUI X Charts components.
52 lines (45 loc) • 1.48 kB
JavaScript
'use client';
import { useSeriesOfType, useAllSeriesOfType } from "../internals/seriesSelectorOfType.mjs";
import { useStore } from "../internals/store/useStore.mjs";
import { selectorChartSeriesLayout } from "../internals/plugins/corePlugins/useChartSeries/index.mjs";
/**
* Get access to the internal state of pie series.
*
* @param {SeriesId} seriesId The id of the series to get.
* @returns {UsePieSeriesReturnValue} the pie series
*/
/**
* Get access to the internal state of pie series.
*
* When called without arguments, it returns all pie series.
*
* @returns {UsePieSeriesReturnValue[]} the pie series
*/
/**
* Get access to the internal state of pie series.
*
* @param {SeriesId[]} seriesIds The ids of the series to get. Order is preserved.
* @returns {UsePieSeriesReturnValue[]} the pie series
*/
export function usePieSeries(seriesIds) {
return useSeriesOfType('pie', seriesIds);
}
/**
* Get access to the internal state of pie series.
* The returned object contains:
* - series: a mapping from ids to series attributes.
* - seriesOrder: the array of series ids.
* @returns the pie series
*/
export function usePieSeriesContext() {
return useAllSeriesOfType('pie');
}
/**
* Get access to the pie layout.
* @returns {Record<SeriesId, PieSeriesLayout>} the pie layout
*/
export function usePieSeriesLayout() {
const store = useStore();
const seriesLayout = store.use(selectorChartSeriesLayout);
return seriesLayout.pie ?? {};
}