@mui/x-charts
Version:
The community edition of the Charts components (MUI X).
116 lines (115 loc) • 2.37 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useScatterChartProps = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
/**
* 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,
tooltip,
axisHighlight,
voronoiMaxRadius,
disableVoronoi,
legend,
width,
height,
margin,
colors,
sx,
grid,
topAxis,
leftAxis,
rightAxis,
bottomAxis,
onItemClick,
children,
slots,
slotProps,
loading,
highlightedItem,
onHighlightChange
} = props;
const chartContainerProps = {
series: series.map(s => (0, _extends2.default)({
type: 'scatter'
}, s)),
width,
height,
margin,
colors,
xAxis,
yAxis,
sx,
highlightedItem,
onHighlightChange
};
const zAxisProps = {
zAxis
};
const voronoiHandlerProps = {
voronoiMaxRadius,
onItemClick: onItemClick
};
const chartsAxisProps = {
topAxis,
leftAxis,
rightAxis,
bottomAxis,
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 = (0, _extends2.default)({}, legend, {
slots,
slotProps
});
const axisHighlightProps = (0, _extends2.default)({
y: 'none',
x: 'none'
}, axisHighlight);
const tooltipProps = (0, _extends2.default)({
trigger: 'item'
}, tooltip, {
slots,
slotProps
});
return {
chartContainerProps,
zAxisProps,
voronoiHandlerProps,
chartsAxisProps,
gridProps,
scatterPlotProps,
overlayProps,
legendProps,
axisHighlightProps,
tooltipProps,
children
};
};
exports.useScatterChartProps = useScatterChartProps;