@mui/x-charts
Version:
The community edition of MUI X Charts components.
112 lines (111 loc) • 3.17 kB
JavaScript
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useScatterChartProps = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _ScatterChart = require("./ScatterChart.plugins");
const _excluded = ["xAxis", "yAxis", "zAxis", "series", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className", "showToolbar"];
/**
* A helper function that extracts ScatterChartProps from the input props
* and returns an object with props for the children components of ScatterChart.
*
* @param props The input props for ScatterChart
* @returns An object with props for the children components of ScatterChart
*/
const useScatterChartProps = props => {
const {
xAxis,
yAxis,
zAxis,
series,
axisHighlight,
voronoiMaxRadius,
disableVoronoi,
width,
height,
margin,
colors,
sx,
grid,
onItemClick,
children,
slots,
slotProps,
loading,
highlightedItem,
onHighlightChange,
className
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const seriesWithDefault = React.useMemo(() => series.map(s => (0, _extends2.default)({
type: 'scatter'
}, s)), [series]);
const chartContainerProps = (0, _extends2.default)({}, other, {
series: seriesWithDefault,
width,
height,
margin,
colors,
xAxis,
yAxis,
zAxis,
highlightedItem,
onHighlightChange,
disableVoronoi,
voronoiMaxRadius,
onItemClick: disableVoronoi ? undefined : onItemClick,
className,
plugins: _ScatterChart.SCATTER_CHART_PLUGINS,
slots,
slotProps
});
const chartsAxisProps = {
slots,
slotProps
};
const gridProps = {
vertical: grid?.vertical,
horizontal: grid?.horizontal
};
const scatterPlotProps = {
onItemClick: disableVoronoi ? onItemClick : undefined,
slots,
slotProps
};
const overlayProps = {
loading,
slots,
slotProps
};
const legendProps = {
slots,
slotProps
};
const axisHighlightProps = (0, _extends2.default)({
y: 'none',
x: 'none'
}, axisHighlight);
const chartsWrapperProps = {
sx,
legendPosition: props.slotProps?.legend?.position,
legendDirection: props.slotProps?.legend?.direction
};
return {
chartsWrapperProps,
chartContainerProps,
chartsAxisProps,
gridProps,
scatterPlotProps,
overlayProps,
legendProps,
axisHighlightProps,
children
};
};
exports.useScatterChartProps = useScatterChartProps;
;