UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

104 lines (103 loc) 2.68 kB
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; 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"]; import * as React from 'react'; import { SCATTER_CHART_PLUGINS } from "./ScatterChart.plugins.js"; /** * 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 */ export 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 = _objectWithoutPropertiesLoose(props, _excluded); const seriesWithDefault = React.useMemo(() => series.map(s => _extends({ type: 'scatter' }, s)), [series]); const chartContainerProps = _extends({}, other, { series: seriesWithDefault, width, height, margin, colors, xAxis, yAxis, zAxis, highlightedItem, onHighlightChange, disableVoronoi, voronoiMaxRadius, onItemClick: disableVoronoi ? undefined : onItemClick, className, plugins: 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 = _extends({ 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 }; };