UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

124 lines (123 loc) 3.98 kB
'use client'; import PropTypes from 'prop-types'; import { PieArcPlot } from "./PieArcPlot.js"; import { PieArcLabelPlot } from "./PieArcLabelPlot.js"; import { usePieSeriesContext, usePieSeriesLayout } from "../hooks/usePieSeries.js"; import { useSkipAnimation } from "../hooks/useSkipAnimation.js"; import { useUtilityClasses } from "./pieClasses.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** * Demos: * * - [Pie](https://mui.com/x/react-charts/pie/) * - [Pie demonstration](https://mui.com/x/react-charts/pie-demo/) * * API: * * - [PiePlot API](https://mui.com/x/api/charts/pie-plot/) */ function PiePlot(props) { const { skipAnimation: inSkipAnimation, slots, slotProps, onItemClick } = props; const seriesData = usePieSeriesContext(); const seriesLayout = usePieSeriesLayout(); const skipAnimation = useSkipAnimation(inSkipAnimation); const classes = useUtilityClasses(); if (seriesData === undefined) { return null; } const { series, seriesOrder } = seriesData; return /*#__PURE__*/_jsxs("g", { children: [seriesOrder.map(seriesId => { const { cornerRadius, paddingAngle, data, highlighted, faded } = series[seriesId]; return /*#__PURE__*/_jsx("g", { className: classes.series, transform: `translate(${seriesLayout[seriesId].center.x}, ${seriesLayout[seriesId].center.y})`, "data-series": seriesId, children: /*#__PURE__*/_jsx(PieArcPlot, { innerRadius: seriesLayout[seriesId].radius.inner, outerRadius: seriesLayout[seriesId].radius.outer, cornerRadius: cornerRadius, paddingAngle: paddingAngle, id: seriesId, data: data, skipAnimation: skipAnimation, highlighted: highlighted, faded: faded, onItemClick: onItemClick, slots: slots, slotProps: slotProps }) }, seriesId); }), seriesOrder.map(seriesId => { const { cornerRadius, paddingAngle, arcLabel, arcLabelMinAngle, data } = series[seriesId]; return /*#__PURE__*/_jsx("g", { className: classes.seriesLabels, transform: `translate(${seriesLayout[seriesId].center.x}, ${seriesLayout[seriesId].center.y})`, "data-series": seriesId, children: /*#__PURE__*/_jsx(PieArcLabelPlot, { innerRadius: seriesLayout[seriesId].radius.inner, outerRadius: seriesLayout[seriesId].radius.outer, arcLabelRadius: seriesLayout[seriesId].radius.label, cornerRadius: cornerRadius, paddingAngle: paddingAngle, id: seriesId, data: data, skipAnimation: skipAnimation, arcLabel: arcLabel, arcLabelMinAngle: arcLabelMinAngle, slots: slots, slotProps: slotProps }) }, seriesId); })] }); } process.env.NODE_ENV !== "production" ? PiePlot.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- /** * Callback fired when a pie item is clicked. * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback. * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier. * @param {DefaultizedPieValueType} item The pie item. */ onItemClick: PropTypes.func, /** * If `true`, animations are skipped. * @default false */ skipAnimation: PropTypes.bool, /** * The props used for each component slot. * @default {} */ slotProps: PropTypes.object, /** * Overridable component slots. * @default {} */ slots: PropTypes.object } : void 0; export { PiePlot };