@mui/x-charts
Version:
The community edition of the charts components (MUI X).
61 lines (60 loc) • 1.94 kB
JavaScript
import * as React from 'react';
import useForkRef from '@mui/utils/useForkRef';
import { DrawingProvider } from '../context/DrawingProvider';
import { SeriesContextProvider } from '../context/SeriesContextProvider';
import { InteractionProvider } from '../context/InteractionProvider';
import { useReducedMotion } from '../hooks/useReducedMotion';
import { ChartsSurface } from '../ChartsSurface';
import { CartesianContextProvider } from '../context/CartesianContextProvider';
import { HighlightProvider } from '../context/HighlightProvider';
import { jsx as _jsx } from "react/jsx-runtime";
export const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
const {
width,
height,
series,
margin,
xAxis,
yAxis,
colors,
dataset,
sx,
title,
desc,
disableAxisListener,
children
} = props;
const svgRef = React.useRef(null);
const handleRef = useForkRef(ref, svgRef);
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
return /*#__PURE__*/_jsx(DrawingProvider, {
width: width,
height: height,
margin: margin,
svgRef: svgRef,
children: /*#__PURE__*/_jsx(SeriesContextProvider, {
series: series,
colors: colors,
dataset: dataset,
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
xAxis: xAxis,
yAxis: yAxis,
dataset: dataset,
children: /*#__PURE__*/_jsx(InteractionProvider, {
children: /*#__PURE__*/_jsx(HighlightProvider, {
children: /*#__PURE__*/_jsx(ChartsSurface, {
width: width,
height: height,
ref: handleRef,
sx: sx,
title: title,
desc: desc,
disableAxisListener: disableAxisListener,
children: children
})
})
})
})
})
});
});