@mui/x-charts
Version:
The community edition of the charts components (MUI X).
72 lines • 2.66 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import PropTypes from 'prop-types';
import { Scatter } from './Scatter';
import { SeriesContext } from '../context/SeriesContextProvider';
import { CartesianContext } from '../context/CartesianContextProvider';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Demos:
*
* - [Scatter](https://mui.com/x/react-charts/scatter/)
* - [Scatter demonstration](https://mui.com/x/react-charts/scatter-demo/)
*
* API:
*
* - [ScatterPlot API](https://mui.com/x/api/charts/scatter-plot/)
*/
function ScatterPlot(props) {
var _slots$scatter;
var slots = props.slots,
slotProps = props.slotProps;
var seriesData = React.useContext(SeriesContext).scatter;
var axisData = React.useContext(CartesianContext);
if (seriesData === undefined) {
return null;
}
var series = seriesData.series,
seriesOrder = seriesData.seriesOrder;
var xAxis = axisData.xAxis,
yAxis = axisData.yAxis,
xAxisIds = axisData.xAxisIds,
yAxisIds = axisData.yAxisIds;
var defaultXAxisId = xAxisIds[0];
var defaultYAxisId = yAxisIds[0];
var ScatterItems = (_slots$scatter = slots == null ? void 0 : slots.scatter) != null ? _slots$scatter : Scatter;
return /*#__PURE__*/_jsx(React.Fragment, {
children: seriesOrder.map(function (seriesId) {
var _series$seriesId = series[seriesId],
id = _series$seriesId.id,
xAxisKey = _series$seriesId.xAxisKey,
yAxisKey = _series$seriesId.yAxisKey,
markerSize = _series$seriesId.markerSize,
color = _series$seriesId.color;
var xScale = xAxis[xAxisKey != null ? xAxisKey : defaultXAxisId].scale;
var yScale = yAxis[yAxisKey != null ? yAxisKey : defaultYAxisId].scale;
return /*#__PURE__*/_jsx(ScatterItems, _extends({
xScale: xScale,
yScale: yScale,
color: color,
markerSize: markerSize != null ? markerSize : 4,
series: series[seriesId]
}, slotProps == null ? void 0 : slotProps.scatter), id);
})
});
}
process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* The props used for each component slot.
* @default {}
*/
slotProps: PropTypes.object,
/**
* Overridable component slots.
* @default {}
*/
slots: PropTypes.object
} : void 0;
export { ScatterPlot };