UNPKG

@mui/x-charts

Version:

The community edition of the charts components (MUI X).

86 lines (85 loc) 3.46 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ScatterPlot = ScatterPlot; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _Scatter = require("./Scatter"); var _SeriesContextProvider = require("../context/SeriesContextProvider"); var _CartesianContextProvider = require("../context/CartesianContextProvider"); var _jsxRuntime = require("react/jsx-runtime"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * 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) { const { slots, slotProps } = props; const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).scatter; const axisData = React.useContext(_CartesianContextProvider.CartesianContext); if (seriesData === undefined) { return null; } const { series, seriesOrder } = seriesData; const { xAxis, yAxis, xAxisIds, yAxisIds } = axisData; const defaultXAxisId = xAxisIds[0]; const defaultYAxisId = yAxisIds[0]; const ScatterItems = slots?.scatter ?? _Scatter.Scatter; return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, { children: seriesOrder.map(seriesId => { const { id, xAxisKey, yAxisKey, markerSize, color } = series[seriesId]; const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale; const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale; return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({ xScale: xScale, yScale: yScale, color: color, markerSize: markerSize ?? 4, series: series[seriesId] }, 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.default.object, /** * Overridable component slots. * @default {} */ slots: _propTypes.default.object } : void 0;