132 lines
4.3 KiB
JavaScript
132 lines
4.3 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { defaultSlotsMaterial } from "../internals/material/index.js";
|
|
import { ChartsSlotsProvider } from "../context/ChartsSlotsContext.js";
|
|
import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
|
|
import { ChartProvider } from "../context/ChartProvider/index.js";
|
|
import { ChartsLocalizationProvider } from "../ChartsLocalizationProvider/index.js";
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
/**
|
|
* Orchestrates the data providers for the chart components and hooks.
|
|
*
|
|
* Use this component if you have custom HTML components that need to access the chart data.
|
|
*
|
|
* Demos:
|
|
*
|
|
* - [Composition](https://mui.com/x/react-charts/composition/)
|
|
*
|
|
* API:
|
|
*
|
|
* - [ChartDataProvider API](https://mui.com/x/api/charts/chart-data-provider/)
|
|
*
|
|
* @example
|
|
* ```jsx
|
|
* <ChartDataProvider
|
|
* series={[{ label: "Label", type: "bar", data: [10, 20] }]}
|
|
* xAxis={[{ data: ["A", "B"], scaleType: "band", id: "x-axis" }]}
|
|
* >
|
|
* <ChartsSurface>
|
|
* <BarPlot />
|
|
* <ChartsXAxis axisId="x-axis" />
|
|
* </ChartsSurface>
|
|
* {'Custom Legend Component'}
|
|
* </ChartDataProvider>
|
|
* ```
|
|
*/
|
|
function ChartDataProvider(props) {
|
|
const {
|
|
children,
|
|
localeText,
|
|
chartProviderProps,
|
|
slots,
|
|
slotProps
|
|
} = useChartDataProviderProps(props);
|
|
return /*#__PURE__*/_jsx(ChartProvider, _extends({}, chartProviderProps, {
|
|
children: /*#__PURE__*/_jsx(ChartsLocalizationProvider, {
|
|
localeText: localeText,
|
|
children: /*#__PURE__*/_jsx(ChartsSlotsProvider, {
|
|
slots: slots,
|
|
slotProps: slotProps,
|
|
defaultSlots: defaultSlotsMaterial,
|
|
children: children
|
|
})
|
|
})
|
|
}));
|
|
}
|
|
process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
apiRef: PropTypes.shape({
|
|
current: PropTypes.any
|
|
}),
|
|
/**
|
|
* Color palette used to colorize multiple series.
|
|
* @default rainbowSurgePalette
|
|
*/
|
|
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
/**
|
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
*/
|
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
/**
|
|
* Options to enable features planned for the next major.
|
|
*/
|
|
experimentalFeatures: PropTypes.shape({
|
|
preferStrictDomainInLineCharts: PropTypes.bool
|
|
}),
|
|
/**
|
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
*/
|
|
height: PropTypes.number,
|
|
/**
|
|
* This prop is used to help implement the accessibility logic.
|
|
* If you don't provide this prop. It falls back to a randomly generated id.
|
|
*/
|
|
id: PropTypes.string,
|
|
/**
|
|
* Localized text for chart components.
|
|
*/
|
|
localeText: PropTypes.object,
|
|
/**
|
|
* The margin between the SVG and the drawing area.
|
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
*
|
|
* Accepts a `number` to be used on all sides or an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
*/
|
|
margin: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
bottom: PropTypes.number,
|
|
left: PropTypes.number,
|
|
right: PropTypes.number,
|
|
top: PropTypes.number
|
|
})]),
|
|
/**
|
|
* The array of series to display.
|
|
* Each type of series has its own specificity.
|
|
* Please refer to the appropriate docs page to learn more about it.
|
|
*/
|
|
series: PropTypes.arrayOf(PropTypes.object),
|
|
/**
|
|
* If `true`, animations are skipped.
|
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
*/
|
|
skipAnimation: PropTypes.bool,
|
|
/**
|
|
* The props for the slots.
|
|
*/
|
|
slotProps: PropTypes.object,
|
|
/**
|
|
* Slots to customize charts' components.
|
|
*/
|
|
slots: PropTypes.object,
|
|
theme: PropTypes.oneOf(['dark', 'light']),
|
|
/**
|
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
*/
|
|
width: PropTypes.number
|
|
} : void 0;
|
|
export { ChartDataProvider }; |