UNPKG

@mui/x-charts

Version:

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

68 lines (67 loc) 1.67 kB
import * as React from 'react'; import { styled } from '@mui/material/styles'; import { useChartRootRef } from "../../../hooks/useChartRootRef.js"; import { jsx as _jsx } from "react/jsx-runtime"; const getDirection = (direction, position) => { if (direction === 'vertical') { if (position?.horizontal === 'start') { return 'row'; } return 'row-reverse'; } if (position?.vertical === 'bottom') { return 'column-reverse'; } return 'column'; }; const getAlign = (direction, position) => { if (direction === 'vertical') { if (position?.vertical === 'top') { return 'flex-start'; } if (position?.vertical === 'bottom') { return 'flex-end'; } } if (direction === 'horizontal') { if (position?.horizontal === 'start') { return 'flex-start'; } if (position?.horizontal === 'end') { return 'flex-end'; } } return 'center'; }; const Root = styled('div', { name: 'MuiChartsWrapper', slot: 'Root' })(({ ownerState }) => ({ display: 'flex', flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition), flex: 1, justifyContent: 'center', alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition) })); /** * @ignore - internal component. * * Wrapper for the charts components. * Its main purpose is to position the HTML legend in the correct place. */ function ChartsWrapper(props) { const { children, sx } = props; const chartRootRef = useChartRootRef(); return /*#__PURE__*/_jsx(Root, { ref: chartRootRef, ownerState: props, sx: sx, children: children }); } export { ChartsWrapper };